Scippy

SCIP

Solving Constraint Integer Programs

tree.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file tree.c
17  * @brief methods for branch and bound tree
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #include <assert.h>
26 
27 #include "scip/def.h"
28 #include "scip/set.h"
29 #include "scip/stat.h"
30 #include "scip/clock.h"
31 #include "scip/visual.h"
32 #include "scip/event.h"
33 #include "scip/lp.h"
34 #include "scip/relax.h"
35 #include "scip/var.h"
36 #include "scip/implics.h"
37 #include "scip/primal.h"
38 #include "scip/tree.h"
39 #include "scip/reopt.h"
40 #include "scip/conflictstore.h"
41 #include "scip/solve.h"
42 #include "scip/cons.h"
43 #include "scip/nodesel.h"
44 #include "scip/prop.h"
45 #include "scip/debug.h"
46 #include "scip/prob.h"
47 #include "scip/scip.h"
48 #include "scip/pub_message.h"
49 #include "lpi/lpi.h"
50 
51 
52 #define MAXREPROPMARK 511 /**< maximal subtree repropagation marker; must correspond to node data structure */
53 
54 
55 /*
56  * dynamic memory arrays
57  */
58 
59 /** resizes children arrays to be able to store at least num nodes */
60 static
62  SCIP_TREE* tree, /**< branch and bound tree */
63  SCIP_SET* set, /**< global SCIP settings */
64  int num /**< minimal number of node slots in array */
65  )
66 {
67  assert(tree != NULL);
68  assert(set != NULL);
69 
70  if( num > tree->childrensize )
71  {
72  int newsize;
73 
74  newsize = SCIPsetCalcMemGrowSize(set, num);
75  SCIP_ALLOC( BMSreallocMemoryArray(&tree->children, newsize) );
76  SCIP_ALLOC( BMSreallocMemoryArray(&tree->childrenprio, newsize) );
77  tree->childrensize = newsize;
78  }
79  assert(num <= tree->childrensize);
80 
81  return SCIP_OKAY;
82 }
83 
84 /** resizes path array to be able to store at least num nodes */
85 static
87  SCIP_TREE* tree, /**< branch and bound tree */
88  SCIP_SET* set, /**< global SCIP settings */
89  int num /**< minimal number of node slots in path */
90  )
91 {
92  assert(tree != NULL);
93  assert(set != NULL);
94 
95  if( num > tree->pathsize )
96  {
97  int newsize;
98 
99  newsize = SCIPsetCalcPathGrowSize(set, num);
100  SCIP_ALLOC( BMSreallocMemoryArray(&tree->path, newsize) );
101  SCIP_ALLOC( BMSreallocMemoryArray(&tree->pathnlpcols, newsize) );
102  SCIP_ALLOC( BMSreallocMemoryArray(&tree->pathnlprows, newsize) );
103  tree->pathsize = newsize;
104  }
105  assert(num <= tree->pathsize);
106 
107  return SCIP_OKAY;
108 }
109 
110 /** resizes pendingbdchgs array to be able to store at least num nodes */
111 static
113  SCIP_TREE* tree, /**< branch and bound tree */
114  SCIP_SET* set, /**< global SCIP settings */
115  int num /**< minimal number of node slots in path */
116  )
117 {
118  assert(tree != NULL);
119  assert(set != NULL);
120 
121  if( num > tree->pendingbdchgssize )
122  {
123  int newsize;
124 
125  newsize = SCIPsetCalcMemGrowSize(set, num);
126  SCIP_ALLOC( BMSreallocMemoryArray(&tree->pendingbdchgs, newsize) );
127  tree->pendingbdchgssize = newsize;
128  }
129  assert(num <= tree->pendingbdchgssize);
130 
131  return SCIP_OKAY;
132 }
133 
134 
135 
136 
137 /*
138  * Node methods
139  */
140 
141 /** node comparator for best lower bound */
142 SCIP_DECL_SORTPTRCOMP(SCIPnodeCompLowerbound)
143 { /*lint --e{715}*/
144  assert(elem1 != NULL);
145  assert(elem2 != NULL);
146 
147  if( ((SCIP_NODE*)elem1)->lowerbound < ((SCIP_NODE*)elem2)->lowerbound )
148  return -1;
149  else if( ((SCIP_NODE*)elem1)->lowerbound > ((SCIP_NODE*)elem2)->lowerbound )
150  return +1;
151  else
152  return 0;
153 }
154 
155 /** increases the reference counter of the LP state in the fork */
156 static
158  SCIP_FORK* fork, /**< fork data */
159  int nuses /**< number to add to the usage counter */
160  )
161 {
162  assert(fork != NULL);
163  assert(fork->nlpistateref >= 0);
164  assert(nuses > 0);
165 
166  fork->nlpistateref += nuses;
167  SCIPdebugMessage("captured LPI state of fork %p %d times -> new nlpistateref=%d\n", (void*)fork, nuses, fork->nlpistateref);
168 }
169 
170 /** decreases the reference counter of the LP state in the fork */
171 static
173  SCIP_FORK* fork, /**< fork data */
174  BMS_BLKMEM* blkmem, /**< block memory buffers */
175  SCIP_LP* lp /**< current LP data */
176  )
177 {
178  assert(fork != NULL);
179  assert(fork->nlpistateref > 0);
180  assert(blkmem != NULL);
181  assert(lp != NULL);
182 
183  fork->nlpistateref--;
184  if( fork->nlpistateref == 0 )
185  {
186  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &(fork->lpistate)) );
187  }
188 
189  SCIPdebugMessage("released LPI state of fork %p -> new nlpistateref=%d\n", (void*)fork, fork->nlpistateref);
190 
191  return SCIP_OKAY;
192 }
193 
194 /** increases the reference counter of the LP state in the subroot */
195 static
197  SCIP_SUBROOT* subroot, /**< subroot data */
198  int nuses /**< number to add to the usage counter */
199  )
200 {
201  assert(subroot != NULL);
202  assert(subroot->nlpistateref >= 0);
203  assert(nuses > 0);
204 
205  subroot->nlpistateref += nuses;
206  SCIPdebugMessage("captured LPI state of subroot %p %d times -> new nlpistateref=%d\n",
207  (void*)subroot, nuses, subroot->nlpistateref);
208 }
209 
210 /** decreases the reference counter of the LP state in the subroot */
211 static
213  SCIP_SUBROOT* subroot, /**< subroot data */
214  BMS_BLKMEM* blkmem, /**< block memory buffers */
215  SCIP_LP* lp /**< current LP data */
216  )
217 {
218  assert(subroot != NULL);
219  assert(subroot->nlpistateref > 0);
220  assert(blkmem != NULL);
221  assert(lp != NULL);
222 
223  subroot->nlpistateref--;
224  if( subroot->nlpistateref == 0 )
225  {
226  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &(subroot->lpistate)) );
227  }
228 
229  SCIPdebugMessage("released LPI state of subroot %p -> new nlpistateref=%d\n", (void*)subroot, subroot->nlpistateref);
230 
231  return SCIP_OKAY;
232 }
233 
234 /** increases the reference counter of the LP state in the fork or subroot node */
236  SCIP_NODE* node, /**< fork/subroot node */
237  int nuses /**< number to add to the usage counter */
238  )
239 {
240  assert(node != NULL);
241 
242  SCIPdebugMessage("capture %d times LPI state of node #%" SCIP_LONGINT_FORMAT " at depth %d (current: %d)\n",
243  nuses, SCIPnodeGetNumber(node), SCIPnodeGetDepth(node),
245 
246  switch( SCIPnodeGetType(node) )
247  {
248  case SCIP_NODETYPE_FORK:
249  forkCaptureLPIState(node->data.fork, nuses);
250  break;
252  subrootCaptureLPIState(node->data.subroot, nuses);
253  break;
254  default:
255  SCIPerrorMessage("node for capturing the LPI state is neither fork nor subroot\n");
256  SCIPABORT();
257  return SCIP_INVALIDDATA; /*lint !e527*/
258  } /*lint !e788*/
259  return SCIP_OKAY;
260 }
261 
262 /** decreases the reference counter of the LP state in the fork or subroot node */
264  SCIP_NODE* node, /**< fork/subroot node */
265  BMS_BLKMEM* blkmem, /**< block memory buffers */
266  SCIP_LP* lp /**< current LP data */
267  )
268 {
269  assert(node != NULL);
270 
271  SCIPdebugMessage("release LPI state of node #%" SCIP_LONGINT_FORMAT " at depth %d (current: %d)\n",
272  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node),
274  switch( SCIPnodeGetType(node) )
275  {
276  case SCIP_NODETYPE_FORK:
277  return forkReleaseLPIState(node->data.fork, blkmem, lp);
279  return subrootReleaseLPIState(node->data.subroot, blkmem, lp);
280  default:
281  SCIPerrorMessage("node for releasing the LPI state is neither fork nor subroot\n");
282  return SCIP_INVALIDDATA;
283  } /*lint !e788*/
284 }
285 
286 /** creates probingnode data without LP information */
287 static
289  SCIP_PROBINGNODE** probingnode, /**< pointer to probingnode data */
290  BMS_BLKMEM* blkmem, /**< block memory */
291  SCIP_LP* lp /**< current LP data */
292  )
293 {
294  assert(probingnode != NULL);
295 
296  SCIP_ALLOC( BMSallocBlockMemory(blkmem, probingnode) );
297 
298  (*probingnode)->lpistate = NULL;
299  (*probingnode)->lpinorms = NULL;
300  (*probingnode)->ninitialcols = SCIPlpGetNCols(lp);
301  (*probingnode)->ninitialrows = SCIPlpGetNRows(lp);
302  (*probingnode)->ncols = (*probingnode)->ninitialcols;
303  (*probingnode)->nrows = (*probingnode)->ninitialrows;
304  (*probingnode)->origobjvars = NULL;
305  (*probingnode)->origobjvals = NULL;
306  (*probingnode)->nchgdobjs = 0;
307 
308  SCIPdebugMessage("created probingnode information (%d cols, %d rows)\n", (*probingnode)->ncols, (*probingnode)->nrows);
309 
310  return SCIP_OKAY;
311 }
312 
313 /** updates LP information in probingnode data */
314 static
316  SCIP_PROBINGNODE* probingnode, /**< probingnode data */
317  BMS_BLKMEM* blkmem, /**< block memory */
318  SCIP_TREE* tree, /**< branch and bound tree */
319  SCIP_LP* lp /**< current LP data */
320  )
321 {
322  SCIP_Bool storenorms = FALSE;
323 
324  assert(probingnode != NULL);
325  assert(SCIPtreeIsPathComplete(tree));
326  assert(lp != NULL);
327 
328  /* free old LP state */
329  if( probingnode->lpistate != NULL )
330  {
331  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &probingnode->lpistate) );
332  }
333 
334  /* free old LP norms */
335  if( probingnode->lpinorms != NULL )
336  {
337  SCIP_CALL( SCIPlpFreeNorms(lp, blkmem, &probingnode->lpinorms) );
338  probingnode->lpinorms = NULL;
339  storenorms = TRUE;
340  }
341 
342  /* get current LP state */
343  if( lp->flushed && lp->solved )
344  {
345  SCIP_CALL( SCIPlpGetState(lp, blkmem, &probingnode->lpistate) );
346 
347  /* if LP norms were stored at this node before, store the new ones */
348  if( storenorms )
349  {
350  SCIP_CALL( SCIPlpGetNorms(lp, blkmem, &probingnode->lpinorms) );
351  }
352  probingnode->lpwasprimfeas = lp->primalfeasible;
353  probingnode->lpwasprimchecked = lp->primalchecked;
354  probingnode->lpwasdualfeas = lp->dualfeasible;
355  probingnode->lpwasdualchecked = lp->dualchecked;
356  }
357  else
358  probingnode->lpistate = NULL;
359 
360  probingnode->ncols = SCIPlpGetNCols(lp);
361  probingnode->nrows = SCIPlpGetNRows(lp);
362 
363  SCIPdebugMessage("updated probingnode information (%d cols, %d rows)\n", probingnode->ncols, probingnode->nrows);
364 
365  return SCIP_OKAY;
366 }
367 
368 /** frees probingnode data */
369 static
371  SCIP_PROBINGNODE** probingnode, /**< probingnode data */
372  BMS_BLKMEM* blkmem, /**< block memory */
373  SCIP_LP* lp /**< current LP data */
374  )
375 {
376  assert(probingnode != NULL);
377  assert(*probingnode != NULL);
378 
379  /* free the associated LP state */
380  if( (*probingnode)->lpistate != NULL )
381  {
382  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &(*probingnode)->lpistate) );
383  }
384  /* free the associated LP norms */
385  if( (*probingnode)->lpinorms != NULL )
386  {
387  SCIP_CALL( SCIPlpFreeNorms(lp, blkmem, &(*probingnode)->lpinorms) );
388  }
389 
390  /* free objective information */
391  if( (*probingnode)->nchgdobjs > 0 )
392  {
393  assert((*probingnode)->origobjvars != NULL);
394  assert((*probingnode)->origobjvals != NULL);
395 
396  BMSfreeMemoryArray(&(*probingnode)->origobjvars);
397  BMSfreeMemoryArray(&(*probingnode)->origobjvals);
398  }
399 
400  BMSfreeBlockMemory(blkmem, probingnode);
401 
402  return SCIP_OKAY;
403 }
404 
405 /** initializes junction data */
406 static
408  SCIP_JUNCTION* junction, /**< pointer to junction data */
409  SCIP_TREE* tree /**< branch and bound tree */
410  )
411 {
412  assert(junction != NULL);
413  assert(tree != NULL);
414  assert(tree->nchildren > 0);
415  assert(SCIPtreeIsPathComplete(tree));
416  assert(tree->focusnode != NULL);
417 
418  junction->nchildren = tree->nchildren;
419 
420  /* increase the LPI state usage counter of the current LP fork */
421  if( tree->focuslpstatefork != NULL )
422  {
424  }
425 
426  return SCIP_OKAY;
427 }
428 
429 /** creates pseudofork data */
430 static
432  SCIP_PSEUDOFORK** pseudofork, /**< pointer to pseudofork data */
433  BMS_BLKMEM* blkmem, /**< block memory */
434  SCIP_TREE* tree, /**< branch and bound tree */
435  SCIP_LP* lp /**< current LP data */
436  )
437 {
438  assert(pseudofork != NULL);
439  assert(blkmem != NULL);
440  assert(tree != NULL);
441  assert(tree->nchildren > 0);
442  assert(SCIPtreeIsPathComplete(tree));
443  assert(tree->focusnode != NULL);
444 
445  SCIP_ALLOC( BMSallocBlockMemory(blkmem, pseudofork) );
446 
447  (*pseudofork)->addedcols = NULL;
448  (*pseudofork)->addedrows = NULL;
449  (*pseudofork)->naddedcols = SCIPlpGetNNewcols(lp);
450  (*pseudofork)->naddedrows = SCIPlpGetNNewrows(lp);
451  (*pseudofork)->nchildren = tree->nchildren;
452 
453  SCIPdebugMessage("creating pseudofork information with %d children (%d new cols, %d new rows)\n",
454  (*pseudofork)->nchildren, (*pseudofork)->naddedcols, (*pseudofork)->naddedrows);
455 
456  if( (*pseudofork)->naddedcols > 0 )
457  {
458  /* copy the newly created columns to the pseudofork's col array */
459  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &(*pseudofork)->addedcols, SCIPlpGetNewcols(lp), (*pseudofork)->naddedcols) ); /*lint !e666*/
460  }
461  if( (*pseudofork)->naddedrows > 0 )
462  {
463  int i;
464 
465  /* copy the newly created rows to the pseudofork's row array */
466  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &(*pseudofork)->addedrows, SCIPlpGetNewrows(lp), (*pseudofork)->naddedrows) ); /*lint !e666*/
467 
468  /* capture the added rows */
469  for( i = 0; i < (*pseudofork)->naddedrows; ++i )
470  SCIProwCapture((*pseudofork)->addedrows[i]);
471  }
472 
473  /* increase the LPI state usage counter of the current LP fork */
474  if( tree->focuslpstatefork != NULL )
475  {
477  }
478 
479  return SCIP_OKAY;
480 }
481 
482 /** frees pseudofork data */
483 static
485  SCIP_PSEUDOFORK** pseudofork, /**< pseudofork data */
486  BMS_BLKMEM* blkmem, /**< block memory */
487  SCIP_SET* set, /**< global SCIP settings */
488  SCIP_LP* lp /**< current LP data */
489  )
490 {
491  int i;
492 
493  assert(pseudofork != NULL);
494  assert(*pseudofork != NULL);
495  assert((*pseudofork)->nchildren == 0);
496  assert(blkmem != NULL);
497  assert(set != NULL);
498 
499  /* release the added rows */
500  for( i = 0; i < (*pseudofork)->naddedrows; ++i )
501  {
502  SCIP_CALL( SCIProwRelease(&(*pseudofork)->addedrows[i], blkmem, set, lp) );
503  }
504 
505  BMSfreeBlockMemoryArrayNull(blkmem, &(*pseudofork)->addedcols, (*pseudofork)->naddedcols);
506  BMSfreeBlockMemoryArrayNull(blkmem, &(*pseudofork)->addedrows, (*pseudofork)->naddedrows);
507  BMSfreeBlockMemory(blkmem, pseudofork);
508 
509  return SCIP_OKAY;
510 }
511 
512 /** creates fork data */
513 static
515  SCIP_FORK** fork, /**< pointer to fork data */
516  BMS_BLKMEM* blkmem, /**< block memory */
517  SCIP_SET* set, /**< global SCIP settings */
518  SCIP_PROB* prob, /**< transformed problem after presolve */
519  SCIP_TREE* tree, /**< branch and bound tree */
520  SCIP_LP* lp /**< current LP data */
521  )
522 {
523  assert(fork != NULL);
524  assert(blkmem != NULL);
525  assert(tree != NULL);
526  assert(tree->nchildren > 0);
527  assert(tree->nchildren < (1 << 30));
528  assert(SCIPtreeIsPathComplete(tree));
529  assert(tree->focusnode != NULL);
530  assert(lp != NULL);
531  assert(lp->flushed);
532  assert(lp->solved);
534 
535  SCIP_ALLOC( BMSallocBlockMemory(blkmem, fork) );
536 
537  SCIP_CALL( SCIPlpGetState(lp, blkmem, &((*fork)->lpistate)) );
538  (*fork)->lpwasprimfeas = lp->primalfeasible;
539  (*fork)->lpwasprimchecked = lp->primalchecked;
540  (*fork)->lpwasdualfeas = lp->dualfeasible;
541  (*fork)->lpwasdualchecked = lp->dualchecked;
542  (*fork)->lpobjval = SCIPlpGetObjval(lp, set, prob);
543  (*fork)->nlpistateref = 0;
544  (*fork)->addedcols = NULL;
545  (*fork)->addedrows = NULL;
546  (*fork)->naddedcols = SCIPlpGetNNewcols(lp);
547  (*fork)->naddedrows = SCIPlpGetNNewrows(lp);
548  (*fork)->nchildren = (unsigned int) tree->nchildren;
549 
550  SCIPsetDebugMsg(set, "creating fork information with %u children (%d new cols, %d new rows)\n", (*fork)->nchildren, (*fork)->naddedcols, (*fork)->naddedrows);
551 
552  if( (*fork)->naddedcols > 0 )
553  {
554  /* copy the newly created columns to the fork's col array */
555  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &(*fork)->addedcols, SCIPlpGetNewcols(lp), (*fork)->naddedcols) ); /*lint !e666*/
556  }
557  if( (*fork)->naddedrows > 0 )
558  {
559  int i;
560 
561  /* copy the newly created rows to the fork's row array */
562  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &(*fork)->addedrows, SCIPlpGetNewrows(lp), (*fork)->naddedrows) ); /*lint !e666*/
563 
564  /* capture the added rows */
565  for( i = 0; i < (*fork)->naddedrows; ++i )
566  SCIProwCapture((*fork)->addedrows[i]);
567  }
568 
569  /* capture the LPI state for the children */
570  forkCaptureLPIState(*fork, tree->nchildren);
571 
572  return SCIP_OKAY;
573 }
574 
575 /** frees fork data */
576 static
578  SCIP_FORK** fork, /**< fork data */
579  BMS_BLKMEM* blkmem, /**< block memory */
580  SCIP_SET* set, /**< global SCIP settings */
581  SCIP_LP* lp /**< current LP data */
582  )
583 {
584  int i;
585 
586  assert(fork != NULL);
587  assert(*fork != NULL);
588  assert((*fork)->nchildren == 0);
589  assert((*fork)->nlpistateref == 0);
590  assert((*fork)->lpistate == NULL);
591  assert(blkmem != NULL);
592  assert(set != NULL);
593  assert(lp != NULL);
594 
595  /* release the added rows */
596  for( i = (*fork)->naddedrows - 1; i >= 0; --i )
597  {
598  SCIP_CALL( SCIProwRelease(&(*fork)->addedrows[i], blkmem, set, lp) );
599  }
600 
601  BMSfreeBlockMemoryArrayNull(blkmem, &(*fork)->addedcols, (*fork)->naddedcols);
602  BMSfreeBlockMemoryArrayNull(blkmem, &(*fork)->addedrows, (*fork)->naddedrows);
603  BMSfreeBlockMemory(blkmem, fork);
604 
605  return SCIP_OKAY;
606 }
607 
608 #ifdef WITHSUBROOTS /** @todo test whether subroots should be created */
609 /** creates subroot data */
610 static
611 SCIP_RETCODE subrootCreate(
612  SCIP_SUBROOT** subroot, /**< pointer to subroot data */
613  BMS_BLKMEM* blkmem, /**< block memory */
614  SCIP_SET* set, /**< global SCIP settings */
615  SCIP_PROB* prob, /**< transformed problem after presolve */
616  SCIP_TREE* tree, /**< branch and bound tree */
617  SCIP_LP* lp /**< current LP data */
618  )
619 {
620  int i;
621 
622  assert(subroot != NULL);
623  assert(blkmem != NULL);
624  assert(tree != NULL);
625  assert(tree->nchildren > 0);
626  assert(SCIPtreeIsPathComplete(tree));
627  assert(tree->focusnode != NULL);
628  assert(lp != NULL);
629  assert(lp->flushed);
630  assert(lp->solved);
632 
633  SCIP_ALLOC( BMSallocBlockMemory(blkmem, subroot) );
634  (*subroot)->lpobjval = SCIPlpGetObjval(lp, set, prob);
635  (*subroot)->nlpistateref = 0;
636  (*subroot)->ncols = SCIPlpGetNCols(lp);
637  (*subroot)->nrows = SCIPlpGetNRows(lp);
638  (*subroot)->nchildren = (unsigned int) tree->nchildren;
639  SCIP_CALL( SCIPlpGetState(lp, blkmem, &((*subroot)->lpistate)) );
640  (*subroot)->lpwasprimfeas = lp->primalfeasible;
641  (*subroot)->lpwasprimchecked = lp->primalchecked;
642  (*subroot)->lpwasdualfeas = lp->dualfeasible;
643  (*subroot)->lpwasdualchecked = lp->dualchecked;
644 
645  if( (*subroot)->ncols != 0 )
646  {
647  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &(*subroot)->cols, SCIPlpGetCols(lp), (*subroot)->ncols) );
648  }
649  else
650  (*subroot)->cols = NULL;
651  if( (*subroot)->nrows != 0 )
652  {
653  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &(*subroot)->rows, SCIPlpGetRows(lp), (*subroot)->nrows) );
654  }
655  else
656  (*subroot)->rows = NULL;
657 
658  /* capture the rows of the subroot */
659  for( i = 0; i < (*subroot)->nrows; ++i )
660  SCIProwCapture((*subroot)->rows[i]);
661 
662  /* capture the LPI state for the children */
663  subrootCaptureLPIState(*subroot, tree->nchildren);
664 
665  return SCIP_OKAY;
666 }
667 #endif
668 
669 /** frees subroot */
670 static
672  SCIP_SUBROOT** subroot, /**< subroot data */
673  BMS_BLKMEM* blkmem, /**< block memory */
674  SCIP_SET* set, /**< global SCIP settings */
675  SCIP_LP* lp /**< current LP data */
676  )
677 {
678  int i;
679 
680  assert(subroot != NULL);
681  assert(*subroot != NULL);
682  assert((*subroot)->nchildren == 0);
683  assert((*subroot)->nlpistateref == 0);
684  assert((*subroot)->lpistate == NULL);
685  assert(blkmem != NULL);
686  assert(set != NULL);
687  assert(lp != NULL);
688 
689  /* release the rows of the subroot */
690  for( i = 0; i < (*subroot)->nrows; ++i )
691  {
692  SCIP_CALL( SCIProwRelease(&(*subroot)->rows[i], blkmem, set, lp) );
693  }
694 
695  BMSfreeBlockMemoryArrayNull(blkmem, &(*subroot)->cols, (*subroot)->ncols);
696  BMSfreeBlockMemoryArrayNull(blkmem, &(*subroot)->rows, (*subroot)->nrows);
697  BMSfreeBlockMemory(blkmem, subroot);
698 
699  return SCIP_OKAY;
700 }
701 
702 /** removes given sibling node from the siblings array */
703 static
705  SCIP_TREE* tree, /**< branch and bound tree */
706  SCIP_NODE* sibling /**< sibling node to remove */
707  )
708 {
709  int delpos;
710 
711  assert(tree != NULL);
712  assert(sibling != NULL);
713  assert(SCIPnodeGetType(sibling) == SCIP_NODETYPE_SIBLING);
714  assert(sibling->data.sibling.arraypos >= 0 && sibling->data.sibling.arraypos < tree->nsiblings);
715  assert(tree->siblings[sibling->data.sibling.arraypos] == sibling);
716  assert(SCIPnodeGetType(tree->siblings[tree->nsiblings-1]) == SCIP_NODETYPE_SIBLING);
717 
718  delpos = sibling->data.sibling.arraypos;
719 
720  /* move last sibling in array to position of removed sibling */
721  tree->siblings[delpos] = tree->siblings[tree->nsiblings-1];
722  tree->siblingsprio[delpos] = tree->siblingsprio[tree->nsiblings-1];
723  tree->siblings[delpos]->data.sibling.arraypos = delpos;
724  sibling->data.sibling.arraypos = -1;
725  tree->nsiblings--;
726 }
727 
728 /** adds given child node to children array of focus node */
729 static
731  SCIP_TREE* tree, /**< branch and bound tree */
732  SCIP_SET* set, /**< global SCIP settings */
733  SCIP_NODE* child, /**< child node to add */
734  SCIP_Real nodeselprio /**< node selection priority of child node */
735  )
736 {
737  assert(tree != NULL);
738  assert(child != NULL);
739  assert(SCIPnodeGetType(child) == SCIP_NODETYPE_CHILD);
740  assert(child->data.child.arraypos == -1);
741 
742  SCIP_CALL( treeEnsureChildrenMem(tree, set, tree->nchildren+1) );
743  tree->children[tree->nchildren] = child;
744  tree->childrenprio[tree->nchildren] = nodeselprio;
745  child->data.child.arraypos = tree->nchildren;
746  tree->nchildren++;
747 
748  return SCIP_OKAY;
749 }
750 
751 /** removes given child node from the children array */
752 static
754  SCIP_TREE* tree, /**< branch and bound tree */
755  SCIP_NODE* child /**< child node to remove */
756  )
757 {
758  int delpos;
759 
760  assert(tree != NULL);
761  assert(child != NULL);
762  assert(SCIPnodeGetType(child) == SCIP_NODETYPE_CHILD);
763  assert(child->data.child.arraypos >= 0 && child->data.child.arraypos < tree->nchildren);
764  assert(tree->children[child->data.child.arraypos] == child);
765  assert(SCIPnodeGetType(tree->children[tree->nchildren-1]) == SCIP_NODETYPE_CHILD);
766 
767  delpos = child->data.child.arraypos;
768 
769  /* move last child in array to position of removed child */
770  tree->children[delpos] = tree->children[tree->nchildren-1];
771  tree->childrenprio[delpos] = tree->childrenprio[tree->nchildren-1];
772  tree->children[delpos]->data.child.arraypos = delpos;
773  child->data.child.arraypos = -1;
774  tree->nchildren--;
775 }
776 
777 /** makes node a child of the given parent node, which must be the focus node; if the child is a probing node,
778  * the parent node can also be a refocused node or a probing node
779  */
780 static
782  SCIP_NODE* node, /**< child node */
783  BMS_BLKMEM* blkmem, /**< block memory buffers */
784  SCIP_SET* set, /**< global SCIP settings */
785  SCIP_TREE* tree, /**< branch and bound tree */
786  SCIP_NODE* parent, /**< parent (= focus) node (or NULL, if node is root) */
787  SCIP_Real nodeselprio /**< node selection priority of child node */
788  )
789 {
790  assert(node != NULL);
791  assert(node->parent == NULL);
793  assert(node->conssetchg == NULL);
794  assert(node->domchg == NULL);
795  assert(SCIPsetIsInfinity(set, -node->lowerbound)); /* node was just created */
796  assert(blkmem != NULL);
797  assert(set != NULL);
798  assert(tree != NULL);
799  assert(SCIPtreeIsPathComplete(tree));
800  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] == parent);
801  assert(parent == tree->focusnode || SCIPnodeGetType(parent) == SCIP_NODETYPE_PROBINGNODE);
802  assert(parent == NULL || SCIPnodeGetType(parent) == SCIP_NODETYPE_FOCUSNODE
806 
807  /* link node to parent */
808  node->parent = parent;
809  if( parent != NULL )
810  {
811  assert(parent->lowerbound <= parent->estimate);
812  node->lowerbound = parent->lowerbound;
813  node->estimate = parent->estimate;
814  node->depth = parent->depth+1; /*lint !e732*/
815  if( parent->depth >= SCIP_MAXTREEDEPTH )
816  {
817  SCIPerrorMessage("maximal depth level exceeded\n");
818  return SCIP_MAXDEPTHLEVEL;
819  }
820  }
821  SCIPsetDebugMsg(set, "assigning parent #%" SCIP_LONGINT_FORMAT " to node #%" SCIP_LONGINT_FORMAT " at depth %d\n",
822  parent != NULL ? SCIPnodeGetNumber(parent) : -1, SCIPnodeGetNumber(node), SCIPnodeGetDepth(node));
823 
824  /* register node in the childlist of the focus (the parent) node */
825  if( SCIPnodeGetType(node) == SCIP_NODETYPE_CHILD )
826  {
827  assert(parent == NULL || SCIPnodeGetType(parent) == SCIP_NODETYPE_FOCUSNODE);
828  SCIP_CALL( treeAddChild(tree, set, node, nodeselprio) );
829  }
830 
831  return SCIP_OKAY;
832 }
833 
834 /** decreases number of children of the parent, frees it if no children are left */
835 static
837  SCIP_NODE* node, /**< child node */
838  BMS_BLKMEM* blkmem, /**< block memory buffer */
839  SCIP_SET* set, /**< global SCIP settings */
840  SCIP_STAT* stat, /**< problem statistics */
841  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
842  SCIP_TREE* tree, /**< branch and bound tree */
843  SCIP_LP* lp /**< current LP data */
844  )
845 {
846  SCIP_NODE* parent;
847 
848  assert(node != NULL);
849  assert(blkmem != NULL);
850  assert(tree != NULL);
851 
852  SCIPsetDebugMsg(set, "releasing parent-child relationship of node #%" SCIP_LONGINT_FORMAT " at depth %d of type %d with parent #%" SCIP_LONGINT_FORMAT " of type %d\n",
854  node->parent != NULL ? SCIPnodeGetNumber(node->parent) : -1,
855  node->parent != NULL ? (int)SCIPnodeGetType(node->parent) : -1);
856  parent = node->parent;
857  if( parent != NULL )
858  {
859  SCIP_Bool freeParent;
860  SCIP_Bool singleChild;
861 
862  freeParent = FALSE;
863  singleChild = FALSE;
864  switch( SCIPnodeGetType(parent) )
865  {
867  assert(parent->active);
869  || SCIPnodeGetType(node) == SCIP_NODETYPE_LEAF);
870  if( SCIPnodeGetType(node) == SCIP_NODETYPE_CHILD )
871  treeRemoveChild(tree, node);
872  /* don't kill the focus node at this point => freeParent = FALSE */
873  break;
875  assert(SCIPtreeProbing(tree));
876  /* probing nodes have to be freed individually => freeParent = FALSE */
877  break;
879  SCIPerrorMessage("sibling cannot be a parent node\n");
880  return SCIP_INVALIDDATA;
881  case SCIP_NODETYPE_CHILD:
882  SCIPerrorMessage("child cannot be a parent node\n");
883  return SCIP_INVALIDDATA;
884  case SCIP_NODETYPE_LEAF:
885  SCIPerrorMessage("leaf cannot be a parent node\n");
886  return SCIP_INVALIDDATA;
888  SCIPerrorMessage("dead-end cannot be a parent node\n");
889  return SCIP_INVALIDDATA;
891  assert(parent->data.junction.nchildren > 0);
892  parent->data.junction.nchildren--;
893  freeParent = (parent->data.junction.nchildren == 0); /* free parent if it has no more children */
894  singleChild = (parent->data.junction.nchildren == 1);
895  break;
897  assert(parent->data.pseudofork != NULL);
898  assert(parent->data.pseudofork->nchildren > 0);
899  parent->data.pseudofork->nchildren--;
900  freeParent = (parent->data.pseudofork->nchildren == 0); /* free parent if it has no more children */
901  singleChild = (parent->data.pseudofork->nchildren == 1);
902  break;
903  case SCIP_NODETYPE_FORK:
904  assert(parent->data.fork != NULL);
905  assert(parent->data.fork->nchildren > 0);
906  parent->data.fork->nchildren--;
907  freeParent = (parent->data.fork->nchildren == 0); /* free parent if it has no more children */
908  singleChild = (parent->data.fork->nchildren == 1);
909  break;
911  assert(parent->data.subroot != NULL);
912  assert(parent->data.subroot->nchildren > 0);
913  parent->data.subroot->nchildren--;
914  freeParent = (parent->data.subroot->nchildren == 0); /* free parent if it has no more children */
915  singleChild = (parent->data.subroot->nchildren == 1);
916  break;
918  /* the only possible child a refocused node can have in its refocus state is the probing root node;
919  * we don't want to free the refocused node, because we first have to convert it back to its original
920  * type (where it possibly has children) => freeParent = FALSE
921  */
923  assert(!SCIPtreeProbing(tree));
924  break;
925  default:
926  SCIPerrorMessage("unknown node type %d\n", SCIPnodeGetType(parent));
927  return SCIP_INVALIDDATA;
928  }
929 
930  /* free parent, if it is not on the current active path */
931  if( freeParent && !parent->active )
932  {
933  SCIP_CALL( SCIPnodeFree(&node->parent, blkmem, set, stat, eventqueue, tree, lp) );
934  }
935 
936  /* update the effective root depth
937  * in reoptimization we must not increase the effective root depth
938  */
939  assert(tree->effectiverootdepth >= 0);
940  if( singleChild && SCIPnodeGetDepth(parent) == tree->effectiverootdepth && !set->reopt_enable )
941  {
942  tree->effectiverootdepth++;
943  SCIPsetDebugMsg(set, "unlinked node #%" SCIP_LONGINT_FORMAT " in depth %d -> new effective root depth: %d\n",
945  }
946  }
947 
948  return SCIP_OKAY;
949 }
950 
951 /** creates a node data structure */
952 static
954  SCIP_NODE** node, /**< pointer to node data structure */
955  BMS_BLKMEM* blkmem, /**< block memory */
956  SCIP_SET* set /**< global SCIP settings */
957  )
958 {
959  assert(node != NULL);
960 
961  SCIP_ALLOC( BMSallocBlockMemory(blkmem, node) );
962  (*node)->parent = NULL;
963  (*node)->conssetchg = NULL;
964  (*node)->domchg = NULL;
965  (*node)->number = 0;
966  (*node)->lowerbound = -SCIPsetInfinity(set);
967  (*node)->estimate = -SCIPsetInfinity(set);
968  (*node)->reoptid = 0;
969  (*node)->reopttype = (unsigned int) SCIP_REOPTTYPE_NONE;
970  (*node)->depth = 0;
971  (*node)->active = FALSE;
972  (*node)->cutoff = FALSE;
973  (*node)->reprop = FALSE;
974  (*node)->repropsubtreemark = 0;
975 
976  return SCIP_OKAY;
977 }
978 
979 /** creates a child node of the focus node */
981  SCIP_NODE** node, /**< pointer to node data structure */
982  BMS_BLKMEM* blkmem, /**< block memory */
983  SCIP_SET* set, /**< global SCIP settings */
984  SCIP_STAT* stat, /**< problem statistics */
985  SCIP_TREE* tree, /**< branch and bound tree */
986  SCIP_Real nodeselprio, /**< node selection priority of new node */
987  SCIP_Real estimate /**< estimate for (transformed) objective value of best feasible solution in subtree */
988  )
989 {
990  assert(node != NULL);
991  assert(blkmem != NULL);
992  assert(set != NULL);
993  assert(stat != NULL);
994  assert(tree != NULL);
995  assert(SCIPtreeIsPathComplete(tree));
996  assert(tree->pathlen == 0 || tree->path != NULL);
997  assert((tree->pathlen == 0) == (tree->focusnode == NULL));
998  assert(tree->focusnode == NULL || tree->focusnode == tree->path[tree->pathlen-1]);
999  assert(tree->focusnode == NULL || SCIPnodeGetType(tree->focusnode) == SCIP_NODETYPE_FOCUSNODE);
1000 
1001  stat->ncreatednodes++;
1002  stat->ncreatednodesrun++;
1003 
1004  /* create the node data structure */
1005  SCIP_CALL( nodeCreate(node, blkmem, set) );
1006  (*node)->number = stat->ncreatednodesrun;
1007 
1008  /* mark node to be a child node */
1009  (*node)->nodetype = SCIP_NODETYPE_CHILD; /*lint !e641*/
1010  (*node)->data.child.arraypos = -1;
1011 
1012  /* make focus node the parent of the new child */
1013  SCIP_CALL( nodeAssignParent(*node, blkmem, set, tree, tree->focusnode, nodeselprio) );
1014 
1015  /* update the estimate of the child */
1016  SCIPnodeSetEstimate(*node, set, estimate);
1017 
1018  /* output node creation to visualization file */
1019  SCIP_CALL( SCIPvisualNewChild(stat->visual, set, stat, *node) );
1020 
1021  SCIPsetDebugMsg(set, "created child node #%" SCIP_LONGINT_FORMAT " at depth %u (prio: %g)\n", SCIPnodeGetNumber(*node), (*node)->depth, nodeselprio);
1022 
1023  return SCIP_OKAY;
1024 }
1025 
1026 /** frees node */
1028  SCIP_NODE** node, /**< node data */
1029  BMS_BLKMEM* blkmem, /**< block memory buffer */
1030  SCIP_SET* set, /**< global SCIP settings */
1031  SCIP_STAT* stat, /**< problem statistics */
1032  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1033  SCIP_TREE* tree, /**< branch and bound tree */
1034  SCIP_LP* lp /**< current LP data */
1035  )
1036 {
1037  SCIP_Bool isroot;
1038 
1039  assert(node != NULL);
1040  assert(*node != NULL);
1041  assert(!(*node)->active);
1042  assert(blkmem != NULL);
1043  assert(tree != NULL);
1044 
1045  SCIPsetDebugMsg(set, "free node #%" SCIP_LONGINT_FORMAT " at depth %d of type %d\n", SCIPnodeGetNumber(*node), SCIPnodeGetDepth(*node), SCIPnodeGetType(*node));
1046 
1047  /* inform solution debugger, that the node has been freed */
1048  SCIP_CALL( SCIPdebugRemoveNode(blkmem, set, *node) );
1049 
1050  /* check, if the node to be freed is the root node */
1051  isroot = (SCIPnodeGetDepth(*node) == 0);
1052 
1053  /* free nodetype specific data, and release no longer needed LPI states */
1054  switch( SCIPnodeGetType(*node) )
1055  {
1057  assert(tree->focusnode == *node);
1058  assert(!SCIPtreeProbing(tree));
1059  SCIPerrorMessage("cannot free focus node - has to be converted into a dead end first\n");
1060  return SCIP_INVALIDDATA;
1062  assert(SCIPtreeProbing(tree));
1063  assert(SCIPnodeGetDepth(tree->probingroot) <= SCIPnodeGetDepth(*node));
1064  assert(SCIPnodeGetDepth(*node) > 0);
1065  SCIP_CALL( probingnodeFree(&((*node)->data.probingnode), blkmem, lp) );
1066  break;
1067  case SCIP_NODETYPE_SIBLING:
1068  assert((*node)->data.sibling.arraypos >= 0);
1069  assert((*node)->data.sibling.arraypos < tree->nsiblings);
1070  assert(tree->siblings[(*node)->data.sibling.arraypos] == *node);
1071  if( tree->focuslpstatefork != NULL )
1072  {
1075  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
1076  }
1077  treeRemoveSibling(tree, *node);
1078  break;
1079  case SCIP_NODETYPE_CHILD:
1080  assert((*node)->data.child.arraypos >= 0);
1081  assert((*node)->data.child.arraypos < tree->nchildren);
1082  assert(tree->children[(*node)->data.child.arraypos] == *node);
1083  /* The children capture the LPI state at the moment, where the focus node is
1084  * converted into a junction, pseudofork, fork, or subroot, and a new node is focused.
1085  * At the same time, they become siblings or leaves, such that freeing a child
1086  * of the focus node doesn't require to release the LPI state;
1087  * we don't need to call treeRemoveChild(), because this is done in nodeReleaseParent()
1088  */
1089  break;
1090  case SCIP_NODETYPE_LEAF:
1091  if( (*node)->data.leaf.lpstatefork != NULL )
1092  {
1093  SCIP_CALL( SCIPnodeReleaseLPIState((*node)->data.leaf.lpstatefork, blkmem, lp) );
1094  }
1095  break;
1096  case SCIP_NODETYPE_DEADEND:
1098  break;
1100  SCIP_CALL( pseudoforkFree(&((*node)->data.pseudofork), blkmem, set, lp) );
1101  break;
1102  case SCIP_NODETYPE_FORK:
1103 
1104  /* release special root LPI state capture which is used to keep the root LPI state over the whole solving
1105  * process
1106  */
1107  if( isroot )
1108  {
1109  SCIP_CALL( SCIPnodeReleaseLPIState(*node, blkmem, lp) );
1110  }
1111  SCIP_CALL( forkFree(&((*node)->data.fork), blkmem, set, lp) );
1112  break;
1113  case SCIP_NODETYPE_SUBROOT:
1114  SCIP_CALL( subrootFree(&((*node)->data.subroot), blkmem, set, lp) );
1115  break;
1117  SCIPerrorMessage("cannot free node as long it is refocused\n");
1118  return SCIP_INVALIDDATA;
1119  default:
1120  SCIPerrorMessage("unknown node type %d\n", SCIPnodeGetType(*node));
1121  return SCIP_INVALIDDATA;
1122  }
1123 
1124  /* free common data */
1125  SCIP_CALL( SCIPconssetchgFree(&(*node)->conssetchg, blkmem, set) );
1126  SCIP_CALL( SCIPdomchgFree(&(*node)->domchg, blkmem, set, eventqueue, lp) );
1127  SCIP_CALL( nodeReleaseParent(*node, blkmem, set, stat, eventqueue, tree, lp) );
1128 
1129  /* check, if the node is the current probing root */
1130  if( *node == tree->probingroot )
1131  {
1132  assert(SCIPnodeGetType(*node) == SCIP_NODETYPE_PROBINGNODE);
1133  tree->probingroot = NULL;
1134  }
1135 
1136  BMSfreeBlockMemory(blkmem, node);
1137 
1138  /* delete the tree's root node pointer, if the freed node was the root */
1139  if( isroot )
1140  tree->root = NULL;
1141 
1142  return SCIP_OKAY;
1143 }
1144 
1145 /** cuts off node and whole sub tree from branch and bound tree */
1147  SCIP_NODE* node, /**< node that should be cut off */
1148  SCIP_SET* set, /**< global SCIP settings */
1149  SCIP_STAT* stat, /**< problem statistics */
1150  SCIP_TREE* tree, /**< branch and bound tree */
1151  SCIP_PROB* transprob, /**< transformed problem after presolve */
1152  SCIP_PROB* origprob, /**< original problem */
1153  SCIP_REOPT* reopt, /**< reoptimization data structure */
1154  SCIP_LP* lp, /**< current LP */
1155  BMS_BLKMEM* blkmem /**< block memory */
1156  )
1157 {
1158  SCIP_Real oldbound;
1159 
1160  assert(node != NULL);
1161  assert(set != NULL);
1162  assert(stat != NULL);
1163  assert(tree != NULL);
1164 
1165  if( set->reopt_enable )
1166  {
1167  assert(reopt != NULL);
1168  /* check if the node should be stored for reoptimization */
1170  tree->root == node, tree->focusnode == node, node->lowerbound, tree->effectiverootdepth) );
1171  }
1172 
1173  oldbound = node->lowerbound;
1174  node->cutoff = TRUE;
1175  node->lowerbound = SCIPsetInfinity(set);
1176  node->estimate = SCIPsetInfinity(set);
1177  if( node->active )
1178  tree->cutoffdepth = MIN(tree->cutoffdepth, (int)node->depth);
1179 
1180  /* update primal integral */
1181  if( node->depth == 0 )
1182  {
1183  stat->rootlowerbound = SCIPsetInfinity(set);
1184  if( set->misc_calcintegral )
1185  SCIPstatUpdatePrimalDualIntegral(stat, set, transprob, origprob, SCIPsetInfinity(set), SCIPsetInfinity(set));
1186  }
1187  else if( set->misc_calcintegral && SCIPsetIsEQ(set, oldbound, stat->lastlowerbound) )
1188  {
1189  SCIP_Real lowerbound;
1190  lowerbound = SCIPtreeGetLowerbound(tree, set);
1191 
1192  /* updating the primal integral is only necessary if dual bound has increased since last evaluation */
1193  if( lowerbound > stat->lastlowerbound )
1194  SCIPstatUpdatePrimalDualIntegral(stat, set, transprob, origprob, SCIPsetInfinity(set), SCIPsetInfinity(set));
1195  }
1196 
1197  SCIPvisualCutoffNode(stat->visual, set, stat, node, TRUE);
1198 
1199  SCIPsetDebugMsg(set, "cutting off %s node #%" SCIP_LONGINT_FORMAT " at depth %d (cutoffdepth: %d)\n",
1200  node->active ? "active" : "inactive", SCIPnodeGetNumber(node), SCIPnodeGetDepth(node), tree->cutoffdepth);
1201 
1202  return SCIP_OKAY;
1203 }
1204 
1205 /** marks node, that propagation should be applied again the next time, a node of its subtree is focused */
1207  SCIP_NODE* node, /**< node that should be propagated again */
1208  SCIP_SET* set, /**< global SCIP settings */
1209  SCIP_STAT* stat, /**< problem statistics */
1210  SCIP_TREE* tree /**< branch and bound tree */
1211  )
1212 {
1213  assert(node != NULL);
1214  assert(set != NULL);
1215  assert(stat != NULL);
1216  assert(tree != NULL);
1217 
1218  if( !node->reprop )
1219  {
1220  node->reprop = TRUE;
1221  if( node->active )
1222  tree->repropdepth = MIN(tree->repropdepth, (int)node->depth);
1223 
1224  SCIPvisualMarkedRepropagateNode(stat->visual, stat, node);
1225 
1226  SCIPsetDebugMsg(set, "marked %s node #%" SCIP_LONGINT_FORMAT " at depth %d to be propagated again (repropdepth: %d)\n",
1227  node->active ? "active" : "inactive", SCIPnodeGetNumber(node), SCIPnodeGetDepth(node), tree->repropdepth);
1228  }
1229 }
1230 
1231 /** marks node, that it is completely propagated in the current repropagation subtree level */
1233  SCIP_NODE* node, /**< node that should be marked to be propagated */
1234  SCIP_TREE* tree /**< branch and bound tree */
1235  )
1236 {
1237  assert(node != NULL);
1238  assert(tree != NULL);
1239 
1240  if( node->parent != NULL )
1241  node->repropsubtreemark = node->parent->repropsubtreemark; /*lint !e732*/
1242  node->reprop = FALSE;
1243 
1244  /* if the node was the highest repropagation node in the path, update the repropdepth in the tree data */
1245  if( node->active && node->depth == tree->repropdepth )
1246  {
1247  do
1248  {
1249  assert(tree->repropdepth < tree->pathlen);
1250  assert(tree->path[tree->repropdepth]->active);
1251  assert(!tree->path[tree->repropdepth]->reprop);
1252  tree->repropdepth++;
1253  }
1254  while( tree->repropdepth < tree->pathlen && !tree->path[tree->repropdepth]->reprop );
1255  if( tree->repropdepth == tree->pathlen )
1256  tree->repropdepth = INT_MAX;
1257  }
1258 }
1259 
1260 /** moves the subtree repropagation counter to the next value */
1261 static
1263  SCIP_TREE* tree /**< branch and bound tree */
1264  )
1265 {
1266  assert(tree != NULL);
1267 
1268  tree->repropsubtreecount++;
1269  tree->repropsubtreecount %= (MAXREPROPMARK+1);
1270 }
1271 
1272 /** applies propagation on the node, that was marked to be propagated again */
1273 static
1275  SCIP_NODE* node, /**< node to apply propagation on */
1276  BMS_BLKMEM* blkmem, /**< block memory buffers */
1277  SCIP_SET* set, /**< global SCIP settings */
1278  SCIP_STAT* stat, /**< dynamic problem statistics */
1279  SCIP_PROB* transprob, /**< transformed problem */
1280  SCIP_PROB* origprob, /**< original problem */
1281  SCIP_PRIMAL* primal, /**< primal data */
1282  SCIP_TREE* tree, /**< branch and bound tree */
1283  SCIP_REOPT* reopt, /**< reoptimization data structure */
1284  SCIP_LP* lp, /**< current LP data */
1285  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1286  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1287  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1288  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1289  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1290  SCIP_Bool* cutoff /**< pointer to store whether the node can be cut off */
1291  )
1292 {
1293  SCIP_NODETYPE oldtype;
1294  SCIP_NODE* oldfocusnode;
1295  SCIP_NODE* oldfocuslpfork;
1296  SCIP_NODE* oldfocuslpstatefork;
1297  SCIP_NODE* oldfocussubroot;
1298  SCIP_Longint oldfocuslpstateforklpcount;
1299  int oldnchildren;
1300  int oldnsiblings;
1301  SCIP_Bool oldfocusnodehaslp;
1302  SCIP_Longint oldnboundchgs;
1303  SCIP_Bool initialreprop;
1304  SCIP_Bool clockisrunning;
1305 
1306  assert(node != NULL);
1312  assert(node->active);
1313  assert(node->reprop || node->repropsubtreemark != node->parent->repropsubtreemark);
1314  assert(stat != NULL);
1315  assert(tree != NULL);
1316  assert(SCIPeventqueueIsDelayed(eventqueue));
1317  assert(cutoff != NULL);
1318 
1319  SCIPsetDebugMsg(set, "propagating again node #%" SCIP_LONGINT_FORMAT " at depth %d\n", SCIPnodeGetNumber(node), SCIPnodeGetDepth(node));
1320  initialreprop = node->reprop;
1321 
1322  SCIPvisualRepropagatedNode(stat->visual, stat, node);
1323 
1324  /* process the delayed events in order to flush the problem changes */
1325  SCIP_CALL( SCIPeventqueueProcess(eventqueue, blkmem, set, primal, lp, branchcand, eventfilter) );
1326 
1327  /* stop node activation timer */
1328  clockisrunning = SCIPclockIsRunning(stat->nodeactivationtime);
1329  if( clockisrunning )
1330  SCIPclockStop(stat->nodeactivationtime, set);
1331 
1332  /* mark the node refocused and temporarily install it as focus node */
1333  oldtype = (SCIP_NODETYPE)node->nodetype;
1334  oldfocusnode = tree->focusnode;
1335  oldfocuslpfork = tree->focuslpfork;
1336  oldfocuslpstatefork = tree->focuslpstatefork;
1337  oldfocussubroot = tree->focussubroot;
1338  oldfocuslpstateforklpcount = tree->focuslpstateforklpcount;
1339  oldnchildren = tree->nchildren;
1340  oldnsiblings = tree->nsiblings;
1341  oldfocusnodehaslp = tree->focusnodehaslp;
1342  node->nodetype = SCIP_NODETYPE_REFOCUSNODE; /*lint !e641*/
1343  tree->focusnode = node;
1344  tree->focuslpfork = NULL;
1345  tree->focuslpstatefork = NULL;
1346  tree->focussubroot = NULL;
1347  tree->focuslpstateforklpcount = -1;
1348  tree->nchildren = 0;
1349  tree->nsiblings = 0;
1350  tree->focusnodehaslp = FALSE;
1351 
1352  /* propagate the domains again */
1353  oldnboundchgs = stat->nboundchgs;
1354  SCIP_CALL( SCIPpropagateDomains(blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
1355  eventqueue, conflict, cliquetable, SCIPnodeGetDepth(node), 0, SCIP_PROPTIMING_ALWAYS, cutoff) );
1356  assert(!node->reprop || *cutoff);
1357  assert(node->parent == NULL || node->repropsubtreemark == node->parent->repropsubtreemark);
1359  assert(tree->focusnode == node);
1360  assert(tree->focuslpfork == NULL);
1361  assert(tree->focuslpstatefork == NULL);
1362  assert(tree->focussubroot == NULL);
1363  assert(tree->focuslpstateforklpcount == -1);
1364  assert(tree->nchildren == 0);
1365  assert(tree->nsiblings == 0);
1366  assert(tree->focusnodehaslp == FALSE);
1367  assert(stat->nboundchgs >= oldnboundchgs);
1368  stat->nreprops++;
1369  stat->nrepropboundchgs += stat->nboundchgs - oldnboundchgs;
1370  if( *cutoff )
1371  stat->nrepropcutoffs++;
1372 
1373  SCIPsetDebugMsg(set, "repropagation %" SCIP_LONGINT_FORMAT " at depth %u changed %" SCIP_LONGINT_FORMAT " bounds (total reprop bound changes: %" SCIP_LONGINT_FORMAT "), cutoff: %u\n",
1374  stat->nreprops, node->depth, stat->nboundchgs - oldnboundchgs, stat->nrepropboundchgs, *cutoff);
1375 
1376  /* if a propagation marked with the reprop flag was successful, we want to repropagate the whole subtree */
1377  /**@todo because repropsubtree is only a bit flag, we cannot mark a whole subtree a second time for
1378  * repropagation; use a (small) part of the node's bits to be able to store larger numbers,
1379  * and update tree->repropsubtreelevel with this number
1380  */
1381  if( initialreprop && !(*cutoff) && stat->nboundchgs > oldnboundchgs )
1382  {
1384  node->repropsubtreemark = tree->repropsubtreecount; /*lint !e732*/
1385  SCIPsetDebugMsg(set, "initial repropagation at depth %u changed %" SCIP_LONGINT_FORMAT " bounds -> repropagating subtree (new mark: %d)\n",
1386  node->depth, stat->nboundchgs - oldnboundchgs, tree->repropsubtreecount);
1387  assert((int)(node->repropsubtreemark) == tree->repropsubtreecount); /* bitfield must be large enough */
1388  }
1389 
1390  /* reset the node's type and reinstall the old focus node */
1391  node->nodetype = oldtype; /*lint !e641*/
1392  tree->focusnode = oldfocusnode;
1393  tree->focuslpfork = oldfocuslpfork;
1394  tree->focuslpstatefork = oldfocuslpstatefork;
1395  tree->focussubroot = oldfocussubroot;
1396  tree->focuslpstateforklpcount = oldfocuslpstateforklpcount;
1397  tree->nchildren = oldnchildren;
1398  tree->nsiblings = oldnsiblings;
1399  tree->focusnodehaslp = oldfocusnodehaslp;
1400 
1401  /* make the domain change data static again to save memory */
1403  {
1404  SCIP_CALL( SCIPdomchgMakeStatic(&node->domchg, blkmem, set, eventqueue, lp) );
1405  }
1406 
1407  /* start node activation timer again */
1408  if( clockisrunning )
1409  SCIPclockStart(stat->nodeactivationtime, set);
1410 
1411  /* delay events in path switching */
1412  SCIP_CALL( SCIPeventqueueDelay(eventqueue) );
1413 
1414  /* mark the node to be cut off if a cutoff was detected */
1415  if( *cutoff )
1416  {
1417  SCIP_CALL( SCIPnodeCutoff(node, set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
1418  }
1419 
1420  return SCIP_OKAY;
1421 }
1422 
1423 /** informs node, that it is now on the active path and applies any domain and constraint set changes */
1424 static
1426  SCIP_NODE* node, /**< node to activate */
1427  BMS_BLKMEM* blkmem, /**< block memory buffers */
1428  SCIP_SET* set, /**< global SCIP settings */
1429  SCIP_STAT* stat, /**< problem statistics */
1430  SCIP_PROB* transprob, /**< transformed problem */
1431  SCIP_PROB* origprob, /**< original problem */
1432  SCIP_PRIMAL* primal, /**< primal data */
1433  SCIP_TREE* tree, /**< branch and bound tree */
1434  SCIP_REOPT* reopt, /**< reotimization data structure */
1435  SCIP_LP* lp, /**< current LP data */
1436  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1437  SCIP_CONFLICT* conflict, /**< conflict analysis data */
1438  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1439  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1440  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1441  SCIP_Bool* cutoff /**< pointer to store whether the node can be cut off */
1442  )
1443 {
1444  assert(node != NULL);
1445  assert(!node->active);
1446  assert(stat != NULL);
1447  assert(tree != NULL);
1448  assert(!SCIPtreeProbing(tree));
1449  assert(cutoff != NULL);
1450 
1451  SCIPsetDebugMsg(set, "activate node #%" SCIP_LONGINT_FORMAT " at depth %d of type %d (reprop subtree mark: %u)\n",
1453 
1454  /* apply domain and constraint set changes */
1455  SCIP_CALL( SCIPconssetchgApply(node->conssetchg, blkmem, set, stat, node->depth,
1457  SCIP_CALL( SCIPdomchgApply(node->domchg, blkmem, set, stat, lp, branchcand, eventqueue, node->depth, cutoff) );
1458 
1459  /* mark node active */
1460  node->active = TRUE;
1461  stat->nactivatednodes++;
1462 
1463  /* check if the domain change produced a cutoff */
1464  if( *cutoff )
1465  {
1466  /* try to repropagate the node to see, if the propagation also leads to a conflict and a conflict constraint
1467  * could be generated; if propagation conflict analysis is turned off, repropagating the node makes no
1468  * sense, since it is already cut off
1469  */
1470  node->reprop = set->conf_enable && set->conf_useprop;
1471 
1472  /* mark the node to be cut off */
1473  SCIP_CALL( SCIPnodeCutoff(node, set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
1474  }
1475 
1476  /* propagate node again, if the reprop flag is set; in the new focus node, no repropagation is necessary, because
1477  * the focus node is propagated anyways
1478  */
1480  && (node->reprop || (node->parent != NULL && node->repropsubtreemark != node->parent->repropsubtreemark)) )
1481  {
1482  SCIP_Bool propcutoff;
1483 
1484  SCIP_CALL( nodeRepropagate(node, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand, conflict,
1485  eventfilter, eventqueue, cliquetable, &propcutoff) );
1486  *cutoff = *cutoff || propcutoff;
1487  }
1488 
1489  return SCIP_OKAY;
1490 }
1491 
1492 /** informs node, that it is no longer on the active path and undoes any domain and constraint set changes */
1493 static
1495  SCIP_NODE* node, /**< node to deactivate */
1496  BMS_BLKMEM* blkmem, /**< block memory buffers */
1497  SCIP_SET* set, /**< global SCIP settings */
1498  SCIP_STAT* stat, /**< problem statistics */
1499  SCIP_TREE* tree, /**< branch and bound tree */
1500  SCIP_LP* lp, /**< current LP data */
1501  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1502  SCIP_EVENTQUEUE* eventqueue /**< event queue */
1503  )
1504 {
1505  SCIP_Bool freeNode;
1506 
1507  assert(node != NULL);
1508  assert(node->active);
1509  assert(tree != NULL);
1510  assert(SCIPnodeGetType(node) != SCIP_NODETYPE_FOCUSNODE);
1511 
1512  SCIPsetDebugMsg(set, "deactivate node #%" SCIP_LONGINT_FORMAT " at depth %d of type %d (reprop subtree mark: %u)\n",
1514 
1515  /* undo domain and constraint set changes */
1516  SCIP_CALL( SCIPdomchgUndo(node->domchg, blkmem, set, stat, lp, branchcand, eventqueue) );
1517  SCIP_CALL( SCIPconssetchgUndo(node->conssetchg, blkmem, set, stat) );
1518 
1519  /* mark node inactive */
1520  node->active = FALSE;
1521 
1522  /* count number of deactivated nodes (ignoring probing switches) */
1523  if( !SCIPtreeProbing(tree) )
1524  stat->ndeactivatednodes++;
1525 
1526  /* free node if it is a dead-end node, i.e., has no children */
1527  switch( SCIPnodeGetType(node) )
1528  {
1531  case SCIP_NODETYPE_SIBLING:
1532  case SCIP_NODETYPE_CHILD:
1533  case SCIP_NODETYPE_LEAF:
1534  case SCIP_NODETYPE_DEADEND:
1536  freeNode = FALSE;
1537  break;
1539  freeNode = (node->data.junction.nchildren == 0);
1540  break;
1542  freeNode = (node->data.pseudofork->nchildren == 0);
1543  break;
1544  case SCIP_NODETYPE_FORK:
1545  freeNode = (node->data.fork->nchildren == 0);
1546  break;
1547  case SCIP_NODETYPE_SUBROOT:
1548  freeNode = (node->data.subroot->nchildren == 0);
1549  break;
1550  default:
1551  SCIPerrorMessage("unknown node type %d\n", SCIPnodeGetType(node));
1552  return SCIP_INVALIDDATA;
1553  }
1554  if( freeNode )
1555  {
1556  SCIP_CALL( SCIPnodeFree(&node, blkmem, set, stat, eventqueue, tree, lp) );
1557  }
1558 
1559  return SCIP_OKAY;
1560 }
1561 
1562 /** adds constraint locally to the node and captures it; activates constraint, if node is active;
1563  * if a local constraint is added to the root node, it is automatically upgraded into a global constraint
1564  */
1566  SCIP_NODE* node, /**< node to add constraint to */
1567  BMS_BLKMEM* blkmem, /**< block memory */
1568  SCIP_SET* set, /**< global SCIP settings */
1569  SCIP_STAT* stat, /**< problem statistics */
1570  SCIP_TREE* tree, /**< branch and bound tree */
1571  SCIP_CONS* cons /**< constraint to add */
1572  )
1573 {
1574  assert(node != NULL);
1575  assert(cons != NULL);
1576  assert(cons->validdepth <= SCIPnodeGetDepth(node));
1577  assert(tree != NULL);
1578  assert(tree->effectiverootdepth >= 0);
1579  assert(tree->root != NULL);
1580  assert(SCIPconsIsGlobal(cons) || SCIPnodeGetDepth(node) > tree->effectiverootdepth);
1581 
1582 #ifndef NDEBUG
1583  /* check if we add this constraint to the same scip, where we create the constraint */
1584  if( cons->scip != set->scip )
1585  {
1586  SCIPerrorMessage("try to add a constraint of another scip instance\n");
1587  return SCIP_INVALIDDATA;
1588  }
1589 #endif
1590 
1591  /* add constraint addition to the node's constraint set change data, and activate constraint if node is active */
1592  SCIP_CALL( SCIPconssetchgAddAddedCons(&node->conssetchg, blkmem, set, stat, cons, node->depth,
1593  (SCIPnodeGetType(node) == SCIP_NODETYPE_FOCUSNODE), node->active) );
1594  assert(node->conssetchg != NULL);
1595  assert(node->conssetchg->addedconss != NULL);
1596  assert(!node->active || SCIPconsIsActive(cons));
1597 
1598  /* if the constraint is added to an active node which is not a probing node, increment the corresponding counter */
1599  if( node->active && SCIPnodeGetType(node) != SCIP_NODETYPE_PROBINGNODE )
1600  stat->nactiveconssadded++;
1601 
1602  return SCIP_OKAY;
1603 }
1604 
1605 /** locally deletes constraint at the given node by disabling its separation, enforcing, and propagation capabilities
1606  * at the node; captures constraint; disables constraint, if node is active
1607  */
1609  SCIP_NODE* node, /**< node to add constraint to */
1610  BMS_BLKMEM* blkmem, /**< block memory */
1611  SCIP_SET* set, /**< global SCIP settings */
1612  SCIP_STAT* stat, /**< problem statistics */
1613  SCIP_TREE* tree, /**< branch and bound tree */
1614  SCIP_CONS* cons /**< constraint to locally delete */
1615  )
1616 {
1617  assert(node != NULL);
1618  assert(tree != NULL);
1619  assert(cons != NULL);
1620 
1621  SCIPsetDebugMsg(set, "disabling constraint <%s> at node at depth %u\n", cons->name, node->depth);
1622 
1623  /* add constraint disabling to the node's constraint set change data */
1624  SCIP_CALL( SCIPconssetchgAddDisabledCons(&node->conssetchg, blkmem, set, cons) );
1625  assert(node->conssetchg != NULL);
1626  assert(node->conssetchg->disabledconss != NULL);
1627 
1628  /* disable constraint, if node is active */
1629  if( node->active && cons->enabled && !cons->updatedisable )
1630  {
1631  SCIP_CALL( SCIPconsDisable(cons, set, stat) );
1632  }
1633 
1634  return SCIP_OKAY;
1635 }
1636 
1637 /** returns all constraints added to a given node */
1639  SCIP_NODE* node, /**< node */
1640  SCIP_CONS** addedconss, /**< array to store the constraints */
1641  int* naddedconss, /**< number of added constraints */
1642  int addedconsssize /**< size of the constraint array */
1643  )
1644 {
1645  int cons;
1646 
1647  assert(node != NULL );
1648  assert(node->conssetchg != NULL);
1649  assert(node->conssetchg->addedconss != NULL);
1650  assert(node->conssetchg->naddedconss >= 1);
1651 
1652  *naddedconss = node->conssetchg->naddedconss;
1653 
1654  /* check the size and return if the array is not large enough */
1655  if( addedconsssize < *naddedconss )
1656  return;
1657 
1658  /* fill the array */
1659  for( cons = 0; cons < *naddedconss; cons++ )
1660  {
1661  addedconss[cons] = node->conssetchg->addedconss[cons];
1662  }
1663 
1664  return;
1665 }
1666 
1667 /** returns the number of added constraints to the given node */
1669  SCIP_NODE* node /**< node */
1670  )
1671 {
1672  assert(node != NULL);
1673 
1674  if( node->conssetchg == NULL )
1675  return 0;
1676  else
1677  return node->conssetchg->naddedconss;
1678 }
1679 
1680 /** adds the given bound change to the list of pending bound changes */
1681 static
1683  SCIP_TREE* tree, /**< branch and bound tree */
1684  SCIP_SET* set, /**< global SCIP settings */
1685  SCIP_NODE* node, /**< node to add bound change to */
1686  SCIP_VAR* var, /**< variable to change the bounds for */
1687  SCIP_Real newbound, /**< new value for bound */
1688  SCIP_BOUNDTYPE boundtype, /**< type of bound: lower or upper bound */
1689  SCIP_CONS* infercons, /**< constraint that deduced the bound change, or NULL */
1690  SCIP_PROP* inferprop, /**< propagator that deduced the bound change, or NULL */
1691  int inferinfo, /**< user information for inference to help resolving the conflict */
1692  SCIP_Bool probingchange /**< is the bound change a temporary setting due to probing? */
1693  )
1694 {
1695  assert(tree != NULL);
1696 
1697  /* make sure that enough memory is allocated for the pendingbdchgs array */
1698  SCIP_CALL( treeEnsurePendingbdchgsMem(tree, set, tree->npendingbdchgs+1) );
1699 
1700  /* capture the variable */
1701  SCIPvarCapture(var);
1702 
1703  /* add the bound change to the pending list */
1704  tree->pendingbdchgs[tree->npendingbdchgs].node = node;
1705  tree->pendingbdchgs[tree->npendingbdchgs].var = var;
1706  tree->pendingbdchgs[tree->npendingbdchgs].newbound = newbound;
1707  tree->pendingbdchgs[tree->npendingbdchgs].boundtype = boundtype;
1708  tree->pendingbdchgs[tree->npendingbdchgs].infercons = infercons;
1709  tree->pendingbdchgs[tree->npendingbdchgs].inferprop = inferprop;
1710  tree->pendingbdchgs[tree->npendingbdchgs].inferinfo = inferinfo;
1711  tree->pendingbdchgs[tree->npendingbdchgs].probingchange = probingchange;
1712  tree->npendingbdchgs++;
1713 
1714  /* check global pending boundchanges against debug solution */
1715  if( node->depth == 0 )
1716  {
1717 #ifndef NDEBUG
1718  SCIP_Real bound = newbound;
1719 
1720  /* get bound adjusted for integrality(, this should already be done) */
1721  SCIPvarAdjustBd(var, set, boundtype, &bound);
1722 
1723  if( boundtype == SCIP_BOUNDTYPE_LOWER )
1724  {
1725  /* check that the bound is feasible */
1726  if( bound > SCIPvarGetUbGlobal(var) )
1727  {
1728  /* due to numerics we only want to be feasible in feasibility tolerance */
1729  assert(SCIPsetIsFeasLE(set, bound, SCIPvarGetUbGlobal(var)));
1730  bound = SCIPvarGetUbGlobal(var);
1731  }
1732  }
1733  else
1734  {
1735  assert(boundtype == SCIP_BOUNDTYPE_UPPER);
1736 
1737  /* check that the bound is feasible */
1738  if( bound < SCIPvarGetLbGlobal(var) )
1739  {
1740  /* due to numerics we only want to be feasible in feasibility tolerance */
1741  assert(SCIPsetIsFeasGE(set, bound, SCIPvarGetLbGlobal(var)));
1742  bound = SCIPvarGetLbGlobal(var);
1743  }
1744  }
1745  /* check that the given bound was already adjusted for integrality */
1746  assert(SCIPsetIsEQ(set, newbound, bound));
1747 #endif
1748  if( boundtype == SCIP_BOUNDTYPE_LOWER )
1749  {
1750  /* check bound on debugging solution */
1751  SCIP_CALL( SCIPdebugCheckLbGlobal(set->scip, var, newbound) ); /*lint !e506 !e774*/
1752  }
1753  else
1754  {
1755  assert(boundtype == SCIP_BOUNDTYPE_UPPER);
1756 
1757  /* check bound on debugging solution */
1758  SCIP_CALL( SCIPdebugCheckUbGlobal(set->scip, var, newbound) ); /*lint !e506 !e774*/
1759  }
1760  }
1761 
1762  return SCIP_OKAY;
1763 }
1764 
1765 /** adds bound change with inference information to focus node, child of focus node, or probing node;
1766  * if possible, adjusts bound to integral value;
1767  * at most one of infercons and inferprop may be non-NULL
1768  */
1770  SCIP_NODE* node, /**< node to add bound change to */
1771  BMS_BLKMEM* blkmem, /**< block memory */
1772  SCIP_SET* set, /**< global SCIP settings */
1773  SCIP_STAT* stat, /**< problem statistics */
1774  SCIP_PROB* transprob, /**< transformed problem after presolve */
1775  SCIP_PROB* origprob, /**< original problem */
1776  SCIP_TREE* tree, /**< branch and bound tree */
1777  SCIP_REOPT* reopt, /**< reoptimization data structure */
1778  SCIP_LP* lp, /**< current LP data */
1779  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1780  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1781  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1782  SCIP_VAR* var, /**< variable to change the bounds for */
1783  SCIP_Real newbound, /**< new value for bound */
1784  SCIP_BOUNDTYPE boundtype, /**< type of bound: lower or upper bound */
1785  SCIP_CONS* infercons, /**< constraint that deduced the bound change, or NULL */
1786  SCIP_PROP* inferprop, /**< propagator that deduced the bound change, or NULL */
1787  int inferinfo, /**< user information for inference to help resolving the conflict */
1788  SCIP_Bool probingchange /**< is the bound change a temporary setting due to probing? */
1789  )
1790 {
1791  SCIP_VAR* infervar;
1792  SCIP_BOUNDTYPE inferboundtype;
1793  SCIP_Real oldlb;
1794  SCIP_Real oldub;
1795  SCIP_Real oldbound;
1796 
1797  assert(node != NULL);
1802  || node->depth == 0);
1803  assert(set != NULL);
1804  assert(tree != NULL);
1805  assert(tree->effectiverootdepth >= 0);
1806  assert(tree->root != NULL);
1807  assert(var != NULL);
1808  assert(node->active || (infercons == NULL && inferprop == NULL));
1809  assert((SCIP_NODETYPE)node->nodetype == SCIP_NODETYPE_PROBINGNODE || !probingchange);
1810 
1811  SCIPsetDebugMsg(set, "adding boundchange at node %llu at depth %u to variable <%s>: old bounds=[%g,%g], new %s bound: %g (infer%s=<%s>, inferinfo=%d)\n",
1812  node->number, node->depth, SCIPvarGetName(var), SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var),
1813  boundtype == SCIP_BOUNDTYPE_LOWER ? "lower" : "upper", newbound, infercons != NULL ? "cons" : "prop",
1814  infercons != NULL ? SCIPconsGetName(infercons) : (inferprop != NULL ? SCIPpropGetName(inferprop) : "-"), inferinfo);
1815 
1816  /* remember variable as inference variable, and get corresponding active variable, bound and bound type */
1817  infervar = var;
1818  inferboundtype = boundtype;
1819 
1820  SCIP_CALL( SCIPvarGetProbvarBound(&var, &newbound, &boundtype) );
1821 
1823  {
1824  SCIPerrorMessage("cannot change bounds of multi-aggregated variable <%s>\n", SCIPvarGetName(var));
1825  SCIPABORT();
1826  return SCIP_INVALIDDATA; /*lint !e527*/
1827  }
1829 
1830  if( (int) node->depth <= tree->effectiverootdepth )
1831  {
1832  oldlb = SCIPvarGetLbGlobal(var);
1833  oldub = SCIPvarGetUbGlobal(var);
1834  }
1835  else
1836  {
1837  oldlb = SCIPvarGetLbLocal(var);
1838  oldub = SCIPvarGetUbLocal(var);
1839  }
1840  assert(SCIPsetIsLE(set, oldlb, oldub));
1841 
1842  if( boundtype == SCIP_BOUNDTYPE_LOWER )
1843  {
1844  /* adjust lower bound w.r.t. to integrality */
1845  SCIPvarAdjustLb(var, set, &newbound);
1846  assert(SCIPsetIsGT(set, newbound, oldlb));
1847  assert(SCIPsetIsFeasLE(set, newbound, oldub));
1848  oldbound = oldlb;
1849  newbound = MIN(newbound, oldub);
1850 
1851  if ( set->stage == SCIP_STAGE_SOLVING && SCIPsetIsInfinity(set, newbound) )
1852  {
1853  SCIPerrorMessage("cannot change lower bound of variable <%s> to infinity.\n", SCIPvarGetName(var));
1854  SCIPABORT();
1855  return SCIP_INVALIDDATA; /*lint !e527*/
1856  }
1857  }
1858  else
1859  {
1860  assert(boundtype == SCIP_BOUNDTYPE_UPPER);
1861 
1862  /* adjust the new upper bound */
1863  SCIPvarAdjustUb(var, set, &newbound);
1864  assert(SCIPsetIsLT(set, newbound, oldub));
1865  assert(SCIPsetIsFeasGE(set, newbound, oldlb));
1866  oldbound = oldub;
1867  newbound = MAX(newbound, oldlb);
1868 
1869  if ( set->stage == SCIP_STAGE_SOLVING && SCIPsetIsInfinity(set, -newbound) )
1870  {
1871  SCIPerrorMessage("cannot change upper bound of variable <%s> to minus infinity.\n", SCIPvarGetName(var));
1872  SCIPABORT();
1873  return SCIP_INVALIDDATA; /*lint !e527*/
1874  }
1875  }
1876 
1877  SCIPsetDebugMsg(set, " -> transformed to active variable <%s>: old bounds=[%g,%g], new %s bound: %g, obj: %g\n",
1878  SCIPvarGetName(var), oldlb, oldub, boundtype == SCIP_BOUNDTYPE_LOWER ? "lower" : "upper", newbound,
1879  SCIPvarGetObj(var));
1880 
1881  /* if the bound change takes place at an active node but is conflicting with the current local bounds,
1882  * we cannot apply it immediately because this would introduce inconsistencies to the bound change data structures
1883  * in the tree and to the bound change information data in the variable;
1884  * instead we have to remember the bound change as a pending bound change and mark the affected nodes on the active
1885  * path to be infeasible
1886  */
1887  if( node->active )
1888  {
1889  int conflictingdepth;
1890 
1891  conflictingdepth = SCIPvarGetConflictingBdchgDepth(var, set, boundtype, newbound);
1892 
1893  if( conflictingdepth >= 0 )
1894  {
1895  /* 0 would mean the bound change conflicts with a global bound */
1896  assert(conflictingdepth > 0);
1897  assert(conflictingdepth < tree->pathlen);
1898 
1899  SCIPsetDebugMsg(set, " -> bound change <%s> %s %g violates current local bounds [%g,%g] since depth %d: remember for later application\n",
1900  SCIPvarGetName(var), boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", newbound,
1901  SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var), conflictingdepth);
1902 
1903  /* remember the pending bound change */
1904  SCIP_CALL( treeAddPendingBdchg(tree, set, node, var, newbound, boundtype, infercons, inferprop, inferinfo,
1905  probingchange) );
1906 
1907  /* mark the node with the conflicting bound change to be cut off */
1908  SCIP_CALL( SCIPnodeCutoff(tree->path[conflictingdepth], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
1909 
1910  return SCIP_OKAY;
1911  }
1912  }
1913 
1914  SCIPstatIncrement(stat, set, nboundchgs);
1915 
1916  /* if we are in probing mode we have to additionally count the bound changes for the probing statistic */
1917  if( tree->probingroot != NULL )
1918  SCIPstatIncrement(stat, set, nprobboundchgs);
1919 
1920  /* if the node is the root node: change local and global bound immediately */
1921  if( SCIPnodeGetDepth(node) <= tree->effectiverootdepth )
1922  {
1923  assert(node->active || tree->focusnode == NULL );
1924  assert(SCIPnodeGetType(node) != SCIP_NODETYPE_PROBINGNODE);
1925  assert(!probingchange);
1926 
1927  SCIPsetDebugMsg(set, " -> bound change in root node: perform global bound change\n");
1928  SCIP_CALL( SCIPvarChgBdGlobal(var, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable, newbound, boundtype) );
1929 
1930  if( set->stage == SCIP_STAGE_SOLVING )
1931  {
1932  /* the root should be repropagated due to the bound change */
1933  SCIPnodePropagateAgain(tree->root, set, stat, tree);
1934  SCIPsetDebugMsg(set, "marked root node to be repropagated due to global bound change <%s>:[%g,%g] -> [%g,%g] found in depth %u\n",
1935  SCIPvarGetName(var), oldlb, oldub, boundtype == SCIP_BOUNDTYPE_LOWER ? newbound : oldlb,
1936  boundtype == SCIP_BOUNDTYPE_LOWER ? oldub : newbound, node->depth);
1937  }
1938 
1939  return SCIP_OKAY;
1940  }
1941 
1942  /* if the node is a child, or the bound is a temporary probing bound
1943  * - the bound change is a branching decision
1944  * - the child's lower bound can be updated due to the changed pseudo solution
1945  * otherwise:
1946  * - the bound change is an inference
1947  */
1948  if( SCIPnodeGetType(node) == SCIP_NODETYPE_CHILD || probingchange )
1949  {
1950  SCIP_Real newpseudoobjval;
1951  SCIP_Real lpsolval;
1952 
1953  assert(!node->active || SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
1954 
1955  /* get the solution value of variable in last solved LP on the active path:
1956  * - if the LP was solved at the current node, the LP values of the columns are valid
1957  * - if the last solved LP was the one in the current lpstatefork, the LP value in the columns are still valid
1958  * - otherwise, the LP values are invalid
1959  */
1960  if( SCIPtreeHasCurrentNodeLP(tree)
1962  {
1963  lpsolval = SCIPvarGetLPSol(var);
1964  }
1965  else
1966  lpsolval = SCIP_INVALID;
1967 
1968  /* remember the bound change as branching decision (infervar/infercons/inferprop are not important: use NULL) */
1969  SCIP_CALL( SCIPdomchgAddBoundchg(&node->domchg, blkmem, set, var, newbound, boundtype, SCIP_BOUNDCHGTYPE_BRANCHING,
1970  lpsolval, NULL, NULL, NULL, 0, inferboundtype) );
1971 
1972  /* update the child's lower bound */
1973  if( set->misc_exactsolve )
1974  newpseudoobjval = SCIPlpGetModifiedProvedPseudoObjval(lp, set, var, oldbound, newbound, boundtype);
1975  else
1976  newpseudoobjval = SCIPlpGetModifiedPseudoObjval(lp, set, transprob, var, oldbound, newbound, boundtype);
1977  SCIPnodeUpdateLowerbound(node, stat, set, tree, transprob, origprob, newpseudoobjval);
1978  }
1979  else
1980  {
1981  /* check the infered bound change on the debugging solution */
1982  SCIP_CALL( SCIPdebugCheckInference(blkmem, set, node, var, newbound, boundtype) ); /*lint !e506 !e774*/
1983 
1984  /* remember the bound change as inference (lpsolval is not important: use 0.0) */
1985  SCIP_CALL( SCIPdomchgAddBoundchg(&node->domchg, blkmem, set, var, newbound, boundtype,
1987  0.0, infervar, infercons, inferprop, inferinfo, inferboundtype) );
1988  }
1989 
1990  assert(node->domchg != NULL);
1991  assert(node->domchg->domchgdyn.domchgtype == SCIP_DOMCHGTYPE_DYNAMIC); /*lint !e641*/
1992  assert(node->domchg->domchgdyn.boundchgs != NULL);
1993  assert(node->domchg->domchgdyn.nboundchgs > 0);
1994  assert(node->domchg->domchgdyn.boundchgs[node->domchg->domchgdyn.nboundchgs-1].var == var);
1995  assert(node->domchg->domchgdyn.boundchgs[node->domchg->domchgdyn.nboundchgs-1].newbound == newbound); /*lint !e777*/
1996 
1997  /* if node is active, apply the bound change immediately */
1998  if( node->active )
1999  {
2000  SCIP_Bool cutoff;
2001 
2002  /**@todo if the node is active, it currently must either be the effective root (see above) or the current node;
2003  * if a bound change to an intermediate active node should be added, we must make sure, the bound change
2004  * information array of the variable stays sorted (new info must be sorted in instead of putting it to
2005  * the end of the array), and we should identify now redundant bound changes that are applied at a
2006  * later node on the active path
2007  */
2008  assert(SCIPtreeGetCurrentNode(tree) == node);
2010  blkmem, set, stat, lp, branchcand, eventqueue, node->depth, node->domchg->domchgdyn.nboundchgs-1, &cutoff) );
2011  assert(node->domchg->domchgdyn.boundchgs[node->domchg->domchgdyn.nboundchgs-1].var == var);
2012  assert(!cutoff);
2013  }
2014 
2015  return SCIP_OKAY;
2016 }
2017 
2018 /** adds bound change to focus node, or child of focus node, or probing node;
2019  * if possible, adjusts bound to integral value
2020  */
2022  SCIP_NODE* node, /**< node to add bound change to */
2023  BMS_BLKMEM* blkmem, /**< block memory */
2024  SCIP_SET* set, /**< global SCIP settings */
2025  SCIP_STAT* stat, /**< problem statistics */
2026  SCIP_PROB* transprob, /**< transformed problem after presolve */
2027  SCIP_PROB* origprob, /**< original problem */
2028  SCIP_TREE* tree, /**< branch and bound tree */
2029  SCIP_REOPT* reopt, /**< reoptimization data structure */
2030  SCIP_LP* lp, /**< current LP data */
2031  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2032  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2033  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
2034  SCIP_VAR* var, /**< variable to change the bounds for */
2035  SCIP_Real newbound, /**< new value for bound */
2036  SCIP_BOUNDTYPE boundtype, /**< type of bound: lower or upper bound */
2037  SCIP_Bool probingchange /**< is the bound change a temporary setting due to probing? */
2038  )
2039 {
2040  SCIP_CALL( SCIPnodeAddBoundinfer(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
2041  cliquetable, var, newbound, boundtype, NULL, NULL, 0, probingchange) );
2042 
2043  return SCIP_OKAY;
2044 }
2045 
2046 /** adds hole with inference information to focus node, child of focus node, or probing node;
2047  * if possible, adjusts bound to integral value;
2048  * at most one of infercons and inferprop may be non-NULL
2049  */
2051  SCIP_NODE* node, /**< node to add bound change to */
2052  BMS_BLKMEM* blkmem, /**< block memory */
2053  SCIP_SET* set, /**< global SCIP settings */
2054  SCIP_STAT* stat, /**< problem statistics */
2055  SCIP_TREE* tree, /**< branch and bound tree */
2056  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2057  SCIP_VAR* var, /**< variable to change the bounds for */
2058  SCIP_Real left, /**< left bound of open interval defining the hole (left,right) */
2059  SCIP_Real right, /**< right bound of open interval defining the hole (left,right) */
2060  SCIP_CONS* infercons, /**< constraint that deduced the bound change, or NULL */
2061  SCIP_PROP* inferprop, /**< propagator that deduced the bound change, or NULL */
2062  int inferinfo, /**< user information for inference to help resolving the conflict */
2063  SCIP_Bool probingchange, /**< is the bound change a temporary setting due to probing? */
2064  SCIP_Bool* added /**< pointer to store whether the hole was added, or NULL */
2065  )
2066 {
2067 #if 0
2068  SCIP_VAR* infervar;
2069 #endif
2070 
2071  assert(node != NULL);
2076  || node->depth == 0);
2077  assert(blkmem != NULL);
2078  assert(set != NULL);
2079  assert(tree != NULL);
2080  assert(tree->effectiverootdepth >= 0);
2081  assert(tree->root != NULL);
2082  assert(var != NULL);
2083  assert(node->active || (infercons == NULL && inferprop == NULL));
2084  assert((SCIP_NODETYPE)node->nodetype == SCIP_NODETYPE_PROBINGNODE || !probingchange);
2085 
2086  /* the interval should not be empty */
2087  assert(SCIPsetIsLT(set, left, right));
2088 
2089 #ifndef NDEBUG
2090  {
2091  SCIP_Real adjustedleft;
2092  SCIP_Real adjustedright;
2093 
2094  adjustedleft = left;
2095  adjustedright = right;
2096 
2097  SCIPvarAdjustUb(var, set, &adjustedleft);
2098  SCIPvarAdjustLb(var, set, &adjustedright);
2099 
2100  assert(SCIPsetIsEQ(set, left, adjustedleft));
2101  assert(SCIPsetIsEQ(set, right, adjustedright));
2102  }
2103 #endif
2104 
2105  /* the hole should lay within the lower and upper bounds */
2106  assert(SCIPsetIsGE(set, left, SCIPvarGetLbLocal(var)));
2107  assert(SCIPsetIsLE(set, right, SCIPvarGetUbLocal(var)));
2108 
2109  SCIPsetDebugMsg(set, "adding hole (%g,%g) at node at depth %u to variable <%s>: bounds=[%g,%g], (infer%s=<%s>, inferinfo=%d)\n",
2110  left, right, node->depth, SCIPvarGetName(var), SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var), infercons != NULL ? "cons" : "prop",
2111  infercons != NULL ? SCIPconsGetName(infercons) : (inferprop != NULL ? SCIPpropGetName(inferprop) : "-"), inferinfo);
2112 
2113 #if 0
2114  /* remember variable as inference variable, and get corresponding active variable, bound and bound type */
2115  infervar = var;
2116 #endif
2117  SCIP_CALL( SCIPvarGetProbvarHole(&var, &left, &right) );
2118 
2120  {
2121  SCIPerrorMessage("cannot change bounds of multi-aggregated variable <%s>\n", SCIPvarGetName(var));
2122  SCIPABORT();
2123  return SCIP_INVALIDDATA; /*lint !e527*/
2124  }
2126 
2127  SCIPsetDebugMsg(set, " -> transformed to active variable <%s>: hole (%g,%g), obj: %g\n", SCIPvarGetName(var), left, right, SCIPvarGetObj(var));
2128 
2129  stat->nholechgs++;
2130 
2131  /* if we are in probing mode we have to additionally count the bound changes for the probing statistic */
2132  if( tree->probingroot != NULL )
2133  stat->nprobholechgs++;
2134 
2135  /* if the node is the root node: change local and global bound immediately */
2136  if( SCIPnodeGetDepth(node) <= tree->effectiverootdepth )
2137  {
2138  assert(node->active || tree->focusnode == NULL );
2139  assert(SCIPnodeGetType(node) != SCIP_NODETYPE_PROBINGNODE);
2140  assert(!probingchange);
2141 
2142  SCIPsetDebugMsg(set, " -> hole added in root node: perform global domain change\n");
2143  SCIP_CALL( SCIPvarAddHoleGlobal(var, blkmem, set, stat, eventqueue, left, right, added) );
2144 
2145  if( set->stage == SCIP_STAGE_SOLVING && (*added) )
2146  {
2147  /* the root should be repropagated due to the bound change */
2148  SCIPnodePropagateAgain(tree->root, set, stat, tree);
2149  SCIPsetDebugMsg(set, "marked root node to be repropagated due to global added hole <%s>: (%g,%g) found in depth %u\n",
2150  SCIPvarGetName(var), left, right, node->depth);
2151  }
2152 
2153  return SCIP_OKAY;
2154  }
2155 
2156  /**@todo add adding of local domain holes */
2157 
2158  (*added) = FALSE;
2159  SCIPerrorMessage("WARNING: currently domain holes can only be handled globally!\n");
2160 
2161  stat->nholechgs--;
2162 
2163  /* if we are in probing mode we have to additionally count the bound changes for the probing statistic */
2164  if( tree->probingroot != NULL )
2165  stat->nprobholechgs--;
2166 
2167  return SCIP_OKAY;
2168 }
2169 
2170 /** adds hole change to focus node, or child of focus node */
2172  SCIP_NODE* node, /**< node to add bound change to */
2173  BMS_BLKMEM* blkmem, /**< block memory */
2174  SCIP_SET* set, /**< global SCIP settings */
2175  SCIP_STAT* stat, /**< problem statistics */
2176  SCIP_TREE* tree, /**< branch and bound tree */
2177  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2178  SCIP_VAR* var, /**< variable to change the bounds for */
2179  SCIP_Real left, /**< left bound of open interval defining the hole (left,right) */
2180  SCIP_Real right, /**< right bound of open interval defining the hole (left,right) */
2181  SCIP_Bool probingchange, /**< is the bound change a temporary setting due to probing? */
2182  SCIP_Bool* added /**< pointer to store whether the hole was added, or NULL */
2183  )
2184 {
2185  assert(node != NULL);
2189  assert(blkmem != NULL);
2190 
2191  SCIPsetDebugMsg(set, "adding hole (%g,%g) at node at depth %u of variable <%s>\n",
2192  left, right, node->depth, SCIPvarGetName(var));
2193 
2194  SCIP_CALL( SCIPnodeAddHoleinfer(node, blkmem, set, stat, tree, eventqueue, var, left, right,
2195  NULL, NULL, 0, probingchange, added) );
2196 
2197  /**@todo apply hole change on active nodes and issue event */
2198 
2199  return SCIP_OKAY;
2200 }
2201 
2202 /** applies the pending bound changes */
2203 static
2205  SCIP_TREE* tree, /**< branch and bound tree */
2206  SCIP_REOPT* reopt, /**< reoptimization data structure */
2207  BMS_BLKMEM* blkmem, /**< block memory */
2208  SCIP_SET* set, /**< global SCIP settings */
2209  SCIP_STAT* stat, /**< problem statistics */
2210  SCIP_PROB* transprob, /**< transformed problem after presolve */
2211  SCIP_PROB* origprob, /**< original problem */
2212  SCIP_LP* lp, /**< current LP data */
2213  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2214  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2215  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
2216  )
2217 {
2218  SCIP_VAR* var;
2219  int npendingbdchgs;
2220  int conflictdepth;
2221  int i;
2222 
2223  assert(tree != NULL);
2224 
2225  npendingbdchgs = tree->npendingbdchgs;
2226  for( i = 0; i < npendingbdchgs; ++i )
2227  {
2228  var = tree->pendingbdchgs[i].var;
2229  assert(SCIPnodeGetDepth(tree->pendingbdchgs[i].node) < tree->cutoffdepth);
2230 
2231  conflictdepth = SCIPvarGetConflictingBdchgDepth(var, set, tree->pendingbdchgs[i].boundtype,
2232  tree->pendingbdchgs[i].newbound);
2233 
2234  /* It can happen, that a pending bound change conflicts with the global bounds, because when it was collected, it
2235  * just conflicted with the local bounds, but a conflicting global bound change was applied afterwards. In this
2236  * case, we can cut off the node where the pending bound change should be applied.
2237  */
2238  if( conflictdepth == 0 )
2239  {
2240  SCIP_CALL( SCIPnodeCutoff(tree->pendingbdchgs[i].node, set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
2241 
2242  if( ((int) tree->pendingbdchgs[i].node->depth) <= tree->effectiverootdepth )
2243  break; /* break here to clear all pending bound changes */
2244  else
2245  continue;
2246  }
2247 
2248  assert(conflictdepth == -1);
2249 
2250  SCIPsetDebugMsg(set, "applying pending bound change <%s>[%g,%g] %s %g\n", SCIPvarGetName(var),
2252  tree->pendingbdchgs[i].boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
2253  tree->pendingbdchgs[i].newbound);
2254 
2255  /* ignore bounds that are now redundant (for example, multiple entries in the pendingbdchgs for the same
2256  * variable)
2257  */
2258  if( tree->pendingbdchgs[i].boundtype == SCIP_BOUNDTYPE_LOWER )
2259  {
2260  SCIP_Real lb;
2261 
2262  lb = SCIPvarGetLbLocal(var);
2263  if( !SCIPsetIsGT(set, tree->pendingbdchgs[i].newbound, lb) )
2264  continue;
2265  }
2266  else
2267  {
2268  SCIP_Real ub;
2269 
2270  assert(tree->pendingbdchgs[i].boundtype == SCIP_BOUNDTYPE_UPPER);
2271  ub = SCIPvarGetUbLocal(var);
2272  if( !SCIPsetIsLT(set, tree->pendingbdchgs[i].newbound, ub) )
2273  continue;
2274  }
2275 
2276  SCIP_CALL( SCIPnodeAddBoundinfer(tree->pendingbdchgs[i].node, blkmem, set, stat, transprob, origprob, tree, reopt,
2277  lp, branchcand, eventqueue, cliquetable, var, tree->pendingbdchgs[i].newbound, tree->pendingbdchgs[i].boundtype,
2279  tree->pendingbdchgs[i].probingchange) );
2280  assert(tree->npendingbdchgs == npendingbdchgs); /* this time, the bound change can be applied! */
2281  }
2282 
2283  /* clear pending bound changes */
2284  for( i = 0; i < tree->npendingbdchgs; ++i )
2285  {
2286  var = tree->pendingbdchgs[i].var;
2287  assert(var != NULL);
2288 
2289  /* release the variable */
2290  SCIP_CALL( SCIPvarRelease(&var, blkmem, set, eventqueue, lp) );
2291  }
2292 
2293  tree->npendingbdchgs = 0;
2294 
2295  return SCIP_OKAY;
2296 }
2297 
2298 /** if given value is larger than the node's lower bound, sets the node's lower bound to the new value */
2300  SCIP_NODE* node, /**< node to update lower bound for */
2301  SCIP_STAT* stat, /**< problem statistics */
2302  SCIP_SET* set, /**< global SCIP settings */
2303  SCIP_TREE* tree, /**< branch and bound tree */
2304  SCIP_PROB* transprob, /**< transformed problem after presolve */
2305  SCIP_PROB* origprob, /**< original problem */
2306  SCIP_Real newbound /**< new lower bound for the node (if it's larger than the old one) */
2307  )
2308 {
2309  assert(node != NULL);
2310  assert(stat != NULL);
2311 
2312  if( newbound > node->lowerbound )
2313  {
2314  SCIP_Real oldbound;
2315 
2316  oldbound = node->lowerbound;
2317  node->lowerbound = newbound;
2318  node->estimate = MAX(node->estimate, newbound);
2319 
2320  if( node->depth == 0 )
2321  {
2322  stat->rootlowerbound = newbound;
2323  if( set->misc_calcintegral )
2324  SCIPstatUpdatePrimalDualIntegral(stat, set, transprob, origprob, SCIPsetInfinity(set), newbound);
2325  SCIPvisualLowerbound(stat->visual, set, stat, newbound);
2326  }
2327  else if ( SCIPnodeGetType(node) != SCIP_NODETYPE_PROBINGNODE )
2328  {
2329  SCIP_Real lowerbound;
2330 
2331  lowerbound = SCIPtreeGetLowerbound(tree, set);
2332  assert(newbound >= lowerbound);
2333  SCIPvisualLowerbound(stat->visual, set, stat, lowerbound);
2334 
2335  /* updating the primal integral is only necessary if dual bound has increased since last evaluation */
2336  if( set->misc_calcintegral && SCIPsetIsEQ(set, oldbound, stat->lastlowerbound) && lowerbound > stat->lastlowerbound )
2337  SCIPstatUpdatePrimalDualIntegral(stat, set, transprob, origprob, SCIPsetInfinity(set), lowerbound);
2338  }
2339  }
2340 }
2341 
2342 /** updates lower bound of node using lower bound of LP */
2344  SCIP_NODE* node, /**< node to set lower bound for */
2345  SCIP_SET* set, /**< global SCIP settings */
2346  SCIP_STAT* stat, /**< problem statistics */
2347  SCIP_TREE* tree, /**< branch and bound tree */
2348  SCIP_PROB* transprob, /**< transformed problem after presolve */
2349  SCIP_PROB* origprob, /**< original problem */
2350  SCIP_LP* lp /**< LP data */
2351  )
2352 {
2353  SCIP_Real lpobjval;
2354 
2355  assert(set != NULL);
2356  assert(lp->flushed);
2357 
2358  /* in case of iteration or time limit, the LP value may not be a valid dual bound */
2359  /* @todo check for dual feasibility of LP solution and use sub-optimal solution if they are dual feasible */
2361  return SCIP_OKAY;
2362 
2363  if( set->misc_exactsolve )
2364  {
2365  SCIP_CALL( SCIPlpGetProvedLowerbound(lp, set, &lpobjval) );
2366  }
2367  else
2368  lpobjval = SCIPlpGetObjval(lp, set, transprob);
2369 
2370  SCIPnodeUpdateLowerbound(node, stat, set, tree, transprob, origprob, lpobjval);
2371 
2372  return SCIP_OKAY;
2373 }
2374 
2375 
2376 /** change the node selection priority of the given child */
2378  SCIP_TREE* tree, /**< branch and bound tree */
2379  SCIP_NODE* child, /**< child to update the node selection priority */
2380  SCIP_Real priority /**< node selection priority value */
2381  )
2382 {
2383  int pos;
2384 
2385  assert( SCIPnodeGetType(child) == SCIP_NODETYPE_CHILD );
2386 
2387  pos = child->data.child.arraypos;
2388  assert( pos >= 0 );
2389 
2390  tree->childrenprio[pos] = priority;
2391 }
2392 
2393 
2394 /** sets the node's estimated bound to the new value */
2396  SCIP_NODE* node, /**< node to update lower bound for */
2397  SCIP_SET* set, /**< global SCIP settings */
2398  SCIP_Real newestimate /**< new estimated bound for the node */
2399  )
2400 {
2401  assert(node != NULL);
2402  assert(set != NULL);
2403  assert(SCIPsetIsRelGE(set, newestimate, node->lowerbound));
2404 
2405  node->estimate = newestimate;
2406 }
2407 
2408 /** propagates implications of binary fixings at the given node triggered by the implication graph and the clique table */
2410  SCIP_NODE* node, /**< node to propagate implications on */
2411  BMS_BLKMEM* blkmem, /**< block memory */
2412  SCIP_SET* set, /**< global SCIP settings */
2413  SCIP_STAT* stat, /**< problem statistics */
2414  SCIP_PROB* transprob, /**< transformed problem after presolve */
2415  SCIP_PROB* origprob, /**< original problem */
2416  SCIP_TREE* tree, /**< branch and bound tree */
2417  SCIP_REOPT* reopt, /**< reoptimization data structure */
2418  SCIP_LP* lp, /**< current LP data */
2419  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2420  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2421  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
2422  SCIP_Bool* cutoff /**< pointer to store whether the node can be cut off */
2423  )
2424 {
2425  int nboundchgs;
2426  int i;
2427 
2428  assert(node != NULL);
2429  assert(SCIPnodeIsActive(node));
2433  assert(cutoff != NULL);
2434 
2435  SCIPsetDebugMsg(set, "implication graph propagation of node #%" SCIP_LONGINT_FORMAT " in depth %d\n",
2436  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node));
2437 
2438  *cutoff = FALSE;
2439 
2440  /* propagate all fixings of binary variables performed at this node */
2441  nboundchgs = SCIPdomchgGetNBoundchgs(node->domchg);
2442  for( i = 0; i < nboundchgs && !(*cutoff); ++i )
2443  {
2444  SCIP_BOUNDCHG* boundchg;
2445  SCIP_VAR* var;
2446 
2447  boundchg = SCIPdomchgGetBoundchg(node->domchg, i);
2448 
2449  /* ignore redundant bound changes */
2450  if( SCIPboundchgIsRedundant(boundchg) )
2451  continue;
2452 
2453  var = SCIPboundchgGetVar(boundchg);
2454  if( SCIPvarIsBinary(var) )
2455  {
2456  SCIP_Bool varfixing;
2457  int nimpls;
2458  SCIP_VAR** implvars;
2459  SCIP_BOUNDTYPE* impltypes;
2460  SCIP_Real* implbounds;
2461  SCIP_CLIQUE** cliques;
2462  int ncliques;
2463  int j;
2464 
2465  varfixing = (SCIPboundchgGetBoundtype(boundchg) == SCIP_BOUNDTYPE_LOWER);
2466  nimpls = SCIPvarGetNImpls(var, varfixing);
2467  implvars = SCIPvarGetImplVars(var, varfixing);
2468  impltypes = SCIPvarGetImplTypes(var, varfixing);
2469  implbounds = SCIPvarGetImplBounds(var, varfixing);
2470 
2471  /* apply implications */
2472  for( j = 0; j < nimpls; ++j )
2473  {
2474  SCIP_Real lb;
2475  SCIP_Real ub;
2476 
2477  /* @note should this be checked here (because SCIPnodeAddBoundinfer fails for multi-aggregated variables)
2478  * or should SCIPnodeAddBoundinfer() just return for multi-aggregated variables?
2479  */
2481  continue;
2482 
2483  /* check for infeasibility */
2484  lb = SCIPvarGetLbLocal(implvars[j]);
2485  ub = SCIPvarGetUbLocal(implvars[j]);
2486  if( impltypes[j] == SCIP_BOUNDTYPE_LOWER )
2487  {
2488  if( SCIPsetIsFeasGT(set, implbounds[j], ub) )
2489  {
2490  *cutoff = TRUE;
2491  return SCIP_OKAY;
2492  }
2493  if( SCIPsetIsFeasLE(set, implbounds[j], lb) )
2494  continue;
2495  }
2496  else
2497  {
2498  if( SCIPsetIsFeasLT(set, implbounds[j], lb) )
2499  {
2500  *cutoff = TRUE;
2501  return SCIP_OKAY;
2502  }
2503  if( SCIPsetIsFeasGE(set, implbounds[j], ub) )
2504  continue;
2505  }
2506 
2507  /* @note the implication might affect a fixed variable (after resolving (multi-)aggregations);
2508  * normally, the implication should have been deleted in that case, but this is only possible
2509  * if the implied variable has the reverse implication stored as a variable bound;
2510  * due to numerics, the variable bound may not be present and so the implication is not deleted
2511  */
2513  continue;
2514 
2515  /* apply the implication */
2516  SCIP_CALL( SCIPnodeAddBoundinfer(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
2517  eventqueue, cliquetable, implvars[j], implbounds[j], impltypes[j], NULL, NULL, 0, FALSE) );
2518  }
2519 
2520  /* apply cliques */
2521  ncliques = SCIPvarGetNCliques(var, varfixing);
2522  cliques = SCIPvarGetCliques(var, varfixing);
2523  for( j = 0; j < ncliques; ++j )
2524  {
2525  SCIP_VAR** vars;
2526  SCIP_Bool* values;
2527  int nvars;
2528  int k;
2529 
2530  nvars = SCIPcliqueGetNVars(cliques[j]);
2531  vars = SCIPcliqueGetVars(cliques[j]);
2532  values = SCIPcliqueGetValues(cliques[j]);
2533  for( k = 0; k < nvars; ++k )
2534  {
2535  SCIP_Real lb;
2536  SCIP_Real ub;
2537 
2538  assert(SCIPvarIsBinary(vars[k]));
2539 
2540  if( SCIPvarGetStatus(vars[k]) == SCIP_VARSTATUS_MULTAGGR )
2541  continue;
2542 
2543  if( vars[k] == var && values[k] == varfixing )
2544  continue;
2545 
2546  /* check for infeasibility */
2547  lb = SCIPvarGetLbLocal(vars[k]);
2548  ub = SCIPvarGetUbLocal(vars[k]);
2549  if( values[k] == FALSE )
2550  {
2551  if( ub < 0.5 )
2552  {
2553  *cutoff = TRUE;
2554  return SCIP_OKAY;
2555  }
2556  if( lb > 0.5 )
2557  continue;
2558  }
2559  else
2560  {
2561  if( lb > 0.5 )
2562  {
2563  *cutoff = TRUE;
2564  return SCIP_OKAY;
2565  }
2566  if( ub < 0.5 )
2567  continue;
2568  }
2569 
2571  continue;
2572 
2573  /* apply the clique implication */
2574  SCIP_CALL( SCIPnodeAddBoundinfer(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
2575  eventqueue, cliquetable, vars[k], (SCIP_Real)(!values[k]), values[k] ? SCIP_BOUNDTYPE_UPPER : SCIP_BOUNDTYPE_LOWER,
2576  NULL, NULL, 0, FALSE) );
2577  }
2578  }
2579  }
2580  }
2581 
2582  return SCIP_OKAY;
2583 }
2584 
2585 
2586 
2587 
2588 /*
2589  * Path Switching
2590  */
2591 
2592 /** updates the LP sizes of the active path starting at the given depth */
2593 static
2595  SCIP_TREE* tree, /**< branch and bound tree */
2596  int startdepth /**< depth to start counting */
2597  )
2598 {
2599  SCIP_NODE* node;
2600  int ncols;
2601  int nrows;
2602  int i;
2603 
2604  assert(tree != NULL);
2605  assert(startdepth >= 0);
2606  assert(startdepth <= tree->pathlen);
2607 
2608  if( startdepth == 0 )
2609  {
2610  ncols = 0;
2611  nrows = 0;
2612  }
2613  else
2614  {
2615  ncols = tree->pathnlpcols[startdepth-1];
2616  nrows = tree->pathnlprows[startdepth-1];
2617  }
2618 
2619  for( i = startdepth; i < tree->pathlen; ++i )
2620  {
2621  node = tree->path[i];
2622  assert(node != NULL);
2623  assert(node->active);
2624  assert((int)(node->depth) == i);
2625 
2626  switch( SCIPnodeGetType(node) )
2627  {
2629  assert(i == tree->pathlen-1 || SCIPtreeProbing(tree));
2630  break;
2632  assert(SCIPtreeProbing(tree));
2633  assert(i >= 1);
2634  assert(SCIPnodeGetType(tree->path[i-1]) == SCIP_NODETYPE_FOCUSNODE
2635  || (ncols == node->data.probingnode->ninitialcols && nrows == node->data.probingnode->ninitialrows));
2636  assert(ncols <= node->data.probingnode->ncols || !tree->focuslpconstructed);
2637  assert(nrows <= node->data.probingnode->nrows || !tree->focuslpconstructed);
2638  if( i < tree->pathlen-1 )
2639  {
2640  ncols = node->data.probingnode->ncols;
2641  nrows = node->data.probingnode->nrows;
2642  }
2643  else
2644  {
2645  /* for the current probing node, the initial LP size is stored in the path */
2646  ncols = node->data.probingnode->ninitialcols;
2647  nrows = node->data.probingnode->ninitialrows;
2648  }
2649  break;
2650  case SCIP_NODETYPE_SIBLING:
2651  SCIPerrorMessage("sibling cannot be in the active path\n");
2652  SCIPABORT();
2653  return SCIP_INVALIDDATA; /*lint !e527*/
2654  case SCIP_NODETYPE_CHILD:
2655  SCIPerrorMessage("child cannot be in the active path\n");
2656  SCIPABORT();
2657  return SCIP_INVALIDDATA; /*lint !e527*/
2658  case SCIP_NODETYPE_LEAF:
2659  SCIPerrorMessage("leaf cannot be in the active path\n");
2660  SCIPABORT();
2661  return SCIP_INVALIDDATA; /*lint !e527*/
2662  case SCIP_NODETYPE_DEADEND:
2663  SCIPerrorMessage("dead-end cannot be in the active path\n");
2664  SCIPABORT();
2665  return SCIP_INVALIDDATA; /*lint !e527*/
2667  break;
2669  assert(node->data.pseudofork != NULL);
2670  ncols += node->data.pseudofork->naddedcols;
2671  nrows += node->data.pseudofork->naddedrows;
2672  break;
2673  case SCIP_NODETYPE_FORK:
2674  assert(node->data.fork != NULL);
2675  ncols += node->data.fork->naddedcols;
2676  nrows += node->data.fork->naddedrows;
2677  break;
2678  case SCIP_NODETYPE_SUBROOT:
2679  assert(node->data.subroot != NULL);
2680  ncols = node->data.subroot->ncols;
2681  nrows = node->data.subroot->nrows;
2682  break;
2684  SCIPerrorMessage("node cannot be of type REFOCUSNODE at this point\n");
2685  SCIPABORT();
2686  return SCIP_INVALIDDATA; /*lint !e527*/
2687  default:
2688  SCIPerrorMessage("unknown node type %d\n", SCIPnodeGetType(node));
2689  SCIPABORT();
2690  return SCIP_INVALIDDATA; /*lint !e527*/
2691  }
2692  tree->pathnlpcols[i] = ncols;
2693  tree->pathnlprows[i] = nrows;
2694  }
2695  return SCIP_OKAY;
2696 }
2697 
2698 /** finds the common fork node, the new LP state defining fork, and the new focus subroot, if the path is switched to
2699  * the given node
2700  */
2701 static
2703  SCIP_TREE* tree, /**< branch and bound tree */
2704  SCIP_NODE* node, /**< new focus node, or NULL */
2705  SCIP_NODE** commonfork, /**< pointer to store common fork node of old and new focus node */
2706  SCIP_NODE** newlpfork, /**< pointer to store the new LP defining fork node */
2707  SCIP_NODE** newlpstatefork, /**< pointer to store the new LP state defining fork node */
2708  SCIP_NODE** newsubroot, /**< pointer to store the new subroot node */
2709  SCIP_Bool* cutoff /**< pointer to store whether the given node can be cut off and no path switching
2710  * should be performed */
2711  )
2712 {
2713  SCIP_NODE* fork;
2714  SCIP_NODE* lpfork;
2715  SCIP_NODE* lpstatefork;
2716  SCIP_NODE* subroot;
2717 
2718  assert(tree != NULL);
2719  assert(tree->root != NULL);
2720  assert((tree->focusnode == NULL) == !tree->root->active);
2721  assert(tree->focuslpfork == NULL || tree->focusnode != NULL);
2722  assert(tree->focuslpfork == NULL || tree->focuslpfork->depth < tree->focusnode->depth);
2723  assert(tree->focuslpstatefork == NULL || tree->focuslpfork != NULL);
2724  assert(tree->focuslpstatefork == NULL || tree->focuslpstatefork->depth <= tree->focuslpfork->depth);
2725  assert(tree->focussubroot == NULL || tree->focuslpstatefork != NULL);
2726  assert(tree->focussubroot == NULL || tree->focussubroot->depth <= tree->focuslpstatefork->depth);
2727  assert(tree->cutoffdepth >= 0);
2728  assert(tree->cutoffdepth == INT_MAX || tree->cutoffdepth < tree->pathlen);
2729  assert(tree->cutoffdepth == INT_MAX || tree->path[tree->cutoffdepth]->cutoff);
2730  assert(tree->repropdepth >= 0);
2731  assert(tree->repropdepth == INT_MAX || tree->repropdepth < tree->pathlen);
2732  assert(tree->repropdepth == INT_MAX || tree->path[tree->repropdepth]->reprop);
2733  assert(commonfork != NULL);
2734  assert(newlpfork != NULL);
2735  assert(newlpstatefork != NULL);
2736  assert(newsubroot != NULL);
2737  assert(cutoff != NULL);
2738 
2739  *commonfork = NULL;
2740  *newlpfork = NULL;
2741  *newlpstatefork = NULL;
2742  *newsubroot = NULL;
2743  *cutoff = FALSE;
2744 
2745  /* if the new focus node is NULL, there is no common fork node, and the new LP fork, LP state fork, and subroot
2746  * are NULL
2747  */
2748  if( node == NULL )
2749  {
2750  tree->cutoffdepth = INT_MAX;
2751  tree->repropdepth = INT_MAX;
2752  return;
2753  }
2754 
2755  /* check if the new node is marked to be cut off */
2756  if( node->cutoff )
2757  {
2758  *cutoff = TRUE;
2759  return;
2760  }
2761 
2762  /* if the old focus node is NULL, there is no common fork node, and we have to search the new LP fork, LP state fork
2763  * and subroot
2764  */
2765  if( tree->focusnode == NULL )
2766  {
2767  assert(!tree->root->active);
2768  assert(tree->pathlen == 0);
2769  assert(tree->cutoffdepth == INT_MAX);
2770  assert(tree->repropdepth == INT_MAX);
2771 
2772  lpfork = node;
2773  while( SCIPnodeGetType(lpfork) != SCIP_NODETYPE_PSEUDOFORK
2775  {
2776  lpfork = lpfork->parent;
2777  if( lpfork == NULL )
2778  return;
2779  if( lpfork->cutoff )
2780  {
2781  *cutoff = TRUE;
2782  return;
2783  }
2784  }
2785  *newlpfork = lpfork;
2786 
2787  lpstatefork = lpfork;
2788  while( SCIPnodeGetType(lpstatefork) != SCIP_NODETYPE_FORK && SCIPnodeGetType(lpstatefork) != SCIP_NODETYPE_SUBROOT )
2789  {
2790  lpstatefork = lpstatefork->parent;
2791  if( lpstatefork == NULL )
2792  return;
2793  if( lpstatefork->cutoff )
2794  {
2795  *cutoff = TRUE;
2796  return;
2797  }
2798  }
2799  *newlpstatefork = lpstatefork;
2800 
2801  subroot = lpstatefork;
2802  while( SCIPnodeGetType(subroot) != SCIP_NODETYPE_SUBROOT )
2803  {
2804  subroot = subroot->parent;
2805  if( subroot == NULL )
2806  return;
2807  if( subroot->cutoff )
2808  {
2809  *cutoff = TRUE;
2810  return;
2811  }
2812  }
2813  *newsubroot = subroot;
2814 
2815  fork = subroot;
2816  while( fork->parent != NULL )
2817  {
2818  fork = fork->parent;
2819  if( fork->cutoff )
2820  {
2821  *cutoff = TRUE;
2822  return;
2823  }
2824  }
2825  return;
2826  }
2827 
2828  /* find the common fork node, the new LP defining fork, the new LP state defining fork, and the new focus subroot */
2829  fork = node;
2830  lpfork = NULL;
2831  lpstatefork = NULL;
2832  subroot = NULL;
2833  assert(fork != NULL);
2834 
2835  while( !fork->active )
2836  {
2837  fork = fork->parent;
2838  assert(fork != NULL); /* because the root is active, there must be a common fork node */
2839 
2840  if( fork->cutoff )
2841  {
2842  *cutoff = TRUE;
2843  return;
2844  }
2845  if( lpfork == NULL
2848  lpfork = fork;
2849  if( lpstatefork == NULL
2851  lpstatefork = fork;
2852  if( subroot == NULL && SCIPnodeGetType(fork) == SCIP_NODETYPE_SUBROOT )
2853  subroot = fork;
2854  }
2855  assert(lpfork == NULL || !lpfork->active || lpfork == fork);
2856  assert(lpstatefork == NULL || !lpstatefork->active || lpstatefork == fork);
2857  assert(subroot == NULL || !subroot->active || subroot == fork);
2858  SCIPdebugMessage("find switch forks: forkdepth=%u\n", fork->depth);
2859 
2860  /* if the common fork node is below the current cutoff depth, the cutoff node is an ancestor of the common fork
2861  * and thus an ancestor of the new focus node, s.t. the new node can also be cut off
2862  */
2863  assert((int)fork->depth != tree->cutoffdepth);
2864  if( (int)fork->depth > tree->cutoffdepth )
2865  {
2866 #ifndef NDEBUG
2867  while( !fork->cutoff )
2868  {
2869  fork = fork->parent;
2870  assert(fork != NULL);
2871  }
2872  assert((int)fork->depth >= tree->cutoffdepth);
2873 #endif
2874  *cutoff = TRUE;
2875  return;
2876  }
2877  tree->cutoffdepth = INT_MAX;
2878 
2879  /* if not already found, continue searching the LP defining fork; it cannot be deeper than the common fork */
2880  if( lpfork == NULL )
2881  {
2882  if( tree->focuslpfork != NULL && (int)(tree->focuslpfork->depth) > fork->depth )
2883  {
2884  /* focuslpfork is not on the same active path as the new node: we have to continue searching */
2885  lpfork = fork;
2886  while( lpfork != NULL
2888  && SCIPnodeGetType(lpfork) != SCIP_NODETYPE_FORK
2889  && SCIPnodeGetType(lpfork) != SCIP_NODETYPE_SUBROOT )
2890  {
2891  assert(lpfork->active);
2892  lpfork = lpfork->parent;
2893  }
2894  }
2895  else
2896  {
2897  /* focuslpfork is on the same active path as the new node: old and new node have the same lpfork */
2898  lpfork = tree->focuslpfork;
2899  }
2900  assert(lpfork == NULL || (int)(lpfork->depth) <= fork->depth);
2901  assert(lpfork == NULL || lpfork->active);
2902  }
2903  assert(lpfork == NULL
2905  || SCIPnodeGetType(lpfork) == SCIP_NODETYPE_FORK
2906  || SCIPnodeGetType(lpfork) == SCIP_NODETYPE_SUBROOT);
2907  SCIPdebugMessage("find switch forks: lpforkdepth=%d\n", lpfork == NULL ? -1 : (int)(lpfork->depth));
2908 
2909  /* if not already found, continue searching the LP state defining fork; it cannot be deeper than the
2910  * LP defining fork and the common fork
2911  */
2912  if( lpstatefork == NULL )
2913  {
2914  if( tree->focuslpstatefork != NULL && (int)(tree->focuslpstatefork->depth) > fork->depth )
2915  {
2916  /* focuslpstatefork is not on the same active path as the new node: we have to continue searching */
2917  if( lpfork != NULL && lpfork->depth < fork->depth )
2918  lpstatefork = lpfork;
2919  else
2920  lpstatefork = fork;
2921  while( lpstatefork != NULL
2922  && SCIPnodeGetType(lpstatefork) != SCIP_NODETYPE_FORK
2923  && SCIPnodeGetType(lpstatefork) != SCIP_NODETYPE_SUBROOT )
2924  {
2925  assert(lpstatefork->active);
2926  lpstatefork = lpstatefork->parent;
2927  }
2928  }
2929  else
2930  {
2931  /* focuslpstatefork is on the same active path as the new node: old and new node have the same lpstatefork */
2932  lpstatefork = tree->focuslpstatefork;
2933  }
2934  assert(lpstatefork == NULL || (int)(lpstatefork->depth) <= fork->depth);
2935  assert(lpstatefork == NULL || lpstatefork->active);
2936  }
2937  assert(lpstatefork == NULL
2938  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK
2939  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT);
2940  assert(lpstatefork == NULL || (lpfork != NULL && lpstatefork->depth <= lpfork->depth));
2941  SCIPdebugMessage("find switch forks: lpstateforkdepth=%d\n", lpstatefork == NULL ? -1 : (int)(lpstatefork->depth));
2942 
2943  /* if not already found, continue searching the subroot; it cannot be deeper than the LP defining fork, the
2944  * LP state fork and the common fork
2945  */
2946  if( subroot == NULL )
2947  {
2948  if( tree->focussubroot != NULL && (int)(tree->focussubroot->depth) > fork->depth )
2949  {
2950  /* focussubroot is not on the same active path as the new node: we have to continue searching */
2951  if( lpstatefork != NULL && lpstatefork->depth < fork->depth )
2952  subroot = lpstatefork;
2953  else if( lpfork != NULL && lpfork->depth < fork->depth )
2954  subroot = lpfork;
2955  else
2956  subroot = fork;
2957  while( subroot != NULL && SCIPnodeGetType(subroot) != SCIP_NODETYPE_SUBROOT )
2958  {
2959  assert(subroot->active);
2960  subroot = subroot->parent;
2961  }
2962  }
2963  else
2964  subroot = tree->focussubroot;
2965  assert(subroot == NULL || subroot->depth <= fork->depth);
2966  assert(subroot == NULL || subroot->active);
2967  }
2968  assert(subroot == NULL || SCIPnodeGetType(subroot) == SCIP_NODETYPE_SUBROOT);
2969  assert(subroot == NULL || (lpstatefork != NULL && subroot->depth <= lpstatefork->depth));
2970  SCIPdebugMessage("find switch forks: subrootdepth=%d\n", subroot == NULL ? -1 : (int)(subroot->depth));
2971 
2972  /* if a node prior to the common fork should be repropagated, we select the node to be repropagated as common
2973  * fork in order to undo all bound changes up to this node, repropagate the node, and redo the bound changes
2974  * afterwards
2975  */
2976  if( (int)fork->depth > tree->repropdepth )
2977  {
2978  fork = tree->path[tree->repropdepth];
2979  assert(fork->active);
2980  assert(fork->reprop);
2981  }
2982 
2983  *commonfork = fork;
2984  *newlpfork = lpfork;
2985  *newlpstatefork = lpstatefork;
2986  *newsubroot = subroot;
2987 
2988 #ifndef NDEBUG
2989  while( fork != NULL )
2990  {
2991  assert(fork->active);
2992  assert(!fork->cutoff);
2993  assert(fork->parent == NULL || !fork->parent->reprop);
2994  fork = fork->parent;
2995  }
2996 #endif
2997  tree->repropdepth = INT_MAX;
2998 }
2999 
3000 /** switches the active path to the new focus node, applies domain and constraint set changes */
3001 static
3003  SCIP_TREE* tree, /**< branch and bound tree */
3004  SCIP_REOPT* reopt, /**< reoptimization data structure */
3005  BMS_BLKMEM* blkmem, /**< block memory buffers */
3006  SCIP_SET* set, /**< global SCIP settings */
3007  SCIP_STAT* stat, /**< problem statistics */
3008  SCIP_PROB* transprob, /**< transformed problem after presolve */
3009  SCIP_PROB* origprob, /**< original problem */
3010  SCIP_PRIMAL* primal, /**< primal data */
3011  SCIP_LP* lp, /**< current LP data */
3012  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3013  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3014  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
3015  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3016  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
3017  SCIP_NODE* fork, /**< common fork node of old and new focus node, or NULL */
3018  SCIP_NODE* focusnode, /**< new focus node, or NULL */
3019  SCIP_Bool* cutoff /**< pointer to store whether the new focus node can be cut off */
3020  )
3021 {
3022  int focusnodedepth; /* depth of the new focus node, or -1 if focusnode == NULL */
3023  int forkdepth; /* depth of the common subroot/fork/pseudofork/junction node, or -1 if no common fork exists */
3024  int i;
3025 
3026  assert(tree != NULL);
3027  assert(fork == NULL || (fork->active && !fork->cutoff));
3028  assert(fork == NULL || focusnode != NULL);
3029  assert(focusnode == NULL || (!focusnode->active && !focusnode->cutoff));
3030  assert(focusnode == NULL || SCIPnodeGetType(focusnode) == SCIP_NODETYPE_FOCUSNODE);
3031  assert(cutoff != NULL);
3032 
3033  *cutoff = FALSE;
3034 
3035  SCIPsetDebugMsg(set, "switch path: old pathlen=%d\n", tree->pathlen);
3036 
3037  /* get the nodes' depths */
3038  focusnodedepth = (focusnode != NULL ? (int)focusnode->depth : -1);
3039  forkdepth = (fork != NULL ? (int)fork->depth : -1);
3040  assert(forkdepth <= focusnodedepth);
3041  assert(forkdepth < tree->pathlen);
3042 
3043  /* delay events in path switching */
3044  SCIP_CALL( SCIPeventqueueDelay(eventqueue) );
3045 
3046  /* undo the domain and constraint set changes of the old active path by deactivating the path's nodes */
3047  for( i = tree->pathlen-1; i > forkdepth; --i )
3048  {
3049  SCIP_CALL( nodeDeactivate(tree->path[i], blkmem, set, stat, tree, lp, branchcand, eventqueue) );
3050  }
3051  tree->pathlen = forkdepth+1;
3052 
3053  /* apply the pending bound changes */
3054  SCIP_CALL( treeApplyPendingBdchgs(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, cliquetable) );
3055 
3056  /* create the new active path */
3057  SCIP_CALL( treeEnsurePathMem(tree, set, focusnodedepth+1) );
3058 
3059  while( focusnode != fork )
3060  {
3061  assert(focusnode != NULL);
3062  assert(!focusnode->active);
3063  assert(!focusnode->cutoff);
3064  /* coverity[var_deref_op] */
3065  tree->path[focusnode->depth] = focusnode;
3066  focusnode = focusnode->parent;
3067  }
3068 
3069  /* fork might be cut off when applying the pending bound changes */
3070  if( fork != NULL && fork->cutoff )
3071  *cutoff = TRUE;
3072  else if( fork != NULL && fork->reprop )
3073  {
3074  /* propagate common fork again, if the reprop flag is set */
3075  assert(tree->path[forkdepth] == fork);
3076  assert(fork->active);
3077  assert(!fork->cutoff);
3078 
3079  SCIP_CALL( nodeRepropagate(fork, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand, conflict,
3080  eventfilter, eventqueue, cliquetable, cutoff) );
3081  }
3082  assert(fork != NULL || !(*cutoff));
3083 
3084  /* Apply domain and constraint set changes of the new path by activating the path's nodes;
3085  * on the way, domain propagation might be applied again to the path's nodes, which can result in the cutoff of
3086  * the node (and its subtree).
3087  * We only activate all nodes down to the parent of the new focus node, because the events in this process are
3088  * delayed, which means that multiple changes of a bound of a variable are merged (and might even be cancelled out,
3089  * if the bound is first relaxed when deactivating a node on the old path and then tightened to the same value
3090  * when activating a node on the new path).
3091  * This is valid for all nodes down to the parent of the new focus node, since they have already been propagated.
3092  * Bound change events on the new focus node, however, must not be cancelled out, since they need to be propagated
3093  * and thus, the event must be thrown and catched by the constraint handlers to mark constraints for propagation.
3094  */
3095  for( i = forkdepth+1; i < focusnodedepth && !(*cutoff); ++i )
3096  {
3097  assert(!tree->path[i]->cutoff);
3098  assert(tree->pathlen == i);
3099 
3100  /* activate the node, and apply domain propagation if the reprop flag is set */
3101  tree->pathlen++;
3102  SCIP_CALL( nodeActivate(tree->path[i], blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
3103  conflict, eventfilter, eventqueue, cliquetable, cutoff) );
3104  }
3105 
3106  /* process the delayed events */
3107  SCIP_CALL( SCIPeventqueueProcess(eventqueue, blkmem, set, primal, lp, branchcand, eventfilter) );
3108 
3109  /* activate the new focus node; there is no need to delay these events */
3110  if( !(*cutoff) && (i == focusnodedepth) )
3111  {
3112  assert(!tree->path[focusnodedepth]->cutoff);
3113  assert(tree->pathlen == focusnodedepth);
3114 
3115  /* activate the node, and apply domain propagation if the reprop flag is set */
3116  tree->pathlen++;
3117  SCIP_CALL( nodeActivate(tree->path[focusnodedepth], blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
3118  conflict, eventfilter, eventqueue, cliquetable, cutoff) );
3119  }
3120 
3121  /* mark last node of path to be cut off, if a cutoff was found */
3122  if( *cutoff )
3123  {
3124  assert(tree->pathlen > 0);
3125  assert(tree->path[tree->pathlen-1]->active);
3126  SCIP_CALL( SCIPnodeCutoff(tree->path[tree->pathlen-1], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
3127  }
3128 
3129  /* count the new LP sizes of the path */
3130  SCIP_CALL( treeUpdatePathLPSize(tree, forkdepth+1) );
3131 
3132  SCIPsetDebugMsg(set, "switch path: new pathlen=%d\n", tree->pathlen);
3133 
3134  return SCIP_OKAY;
3135 }
3136 
3137 /** loads the subroot's LP data */
3138 static
3140  SCIP_NODE* subroot, /**< subroot node to construct LP for */
3141  BMS_BLKMEM* blkmem, /**< block memory buffers */
3142  SCIP_SET* set, /**< global SCIP settings */
3143  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3144  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3145  SCIP_LP* lp /**< current LP data */
3146  )
3147 {
3148  SCIP_COL** cols;
3149  SCIP_ROW** rows;
3150  int ncols;
3151  int nrows;
3152  int c;
3153  int r;
3154 
3155  assert(subroot != NULL);
3156  assert(SCIPnodeGetType(subroot) == SCIP_NODETYPE_SUBROOT);
3157  assert(subroot->data.subroot != NULL);
3158  assert(blkmem != NULL);
3159  assert(set != NULL);
3160  assert(lp != NULL);
3161 
3162  cols = subroot->data.subroot->cols;
3163  rows = subroot->data.subroot->rows;
3164  ncols = subroot->data.subroot->ncols;
3165  nrows = subroot->data.subroot->nrows;
3166 
3167  assert(ncols == 0 || cols != NULL);
3168  assert(nrows == 0 || rows != NULL);
3169 
3170  for( c = 0; c < ncols; ++c )
3171  {
3172  SCIP_CALL( SCIPlpAddCol(lp, set, cols[c], subroot->depth) );
3173  }
3174  for( r = 0; r < nrows; ++r )
3175  {
3176  SCIP_CALL( SCIPlpAddRow(lp, blkmem, set, eventqueue, eventfilter, rows[r], subroot->depth) );
3177  }
3178 
3179  return SCIP_OKAY;
3180 }
3181 
3182 /** loads the fork's additional LP data */
3183 static
3185  SCIP_NODE* fork, /**< fork node to construct additional LP for */
3186  BMS_BLKMEM* blkmem, /**< block memory buffers */
3187  SCIP_SET* set, /**< global SCIP settings */
3188  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3189  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3190  SCIP_LP* lp /**< current LP data */
3191  )
3192 {
3193  SCIP_COL** cols;
3194  SCIP_ROW** rows;
3195  int ncols;
3196  int nrows;
3197  int c;
3198  int r;
3199 
3200  assert(fork != NULL);
3201  assert(SCIPnodeGetType(fork) == SCIP_NODETYPE_FORK);
3202  assert(fork->data.fork != NULL);
3203  assert(blkmem != NULL);
3204  assert(set != NULL);
3205  assert(lp != NULL);
3206 
3207  cols = fork->data.fork->addedcols;
3208  rows = fork->data.fork->addedrows;
3209  ncols = fork->data.fork->naddedcols;
3210  nrows = fork->data.fork->naddedrows;
3211 
3212  assert(ncols == 0 || cols != NULL);
3213  assert(nrows == 0 || rows != NULL);
3214 
3215  for( c = 0; c < ncols; ++c )
3216  {
3217  SCIP_CALL( SCIPlpAddCol(lp, set, cols[c], fork->depth) );
3218  }
3219  for( r = 0; r < nrows; ++r )
3220  {
3221  SCIP_CALL( SCIPlpAddRow(lp, blkmem, set, eventqueue, eventfilter, rows[r], fork->depth) );
3222  }
3223 
3224  return SCIP_OKAY;
3225 }
3226 
3227 /** loads the pseudofork's additional LP data */
3228 static
3230  SCIP_NODE* pseudofork, /**< pseudofork node to construct additional LP for */
3231  BMS_BLKMEM* blkmem, /**< block memory buffers */
3232  SCIP_SET* set, /**< global SCIP settings */
3233  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3234  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3235  SCIP_LP* lp /**< current LP data */
3236  )
3237 {
3238  SCIP_COL** cols;
3239  SCIP_ROW** rows;
3240  int ncols;
3241  int nrows;
3242  int c;
3243  int r;
3244 
3245  assert(pseudofork != NULL);
3246  assert(SCIPnodeGetType(pseudofork) == SCIP_NODETYPE_PSEUDOFORK);
3247  assert(pseudofork->data.pseudofork != NULL);
3248  assert(blkmem != NULL);
3249  assert(set != NULL);
3250  assert(lp != NULL);
3251 
3252  cols = pseudofork->data.pseudofork->addedcols;
3253  rows = pseudofork->data.pseudofork->addedrows;
3254  ncols = pseudofork->data.pseudofork->naddedcols;
3255  nrows = pseudofork->data.pseudofork->naddedrows;
3256 
3257  assert(ncols == 0 || cols != NULL);
3258  assert(nrows == 0 || rows != NULL);
3259 
3260  for( c = 0; c < ncols; ++c )
3261  {
3262  SCIP_CALL( SCIPlpAddCol(lp, set, cols[c], pseudofork->depth) );
3263  }
3264  for( r = 0; r < nrows; ++r )
3265  {
3266  SCIP_CALL( SCIPlpAddRow(lp, blkmem, set, eventqueue, eventfilter, rows[r], pseudofork->depth) );
3267  }
3268 
3269  return SCIP_OKAY;
3270 }
3271 
3272 #ifndef NDEBUG
3273 /** checks validity of active path */
3274 static
3276  SCIP_TREE* tree /**< branch and bound tree */
3277  )
3278 {
3279  SCIP_NODE* node;
3280  int ncols;
3281  int nrows;
3282  int d;
3283 
3284  assert(tree != NULL);
3285  assert(tree->path != NULL);
3286 
3287  ncols = 0;
3288  nrows = 0;
3289  for( d = 0; d < tree->pathlen; ++d )
3290  {
3291  node = tree->path[d];
3292  assert(node != NULL);
3293  assert((int)(node->depth) == d);
3294  switch( SCIPnodeGetType(node) )
3295  {
3297  assert(SCIPtreeProbing(tree));
3298  assert(d >= 1);
3299  assert(SCIPnodeGetType(tree->path[d-1]) == SCIP_NODETYPE_FOCUSNODE
3300  || (ncols == node->data.probingnode->ninitialcols && nrows == node->data.probingnode->ninitialrows));
3301  assert(ncols <= node->data.probingnode->ncols || !tree->focuslpconstructed);
3302  assert(nrows <= node->data.probingnode->nrows || !tree->focuslpconstructed);
3303  if( d < tree->pathlen-1 )
3304  {
3305  ncols = node->data.probingnode->ncols;
3306  nrows = node->data.probingnode->nrows;
3307  }
3308  else
3309  {
3310  /* for the current probing node, the initial LP size is stored in the path */
3311  ncols = node->data.probingnode->ninitialcols;
3312  nrows = node->data.probingnode->ninitialrows;
3313  }
3314  break;
3316  break;
3318  ncols += node->data.pseudofork->naddedcols;
3319  nrows += node->data.pseudofork->naddedrows;
3320  break;
3321  case SCIP_NODETYPE_FORK:
3322  ncols += node->data.fork->naddedcols;
3323  nrows += node->data.fork->naddedrows;
3324  break;
3325  case SCIP_NODETYPE_SUBROOT:
3326  ncols = node->data.subroot->ncols;
3327  nrows = node->data.subroot->nrows;
3328  break;
3331  assert(d == tree->pathlen-1 || SCIPtreeProbing(tree));
3332  break;
3333  default:
3334  SCIPerrorMessage("node at depth %d on active path has to be of type JUNCTION, PSEUDOFORK, FORK, SUBROOT, FOCUSNODE, REFOCUSNODE, or PROBINGNODE, but is %d\n",
3335  d, SCIPnodeGetType(node));
3336  SCIPABORT();
3337  } /*lint !e788*/
3338  assert(tree->pathnlpcols[d] == ncols);
3339  assert(tree->pathnlprows[d] == nrows);
3340  }
3341 }
3342 #else
3343 #define treeCheckPath(tree) /**/
3344 #endif
3345 
3346 /** constructs the LP relaxation of the focus node */
3348  SCIP_TREE* tree, /**< branch and bound tree */
3349  BMS_BLKMEM* blkmem, /**< block memory buffers */
3350  SCIP_SET* set, /**< global SCIP settings */
3351  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3352  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3353  SCIP_LP* lp, /**< current LP data */
3354  SCIP_Bool* initroot /**< pointer to store whether the root LP relaxation has to be initialized */
3355  )
3356 {
3357  SCIP_NODE* lpfork;
3358  int lpforkdepth;
3359  int d;
3360 
3361  assert(tree != NULL);
3362  assert(!tree->focuslpconstructed);
3363  assert(tree->path != NULL);
3364  assert(tree->pathlen > 0);
3365  assert(tree->focusnode != NULL);
3367  assert(SCIPnodeGetDepth(tree->focusnode) == tree->pathlen-1);
3368  assert(!SCIPtreeProbing(tree));
3369  assert(tree->focusnode == tree->path[tree->pathlen-1]);
3370  assert(blkmem != NULL);
3371  assert(set != NULL);
3372  assert(lp != NULL);
3373  assert(initroot != NULL);
3374 
3375  SCIPsetDebugMsg(set, "load LP for current fork node #%" SCIP_LONGINT_FORMAT " at depth %d\n",
3376  tree->focuslpfork == NULL ? -1 : SCIPnodeGetNumber(tree->focuslpfork),
3377  tree->focuslpfork == NULL ? -1 : SCIPnodeGetDepth(tree->focuslpfork));
3378  SCIPsetDebugMsg(set, "-> old LP has %d cols and %d rows\n", SCIPlpGetNCols(lp), SCIPlpGetNRows(lp));
3379  SCIPsetDebugMsg(set, "-> correct LP has %d cols and %d rows\n",
3380  tree->correctlpdepth >= 0 ? tree->pathnlpcols[tree->correctlpdepth] : 0,
3381  tree->correctlpdepth >= 0 ? tree->pathnlprows[tree->correctlpdepth] : 0);
3382  SCIPsetDebugMsg(set, "-> old correctlpdepth: %d\n", tree->correctlpdepth);
3383 
3384  treeCheckPath(tree);
3385 
3386  lpfork = tree->focuslpfork;
3387 
3388  /* find out the lpfork's depth (or -1, if lpfork is NULL) */
3389  if( lpfork == NULL )
3390  {
3391  assert(tree->correctlpdepth == -1 || tree->pathnlpcols[tree->correctlpdepth] == 0);
3392  assert(tree->correctlpdepth == -1 || tree->pathnlprows[tree->correctlpdepth] == 0);
3393  assert(tree->focuslpstatefork == NULL);
3394  assert(tree->focussubroot == NULL);
3395  lpforkdepth = -1;
3396  }
3397  else
3398  {
3399  assert(SCIPnodeGetType(lpfork) == SCIP_NODETYPE_PSEUDOFORK
3401  assert(lpfork->active);
3402  assert(tree->path[lpfork->depth] == lpfork);
3403  lpforkdepth = lpfork->depth;
3404  }
3405  assert(lpforkdepth < tree->pathlen-1); /* lpfork must not be the last (the focus) node of the active path */
3406 
3407  /* find out, if we are in the same subtree */
3408  if( tree->correctlpdepth >= 0 )
3409  {
3410  /* same subtree: shrink LP to the deepest node with correct LP */
3411  assert(lpforkdepth == -1 || tree->pathnlpcols[tree->correctlpdepth] <= tree->pathnlpcols[lpforkdepth]);
3412  assert(lpforkdepth == -1 || tree->pathnlprows[tree->correctlpdepth] <= tree->pathnlprows[lpforkdepth]);
3413  assert(lpforkdepth >= 0 || tree->pathnlpcols[tree->correctlpdepth] == 0);
3414  assert(lpforkdepth >= 0 || tree->pathnlprows[tree->correctlpdepth] == 0);
3415  SCIP_CALL( SCIPlpShrinkCols(lp, set, tree->pathnlpcols[tree->correctlpdepth]) );
3416  SCIP_CALL( SCIPlpShrinkRows(lp, blkmem, set, eventqueue, eventfilter, tree->pathnlprows[tree->correctlpdepth]) );
3417  }
3418  else
3419  {
3420  /* other subtree: fill LP with the subroot LP data */
3421  SCIP_CALL( SCIPlpClear(lp, blkmem, set, eventqueue, eventfilter) );
3422  if( tree->focussubroot != NULL )
3423  {
3424  SCIP_CALL( subrootConstructLP(tree->focussubroot, blkmem, set, eventqueue, eventfilter, lp) );
3425  tree->correctlpdepth = tree->focussubroot->depth;
3426  }
3427  }
3428 
3429  assert(lpforkdepth < tree->pathlen);
3430 
3431  /* add the missing columns and rows */
3432  for( d = tree->correctlpdepth+1; d <= lpforkdepth; ++d )
3433  {
3434  SCIP_NODE* pathnode;
3435 
3436  pathnode = tree->path[d];
3437  assert(pathnode != NULL);
3438  assert((int)(pathnode->depth) == d);
3439  assert(SCIPnodeGetType(pathnode) == SCIP_NODETYPE_JUNCTION
3441  || SCIPnodeGetType(pathnode) == SCIP_NODETYPE_FORK);
3442  if( SCIPnodeGetType(pathnode) == SCIP_NODETYPE_FORK )
3443  {
3444  SCIP_CALL( forkAddLP(pathnode, blkmem, set, eventqueue, eventfilter, lp) );
3445  }
3446  else if( SCIPnodeGetType(pathnode) == SCIP_NODETYPE_PSEUDOFORK )
3447  {
3448  SCIP_CALL( pseudoforkAddLP(pathnode, blkmem, set, eventqueue, eventfilter, lp) );
3449  }
3450  }
3451  tree->correctlpdepth = MAX(tree->correctlpdepth, lpforkdepth);
3452  assert(lpforkdepth == -1 || tree->pathnlpcols[tree->correctlpdepth] == tree->pathnlpcols[lpforkdepth]);
3453  assert(lpforkdepth == -1 || tree->pathnlprows[tree->correctlpdepth] == tree->pathnlprows[lpforkdepth]);
3454  assert(lpforkdepth == -1 || SCIPlpGetNCols(lp) == tree->pathnlpcols[lpforkdepth]);
3455  assert(lpforkdepth == -1 || SCIPlpGetNRows(lp) == tree->pathnlprows[lpforkdepth]);
3456  assert(lpforkdepth >= 0 || SCIPlpGetNCols(lp) == 0);
3457  assert(lpforkdepth >= 0 || SCIPlpGetNRows(lp) == 0);
3458 
3459  /* mark the LP's size, such that we know which rows and columns were added in the new node */
3460  SCIPlpMarkSize(lp);
3461 
3462  SCIPsetDebugMsg(set, "-> new correctlpdepth: %d\n", tree->correctlpdepth);
3463  SCIPsetDebugMsg(set, "-> new LP has %d cols and %d rows\n", SCIPlpGetNCols(lp), SCIPlpGetNRows(lp));
3464 
3465  /* if the correct LP depth is still -1, the root LP relaxation has to be initialized */
3466  *initroot = (tree->correctlpdepth == -1);
3467 
3468  /* mark the LP of the focus node constructed */
3469  tree->focuslpconstructed = TRUE;
3470 
3471  return SCIP_OKAY;
3472 }
3473 
3474 /** loads LP state for fork/subroot of the focus node */
3476  SCIP_TREE* tree, /**< branch and bound tree */
3477  BMS_BLKMEM* blkmem, /**< block memory buffers */
3478  SCIP_SET* set, /**< global SCIP settings */
3479  SCIP_STAT* stat, /**< dynamic problem statistics */
3480  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3481  SCIP_LP* lp /**< current LP data */
3482  )
3483 {
3484  SCIP_NODE* lpstatefork;
3485  SCIP_Bool updatefeas;
3486  SCIP_Bool checkbdchgs;
3487  int lpstateforkdepth;
3488  int d;
3489 
3490  assert(tree != NULL);
3491  assert(tree->focuslpconstructed);
3492  assert(tree->path != NULL);
3493  assert(tree->pathlen > 0);
3494  assert(tree->focusnode != NULL);
3495  assert(tree->correctlpdepth < tree->pathlen);
3497  assert(SCIPnodeGetDepth(tree->focusnode) == tree->pathlen-1);
3498  assert(!SCIPtreeProbing(tree));
3499  assert(tree->focusnode == tree->path[tree->pathlen-1]);
3500  assert(blkmem != NULL);
3501  assert(set != NULL);
3502  assert(lp != NULL);
3503 
3504  SCIPsetDebugMsg(set, "load LP state for current fork node #%" SCIP_LONGINT_FORMAT " at depth %d\n",
3506  tree->focuslpstatefork == NULL ? -1 : SCIPnodeGetDepth(tree->focuslpstatefork));
3507 
3508  lpstatefork = tree->focuslpstatefork;
3509 
3510  /* if there is no LP state defining fork, nothing can be done */
3511  if( lpstatefork == NULL )
3512  return SCIP_OKAY;
3513 
3514  /* get the lpstatefork's depth */
3515  assert(SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT);
3516  assert(lpstatefork->active);
3517  assert(tree->path[lpstatefork->depth] == lpstatefork);
3518  lpstateforkdepth = lpstatefork->depth;
3519  assert(lpstateforkdepth < tree->pathlen-1); /* lpstatefork must not be the last (the focus) node of the active path */
3520  assert(lpstateforkdepth <= tree->correctlpdepth); /* LP must have been constructed at least up to the fork depth */
3521  assert(tree->pathnlpcols[tree->correctlpdepth] >= tree->pathnlpcols[lpstateforkdepth]); /* LP can only grow */
3522  assert(tree->pathnlprows[tree->correctlpdepth] >= tree->pathnlprows[lpstateforkdepth]); /* LP can only grow */
3523 
3524  /* load LP state */
3525  if( tree->focuslpstateforklpcount != stat->lpcount )
3526  {
3527  if( SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK )
3528  {
3529  assert(lpstatefork->data.fork != NULL);
3530  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, lpstatefork->data.fork->lpistate,
3531  lpstatefork->data.fork->lpwasprimfeas, lpstatefork->data.fork->lpwasprimchecked,
3532  lpstatefork->data.fork->lpwasdualfeas, lpstatefork->data.fork->lpwasdualchecked) );
3533  }
3534  else
3535  {
3536  assert(SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT);
3537  assert(lpstatefork->data.subroot != NULL);
3538  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, lpstatefork->data.subroot->lpistate,
3539  lpstatefork->data.subroot->lpwasprimfeas, lpstatefork->data.subroot->lpwasprimchecked,
3540  lpstatefork->data.subroot->lpwasdualfeas, lpstatefork->data.subroot->lpwasdualchecked) );
3541  }
3542  updatefeas = !lp->solved || !lp->solisbasic;
3543  checkbdchgs = TRUE;
3544  }
3545  else
3546  {
3547  updatefeas = TRUE;
3548 
3549  /* we do not need to check the bounds, since primalfeasible is updated anyway when flushing the LP */
3550  checkbdchgs = FALSE;
3551  }
3552 
3553  if( updatefeas )
3554  {
3555  /* check whether the size of the LP increased (destroying primal/dual feasibility) */
3556  lp->primalfeasible = lp->primalfeasible
3557  && (tree->pathnlprows[tree->correctlpdepth] == tree->pathnlprows[lpstateforkdepth]);
3558  lp->primalchecked = lp->primalchecked
3559  && (tree->pathnlprows[tree->correctlpdepth] == tree->pathnlprows[lpstateforkdepth]);
3560  lp->dualfeasible = lp->dualfeasible
3561  && (tree->pathnlpcols[tree->correctlpdepth] == tree->pathnlpcols[lpstateforkdepth]);
3562  lp->dualchecked = lp->dualchecked
3563  && (tree->pathnlpcols[tree->correctlpdepth] == tree->pathnlpcols[lpstateforkdepth]);
3564 
3565  /* check the path from LP fork to focus node for domain changes (destroying primal feasibility of LP basis) */
3566  if( checkbdchgs )
3567  {
3568  for( d = lpstateforkdepth; d < (int)(tree->focusnode->depth) && lp->primalfeasible; ++d )
3569  {
3570  assert(d < tree->pathlen);
3571  lp->primalfeasible = (tree->path[d]->domchg == NULL || tree->path[d]->domchg->domchgbound.nboundchgs == 0);
3572  lp->primalchecked = lp->primalfeasible;
3573  }
3574  }
3575  }
3576 
3577  SCIPsetDebugMsg(set, "-> primalfeasible=%u, dualfeasible=%u\n", lp->primalfeasible, lp->dualfeasible);
3578 
3579  return SCIP_OKAY;
3580 }
3581 
3582 
3583 
3584 
3585 /*
3586  * Node Conversion
3587  */
3588 
3589 /** converts node into LEAF and moves it into the array of the node queue
3590  * if node's lower bound is greater or equal than the given upper bound, the node is deleted;
3591  * otherwise, it is moved to the node queue; anyways, the given pointer is NULL after the call
3592  */
3593 static
3595  SCIP_NODE** node, /**< pointer to child or sibling node to convert */
3596  BMS_BLKMEM* blkmem, /**< block memory buffers */
3597  SCIP_SET* set, /**< global SCIP settings */
3598  SCIP_STAT* stat, /**< dynamic problem statistics */
3599  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3600  SCIP_TREE* tree, /**< branch and bound tree */
3601  SCIP_REOPT* reopt, /**< reoptimization data structure */
3602  SCIP_LP* lp, /**< current LP data */
3603  SCIP_NODE* lpstatefork, /**< LP state defining fork of the node */
3604  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
3605  )
3606 {
3609  assert(stat != NULL);
3610  assert(lpstatefork == NULL || lpstatefork->depth < (*node)->depth);
3611  assert(lpstatefork == NULL || lpstatefork->active || SCIPsetIsGE(set, (*node)->lowerbound, cutoffbound));
3612  assert(lpstatefork == NULL
3613  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK
3614  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT);
3615 
3616  /* convert node into leaf */
3617  SCIPsetDebugMsg(set, "convert node #%" SCIP_LONGINT_FORMAT " at depth %d to leaf with lpstatefork #%" SCIP_LONGINT_FORMAT " at depth %d\n",
3618  SCIPnodeGetNumber(*node), SCIPnodeGetDepth(*node),
3619  lpstatefork == NULL ? -1 : SCIPnodeGetNumber(lpstatefork),
3620  lpstatefork == NULL ? -1 : SCIPnodeGetDepth(lpstatefork));
3621  (*node)->nodetype = SCIP_NODETYPE_LEAF; /*lint !e641*/
3622  (*node)->data.leaf.lpstatefork = lpstatefork;
3623 
3624 #ifndef NDEBUG
3625  /* check, if the LP state fork is the first node with LP state information on the path back to the root */
3626  if( !SCIPsetIsInfinity(set, -cutoffbound) ) /* if the node was cut off in SCIPnodeFocus(), the lpstatefork is invalid */
3627  {
3628  SCIP_NODE* pathnode;
3629  pathnode = (*node)->parent;
3630  while( pathnode != NULL && pathnode != lpstatefork )
3631  {
3632  assert(SCIPnodeGetType(pathnode) == SCIP_NODETYPE_JUNCTION
3633  || SCIPnodeGetType(pathnode) == SCIP_NODETYPE_PSEUDOFORK);
3634  pathnode = pathnode->parent;
3635  }
3636  assert(pathnode == lpstatefork);
3637  }
3638 #endif
3639 
3640  /* if node is good enough to keep, put it on the node queue */
3641  if( SCIPsetIsLT(set, (*node)->lowerbound, cutoffbound) )
3642  {
3643  /* insert leaf in node queue */
3644  SCIP_CALL( SCIPnodepqInsert(tree->leaves, set, *node) );
3645 
3646  /* make the domain change data static to save memory */
3647  SCIP_CALL( SCIPdomchgMakeStatic(&(*node)->domchg, blkmem, set, eventqueue, lp) );
3648 
3649  /* node is now member of the node queue: delete the pointer to forbid further access */
3650  *node = NULL;
3651  }
3652  else
3653  {
3654  if( set->reopt_enable )
3655  {
3656  assert(reopt != NULL);
3657  /* check if the node should be stored for reoptimization */
3659  tree->root == *node, tree->focusnode == *node, (*node)->lowerbound, tree->effectiverootdepth) );
3660  }
3661 
3662  /* delete node due to bound cut off */
3663  SCIPvisualCutoffNode(stat->visual, set, stat, *node, FALSE);
3664  SCIP_CALL( SCIPnodeFree(node, blkmem, set, stat, eventqueue, tree, lp) );
3665  }
3666  assert(*node == NULL);
3667 
3668  return SCIP_OKAY;
3669 }
3670 
3671 /** removes variables from the problem, that are marked to be deletable, and were created at the focusnode;
3672  * only removes variables that were created at the focusnode, unless inlp is TRUE (e.g., when the node is cut off, anyway)
3673  */
3674 static
3676  BMS_BLKMEM* blkmem, /**< block memory buffers */
3677  SCIP_SET* set, /**< global SCIP settings */
3678  SCIP_STAT* stat, /**< dynamic problem statistics */
3679  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3680  SCIP_PROB* transprob, /**< transformed problem after presolve */
3681  SCIP_PROB* origprob, /**< original problem */
3682  SCIP_TREE* tree, /**< branch and bound tree */
3683  SCIP_REOPT* reopt, /**< reoptimization data structure */
3684  SCIP_LP* lp, /**< current LP data */
3685  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3686  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
3687  SCIP_Bool inlp /**< should variables in the LP be deleted, too?*/
3688  )
3689 {
3690  SCIP_VAR* var;
3691  int i;
3692  int ndelvars;
3693  SCIP_Bool needdel;
3694  SCIP_Bool deleted;
3695 
3696  assert(blkmem != NULL);
3697  assert(set != NULL);
3698  assert(stat != NULL);
3699  assert(tree != NULL);
3700  assert(!SCIPtreeProbing(tree));
3701  assert(tree->focusnode != NULL);
3703  assert(lp != NULL);
3704 
3705  /* check the settings, whether variables should be deleted */
3706  needdel = (tree->focusnode == tree->root ? set->price_delvarsroot : set->price_delvars);
3707 
3708  if( !needdel )
3709  return SCIP_OKAY;
3710 
3711  ndelvars = 0;
3712 
3713  /* also delete variables currently in the LP, thus remove all new variables from the LP, first */
3714  if( inlp )
3715  {
3716  /* remove all additions to the LP at this node */
3718 
3719  SCIP_CALL( SCIPlpFlush(lp, blkmem, set, eventqueue) );
3720  }
3721 
3722  /* mark variables as deleted */
3723  for( i = 0; i < transprob->nvars; i++ )
3724  {
3725  var = transprob->vars[i];
3726  assert(var != NULL);
3727 
3728  /* check whether variable is deletable */
3729  if( SCIPvarIsDeletable(var) )
3730  {
3731  if( !SCIPvarIsInLP(var) )
3732  {
3733  /* fix the variable to 0, first */
3734  assert(!SCIPsetIsFeasPositive(set, SCIPvarGetLbGlobal(var)));
3735  assert(!SCIPsetIsFeasNegative(set, SCIPvarGetUbGlobal(var)));
3736 
3737  if( !SCIPsetIsFeasZero(set, SCIPvarGetLbGlobal(var)) )
3738  {
3739  SCIP_CALL( SCIPnodeAddBoundchg(tree->root, blkmem, set, stat, transprob, origprob,
3740  tree, reopt, lp, branchcand, eventqueue, cliquetable, var, 0.0, SCIP_BOUNDTYPE_LOWER, FALSE) );
3741  }
3742  if( !SCIPsetIsFeasZero(set, SCIPvarGetUbGlobal(var)) )
3743  {
3744  SCIP_CALL( SCIPnodeAddBoundchg(tree->root, blkmem, set, stat, transprob, origprob,
3745  tree, reopt, lp, branchcand, eventqueue, cliquetable, var, 0.0, SCIP_BOUNDTYPE_UPPER, FALSE) );
3746  }
3747 
3748  SCIP_CALL( SCIPprobDelVar(transprob, blkmem, set, eventqueue, var, &deleted) );
3749 
3750  if( deleted )
3751  ndelvars++;
3752  }
3753  else
3754  {
3755  /* mark variable to be non-deletable, because it will be contained in the basis information
3756  * at this node and must not be deleted from now on
3757  */
3759  }
3760  }
3761  }
3762 
3763  SCIPsetDebugMsg(set, "delvars at node %" SCIP_LONGINT_FORMAT ", deleted %d vars\n", stat->nnodes, ndelvars);
3764 
3765  if( ndelvars > 0 )
3766  {
3767  /* perform the variable deletions from the problem */
3768  SCIP_CALL( SCIPprobPerformVarDeletions(transprob, blkmem, set, stat, eventqueue, cliquetable, lp, branchcand) );
3769  }
3770 
3771  return SCIP_OKAY;
3772 }
3773 
3774 /** converts the focus node into a dead-end node */
3775 static
3777  BMS_BLKMEM* blkmem, /**< block memory buffers */
3778  SCIP_SET* set, /**< global SCIP settings */
3779  SCIP_STAT* stat, /**< dynamic problem statistics */
3780  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3781  SCIP_PROB* transprob, /**< transformed problem after presolve */
3782  SCIP_PROB* origprob, /**< original problem */
3783  SCIP_TREE* tree, /**< branch and bound tree */
3784  SCIP_REOPT* reopt, /**< reoptimization data structure */
3785  SCIP_LP* lp, /**< current LP data */
3786  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3787  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3788  )
3789 {
3790  assert(blkmem != NULL);
3791  assert(tree != NULL);
3792  assert(!SCIPtreeProbing(tree));
3793  assert(tree->focusnode != NULL);
3795  assert(tree->nchildren == 0);
3796 
3797  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to dead-end at depth %d\n",
3799 
3800  /* remove variables from the problem that are marked as deletable and were created at this node */
3801  SCIP_CALL( focusnodeCleanupVars(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand, cliquetable, TRUE) );
3802 
3803  tree->focusnode->nodetype = SCIP_NODETYPE_DEADEND; /*lint !e641*/
3804 
3805  /* release LPI state */
3806  if( tree->focuslpstatefork != NULL )
3807  {
3808  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
3809  }
3810 
3811  return SCIP_OKAY;
3812 }
3813 
3814 /** converts the focus node into a leaf node (if it was postponed) */
3815 static
3817  BMS_BLKMEM* blkmem, /**< block memory buffers */
3818  SCIP_SET* set, /**< global SCIP settings */
3819  SCIP_STAT* stat, /**< dynamic problem statistics */
3820  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3821  SCIP_TREE* tree, /**< branch and bound tree */
3822  SCIP_REOPT* reopt, /**< reoptimization data structure */
3823  SCIP_LP* lp, /**< current LP data */
3824  SCIP_NODE* lpstatefork, /**< LP state defining fork of the node */
3825  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
3826 
3827  )
3828 {
3829  assert(tree != NULL);
3830  assert(!SCIPtreeProbing(tree));
3831  assert(tree->focusnode != NULL);
3832  assert(tree->focusnode->active);
3834 
3835  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to leaf at depth %d\n",
3837 
3838  SCIP_CALL( nodeToLeaf(&tree->focusnode, blkmem, set, stat, eventqueue, tree, reopt, lp, lpstatefork, cutoffbound));
3839 
3840  return SCIP_OKAY;
3841 }
3842 
3843 /** converts the focus node into a junction node */
3844 static
3846  BMS_BLKMEM* blkmem, /**< block memory buffers */
3847  SCIP_SET* set, /**< global SCIP settings */
3848  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3849  SCIP_TREE* tree, /**< branch and bound tree */
3850  SCIP_LP* lp /**< current LP data */
3851  )
3852 {
3853  assert(tree != NULL);
3854  assert(!SCIPtreeProbing(tree));
3855  assert(tree->focusnode != NULL);
3856  assert(tree->focusnode->active); /* otherwise, no children could be created at the focus node */
3858  assert(SCIPlpGetNNewcols(lp) == 0);
3859 
3860  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to junction at depth %d\n",
3862 
3863  /* convert node into junction */
3864  tree->focusnode->nodetype = SCIP_NODETYPE_JUNCTION; /*lint !e641*/
3865 
3866  SCIP_CALL( junctionInit(&tree->focusnode->data.junction, tree) );
3867 
3868  /* release LPI state */
3869  if( tree->focuslpstatefork != NULL )
3870  {
3871  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
3872  }
3873 
3874  /* make the domain change data static to save memory */
3875  SCIP_CALL( SCIPdomchgMakeStatic(&tree->focusnode->domchg, blkmem, set, eventqueue, lp) );
3876 
3877  return SCIP_OKAY;
3878 }
3879 
3880 /** converts the focus node into a pseudofork node */
3881 static
3883  BMS_BLKMEM* blkmem, /**< block memory buffers */
3884  SCIP_SET* set, /**< global SCIP settings */
3885  SCIP_STAT* stat, /**< dynamic problem statistics */
3886  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3887  SCIP_PROB* transprob, /**< transformed problem after presolve */
3888  SCIP_PROB* origprob, /**< original problem */
3889  SCIP_TREE* tree, /**< branch and bound tree */
3890  SCIP_REOPT* reopt, /**< reoptimization data structure */
3891  SCIP_LP* lp, /**< current LP data */
3892  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3893  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3894  )
3895 {
3896  SCIP_PSEUDOFORK* pseudofork;
3897 
3898  assert(blkmem != NULL);
3899  assert(tree != NULL);
3900  assert(!SCIPtreeProbing(tree));
3901  assert(tree->focusnode != NULL);
3902  assert(tree->focusnode->active); /* otherwise, no children could be created at the focus node */
3904  assert(tree->nchildren > 0);
3905  assert(lp != NULL);
3906 
3907  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to pseudofork at depth %d\n",
3909 
3910  /* remove variables from the problem that are marked as deletable and were created at this node */
3911  SCIP_CALL( focusnodeCleanupVars(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand, cliquetable, FALSE) );
3912 
3913  /* create pseudofork data */
3914  SCIP_CALL( pseudoforkCreate(&pseudofork, blkmem, tree, lp) );
3915 
3916  tree->focusnode->nodetype = SCIP_NODETYPE_PSEUDOFORK; /*lint !e641*/
3917  tree->focusnode->data.pseudofork = pseudofork;
3918 
3919  /* release LPI state */
3920  if( tree->focuslpstatefork != NULL )
3921  {
3922  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
3923  }
3924 
3925  /* make the domain change data static to save memory */
3926  SCIP_CALL( SCIPdomchgMakeStatic(&tree->focusnode->domchg, blkmem, set, eventqueue, lp) );
3927 
3928  return SCIP_OKAY;
3929 }
3930 
3931 /** converts the focus node into a fork node */
3932 static
3934  BMS_BLKMEM* blkmem, /**< block memory buffers */
3935  SCIP_SET* set, /**< global SCIP settings */
3936  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
3937  SCIP_STAT* stat, /**< dynamic problem statistics */
3938  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3939  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3940  SCIP_PROB* transprob, /**< transformed problem after presolve */
3941  SCIP_PROB* origprob, /**< original problem */
3942  SCIP_TREE* tree, /**< branch and bound tree */
3943  SCIP_REOPT* reopt, /**< reoptimization data structure */
3944  SCIP_LP* lp, /**< current LP data */
3945  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3946  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3947  )
3948 {
3949  SCIP_FORK* fork;
3950  SCIP_Bool lperror;
3951 
3952  assert(blkmem != NULL);
3953  assert(tree != NULL);
3954  assert(!SCIPtreeProbing(tree));
3955  assert(tree->focusnode != NULL);
3956  assert(tree->focusnode->active); /* otherwise, no children could be created at the focus node */
3958  assert(tree->nchildren > 0);
3959  assert(lp != NULL);
3960  assert(lp->flushed);
3961  assert(lp->solved || lp->resolvelperror);
3962 
3963  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to fork at depth %d\n",
3965 
3966  /* usually, the LP should be solved to optimality; otherwise, numerical troubles occured,
3967  * and we have to forget about the LP and transform the node into a junction (see below)
3968  */
3969  lperror = FALSE;
3971  {
3972  /* clean up newly created part of LP to keep only necessary columns and rows */
3973  SCIP_CALL( SCIPlpCleanupNew(lp, blkmem, set, stat, eventqueue, eventfilter, (tree->focusnode->depth == 0)) );
3974 
3975  /* resolve LP after cleaning up */
3976  if( !lp->solved || !lp->flushed )
3977  {
3978  SCIPsetDebugMsg(set, "resolving LP after cleanup\n");
3979  SCIP_CALL( SCIPlpSolveAndEval(lp, set, messagehdlr, blkmem, stat, eventqueue, eventfilter, transprob, -1LL, FALSE, FALSE, TRUE, &lperror) );
3980  }
3981  }
3982  assert(lp->flushed);
3983  assert(lp->solved || lperror || lp->resolvelperror);
3984 
3985  /* There are two reasons, that the (reduced) LP is not solved to optimality:
3986  * - The primal heuristics (called after the current node's LP was solved) found a new
3987  * solution, that is better than the current node's lower bound.
3988  * (But in this case, all children should be cut off and the node should be converted
3989  * into a dead-end instead of a fork.)
3990  * - Something numerically weird happened after cleaning up or after resolving a diving or probing LP.
3991  * The only thing we can do, is to completely forget about the LP and treat the node as
3992  * if it was only a pseudo-solution node. Therefore we have to remove all additional
3993  * columns and rows from the LP and convert the node into a junction.
3994  * However, the node's lower bound is kept, thus automatically throwing away nodes that
3995  * were cut off due to a primal solution.
3996  */
3997  if( lperror || lp->resolvelperror || SCIPlpGetSolstat(lp) != SCIP_LPSOLSTAT_OPTIMAL )
3998  {
3999  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
4000  "(node %" SCIP_LONGINT_FORMAT ") numerical troubles: LP %" SCIP_LONGINT_FORMAT " not optimal -- convert node into junction instead of fork\n",
4001  stat->nnodes, stat->nlps);
4002 
4003  /* remove all additions to the LP at this node */
4005  SCIP_CALL( SCIPlpShrinkRows(lp, blkmem, set, eventqueue, eventfilter, SCIPlpGetNRows(lp) - SCIPlpGetNNewrows(lp)) );
4006 
4007  /* convert node into a junction */
4008  SCIP_CALL( focusnodeToJunction(blkmem, set, eventqueue, tree, lp) );
4009 
4010  return SCIP_OKAY;
4011  }
4012  assert(lp->flushed);
4013  assert(lp->solved);
4015 
4016  /* remove variables from the problem that are marked as deletable, were created at this node and are not contained in the LP */
4017  SCIP_CALL( focusnodeCleanupVars(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand, cliquetable, FALSE) );
4018 
4019  assert(lp->flushed);
4020  assert(lp->solved);
4021 
4022  /* create fork data */
4023  SCIP_CALL( forkCreate(&fork, blkmem, set, transprob, tree, lp) );
4024 
4025  tree->focusnode->nodetype = SCIP_NODETYPE_FORK; /*lint !e641*/
4026  tree->focusnode->data.fork = fork;
4027 
4028  /* capture the LPI state of the root node to ensure that the LPI state of the root stays for the whole solving
4029  * process
4030  */
4031  if( tree->focusnode == tree->root )
4032  forkCaptureLPIState(fork, 1);
4033 
4034  /* release LPI state */
4035  if( tree->focuslpstatefork != NULL )
4036  {
4037  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
4038  }
4039 
4040  /* make the domain change data static to save memory */
4041  SCIP_CALL( SCIPdomchgMakeStatic(&tree->focusnode->domchg, blkmem, set, eventqueue, lp) );
4042 
4043  return SCIP_OKAY;
4044 }
4045 
4046 #ifdef WITHSUBROOTS /** @todo test whether subroots should be created */
4047 /** converts the focus node into a subroot node */
4048 static
4049 SCIP_RETCODE focusnodeToSubroot(
4050  BMS_BLKMEM* blkmem, /**< block memory buffers */
4051  SCIP_SET* set, /**< global SCIP settings */
4052  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4053  SCIP_STAT* stat, /**< dynamic problem statistics */
4054  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4055  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
4056  SCIP_PROB* transprob, /**< transformed problem after presolve */
4057  SCIP_PROB* origprob, /**< original problem */
4058  SCIP_TREE* tree, /**< branch and bound tree */
4059  SCIP_LP* lp, /**< current LP data */
4060  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4061  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
4062  )
4063 {
4064  SCIP_SUBROOT* subroot;
4065  SCIP_Bool lperror;
4066 
4067  assert(blkmem != NULL);
4068  assert(tree != NULL);
4069  assert(!SCIPtreeProbing(tree));
4070  assert(tree->focusnode != NULL);
4072  assert(tree->focusnode->active); /* otherwise, no children could be created at the focus node */
4073  assert(tree->nchildren > 0);
4074  assert(lp != NULL);
4075  assert(lp->flushed);
4076  assert(lp->solved);
4077 
4078  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to subroot at depth %d\n",
4080 
4081  /* usually, the LP should be solved to optimality; otherwise, numerical troubles occured,
4082  * and we have to forget about the LP and transform the node into a junction (see below)
4083  */
4084  lperror = FALSE;
4086  {
4087  /* clean up whole LP to keep only necessary columns and rows */
4088 #ifdef SCIP_DISABLED_CODE
4089  if( tree->focusnode->depth == 0 )
4090  {
4091  SCIP_CALL( SCIPlpCleanupAll(lp, blkmem, set, stat, eventqueue, eventfilter, (tree->focusnode->depth == 0)) );
4092  }
4093  else
4094 #endif
4095  {
4096  SCIP_CALL( SCIPlpRemoveAllObsoletes(lp, blkmem, set, stat, eventqueue, eventfilter) );
4097  }
4098 
4099  /* resolve LP after cleaning up */
4100  if( !lp->solved || !lp->flushed )
4101  {
4102  SCIPsetDebugMsg(set, "resolving LP after cleanup\n");
4103  SCIP_CALL( SCIPlpSolveAndEval(lp, set, messagehdlr, blkmem, stat, eventqueue, eventfilter, transprob, -1LL, FALSE, FALSE, TRUE, &lperror) );
4104  }
4105  }
4106  assert(lp->flushed);
4107  assert(lp->solved || lperror);
4108 
4109  /* There are two reasons, that the (reduced) LP is not solved to optimality:
4110  * - The primal heuristics (called after the current node's LP was solved) found a new
4111  * solution, that is better than the current node's lower bound.
4112  * (But in this case, all children should be cut off and the node should be converted
4113  * into a dead-end instead of a subroot.)
4114  * - Something numerically weird happened after cleaning up.
4115  * The only thing we can do, is to completely forget about the LP and treat the node as
4116  * if it was only a pseudo-solution node. Therefore we have to remove all additional
4117  * columns and rows from the LP and convert the node into a junction.
4118  * However, the node's lower bound is kept, thus automatically throwing away nodes that
4119  * were cut off due to a primal solution.
4120  */
4121  if( lperror || SCIPlpGetSolstat(lp) != SCIP_LPSOLSTAT_OPTIMAL )
4122  {
4123  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
4124  "(node %" SCIP_LONGINT_FORMAT ") numerical troubles: LP %" SCIP_LONGINT_FORMAT " not optimal -- convert node into junction instead of subroot\n",
4125  stat->nnodes, stat->nlps);
4126 
4127  /* remove all additions to the LP at this node */
4129  SCIP_CALL( SCIPlpShrinkRows(lp, blkmem, set, eventqueue, eventfilter, SCIPlpGetNRows(lp) - SCIPlpGetNNewrows(lp)) );
4130 
4131  /* convert node into a junction */
4132  SCIP_CALL( focusnodeToJunction(blkmem, set, eventqueue, tree, lp) );
4133 
4134  return SCIP_OKAY;
4135  }
4136  assert(lp->flushed);
4137  assert(lp->solved);
4139 
4140  /* remove variables from the problem that are marked as deletable, were created at this node and are not contained in the LP */
4141  SCIP_CALL( focusnodeCleanupVars(blkmem, set, stat, eventqueue, transprob, origprob, tree, lp, branchcand, cliquetable, FALSE) );
4142 
4143  assert(lp->flushed);
4144  assert(lp->solved);
4145 
4146  /* create subroot data */
4147  SCIP_CALL( subrootCreate(&subroot, blkmem, set, transprob, tree, lp) );
4148 
4149  tree->focusnode->nodetype = SCIP_NODETYPE_SUBROOT; /*lint !e641*/
4150  tree->focusnode->data.subroot = subroot;
4151 
4152  /* update the LP column and row counter for the converted node */
4153  SCIP_CALL( treeUpdatePathLPSize(tree, tree->focusnode->depth) );
4154 
4155  /* release LPI state */
4156  if( tree->focuslpstatefork != NULL )
4157  {
4158  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
4159  }
4160 
4161  /* make the domain change data static to save memory */
4162  SCIP_CALL( SCIPdomchgMakeStatic(&tree->focusnode->domchg, blkmem, set, eventqueue, lp) );
4163 
4164  return SCIP_OKAY;
4165 }
4166 #endif
4167 
4168 /** puts all nodes in the array on the node queue and makes them LEAFs */
4169 static
4171  SCIP_TREE* tree, /**< branch and bound tree */
4172  SCIP_REOPT* reopt, /**< reoptimization data structure */
4173  BMS_BLKMEM* blkmem, /**< block memory buffers */
4174  SCIP_SET* set, /**< global SCIP settings */
4175  SCIP_STAT* stat, /**< dynamic problem statistics */
4176  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4177  SCIP_LP* lp, /**< current LP data */
4178  SCIP_NODE** nodes, /**< array of nodes to put on the queue */
4179  int* nnodes, /**< pointer to number of nodes in the array */
4180  SCIP_NODE* lpstatefork, /**< LP state defining fork of the nodes */
4181  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
4182  )
4183 {
4184  int i;
4185 
4186  assert(tree != NULL);
4187  assert(set != NULL);
4188  assert(nnodes != NULL);
4189  assert(*nnodes == 0 || nodes != NULL);
4190 
4191  for( i = 0; i < *nnodes; ++i )
4192  {
4193  /* convert node to LEAF and put it into leaves queue, or delete it if it's lower bound exceeds the cutoff bound */
4194  SCIP_CALL( nodeToLeaf(&nodes[i], blkmem, set, stat, eventqueue, tree, reopt, lp, lpstatefork, cutoffbound) );
4195  assert(nodes[i] == NULL);
4196  }
4197  *nnodes = 0;
4198 
4199  return SCIP_OKAY;
4200 }
4201 
4202 /** converts children into siblings, clears children array */
4203 static
4205  SCIP_TREE* tree /**< branch and bound tree */
4206  )
4207 {
4208  SCIP_NODE** tmpnodes;
4209  SCIP_Real* tmpprios;
4210  int tmpnodessize;
4211  int i;
4212 
4213  assert(tree != NULL);
4214  assert(tree->nsiblings == 0);
4215 
4216  tmpnodes = tree->siblings;
4217  tmpprios = tree->siblingsprio;
4218  tmpnodessize = tree->siblingssize;
4219 
4220  tree->siblings = tree->children;
4221  tree->siblingsprio = tree->childrenprio;
4222  tree->nsiblings = tree->nchildren;
4223  tree->siblingssize = tree->childrensize;
4224 
4225  tree->children = tmpnodes;
4226  tree->childrenprio = tmpprios;
4227  tree->nchildren = 0;
4228  tree->childrensize = tmpnodessize;
4229 
4230  for( i = 0; i < tree->nsiblings; ++i )
4231  {
4232  assert(SCIPnodeGetType(tree->siblings[i]) == SCIP_NODETYPE_CHILD);
4233  tree->siblings[i]->nodetype = SCIP_NODETYPE_SIBLING; /*lint !e641*/
4234 
4235  /* because CHILD and SIBLING structs contain the same data in the same order, we do not have to copy it */
4236  assert(&(tree->siblings[i]->data.sibling.arraypos) == &(tree->siblings[i]->data.child.arraypos));
4237  }
4238 }
4239 
4240 /** installs a child, a sibling, or a leaf node as the new focus node */
4242  SCIP_NODE** node, /**< pointer to node to focus (or NULL to remove focus); the node
4243  * is freed, if it was cut off due to a cut off subtree */
4244  BMS_BLKMEM* blkmem, /**< block memory buffers */
4245  SCIP_SET* set, /**< global SCIP settings */
4246  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4247  SCIP_STAT* stat, /**< problem statistics */
4248  SCIP_PROB* transprob, /**< transformed problem */
4249  SCIP_PROB* origprob, /**< original problem */
4250  SCIP_PRIMAL* primal, /**< primal data */
4251  SCIP_TREE* tree, /**< branch and bound tree */
4252  SCIP_REOPT* reopt, /**< reoptimization data structure */
4253  SCIP_LP* lp, /**< current LP data */
4254  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4255  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4256  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
4257  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4258  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4259  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
4260  SCIP_Bool* cutoff, /**< pointer to store whether the given node can be cut off */
4261  SCIP_Bool postponed, /**< was the current focus node postponed? */
4262  SCIP_Bool exitsolve /**< are we in exitsolve stage, so we only need to loose the children */
4263  )
4264 { /*lint --e{715}*/
4265  SCIP_NODE* oldfocusnode;
4266  SCIP_NODE* fork;
4267  SCIP_NODE* lpfork;
4268  SCIP_NODE* lpstatefork;
4269  SCIP_NODE* subroot;
4270  SCIP_NODE* childrenlpstatefork;
4271  int oldcutoffdepth;
4272 
4273  assert(node != NULL);
4274  assert(*node == NULL
4277  || SCIPnodeGetType(*node) == SCIP_NODETYPE_LEAF);
4278  assert(*node == NULL || !(*node)->active);
4279  assert(stat != NULL);
4280  assert(tree != NULL);
4281  assert(!SCIPtreeProbing(tree));
4282  assert(lp != NULL);
4283  assert(cutoff != NULL);
4284 
4285  SCIPsetDebugMsg(set, "focusing node #%" SCIP_LONGINT_FORMAT " of type %d in depth %d\n",
4286  *node != NULL ? SCIPnodeGetNumber(*node) : -1, *node != NULL ? (int)SCIPnodeGetType(*node) : 0,
4287  *node != NULL ? SCIPnodeGetDepth(*node) : -1);
4288 
4289  /* remember old cutoff depth in order to know, whether the children and siblings can be deleted */
4290  oldcutoffdepth = tree->cutoffdepth;
4291 
4292  /* find the common fork node, the new LP defining fork, and the new focus subroot,
4293  * thereby checking, if the new node can be cut off
4294  */
4295  treeFindSwitchForks(tree, *node, &fork, &lpfork, &lpstatefork, &subroot, cutoff);
4296  SCIPsetDebugMsg(set, "focus node: focusnodedepth=%d, forkdepth=%d, lpforkdepth=%d, lpstateforkdepth=%d, subrootdepth=%d, cutoff=%u\n",
4297  *node != NULL ? (*node)->depth : -1, fork != NULL ? fork->depth : -1, /*lint !e705 */
4298  lpfork != NULL ? lpfork->depth : -1, lpstatefork != NULL ? lpstatefork->depth : -1, /*lint !e705 */
4299  subroot != NULL ? subroot->depth : -1, *cutoff); /*lint !e705 */
4300 
4301  /* free the new node, if it is located in a cut off subtree */
4302  if( *cutoff )
4303  {
4304  assert(*node != NULL);
4305  assert(tree->cutoffdepth == oldcutoffdepth);
4306  if( SCIPnodeGetType(*node) == SCIP_NODETYPE_LEAF )
4307  {
4308  SCIP_CALL( SCIPnodepqRemove(tree->leaves, set, *node) );
4309  }
4310  SCIPvisualCutoffNode(stat->visual, set, stat, *node, FALSE);
4311 
4312  if( set->reopt_enable )
4313  {
4314  assert(reopt != NULL);
4315  /* check if the node should be stored for reoptimization */
4317  tree->root == (*node), tree->focusnode == (*node), (*node)->lowerbound, tree->effectiverootdepth) );
4318  }
4319 
4320  SCIP_CALL( SCIPnodeFree(node, blkmem, set, stat, eventqueue, tree, lp) );
4321 
4322  return SCIP_OKAY;
4323  }
4324 
4325  assert(tree->cutoffdepth == INT_MAX);
4326  assert(fork == NULL || fork->active);
4327  assert(lpstatefork == NULL || lpfork != NULL);
4328  assert(subroot == NULL || lpstatefork != NULL);
4329 
4330  /* remember the depth of the common fork node for LP updates */
4331  SCIPsetDebugMsg(set, "focus node: old correctlpdepth=%d\n", tree->correctlpdepth);
4332  if( subroot == tree->focussubroot && fork != NULL && lpfork != NULL )
4333  {
4334  /* we are in the same subtree with valid LP fork: the LP is correct at most upto the common fork depth */
4335  assert(subroot == NULL || subroot->active);
4336  tree->correctlpdepth = MIN(tree->correctlpdepth, (int)fork->depth);
4337  }
4338  else
4339  {
4340  /* we are in a different subtree, or no valid LP fork exists: the LP is completely incorrect */
4341  assert(subroot == NULL || !subroot->active
4342  || (tree->focussubroot != NULL && (int)(tree->focussubroot->depth) > subroot->depth));
4343  tree->correctlpdepth = -1;
4344  }
4345 
4346  /* if the LP state fork changed, the lpcount information for the new LP state fork is unknown */
4347  if( lpstatefork != tree->focuslpstatefork )
4348  tree->focuslpstateforklpcount = -1;
4349 
4350  /* in exitsolve we only need to take care of open children
4351  *
4352  * @note because we might do a 'newstart' and converted cuts to constraints might have rendered the LP in the current
4353  * focusnode unsolved the latter code would have resolved the LP unnecessarily
4354  */
4355  if( exitsolve && tree->nchildren > 0 )
4356  {
4357  SCIPsetDebugMsg(set, " -> deleting the %d children (in exitsolve) of the old focus node\n", tree->nchildren);
4358  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, NULL, -SCIPsetInfinity(set)) );
4359  assert(tree->nchildren == 0);
4360  }
4361 
4362  /* if the old focus node was cut off, we can delete its children;
4363  * if the old focus node's parent was cut off, we can also delete the focus node's siblings
4364  */
4365  /* coverity[var_compare_op] */
4366  if( tree->focusnode != NULL && oldcutoffdepth <= (int)tree->focusnode->depth )
4367  {
4368  SCIPsetDebugMsg(set, "path to old focus node of depth %u was cut off at depth %d\n", tree->focusnode->depth, oldcutoffdepth);
4369 
4370  /* delete the focus node's children by converting them to leaves with a cutoffbound of -SCIPsetInfinity(set);
4371  * we cannot delete them directly, because in SCIPnodeFree(), the children array is changed, which is the
4372  * same array we would have to iterate over here;
4373  * the children don't have an LP fork, because the old focus node is not yet converted into a fork or subroot
4374  */
4375  SCIPsetDebugMsg(set, " -> deleting the %d children of the old focus node\n", tree->nchildren);
4376  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, NULL, -SCIPsetInfinity(set)) );
4377  assert(tree->nchildren == 0);
4378 
4379  if( oldcutoffdepth < (int)tree->focusnode->depth )
4380  {
4381  /* delete the focus node's siblings by converting them to leaves with a cutoffbound of -SCIPsetInfinity(set);
4382  * we cannot delete them directly, because in SCIPnodeFree(), the siblings array is changed, which is the
4383  * same array we would have to iterate over here;
4384  * the siblings have the same LP state fork as the old focus node
4385  */
4386  SCIPsetDebugMsg(set, " -> deleting the %d siblings of the old focus node\n", tree->nsiblings);
4387  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4388  -SCIPsetInfinity(set)) );
4389  assert(tree->nsiblings == 0);
4390  }
4391  }
4392 
4393  /* convert the old focus node into a fork or subroot node, if it has children;
4394  * otherwise, convert it into a dead-end, which will be freed later in treeSwitchPath();
4395  * if the node was postponed, make it a leaf.
4396  */
4397  childrenlpstatefork = tree->focuslpstatefork;
4398 
4399  assert(!postponed || *node == NULL);
4400  assert(!postponed || tree->focusnode != NULL);
4401 
4402  if( postponed )
4403  {
4404  assert(tree->nchildren == 0);
4405  assert(*node == NULL);
4406 
4407  /* if the node is infeasible, convert it into a deadend; otherwise, put it into the LEAF queue */
4408  if( SCIPsetIsGE(set, tree->focusnode->lowerbound, primal->cutoffbound) )
4409  {
4410  /* in case the LP was not constructed (due to the parameter settings for example) we have the finally remember the
4411  * old size of the LP (if it was constructed in an earlier node) before we change the current node into a deadend
4412  */
4413  if( !tree->focuslpconstructed )
4414  SCIPlpMarkSize(lp);
4415 
4416  /* convert old focus node into deadend */
4417  SCIP_CALL( focusnodeToDeadend(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand,
4418  cliquetable) );
4419  }
4420  else
4421  {
4422  SCIP_CALL( focusnodeToLeaf(blkmem, set, stat, eventqueue, tree, reopt, lp, tree->focuslpstatefork,
4423  SCIPsetInfinity(set)) );
4424  }
4425  }
4426  else if( tree->nchildren > 0 )
4427  {
4428  SCIP_Bool selectedchild;
4429 
4430  assert(tree->focusnode != NULL);
4432  assert(oldcutoffdepth == INT_MAX);
4433 
4434  /* check whether the next focus node is a child of the old focus node */
4435  selectedchild = (*node != NULL && SCIPnodeGetType(*node) == SCIP_NODETYPE_CHILD);
4436 
4437  if( tree->focusnodehaslp && lp->isrelax )
4438  {
4439  assert(tree->focuslpconstructed);
4440 
4441 #ifdef WITHSUBROOTS /** @todo test whether subroots should be created, decide: old focus node becomes fork or subroot */
4442  if( tree->focusnode->depth > 0 && tree->focusnode->depth % 25 == 0 )
4443  {
4444  /* convert old focus node into a subroot node */
4445  SCIP_CALL( focusnodeToSubroot(blkmem, set, messagehdlr, stat, eventqueue, eventfilter, transprob, origprob, tree, lp, branchcand) );
4446  if( *node != NULL && SCIPnodeGetType(*node) == SCIP_NODETYPE_CHILD
4448  subroot = tree->focusnode;
4449  }
4450  else
4451 #endif
4452  {
4453  /* convert old focus node into a fork node */
4454  SCIP_CALL( focusnodeToFork(blkmem, set, messagehdlr, stat, eventqueue, eventfilter, transprob, origprob, tree,
4455  reopt, lp, branchcand, cliquetable) );
4456  }
4457 
4458  /* check, if the conversion into a subroot or fork was successful */
4461  {
4462  childrenlpstatefork = tree->focusnode;
4463 
4464  /* if a child of the old focus node was selected as new focus node, the old node becomes the new focus
4465  * LP fork and LP state fork
4466  */
4467  if( selectedchild )
4468  {
4469  lpfork = tree->focusnode;
4470  tree->correctlpdepth = tree->focusnode->depth;
4471  lpstatefork = tree->focusnode;
4472  tree->focuslpstateforklpcount = stat->lpcount;
4473  }
4474  }
4475 
4476  /* update the path's LP size */
4477  tree->pathnlpcols[tree->focusnode->depth] = SCIPlpGetNCols(lp);
4478  tree->pathnlprows[tree->focusnode->depth] = SCIPlpGetNRows(lp);
4479  }
4480  else if( tree->focuslpconstructed && (SCIPlpGetNNewcols(lp) > 0 || SCIPlpGetNNewrows(lp) > 0) )
4481  {
4482  /* convert old focus node into pseudofork */
4483  SCIP_CALL( focusnodeToPseudofork(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp,
4484  branchcand, cliquetable) );
4486 
4487  /* update the path's LP size */
4488  tree->pathnlpcols[tree->focusnode->depth] = SCIPlpGetNCols(lp);
4489  tree->pathnlprows[tree->focusnode->depth] = SCIPlpGetNRows(lp);
4490 
4491  /* if a child of the old focus node was selected as new focus node, the old node becomes the new focus LP fork */
4492  if( selectedchild )
4493  {
4494  lpfork = tree->focusnode;
4495  tree->correctlpdepth = tree->focusnode->depth;
4496  }
4497  }
4498  else
4499  {
4500  /* in case the LP was not constructed (due to the parameter settings for example) we have the finally remember the
4501  * old size of the LP (if it was constructed in an earlier node) before we change the current node into a junction
4502  */
4503  SCIPlpMarkSize(lp);
4504 
4505  /* convert old focus node into junction */
4506  SCIP_CALL( focusnodeToJunction(blkmem, set, eventqueue, tree, lp) );
4507  }
4508  }
4509  else if( tree->focusnode != NULL )
4510  {
4511  /* in case the LP was not constructed (due to the parameter settings for example) we have the finally remember the
4512  * old size of the LP (if it was constructed in an earlier node) before we change the current node into a deadend
4513  */
4514  if( !tree->focuslpconstructed )
4515  SCIPlpMarkSize(lp);
4516 
4517  /* convert old focus node into deadend */
4518  SCIP_CALL( focusnodeToDeadend(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand, cliquetable) );
4519  }
4520  assert(subroot == NULL || SCIPnodeGetType(subroot) == SCIP_NODETYPE_SUBROOT);
4521  assert(lpstatefork == NULL
4522  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT
4523  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK);
4524  assert(childrenlpstatefork == NULL
4525  || SCIPnodeGetType(childrenlpstatefork) == SCIP_NODETYPE_SUBROOT
4526  || SCIPnodeGetType(childrenlpstatefork) == SCIP_NODETYPE_FORK);
4527  assert(lpfork == NULL
4529  || SCIPnodeGetType(lpfork) == SCIP_NODETYPE_FORK
4531  SCIPsetDebugMsg(set, "focus node: new correctlpdepth=%d\n", tree->correctlpdepth);
4532 
4533  /* set up the new lists of siblings and children */
4534  oldfocusnode = tree->focusnode;
4535  if( *node == NULL )
4536  {
4537  /* move siblings to the queue, make them LEAFs */
4538  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4539  primal->cutoffbound) );
4540 
4541  /* move children to the queue, make them LEAFs */
4542  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, childrenlpstatefork,
4543  primal->cutoffbound) );
4544  }
4545  else
4546  {
4547  SCIP_NODE* bestleaf;
4548 
4549  switch( SCIPnodeGetType(*node) )
4550  {
4551  case SCIP_NODETYPE_SIBLING:
4552  /* reset plunging depth, if the selected node is better than all leaves */
4553  bestleaf = SCIPtreeGetBestLeaf(tree);
4554  if( bestleaf == NULL || SCIPnodepqCompare(tree->leaves, set, *node, bestleaf) <= 0 )
4555  stat->plungedepth = 0;
4556 
4557  /* move children to the queue, make them LEAFs */
4558  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, childrenlpstatefork,
4559  primal->cutoffbound) );
4560 
4561  /* remove selected sibling from the siblings array */
4562  treeRemoveSibling(tree, *node);
4563 
4564  SCIPsetDebugMsg(set, "selected sibling node, lowerbound=%g, plungedepth=%d\n", (*node)->lowerbound, stat->plungedepth);
4565  break;
4566 
4567  case SCIP_NODETYPE_CHILD:
4568  /* reset plunging depth, if the selected node is better than all leaves; otherwise, increase plunging depth */
4569  bestleaf = SCIPtreeGetBestLeaf(tree);
4570  if( bestleaf == NULL || SCIPnodepqCompare(tree->leaves, set, *node, bestleaf) <= 0 )
4571  stat->plungedepth = 0;
4572  else
4573  stat->plungedepth++;
4574 
4575  /* move siblings to the queue, make them LEAFs */
4576  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4577  primal->cutoffbound) );
4578 
4579  /* remove selected child from the children array */
4580  treeRemoveChild(tree, *node);
4581 
4582  /* move remaining children to the siblings array, make them SIBLINGs */
4583  treeChildrenToSiblings(tree);
4584 
4585  SCIPsetDebugMsg(set, "selected child node, lowerbound=%g, plungedepth=%d\n", (*node)->lowerbound, stat->plungedepth);
4586  break;
4587 
4588  case SCIP_NODETYPE_LEAF:
4589  /* move siblings to the queue, make them LEAFs */
4590  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4591  primal->cutoffbound) );
4592 
4593  /* encounter an early backtrack if there is a child which does not exceed given reference bound */
4594  if( !SCIPsetIsInfinity(set, stat->referencebound) )
4595  {
4596  int c;
4597 
4598  /* loop over children and stop if we find a child with a lower bound below given reference bound */
4599  for( c = 0; c < tree->nchildren; ++c )
4600  {
4601  if( SCIPsetIsLT(set, SCIPnodeGetLowerbound(tree->children[c]), stat->referencebound) )
4602  {
4603  ++stat->nearlybacktracks;
4604  break;
4605  }
4606  }
4607  }
4608  /* move children to the queue, make them LEAFs */
4609  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, childrenlpstatefork,
4610  primal->cutoffbound) );
4611 
4612  /* remove node from the queue */
4613  SCIP_CALL( SCIPnodepqRemove(tree->leaves, set, *node) );
4614 
4615  stat->plungedepth = 0;
4616  if( SCIPnodeGetDepth(*node) > 0 )
4617  stat->nbacktracks++;
4618  SCIPsetDebugMsg(set, "selected leaf node, lowerbound=%g, plungedepth=%d\n", (*node)->lowerbound, stat->plungedepth);
4619  break;
4620 
4621  default:
4622  SCIPerrorMessage("selected node is neither sibling, child, nor leaf (nodetype=%d)\n", SCIPnodeGetType(*node));
4623  return SCIP_INVALIDDATA;
4624  } /*lint !e788*/
4625 
4626  /* convert node into the focus node */
4627  (*node)->nodetype = SCIP_NODETYPE_FOCUSNODE; /*lint !e641*/
4628  }
4629  assert(tree->nchildren == 0);
4630 
4631  /* set new focus node, LP fork, LP state fork, and subroot */
4632  assert(subroot == NULL || (lpstatefork != NULL && subroot->depth <= lpstatefork->depth));
4633  assert(lpstatefork == NULL || (lpfork != NULL && lpstatefork->depth <= lpfork->depth));
4634  assert(lpfork == NULL || (*node != NULL && lpfork->depth < (*node)->depth));
4635  tree->focusnode = *node;
4636  tree->focuslpfork = lpfork;
4637  tree->focuslpstatefork = lpstatefork;
4638  tree->focussubroot = subroot;
4639  tree->focuslpconstructed = FALSE;
4640  lp->resolvelperror = FALSE;
4641 
4642  /* track the path from the old focus node to the new node, and perform domain and constraint set changes */
4643  SCIP_CALL( treeSwitchPath(tree, reopt, blkmem, set, stat, transprob, origprob, primal, lp, branchcand, conflict,
4644  eventfilter, eventqueue, cliquetable, fork, *node, cutoff) );
4645  assert(tree->pathlen >= 0);
4646  assert(*node != NULL || tree->pathlen == 0);
4647  assert(*node == NULL || tree->pathlen-1 <= (int)(*node)->depth);
4648 
4649  /* if the old focus node is a dead end (has no children), delete it */
4650  if( oldfocusnode != NULL && SCIPnodeGetType(oldfocusnode) == SCIP_NODETYPE_DEADEND )
4651  {
4652  int appliedeffectiverootdepth;
4653 
4654  appliedeffectiverootdepth = tree->appliedeffectiverootdepth;
4655  assert(appliedeffectiverootdepth <= tree->effectiverootdepth);
4656 
4657  SCIP_CALL( SCIPnodeFree(&oldfocusnode, blkmem, set, stat, eventqueue, tree, lp) );
4658  assert(tree->effectiverootdepth < tree->pathlen || *node == NULL || *cutoff);
4659 
4660  if( tree->effectiverootdepth > appliedeffectiverootdepth && *node != NULL && !(*cutoff) )
4661  {
4662  int d;
4663 
4664  /* promote the constraint set and bound changes up to the new effective root to be global changes */
4665  SCIPsetDebugMsg(set, "effective root is now at depth %d: applying constraint set and bound changes to global problem\n",
4666  tree->effectiverootdepth);
4667 
4668  for( d = appliedeffectiverootdepth + 1; d <= tree->effectiverootdepth; ++d )
4669  {
4670  SCIP_Bool nodecutoff;
4671 
4672  SCIPsetDebugMsg(set, " -> applying constraint set changes of depth %d\n", d);
4673  SCIP_CALL( SCIPconssetchgMakeGlobal(&tree->path[d]->conssetchg, blkmem, set, stat, transprob, reopt) );
4674  SCIPsetDebugMsg(set, " -> applying bound changes of depth %d\n", d);
4675  SCIP_CALL( SCIPdomchgApplyGlobal(tree->path[d]->domchg, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
4676  &nodecutoff) );
4677 
4678  if( nodecutoff )
4679  {
4680  SCIP_CALL( SCIPnodeCutoff(tree->path[d], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
4681  *cutoff = TRUE;
4682  }
4683  }
4684 
4686  }
4687  }
4688  assert(*cutoff || SCIPtreeIsPathComplete(tree));
4689 
4690  return SCIP_OKAY;
4691 }
4692 
4693 
4694 
4695 
4696 /*
4697  * Tree methods
4698  */
4699 
4700 /** creates an initialized tree data structure */
4702  SCIP_TREE** tree, /**< pointer to tree data structure */
4703  BMS_BLKMEM* blkmem, /**< block memory buffers */
4704  SCIP_SET* set, /**< global SCIP settings */
4705  SCIP_NODESEL* nodesel /**< node selector to use for sorting leaves in the priority queue */
4706  )
4707 {
4708  int p;
4709 
4710  assert(tree != NULL);
4711  assert(blkmem != NULL);
4712 
4713  SCIP_ALLOC( BMSallocMemory(tree) );
4714 
4715  (*tree)->root = NULL;
4716 
4717  SCIP_CALL( SCIPnodepqCreate(&(*tree)->leaves, set, nodesel) );
4718 
4719  /* allocate one slot for the prioritized and the unprioritized bound change */
4720  for( p = 0; p <= 1; ++p )
4721  {
4722  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*tree)->divebdchgdirs[p], 1) ); /*lint !e866*/
4723  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*tree)->divebdchgvars[p], 1) ); /*lint !e866*/
4724  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*tree)->divebdchgvals[p], 1) ); /*lint !e866*/
4725  (*tree)->ndivebdchanges[p] = 0;
4726  (*tree)->divebdchgsize[p] = 1;
4727  }
4728 
4729  (*tree)->path = NULL;
4730  (*tree)->focusnode = NULL;
4731  (*tree)->focuslpfork = NULL;
4732  (*tree)->focuslpstatefork = NULL;
4733  (*tree)->focussubroot = NULL;
4734  (*tree)->children = NULL;
4735  (*tree)->siblings = NULL;
4736  (*tree)->probingroot = NULL;
4737  (*tree)->childrenprio = NULL;
4738  (*tree)->siblingsprio = NULL;
4739  (*tree)->pathnlpcols = NULL;
4740  (*tree)->pathnlprows = NULL;
4741  (*tree)->probinglpistate = NULL;
4742  (*tree)->probinglpinorms = NULL;
4743  (*tree)->pendingbdchgs = NULL;
4744  (*tree)->probdiverelaxsol = NULL;
4745  (*tree)->pendingbdchgssize = 0;
4746  (*tree)->npendingbdchgs = 0;
4747  (*tree)->focuslpstateforklpcount = -1;
4748  (*tree)->childrensize = 0;
4749  (*tree)->nchildren = 0;
4750  (*tree)->siblingssize = 0;
4751  (*tree)->nsiblings = 0;
4752  (*tree)->pathlen = 0;
4753  (*tree)->pathsize = 0;
4754  (*tree)->effectiverootdepth = 0;
4755  (*tree)->appliedeffectiverootdepth = 0;
4756  (*tree)->correctlpdepth = -1;
4757  (*tree)->cutoffdepth = INT_MAX;
4758  (*tree)->repropdepth = INT_MAX;
4759  (*tree)->repropsubtreecount = 0;
4760  (*tree)->focusnodehaslp = FALSE;
4761  (*tree)->probingnodehaslp = FALSE;
4762  (*tree)->focuslpconstructed = FALSE;
4763  (*tree)->cutoffdelayed = FALSE;
4764  (*tree)->probinglpwasflushed = FALSE;
4765  (*tree)->probinglpwassolved = FALSE;
4766  (*tree)->probingloadlpistate = FALSE;
4767  (*tree)->probinglpwasrelax = FALSE;
4768  (*tree)->probingsolvedlp = FALSE;
4769  (*tree)->forcinglpmessage = FALSE;
4770  (*tree)->sbprobing = FALSE;
4771  (*tree)->probinglpwasprimfeas = TRUE;
4772  (*tree)->probinglpwasdualfeas = TRUE;
4773  (*tree)->probdiverelaxstored = FALSE;
4774  (*tree)->probdiverelaxincludeslp = FALSE;
4775 
4776  return SCIP_OKAY;
4777 }
4778 
4779 /** frees tree data structure */
4781  SCIP_TREE** tree, /**< pointer to tree data structure */
4782  BMS_BLKMEM* blkmem, /**< block memory buffers */
4783  SCIP_SET* set, /**< global SCIP settings */
4784  SCIP_STAT* stat, /**< problem statistics */
4785  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4786  SCIP_LP* lp /**< current LP data */
4787  )
4788 {
4789  int p;
4790 
4791  assert(tree != NULL);
4792  assert(*tree != NULL);
4793  assert((*tree)->nchildren == 0);
4794  assert((*tree)->nsiblings == 0);
4795  assert((*tree)->focusnode == NULL);
4796  assert(!SCIPtreeProbing(*tree));
4797 
4798  SCIPsetDebugMsg(set, "free tree\n");
4799 
4800  /* free node queue */
4801  SCIP_CALL( SCIPnodepqFree(&(*tree)->leaves, blkmem, set, stat, eventqueue, *tree, lp) );
4802 
4803  /* free diving bound change storage */
4804  for( p = 0; p <= 1; ++p )
4805  {
4806  BMSfreeBlockMemoryArray(blkmem, &(*tree)->divebdchgdirs[p], (*tree)->divebdchgsize[p]); /*lint !e866*/
4807  BMSfreeBlockMemoryArray(blkmem, &(*tree)->divebdchgvals[p], (*tree)->divebdchgsize[p]); /*lint !e866*/
4808  BMSfreeBlockMemoryArray(blkmem, &(*tree)->divebdchgvars[p], (*tree)->divebdchgsize[p]); /*lint !e866*/
4809  }
4810 
4811  /* free pointer arrays */
4812  BMSfreeMemoryArrayNull(&(*tree)->path);
4813  BMSfreeMemoryArrayNull(&(*tree)->children);
4814  BMSfreeMemoryArrayNull(&(*tree)->siblings);
4815  BMSfreeMemoryArrayNull(&(*tree)->childrenprio);
4816  BMSfreeMemoryArrayNull(&(*tree)->siblingsprio);
4817  BMSfreeMemoryArrayNull(&(*tree)->pathnlpcols);
4818  BMSfreeMemoryArrayNull(&(*tree)->pathnlprows);
4819  BMSfreeMemoryArrayNull(&(*tree)->probdiverelaxsol);
4820  BMSfreeMemoryArrayNull(&(*tree)->pendingbdchgs);
4821 
4822  BMSfreeMemory(tree);
4823 
4824  return SCIP_OKAY;
4825 }
4826 
4827 /** clears and resets tree data structure and deletes all nodes */
4829  SCIP_TREE* tree, /**< tree data structure */
4830  BMS_BLKMEM* blkmem, /**< block memory buffers */
4831  SCIP_SET* set, /**< global SCIP settings */
4832  SCIP_STAT* stat, /**< problem statistics */
4833  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4834  SCIP_LP* lp /**< current LP data */
4835  )
4836 {
4837  int v;
4838 
4839  assert(tree != NULL);
4840  assert(tree->nchildren == 0);
4841  assert(tree->nsiblings == 0);
4842  assert(tree->focusnode == NULL);
4843  assert(!SCIPtreeProbing(tree));
4844 
4845  SCIPsetDebugMsg(set, "clearing tree\n");
4846 
4847  /* clear node queue */
4848  SCIP_CALL( SCIPnodepqClear(tree->leaves, blkmem, set, stat, eventqueue, tree, lp) );
4849  assert(tree->root == NULL);
4850 
4851  /* we have to remove the captures of the variables within the pending bound change data structure */
4852  for( v = tree->npendingbdchgs-1; v >= 0; --v )
4853  {
4854  SCIP_VAR* var;
4855 
4856  var = tree->pendingbdchgs[v].var;
4857  assert(var != NULL);
4858 
4859  /* release the variable */
4860  SCIP_CALL( SCIPvarRelease(&var, blkmem, set, eventqueue, lp) );
4861  }
4862 
4863  /* mark working arrays to be empty and reset data */
4864  tree->focuslpstateforklpcount = -1;
4865  tree->nchildren = 0;
4866  tree->nsiblings = 0;
4867  tree->pathlen = 0;
4868  tree->effectiverootdepth = 0;
4869  tree->appliedeffectiverootdepth = 0;
4870  tree->correctlpdepth = -1;
4871  tree->cutoffdepth = INT_MAX;
4872  tree->repropdepth = INT_MAX;
4873  tree->repropsubtreecount = 0;
4874  tree->npendingbdchgs = 0;
4875  tree->focusnodehaslp = FALSE;
4876  tree->probingnodehaslp = FALSE;
4877  tree->cutoffdelayed = FALSE;
4878  tree->probinglpwasflushed = FALSE;
4879  tree->probinglpwassolved = FALSE;
4880  tree->probingloadlpistate = FALSE;
4881  tree->probinglpwasrelax = FALSE;
4882  tree->probingsolvedlp = FALSE;
4883 
4884  return SCIP_OKAY;
4885 }
4886 
4887 /** creates the root node of the tree and puts it into the leaves queue */
4889  SCIP_TREE* tree, /**< tree data structure */
4890  SCIP_REOPT* reopt, /**< reoptimization data structure */
4891  BMS_BLKMEM* blkmem, /**< block memory buffers */
4892  SCIP_SET* set, /**< global SCIP settings */
4893  SCIP_STAT* stat, /**< problem statistics */
4894  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4895  SCIP_LP* lp /**< current LP data */
4896  )
4897 {
4898  assert(tree != NULL);
4899  assert(tree->nchildren == 0);
4900  assert(tree->nsiblings == 0);
4901  assert(tree->root == NULL);
4902  assert(tree->focusnode == NULL);
4903  assert(!SCIPtreeProbing(tree));
4904 
4905  /* create root node */
4906  SCIP_CALL( SCIPnodeCreateChild(&tree->root, blkmem, set, stat, tree, 0.0, -SCIPsetInfinity(set)) );
4907  assert(tree->nchildren == 1);
4908 
4909 #ifndef NDEBUG
4910  /* check, if the sizes in the data structures match the maximal numbers defined here */
4911  tree->root->depth = SCIP_MAXTREEDEPTH + 1;
4913  assert(tree->root->depth - 1 == SCIP_MAXTREEDEPTH); /*lint !e650*/
4914  assert(tree->root->repropsubtreemark == MAXREPROPMARK);
4915  tree->root->depth++; /* this should produce an overflow and reset the value to 0 */
4916  tree->root->repropsubtreemark++; /* this should produce an overflow and reset the value to 0 */
4917  assert(tree->root->depth == 0);
4918  assert((SCIP_NODETYPE)tree->root->nodetype == SCIP_NODETYPE_CHILD);
4919  assert(!tree->root->active);
4920  assert(!tree->root->cutoff);
4921  assert(!tree->root->reprop);
4922  assert(tree->root->repropsubtreemark == 0);
4923 #endif
4924 
4925  /* move root to the queue, convert it to LEAF */
4926  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, NULL,
4927  SCIPsetInfinity(set)) );
4928 
4929  return SCIP_OKAY;
4930 }
4931 
4932 /** creates a temporary presolving root node of the tree and installs it as focus node */
4934  SCIP_TREE* tree, /**< tree data structure */
4935  SCIP_REOPT* reopt, /**< reoptimization data structure */
4936  BMS_BLKMEM* blkmem, /**< block memory buffers */
4937  SCIP_SET* set, /**< global SCIP settings */
4938  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4939  SCIP_STAT* stat, /**< problem statistics */
4940  SCIP_PROB* transprob, /**< transformed problem */
4941  SCIP_PROB* origprob, /**< original problem */
4942  SCIP_PRIMAL* primal, /**< primal data */
4943  SCIP_LP* lp, /**< current LP data */
4944  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4945  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4946  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
4947  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4948  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4949  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
4950  )
4951 {
4952  SCIP_Bool cutoff;
4953 
4954  assert(tree != NULL);
4955  assert(tree->nchildren == 0);
4956  assert(tree->nsiblings == 0);
4957  assert(tree->root == NULL);
4958  assert(tree->focusnode == NULL);
4959  assert(!SCIPtreeProbing(tree));
4960 
4961  /* create temporary presolving root node */
4962  SCIP_CALL( SCIPtreeCreateRoot(tree, reopt, blkmem, set, stat, eventqueue, lp) );
4963  assert(tree->root != NULL);
4964 
4965  /* install the temporary root node as focus node */
4966  SCIP_CALL( SCIPnodeFocus(&tree->root, blkmem, set, messagehdlr, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4967  conflict, conflictstore, eventfilter, eventqueue, cliquetable, &cutoff, FALSE, FALSE) );
4968  assert(!cutoff);
4969 
4970  return SCIP_OKAY;
4971 }
4972 
4973 /** frees the temporary presolving root and resets tree data structure */
4975  SCIP_TREE* tree, /**< tree data structure */
4976  SCIP_REOPT* reopt, /**< reoptimization data structure */
4977  BMS_BLKMEM* blkmem, /**< block memory buffers */
4978  SCIP_SET* set, /**< global SCIP settings */
4979  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4980  SCIP_STAT* stat, /**< problem statistics */
4981  SCIP_PROB* transprob, /**< transformed problem */
4982  SCIP_PROB* origprob, /**< original problem */
4983  SCIP_PRIMAL* primal, /**< primal data */
4984  SCIP_LP* lp, /**< current LP data */
4985  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4986  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4987  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
4988  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4989  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4990  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
4991  )
4992 {
4993  SCIP_NODE* node;
4994  SCIP_Bool cutoff;
4995 
4996  assert(tree != NULL);
4997  assert(tree->root != NULL);
4998  assert(tree->focusnode == tree->root);
4999  assert(tree->pathlen == 1);
5000 
5001  /* unfocus the temporary root node */
5002  node = NULL;
5003  SCIP_CALL( SCIPnodeFocus(&node, blkmem, set, messagehdlr, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
5004  conflict, conflictstore, eventfilter, eventqueue, cliquetable, &cutoff, FALSE, FALSE) );
5005  assert(!cutoff);
5006  assert(tree->root == NULL);
5007  assert(tree->focusnode == NULL);
5008  assert(tree->pathlen == 0);
5009 
5010  /* reset tree data structure */
5011  SCIP_CALL( SCIPtreeClear(tree, blkmem, set, stat, eventqueue, lp) );
5012 
5013  return SCIP_OKAY;
5014 }
5015 
5016 /** returns the node selector associated with the given node priority queue */
5018  SCIP_TREE* tree /**< branch and bound tree */
5019  )
5020 {
5021  assert(tree != NULL);
5022 
5023  return SCIPnodepqGetNodesel(tree->leaves);
5024 }
5025 
5026 /** sets the node selector used for sorting the nodes in the priority queue, and resorts the queue if necessary */
5028  SCIP_TREE* tree, /**< branch and bound tree */
5029  SCIP_SET* set, /**< global SCIP settings */
5030  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
5031  SCIP_STAT* stat, /**< problem statistics */
5032  SCIP_NODESEL* nodesel /**< node selector to use for sorting the nodes in the queue */
5033  )
5034 {
5035  assert(tree != NULL);
5036  assert(stat != NULL);
5037 
5038  if( SCIPnodepqGetNodesel(tree->leaves) != nodesel )
5039  {
5040  /* change the node selector used in the priority queue and resort the queue */
5041  SCIP_CALL( SCIPnodepqSetNodesel(&tree->leaves, set, nodesel) );
5042 
5043  /* issue message */
5044  if( stat->nnodes > 0 )
5045  {
5046  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
5047  "(node %" SCIP_LONGINT_FORMAT ") switching to node selector <%s>\n", stat->nnodes, SCIPnodeselGetName(nodesel));
5048  }
5049  }
5050 
5051  return SCIP_OKAY;
5052 }
5053 
5054 /** cuts off nodes with lower bound not better than given cutoff bound */
5056  SCIP_TREE* tree, /**< branch and bound tree */
5057  SCIP_REOPT* reopt, /**< reoptimization data structure */
5058  BMS_BLKMEM* blkmem, /**< block memory */
5059  SCIP_SET* set, /**< global SCIP settings */
5060  SCIP_STAT* stat, /**< dynamic problem statistics */
5061  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5062  SCIP_LP* lp, /**< current LP data */
5063  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
5064  )
5065 {
5066  SCIP_NODE* node;
5067  int i;
5068 
5069  assert(tree != NULL);
5070  assert(stat != NULL);
5071  assert(lp != NULL);
5072 
5073  /* if we are in diving mode, it is not allowed to cut off nodes, because this can lead to deleting LP rows which
5074  * would modify the currently unavailable (due to diving modifications) SCIP_LP
5075  * -> the cutoff must be delayed and executed after the diving ends
5076  */
5077  if( SCIPlpDiving(lp) )
5078  {
5079  tree->cutoffdelayed = TRUE;
5080  return SCIP_OKAY;
5081  }
5082 
5083  tree->cutoffdelayed = FALSE;
5084 
5085  /* cut off leaf nodes in the queue */
5086  SCIP_CALL( SCIPnodepqBound(tree->leaves, blkmem, set, stat, eventqueue, tree, reopt, lp, cutoffbound) );
5087 
5088  /* cut off siblings: we have to loop backwards, because a removal leads to moving the last node in empty slot */
5089  for( i = tree->nsiblings-1; i >= 0; --i )
5090  {
5091  node = tree->siblings[i];
5092  if( SCIPsetIsGE(set, node->lowerbound, cutoffbound) )
5093  {
5094  SCIPsetDebugMsg(set, "cut off sibling #%" SCIP_LONGINT_FORMAT " at depth %d with lowerbound=%g at position %d\n",
5095  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node), node->lowerbound, i);
5096 
5097  if( set->reopt_enable )
5098  {
5099  assert(reopt != NULL);
5100  /* check if the node should be stored for reoptimization */
5102  tree->root == node, tree->focusnode == node, node->lowerbound, tree->effectiverootdepth) );
5103  }
5104 
5105  SCIPvisualCutoffNode(stat->visual, set, stat, node, FALSE);
5106 
5107  SCIP_CALL( SCIPnodeFree(&node, blkmem, set, stat, eventqueue, tree, lp) );
5108  }
5109  }
5110 
5111  /* cut off children: we have to loop backwards, because a removal leads to moving the last node in empty slot */
5112  for( i = tree->nchildren-1; i >= 0; --i )
5113  {
5114  node = tree->children[i];
5115  if( SCIPsetIsGE(set, node->lowerbound, cutoffbound) )
5116  {
5117  SCIPsetDebugMsg(set, "cut off child #%" SCIP_LONGINT_FORMAT " at depth %d with lowerbound=%g at position %d\n",
5118  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node), node->lowerbound, i);
5119 
5120  if( set->reopt_enable )
5121  {
5122  assert(reopt != NULL);
5123  /* check if the node should be stored for reoptimization */
5125  tree->root == node, tree->focusnode == node, node->lowerbound, tree->effectiverootdepth) );
5126  }
5127 
5128  SCIPvisualCutoffNode(stat->visual, set, stat, node, FALSE);
5129 
5130  SCIP_CALL( SCIPnodeFree(&node, blkmem, set, stat, eventqueue, tree, lp) );
5131  }
5132  }
5133 
5134  return SCIP_OKAY;
5135 }
5136 
5137 /** calculates the node selection priority for moving the given variable's LP value to the given target value;
5138  * this node selection priority can be given to the SCIPcreateChild() call
5139  */
5141  SCIP_TREE* tree, /**< branch and bound tree */
5142  SCIP_SET* set, /**< global SCIP settings */
5143  SCIP_STAT* stat, /**< dynamic problem statistics */
5144  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
5145  SCIP_BRANCHDIR branchdir, /**< type of branching that was performed: upwards, downwards, or fixed
5146  * fixed should only be used, when both bounds changed
5147  */
5148  SCIP_Real targetvalue /**< new value of the variable in the child node */
5149  )
5150 {
5151  SCIP_Real prio;
5152  SCIP_Real varsol;
5153  SCIP_Real varrootsol;
5154  SCIP_Real downinfs;
5155  SCIP_Real upinfs;
5156  SCIP_Bool isroot;
5157  SCIP_Bool haslp;
5158 
5159  assert(set != NULL);
5160 
5161  /* extract necessary information */
5162  isroot = (SCIPtreeGetCurrentDepth(tree) == 0);
5163  haslp = SCIPtreeHasFocusNodeLP(tree);
5164  varsol = SCIPvarGetSol(var, haslp);
5165  varrootsol = SCIPvarGetRootSol(var);
5166  downinfs = SCIPvarGetAvgInferences(var, stat, SCIP_BRANCHDIR_DOWNWARDS);
5167  upinfs = SCIPvarGetAvgInferences(var, stat, SCIP_BRANCHDIR_UPWARDS);
5168 
5169  switch( branchdir )
5170  {
5172  switch( SCIPvarGetBranchDirection(var) )
5173  {
5175  prio = +1.0;
5176  break;
5178  prio = -1.0;
5179  break;
5180  case SCIP_BRANCHDIR_AUTO:
5181  switch( set->nodesel_childsel )
5182  {
5183  case 'd':
5184  prio = +1.0;
5185  break;
5186  case 'u':
5187  prio = -1.0;
5188  break;
5189  case 'p':
5190  prio = -SCIPvarGetPseudocost(var, stat, targetvalue - varsol);
5191  break;
5192  case 'i':
5193  prio = downinfs;
5194  break;
5195  case 'l':
5196  prio = targetvalue - varsol;
5197  break;
5198  case 'r':
5199  prio = varrootsol - varsol;
5200  break;
5201  case 'h':
5202  prio = downinfs + SCIPsetEpsilon(set);
5203  if( !isroot && haslp )
5204  prio *= (varrootsol - varsol + 1.0);
5205  break;
5206  default:
5207  SCIPerrorMessage("invalid child selection rule <%c>\n", set->nodesel_childsel);
5208  prio = 0.0;
5209  break;
5210  }
5211  break;
5212  default:
5213  SCIPerrorMessage("invalid preferred branching direction <%d> of variable <%s>\n",
5215  prio = 0.0;
5216  break;
5217  }
5218  break;
5220  /* the branch is directed upwards */
5221  switch( SCIPvarGetBranchDirection(var) )
5222  {
5224  prio = -1.0;
5225  break;
5227  prio = +1.0;
5228  break;
5229  case SCIP_BRANCHDIR_AUTO:
5230  switch( set->nodesel_childsel )
5231  {
5232  case 'd':
5233  prio = -1.0;
5234  break;
5235  case 'u':
5236  prio = +1.0;
5237  break;
5238  case 'p':
5239  prio = -SCIPvarGetPseudocost(var, stat, targetvalue - varsol);
5240  break;
5241  case 'i':
5242  prio = upinfs;
5243  break;
5244  case 'l':
5245  prio = varsol - targetvalue;
5246  break;
5247  case 'r':
5248  prio = varsol - varrootsol;
5249  break;
5250  case 'h':
5251  prio = upinfs + SCIPsetEpsilon(set);
5252  if( !isroot && haslp )
5253  prio *= (varsol - varrootsol + 1.0);
5254  break;
5255  default:
5256  SCIPerrorMessage("invalid child selection rule <%c>\n", set->nodesel_childsel);
5257  prio = 0.0;
5258  break;
5259  }
5260  /* since choosing the upwards direction is usually superior than the downwards direction (see results of
5261  * Achterberg's thesis (2007)), we break ties towards upwards branching
5262  */
5263  prio += SCIPsetEpsilon(set);
5264  break;
5265 
5266  default:
5267  SCIPerrorMessage("invalid preferred branching direction <%d> of variable <%s>\n",
5269  prio = 0.0;
5270  break;
5271  }
5272  break;
5273  case SCIP_BRANCHDIR_FIXED:
5274  prio = SCIPsetInfinity(set);
5275  break;
5276  case SCIP_BRANCHDIR_AUTO:
5277  default:
5278  SCIPerrorMessage("invalid branching direction <%d> of variable <%s>\n",
5280  prio = 0.0;
5281  break;
5282  }
5283 
5284  return prio;
5285 }
5286 
5287 /** calculates an estimate for the objective of the best feasible solution contained in the subtree after applying the given
5288  * branching; this estimate can be given to the SCIPcreateChild() call
5289  */
5291  SCIP_TREE* tree, /**< branch and bound tree */
5292  SCIP_SET* set, /**< global SCIP settings */
5293  SCIP_STAT* stat, /**< dynamic problem statistics */
5294  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
5295  SCIP_Real targetvalue /**< new value of the variable in the child node */
5296  )
5297 {
5298  SCIP_Real estimateinc;
5299  SCIP_Real estimate;
5300  SCIP_Real varsol;
5301 
5302  assert(tree != NULL);
5303  assert(var != NULL);
5304 
5305  estimate = SCIPnodeGetEstimate(tree->focusnode);
5306  varsol = SCIPvarGetSol(var, SCIPtreeHasFocusNodeLP(tree));
5307 
5308  /* compute increase above parent node's (i.e., focus node's) estimate value */
5310  estimateinc = SCIPvarGetPseudocost(var, stat, targetvalue - varsol);
5311  else
5312  {
5313  SCIP_Real pscdown;
5314  SCIP_Real pscup;
5315 
5316  /* calculate estimate based on pseudo costs:
5317  * estimate = lowerbound + sum(min{f_j * pscdown_j, (1-f_j) * pscup_j})
5318  * = parentestimate - min{f_b * pscdown_b, (1-f_b) * pscup_b} + (targetvalue-oldvalue)*{pscdown_b or pscup_b}
5319  */
5320  pscdown = SCIPvarGetPseudocost(var, stat, SCIPsetFeasFloor(set, varsol) - varsol);
5321  pscup = SCIPvarGetPseudocost(var, stat, SCIPsetFeasCeil(set, varsol) - varsol);
5322  estimateinc = SCIPvarGetPseudocost(var, stat, targetvalue - varsol) - MIN(pscdown, pscup);
5323  }
5324 
5325  /* due to rounding errors estimateinc might be slightly negative; in this case return the parent node's estimate */
5326  if( estimateinc > 0.0 )
5327  estimate += estimateinc;
5328 
5329  return estimate;
5330 }
5331 
5332 /** branches on a variable x
5333  * if x is a continuous variable, then two child nodes will be created
5334  * (x <= x', x >= x')
5335  * but if the bounds of x are such that their relative difference is smaller than epsilon,
5336  * the variable is fixed to val (if not SCIP_INVALID) or a well chosen alternative in the current node,
5337  * i.e., no children are created
5338  * if x is not a continuous variable, then:
5339  * if solution value x' is fractional, two child nodes will be created
5340  * (x <= floor(x'), x >= ceil(x')),
5341  * if solution value is integral, the x' is equal to lower or upper bound of the branching
5342  * variable and the bounds of x are finite, then two child nodes will be created
5343  * (x <= x", x >= x"+1 with x" = floor((lb + ub)/2)),
5344  * otherwise (up to) three child nodes will be created
5345  * (x <= x'-1, x == x', x >= x'+1)
5346  * if solution value is equal to one of the bounds and the other bound is infinite, only two child nodes
5347  * will be created (the third one would be infeasible anyway)
5348  */
5350  SCIP_TREE* tree, /**< branch and bound tree */
5351  SCIP_REOPT* reopt, /**< reoptimization data structure */
5352  BMS_BLKMEM* blkmem, /**< block memory */
5353  SCIP_SET* set, /**< global SCIP settings */
5354  SCIP_STAT* stat, /**< problem statistics data */
5355  SCIP_PROB* transprob, /**< transformed problem after presolve */
5356  SCIP_PROB* origprob, /**< original problem */
5357  SCIP_LP* lp, /**< current LP data */
5358  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5359  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5360  SCIP_VAR* var, /**< variable to branch on */
5361  SCIP_Real val, /**< value to branch on or SCIP_INVALID for branching on current LP/pseudo solution.
5362  * A branching value is required for branching on continuous variables */
5363  SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
5364  SCIP_NODE** eqchild, /**< pointer to return the middle child with variable fixed, or NULL */
5365  SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
5366  )
5367 {
5368  SCIP_NODE* node;
5369  SCIP_Real priority;
5370  SCIP_Real estimate;
5371 
5372  SCIP_Real downub;
5373  SCIP_Real fixval;
5374  SCIP_Real uplb;
5375  SCIP_Real lpval;
5376 
5377  SCIP_Bool validval;
5378 
5379  assert(tree != NULL);
5380  assert(set != NULL);
5381  assert(var != NULL);
5382 
5383  /* initialize children pointer */
5384  if( downchild != NULL )
5385  *downchild = NULL;
5386  if( eqchild != NULL )
5387  *eqchild = NULL;
5388  if( upchild != NULL )
5389  *upchild = NULL;
5390 
5391  /* store whether a valid value was given for branching */
5392  validval = (val != SCIP_INVALID); /*lint !e777 */
5393 
5394  /* get the corresponding active problem variable
5395  * if branching value is given, then transform it to the value of the active variable */
5396  if( validval )
5397  {
5398  SCIP_Real scalar;
5399  SCIP_Real constant;
5400 
5401  scalar = 1.0;
5402  constant = 0.0;
5403 
5404  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
5405 
5406  if( scalar == 0.0 )
5407  {
5408  SCIPerrorMessage("cannot branch on fixed variable <%s>\n", SCIPvarGetName(var));
5409  return SCIP_INVALIDDATA;
5410  }
5411 
5412  /* we should have givenvariable = scalar * activevariable + constant */
5413  val = (val - constant) / scalar;
5414  }
5415  else
5416  var = SCIPvarGetProbvar(var);
5417 
5419  {
5420  SCIPerrorMessage("cannot branch on fixed or multi-aggregated variable <%s>\n", SCIPvarGetName(var));
5421  SCIPABORT();
5422  return SCIP_INVALIDDATA; /*lint !e527*/
5423  }
5424 
5425  /* ensure, that branching on continuous variables will only be performed when a branching point is given. */
5426  if( SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS && !validval )
5427  {
5428  SCIPerrorMessage("Cannot branch on continuous variables without a given branching value.\n", SCIPvarGetName(var));
5429  SCIPABORT();
5430  return SCIP_INVALIDDATA; /*lint !e527*/
5431  }
5432 
5433  assert(SCIPvarIsActive(var));
5434  assert(SCIPvarGetProbindex(var) >= 0);
5438  assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
5439 
5440  /* update the information for the focus node before creating children */
5441  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, tree->focusnode) );
5442 
5443  /* get value of variable in current LP or pseudo solution */
5444  lpval = SCIPvarGetSol(var, tree->focusnodehaslp);
5445 
5446  /* if there was no explicit value given for branching, branch on current LP or pseudo solution value */
5447  if( !validval )
5448  {
5449  val = lpval;
5450 
5451  /* avoid branching on infinite values in pseudo solution */
5452  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5453  {
5454  val = SCIPvarGetWorstBoundLocal(var);
5455 
5456  /* if both bounds are infinite, choose zero as branching point */
5457  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5458  {
5459  assert(SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)));
5460  assert(SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)));
5461  val = 0.0;
5462  }
5463  }
5464  }
5465 
5466  assert(SCIPsetIsFeasGE(set, val, SCIPvarGetLbLocal(var)));
5467  assert(SCIPsetIsFeasLE(set, val, SCIPvarGetUbLocal(var)));
5468  /* see comment in SCIPbranchVarVal */
5469  assert(SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS ||
5470  SCIPrelDiff(SCIPvarGetUbLocal(var), SCIPvarGetLbLocal(var)) <= 2.02 * SCIPsetEpsilon(set) ||
5471  SCIPsetIsInfinity(set, -2.1*SCIPvarGetLbLocal(var)) || SCIPsetIsInfinity(set, 2.1*SCIPvarGetUbLocal(var)) ||
5472  (SCIPsetIsLT(set, 2.1*SCIPvarGetLbLocal(var), 2.1*val) && SCIPsetIsLT(set, 2.1*val, 2.1*SCIPvarGetUbLocal(var))) );
5473 
5474  downub = SCIP_INVALID;
5475  fixval = SCIP_INVALID;
5476  uplb = SCIP_INVALID;
5477 
5479  {
5480  if( SCIPsetIsRelEQ(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)) )
5481  {
5482  SCIPsetDebugMsg(set, "fixing continuous variable <%s> with value %g and bounds [%.15g, %.15g], priority %d (current lower bound: %g)\n",
5484 
5485  /* if val is at least epsilon away from both bounds, then we change both bounds to this value
5486  * otherwise, we fix the variable to its worst bound
5487  */
5488  if( SCIPsetIsGT(set, val, SCIPvarGetLbLocal(var)) && SCIPsetIsLT(set, val, SCIPvarGetUbLocal(var)) )
5489  {
5490  SCIP_CALL( SCIPnodeAddBoundchg(tree->focusnode, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
5491  branchcand, eventqueue, NULL, var, val, SCIP_BOUNDTYPE_LOWER, FALSE) );
5492  SCIP_CALL( SCIPnodeAddBoundchg(tree->focusnode, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
5493  branchcand, eventqueue, NULL, var, val, SCIP_BOUNDTYPE_UPPER, FALSE) );
5494  }
5495  else if( SCIPvarGetObj(var) >= 0.0 )
5496  {
5497  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5498  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetUbLocal(var), SCIP_BOUNDTYPE_LOWER, FALSE) );
5499  }
5500  else
5501  {
5502  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5503  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetLbLocal(var), SCIP_BOUNDTYPE_UPPER, FALSE) );
5504  }
5505  }
5506  else if( SCIPrelDiff(SCIPvarGetUbLocal(var), SCIPvarGetLbLocal(var)) <= 2.02 * SCIPsetEpsilon(set) )
5507  {
5508  /* if the only way to branch is such that in both sides the relative domain width becomes smaller epsilon,
5509  * then fix the variable in both branches right away
5510  *
5511  * however, if one of the bounds is at infinity (and thus the other bound is at most 2eps away from the same infinity (in relative sense),
5512  * then fix the variable to the non-infinite value, as we cannot fix a variable to infinity
5513  */
5514  SCIPsetDebugMsg(set, "continuous branch on variable <%s> with bounds [%.15g, %.15g], priority %d (current lower bound: %g), node %p\n",
5516  if( SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)) )
5517  {
5518  assert(!SCIPsetIsInfinity(set, -SCIPvarGetUbLocal(var)));
5519  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5520  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetUbLocal(var), SCIP_BOUNDTYPE_LOWER, FALSE) );
5521  }
5522  else if( SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)) )
5523  {
5524  assert(!SCIPsetIsInfinity(set, SCIPvarGetLbLocal(var)));
5525  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5526  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetLbLocal(var), SCIP_BOUNDTYPE_UPPER, FALSE) );
5527  }
5528  else
5529  {
5530  downub = SCIPvarGetLbLocal(var);
5531  uplb = SCIPvarGetUbLocal(var);
5532  }
5533  }
5534  else
5535  {
5536  /* in the general case, there is enough space for two branches
5537  * a sophisticated user should have also chosen the branching value such that it is not very close to the bounds
5538  * so here we only ensure that it is at least epsilon away from both bounds
5539  */
5540  SCIPsetDebugMsg(set, "continuous branch on variable <%s> with value %g, priority %d (current lower bound: %g)\n",
5542  downub = MIN(val, SCIPvarGetUbLocal(var) - SCIPsetEpsilon(set)); /*lint !e666*/
5543  uplb = MAX(val, SCIPvarGetLbLocal(var) + SCIPsetEpsilon(set)); /*lint !e666*/
5544  }
5545  }
5546  else if( SCIPsetIsFeasIntegral(set, val) )
5547  {
5548  SCIP_Real lb;
5549  SCIP_Real ub;
5550 
5551  lb = SCIPvarGetLbLocal(var);
5552  ub = SCIPvarGetUbLocal(var);
5553 
5554  /* if there was no explicit value given for branching, the variable has a finite domain and the current LP/pseudo
5555  * solution is one of the bounds, we branch in the center of the domain */
5556  if( !validval && !SCIPsetIsInfinity(set, -lb) && !SCIPsetIsInfinity(set, ub)
5557  && (SCIPsetIsFeasEQ(set, val, lb) || SCIPsetIsFeasEQ(set, val, ub)) )
5558  {
5559  SCIP_Real center;
5560 
5561  /* create child nodes with x <= x", and x >= x"+1 with x" = floor((lb + ub)/2);
5562  * if x" is integral, make the interval smaller in the child in which the current solution x'
5563  * is still feasible
5564  */
5565  center = (ub + lb) / 2.0;
5566  if( val <= center )
5567  {
5568  downub = SCIPsetFeasFloor(set, center);
5569  uplb = downub + 1.0;
5570  }
5571  else
5572  {
5573  uplb = SCIPsetFeasCeil(set, center);
5574  downub = uplb - 1.0;
5575  }
5576  }
5577  else
5578  {
5579  /* create child nodes with x <= x'-1, x = x', and x >= x'+1 */
5580  assert(SCIPsetIsEQ(set, SCIPsetFeasCeil(set, val), SCIPsetFeasFloor(set, val)));
5581 
5582  fixval = SCIPsetFeasCeil(set, val); /* get rid of numerical issues */
5583 
5584  /* create child node with x <= x'-1, if this would be feasible */
5585  if( SCIPsetIsFeasGE(set, fixval-1.0, lb) )
5586  downub = fixval - 1.0;
5587 
5588  /* create child node with x >= x'+1, if this would be feasible */
5589  if( SCIPsetIsFeasLE(set, fixval+1.0, ub) )
5590  uplb = fixval + 1.0;
5591  }
5592  SCIPsetDebugMsg(set, "integral branch on variable <%s> with value %g, priority %d (current lower bound: %g)\n",
5594  }
5595  else
5596  {
5597  /* create child nodes with x <= floor(x'), and x >= ceil(x') */
5598  downub = SCIPsetFeasFloor(set, val);
5599  uplb = downub + 1.0;
5600  assert( SCIPsetIsRelEQ(set, SCIPsetCeil(set, val), uplb) );
5601  SCIPsetDebugMsg(set, "fractional branch on variable <%s> with value %g, root value %g, priority %d (current lower bound: %g)\n",
5603  }
5604 
5605  /* perform the branching;
5606  * set the node selection priority in a way, s.t. a node is preferred whose branching goes in the same direction
5607  * as the deviation from the variable's root solution
5608  */
5609  if( downub != SCIP_INVALID ) /*lint !e777*/
5610  {
5611  /* create child node x <= downub */
5612  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_DOWNWARDS, downub);
5613  /* if LP solution is cutoff in child, compute a new estimate
5614  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
5615  if( SCIPsetIsGT(set, lpval, downub) )
5616  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, downub);
5617  else
5618  estimate = SCIPnodeGetEstimate(tree->focusnode);
5619  SCIPsetDebugMsg(set, " -> creating child: <%s> <= %g (priority: %g, estimate: %g)\n",
5620  SCIPvarGetName(var), downub, priority, estimate);
5621  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5622  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5623  NULL, var, downub, SCIP_BOUNDTYPE_UPPER, FALSE) );
5624  /* output branching bound change to visualization file */
5625  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5626 
5627  if( downchild != NULL )
5628  *downchild = node;
5629  }
5630 
5631  if( fixval != SCIP_INVALID ) /*lint !e777*/
5632  {
5633  /* create child node with x = fixval */
5634  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_FIXED, fixval);
5635  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, fixval);
5636  SCIPsetDebugMsg(set, " -> creating child: <%s> == %g (priority: %g, estimate: %g)\n",
5637  SCIPvarGetName(var), fixval, priority, estimate);
5638  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5639  if( !SCIPsetIsFeasEQ(set, SCIPvarGetLbLocal(var), fixval) )
5640  {
5641  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5642  NULL, var, fixval, SCIP_BOUNDTYPE_LOWER, FALSE) );
5643  }
5644  if( !SCIPsetIsFeasEQ(set, SCIPvarGetUbLocal(var), fixval) )
5645  {
5646  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5647  NULL, var, fixval, SCIP_BOUNDTYPE_UPPER, FALSE) );
5648  }
5649  /* output branching bound change to visualization file */
5650  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5651 
5652  if( eqchild != NULL )
5653  *eqchild = node;
5654  }
5655 
5656  if( uplb != SCIP_INVALID ) /*lint !e777*/
5657  {
5658  /* create child node with x >= uplb */
5659  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_UPWARDS, uplb);
5660  if( SCIPsetIsLT(set, lpval, uplb) )
5661  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, uplb);
5662  else
5663  estimate = SCIPnodeGetEstimate(tree->focusnode);
5664  SCIPsetDebugMsg(set, " -> creating child: <%s> >= %g (priority: %g, estimate: %g)\n",
5665  SCIPvarGetName(var), uplb, priority, estimate);
5666  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5667  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5668  NULL, var, uplb, SCIP_BOUNDTYPE_LOWER, FALSE) );
5669  /* output branching bound change to visualization file */
5670  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5671 
5672  if( upchild != NULL )
5673  *upchild = node;
5674  }
5675 
5676  return SCIP_OKAY;
5677 }
5678 
5679 /** branches a variable x using the given domain hole; two child nodes will be created (x <= left, x >= right) */
5681  SCIP_TREE* tree, /**< branch and bound tree */
5682  SCIP_REOPT* reopt, /**< reoptimization data structure */
5683  BMS_BLKMEM* blkmem, /**< block memory */
5684  SCIP_SET* set, /**< global SCIP settings */
5685  SCIP_STAT* stat, /**< problem statistics data */
5686  SCIP_PROB* transprob, /**< transformed problem after presolve */
5687  SCIP_PROB* origprob, /**< original problem */
5688  SCIP_LP* lp, /**< current LP data */
5689  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5690  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5691  SCIP_VAR* var, /**< variable to branch on */
5692  SCIP_Real left, /**< left side of the domain hole */
5693  SCIP_Real right, /**< right side of the domain hole */
5694  SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
5695  SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
5696  )
5697 {
5698  SCIP_NODE* node;
5699  SCIP_Real priority;
5700  SCIP_Real estimate;
5701  SCIP_Real lpval;
5702 
5703  assert(tree != NULL);
5704  assert(set != NULL);
5705  assert(var != NULL);
5706  assert(SCIPsetIsLT(set, left, SCIPvarGetUbLocal(var)));
5707  assert(SCIPsetIsGE(set, left, SCIPvarGetLbLocal(var)));
5708  assert(SCIPsetIsGT(set, right, SCIPvarGetLbLocal(var)));
5709  assert(SCIPsetIsLE(set, right, SCIPvarGetUbLocal(var)));
5710  assert(SCIPsetIsLE(set, left, right));
5711 
5712  /* initialize children pointer */
5713  if( downchild != NULL )
5714  *downchild = NULL;
5715  if( upchild != NULL )
5716  *upchild = NULL;
5717 
5718  /* get the corresponding active problem variable */
5719  SCIP_CALL( SCIPvarGetProbvarHole(&var, &left, &right) );
5720 
5722  {
5723  SCIPerrorMessage("cannot branch on fixed or multi-aggregated variable <%s>\n", SCIPvarGetName(var));
5724  SCIPABORT();
5725  return SCIP_INVALIDDATA; /*lint !e527*/
5726  }
5727 
5728  assert(SCIPvarIsActive(var));
5729  assert(SCIPvarGetProbindex(var) >= 0);
5733  assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
5734 
5735  assert(SCIPsetIsFeasGE(set, left, SCIPvarGetLbLocal(var)));
5736  assert(SCIPsetIsFeasLE(set, right, SCIPvarGetUbLocal(var)));
5737 
5738  /* adjust left and right side of the domain hole if the variable is integral */
5739  if( SCIPvarIsIntegral(var) )
5740  {
5741  left = SCIPsetFeasFloor(set, left);
5742  right = SCIPsetFeasCeil(set, right);
5743  }
5744 
5745  assert(SCIPsetIsLT(set, left, SCIPvarGetUbLocal(var)));
5746  assert(SCIPsetIsGE(set, left, SCIPvarGetLbLocal(var)));
5747  assert(SCIPsetIsGT(set, right, SCIPvarGetLbLocal(var)));
5748  assert(SCIPsetIsLE(set, right, SCIPvarGetUbLocal(var)));
5749  assert(SCIPsetIsLE(set, left, right));
5750 
5751  /* get value of variable in current LP or pseudo solution */
5752  lpval = SCIPvarGetSol(var, tree->focusnodehaslp);
5753 
5754  /* perform the branching;
5755  * set the node selection priority in a way, s.t. a node is preferred whose branching goes in the same direction
5756  * as the deviation from the variable's root solution
5757  */
5758 
5759  /* create child node x <= left */
5760  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_DOWNWARDS, left);
5761 
5762  /* if LP solution is cutoff in child, compute a new estimate
5763  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node
5764  */
5765  if( SCIPsetIsGT(set, lpval, left) )
5766  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, left);
5767  else
5768  estimate = SCIPnodeGetEstimate(tree->focusnode);
5769 
5770  SCIPsetDebugMsg(set, " -> creating child: <%s> <= %g (priority: %g, estimate: %g)\n",
5771  SCIPvarGetName(var), left, priority, estimate);
5772 
5773  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5774  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, NULL,
5775  var, left, SCIP_BOUNDTYPE_UPPER, FALSE) );
5776  /* output branching bound change to visualization file */
5777  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5778 
5779  if( downchild != NULL )
5780  *downchild = node;
5781 
5782  /* create child node with x >= right */
5783  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_UPWARDS, right);
5784 
5785  if( SCIPsetIsLT(set, lpval, right) )
5786  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, right);
5787  else
5788  estimate = SCIPnodeGetEstimate(tree->focusnode);
5789 
5790  SCIPsetDebugMsg(set, " -> creating child: <%s> >= %g (priority: %g, estimate: %g)\n",
5791  SCIPvarGetName(var), right, priority, estimate);
5792 
5793  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5794  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5795  NULL, var, right, SCIP_BOUNDTYPE_LOWER, FALSE) );
5796  /* output branching bound change to visualization file */
5797  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5798 
5799  if( upchild != NULL )
5800  *upchild = node;
5801 
5802  return SCIP_OKAY;
5803 }
5804 
5805 /** n-ary branching on a variable x
5806  * Branches on variable x such that up to n/2 children are created on each side of the usual branching value.
5807  * The branching value is selected as in SCIPtreeBranchVar().
5808  * If n is 2 or the variables local domain is too small for a branching into n pieces, SCIPtreeBranchVar() is called.
5809  * The parameters minwidth and widthfactor determine the domain width of the branching variable in the child nodes.
5810  * If n is odd, one child with domain width 'width' and having the branching value in the middle is created.
5811  * Otherwise, two children with domain width 'width' and being left and right of the branching value are created.
5812  * Next further nodes to the left and right are created, where width is multiplied by widthfactor with increasing distance from the first nodes.
5813  * The initial width is calculated such that n/2 nodes are created to the left and to the right of the branching value.
5814  * If this value is below minwidth, the initial width is set to minwidth, which may result in creating less than n nodes.
5815  *
5816  * Giving a large value for widthfactor results in creating children with small domain when close to the branching value
5817  * and large domain when closer to the current variable bounds. That is, setting widthfactor to a very large value and n to 3
5818  * results in a ternary branching where the branching variable is mostly fixed in the middle child.
5819  * Setting widthfactor to 1.0 results in children where the branching variable always has the same domain width
5820  * (except for one child if the branching value is not in the middle).
5821  */
5823  SCIP_TREE* tree, /**< branch and bound tree */
5824  SCIP_REOPT* reopt, /**< reoptimization data structure */
5825  BMS_BLKMEM* blkmem, /**< block memory */
5826  SCIP_SET* set, /**< global SCIP settings */
5827  SCIP_STAT* stat, /**< problem statistics data */
5828  SCIP_PROB* transprob, /**< transformed problem after presolve */
5829  SCIP_PROB* origprob, /**< original problem */
5830  SCIP_LP* lp, /**< current LP data */
5831  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5832  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5833  SCIP_VAR* var, /**< variable to branch on */
5834  SCIP_Real val, /**< value to branch on or SCIP_INVALID for branching on current LP/pseudo solution.
5835  * A branching value is required for branching on continuous variables */
5836  int n, /**< attempted number of children to be created, must be >= 2 */
5837  SCIP_Real minwidth, /**< minimal domain width in children */
5838  SCIP_Real widthfactor, /**< multiplier for children domain width with increasing distance from val, must be >= 1.0 */
5839  int* nchildren /**< buffer to store number of created children, or NULL */
5840  )
5841 {
5842  SCIP_NODE* node;
5843  SCIP_Real priority;
5844  SCIP_Real estimate;
5845  SCIP_Real lpval;
5846  SCIP_Real width;
5847  SCIP_Bool validval;
5848  SCIP_Real left;
5849  SCIP_Real right;
5850  SCIP_Real bnd;
5851  int i;
5852 
5853  assert(tree != NULL);
5854  assert(set != NULL);
5855  assert(var != NULL);
5856  assert(n >= 2);
5857  assert(minwidth >= 0.0);
5858 
5859  /* if binary branching is requested or we have not enough space for n children, delegate to SCIPtreeBranchVar */
5860  if( n == 2 ||
5861  2.0 * minwidth >= SCIPvarGetUbLocal(var) - SCIPvarGetLbLocal(var) ||
5863  {
5864  SCIP_NODE* downchild;
5865  SCIP_NODE* fixchild;
5866  SCIP_NODE* upchild;
5867 
5868  SCIP_CALL( SCIPtreeBranchVar(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, var, val,
5869  &downchild, &fixchild, &upchild) );
5870 
5871  if( nchildren != NULL )
5872  *nchildren = (downchild != NULL ? 1 : 0) + (fixchild != NULL ? 1 : 0) + (upchild != NULL ? 1 : 0);
5873 
5874  return SCIP_OKAY;
5875  }
5876 
5877  /* store whether a valid value was given for branching */
5878  validval = (val != SCIP_INVALID); /*lint !e777 */
5879 
5880  /* get the corresponding active problem variable
5881  * if branching value is given, then transform it to the value of the active variable */
5882  if( validval )
5883  {
5884  SCIP_Real scalar;
5885  SCIP_Real constant;
5886 
5887  scalar = 1.0;
5888  constant = 0.0;
5889 
5890  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
5891 
5892  if( scalar == 0.0 )
5893  {
5894  SCIPerrorMessage("cannot branch on fixed variable <%s>\n", SCIPvarGetName(var));
5895  return SCIP_INVALIDDATA;
5896  }
5897 
5898  /* we should have givenvariable = scalar * activevariable + constant */
5899  val = (val - constant) / scalar;
5900  }
5901  else
5902  var = SCIPvarGetProbvar(var);
5903 
5905  {
5906  SCIPerrorMessage("cannot branch on fixed or multi-aggregated variable <%s>\n", SCIPvarGetName(var));
5907  SCIPABORT();
5908  return SCIP_INVALIDDATA; /*lint !e527*/
5909  }
5910 
5911  /* ensure, that branching on continuous variables will only be performed when a branching point is given. */
5912  if( SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS && !validval )
5913  {
5914  SCIPerrorMessage("Cannot branch on continuous variables without a given branching value.\n", SCIPvarGetName(var));
5915  SCIPABORT();
5916  return SCIP_INVALIDDATA; /*lint !e527*/
5917  }
5918 
5919  assert(SCIPvarIsActive(var));
5920  assert(SCIPvarGetProbindex(var) >= 0);
5924  assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
5925 
5926  /* get value of variable in current LP or pseudo solution */
5927  lpval = SCIPvarGetSol(var, tree->focusnodehaslp);
5928 
5929  /* if there was no explicit value given for branching, branch on current LP or pseudo solution value */
5930  if( !validval )
5931  {
5932  val = lpval;
5933 
5934  /* avoid branching on infinite values in pseudo solution */
5935  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5936  {
5937  val = SCIPvarGetWorstBoundLocal(var);
5938 
5939  /* if both bounds are infinite, choose zero as branching point */
5940  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5941  {
5942  assert(SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)));
5943  assert(SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)));
5944  val = 0.0;
5945  }
5946  }
5947  }
5948 
5949  assert(SCIPsetIsFeasGE(set, val, SCIPvarGetLbLocal(var)));
5950  assert(SCIPsetIsFeasLE(set, val, SCIPvarGetUbLocal(var)));
5951  assert(SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS ||
5953  (SCIPsetIsLT(set, 2.1*SCIPvarGetLbLocal(var), 2.1*val) && SCIPsetIsLT(set, 2.1*val, 2.1*SCIPvarGetUbLocal(var))) ); /* see comment in SCIPbranchVarVal */
5954 
5955  /* calculate minimal distance of val from bounds */
5956  width = SCIP_REAL_MAX;
5957  if( !SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)) )
5958  {
5959  width = val - SCIPvarGetLbLocal(var);
5960  }
5961  if( !SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)) )
5962  {
5963  width = MIN(width, SCIPvarGetUbLocal(var) - val); /*lint !e666*/
5964  }
5965  /* calculate initial domain width of child nodes
5966  * if we have at least one finite bound, choose width such that we have roughly the same number of nodes left and right of val
5967  */
5968  if( width == SCIP_REAL_MAX ) /*lint !e777*/
5969  {
5970  /* unbounded variable, let's create a child with a small domain */
5971  width = 1.0;
5972  }
5973  else if( widthfactor == 1.0 )
5974  {
5975  /* most domains get same size */
5976  width /= n/2; /*lint !e653*/ /* rounding is ok at this point */
5977  }
5978  else
5979  {
5980  /* width is increased by widthfactor for each child
5981  * if n is even, compute width such that we can create n/2 nodes with width
5982  * width, widthfactor*width, ..., widthfactor^(n/2)*width on each side, i.e.,
5983  * sum(width * widthfactor^(i-1), i = 1..n/2) = min(ub-val, val-lb)
5984  * <-> width * (widthfactor^(n/2) - 1) / (widthfactor - 1) = min(ub-val, val-lb)
5985  *
5986  * if n is odd, compute width such that we can create one middle node with width width
5987  * and n/2 nodes with width widthfactor*width, ..., widthfactor^(n/2)*width on each side, i.e.,
5988  * width/2 + sum(width * widthfactor^i, i = 1..n/2) = min(ub-val, val-lb)
5989  * <-> width * (1/2 + widthfactor * (widthfactor^(n/2) - 1) / (widthfactor - 1) = min(ub-val, val-lb)
5990  */
5991  assert(widthfactor > 1.0);
5992  if( n % 2 == 0 )
5993  width *= (widthfactor - 1.0) / (pow(widthfactor, (SCIP_Real)(n/2)) - 1.0); /*lint !e653*/
5994  else
5995  width /= 0.5 + widthfactor * (pow(widthfactor, (SCIP_Real)(n/2)) - 1.0) / (widthfactor - 1.0); /*lint !e653*/
5996  }
5998  minwidth = MAX(1.0, minwidth);
5999  if( width < minwidth )
6000  width = minwidth;
6001  assert(SCIPsetIsPositive(set, width));
6002 
6003  SCIPsetDebugMsg(set, "%d-ary branching on variable <%s> [%g, %g] around %g, initial width = %g\n",
6004  n, SCIPvarGetName(var), SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var), val, width);
6005 
6006  if( nchildren != NULL )
6007  *nchildren = 0;
6008 
6009  /* initialize upper bound on children left of val and children right of val
6010  * if we are supposed to create an odd number of children, then create a child that has val in the middle of its domain */
6011  if( n % 2 == 1 )
6012  {
6013  left = val - width/2.0;
6014  right = val + width/2.0;
6015  SCIPvarAdjustLb(var, set, &left);
6016  SCIPvarAdjustUb(var, set, &right);
6017 
6018  /* create child node left <= x <= right, if left <= right */
6019  if( left <= right )
6020  {
6021  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_FIXED, val); /* ????????????? how to compute priority for such a child? */
6022  /* if LP solution is cutoff in child, compute a new estimate
6023  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
6024  if( SCIPsetIsLT(set, lpval, left) )
6025  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, left);
6026  else if( SCIPsetIsGT(set, lpval, right) )
6027  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, right);
6028  else
6029  estimate = SCIPnodeGetEstimate(tree->focusnode);
6030 
6031  SCIPsetDebugMsg(set, " -> creating middle child: %g <= <%s> <= %g (priority: %g, estimate: %g, width: %g)\n",
6032  left, SCIPvarGetName(var), right, priority, estimate, right - left);
6033 
6034  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
6035  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
6036  eventqueue, NULL, var, left , SCIP_BOUNDTYPE_LOWER, FALSE) );
6037  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6038  NULL, var, right, SCIP_BOUNDTYPE_UPPER, FALSE) );
6039  /* output branching bound change to visualization file */
6040  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
6041 
6042  if( nchildren != NULL )
6043  ++*nchildren;
6044  }
6045  --n;
6046 
6048  {
6049  /* if it's a discrete variable, we can use left-1 and right+1 as upper and lower bounds for following nodes on the left and right, resp. */
6050  left -= 1.0;
6051  right += 1.0;
6052  }
6053 
6054  width *= widthfactor;
6055  }
6056  else
6057  {
6059  {
6060  left = SCIPsetFloor(set, val);
6061  right = SCIPsetCeil(set, val);
6062  if( right - left < 0.5 )
6063  left -= 1.0;
6064  }
6065  else if( SCIPsetIsZero(set, val) )
6066  {
6067  left = 0.0;
6068  right = 0.0;
6069  }
6070  else
6071  {
6072  left = val;
6073  right = val;
6074  }
6075  }
6076 
6077  assert(n % 2 == 0);
6078  n /= 2;
6079  for( i = 0; i < n; ++i )
6080  {
6081  /* create child node left - width <= x <= left, if left > lb(x) or x is discrete */
6083  {
6084  /* new lower bound should be variables lower bound, if we are in the last round or left - width is very close to lower bound
6085  * otherwise we take left - width
6086  */
6087  if( i == n-1 || SCIPsetIsRelEQ(set, SCIPvarGetLbLocal(var), left - width))
6088  {
6089  bnd = SCIPvarGetLbLocal(var);
6090  }
6091  else
6092  {
6093  bnd = left - width;
6094  SCIPvarAdjustLb(var, set, &bnd);
6095  bnd = MAX(SCIPvarGetLbLocal(var), bnd); /*lint !e666*/
6096  }
6097  assert(SCIPsetIsRelLT(set, bnd, left));
6098 
6099  /* the nodeselection priority of nodes is decreased as more as they are away from val */
6100  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_DOWNWARDS, bnd) / (i+1);
6101  /* if LP solution is cutoff in child, compute a new estimate
6102  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
6103  if( SCIPsetIsLT(set, lpval, bnd) )
6104  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, bnd);
6105  else if( SCIPsetIsGT(set, lpval, left) )
6106  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, left);
6107  else
6108  estimate = SCIPnodeGetEstimate(tree->focusnode);
6109 
6110  SCIPsetDebugMsg(set, " -> creating left child: %g <= <%s> <= %g (priority: %g, estimate: %g, width: %g)\n",
6111  bnd, SCIPvarGetName(var), left, priority, estimate, left - bnd);
6112 
6113  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
6114  if( SCIPsetIsGT(set, bnd, SCIPvarGetLbLocal(var)) )
6115  {
6116  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6117  NULL, var, bnd, SCIP_BOUNDTYPE_LOWER, FALSE) );
6118  }
6119  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6120  NULL, var, left, SCIP_BOUNDTYPE_UPPER, FALSE) );
6121  /* output branching bound change to visualization file */
6122  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
6123 
6124  if( nchildren != NULL )
6125  ++*nchildren;
6126 
6127  left = bnd;
6129  left -= 1.0;
6130  }
6131 
6132  /* create child node right <= x <= right + width, if right < ub(x) */
6133  if( SCIPsetIsRelGT(set, SCIPvarGetUbLocal(var), right) || SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS )
6134  {
6135  /* new upper bound should be variables upper bound, if we are in the last round or right + width is very close to upper bound
6136  * otherwise we take right + width
6137  */
6138  if( i == n-1 || SCIPsetIsRelEQ(set, SCIPvarGetUbLocal(var), right + width))
6139  {
6140  bnd = SCIPvarGetUbLocal(var);
6141  }
6142  else
6143  {
6144  bnd = right + width;
6145  SCIPvarAdjustUb(var, set, &bnd);
6146  bnd = MIN(SCIPvarGetUbLocal(var), bnd); /*lint !e666*/
6147  }
6148  assert(SCIPsetIsRelGT(set, bnd, right));
6149 
6150  /* the nodeselection priority of nodes is decreased as more as they are away from val */
6151  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_UPWARDS, bnd) / (i+1);
6152  /* if LP solution is cutoff in child, compute a new estimate
6153  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
6154  if( SCIPsetIsLT(set, lpval, right) )
6155  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, right);
6156  else if( SCIPsetIsGT(set, lpval, bnd) )
6157  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, bnd);
6158  else
6159  estimate = SCIPnodeGetEstimate(tree->focusnode);
6160 
6161  SCIPsetDebugMsg(set, " -> creating right child: %g <= <%s> <= %g (priority: %g, estimate: %g, width: %g)\n",
6162  right, SCIPvarGetName(var), bnd, priority, estimate, bnd - right);
6163 
6164  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
6165  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6166  NULL, var, right, SCIP_BOUNDTYPE_LOWER, FALSE) );
6167  if( SCIPsetIsLT(set, bnd, SCIPvarGetUbLocal(var)) )
6168  {
6169  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6170  NULL, var, bnd, SCIP_BOUNDTYPE_UPPER, FALSE) );
6171  }
6172  /* output branching bound change to visualization file */
6173  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
6174 
6175  if( nchildren != NULL )
6176  ++*nchildren;
6177 
6178  right = bnd;
6180  right += 1.0;
6181  }
6182 
6183  width *= widthfactor;
6184  }
6185 
6186  return SCIP_OKAY;
6187 }
6188 
6189 /** adds a diving bound change to the tree together with the information if this is a bound change
6190  * for the preferred direction or not
6191  */
6192 #define ARRAYGROWTH 5
6194  SCIP_TREE* tree, /**< branch and bound tree */
6195  BMS_BLKMEM* blkmem, /**< block memory buffers */
6196  SCIP_VAR* var, /**< variable to apply the bound change to */
6197  SCIP_BRANCHDIR dir, /**< direction of the bound change */
6198  SCIP_Real value, /**< value to adjust this variable bound to */
6199  SCIP_Bool preferred /**< is this a bound change for the preferred child? */
6200  )
6201 {
6202  int idx = preferred ? 0 : 1;
6203  int pos = tree->ndivebdchanges[idx];
6204 
6205  assert(pos < tree->divebdchgsize[idx]);
6206 
6207  if( pos == tree->divebdchgsize[idx] - 1 )
6208  {
6209  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tree->divebdchgdirs[idx], tree->divebdchgsize[idx], tree->divebdchgsize[idx] + ARRAYGROWTH) ); /*lint !e866*/
6210  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tree->divebdchgvars[idx], tree->divebdchgsize[idx], tree->divebdchgsize[idx] + ARRAYGROWTH) ); /*lint !e866*/
6211  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tree->divebdchgvals[idx], tree->divebdchgsize[idx], tree->divebdchgsize[idx] + ARRAYGROWTH) ); /*lint !e866*/
6212  tree->divebdchgsize[idx] += ARRAYGROWTH;
6213  }
6214 
6215  tree->divebdchgvars[idx][pos] = var;
6216  tree->divebdchgdirs[idx][pos] = dir;
6217  tree->divebdchgvals[idx][pos] = value;
6218 
6219  ++tree->ndivebdchanges[idx];
6220 
6221  return SCIP_OKAY;
6222 }
6223 
6224 /** get the dive bound change data for the preferred or the alternative direction */
6226  SCIP_TREE* tree, /**< branch and bound tree */
6227  SCIP_VAR*** variables, /**< pointer to store variables for the specified direction */
6228  SCIP_BRANCHDIR** directions, /**< pointer to store the branching directions */
6229  SCIP_Real** values, /**< pointer to store bound change values */
6230  int* ndivebdchgs, /**< pointer to store the number of dive bound changes */
6231  SCIP_Bool preferred /**< should the dive bound changes for the preferred child be output? */
6232  )
6233 {
6234  int idx = preferred ? 0 : 1;
6235 
6236  assert(variables != NULL);
6237  assert(directions != NULL);
6238  assert(values != NULL);
6239  assert(ndivebdchgs != NULL);
6240 
6241  *variables = tree->divebdchgvars[idx];
6242  *directions = tree->divebdchgdirs[idx];
6243  *values = tree->divebdchgvals[idx];
6244  *ndivebdchgs = tree->ndivebdchanges[idx];
6245 }
6246 
6247 /** clear the tree bound change data structure */
6249  SCIP_TREE* tree /**< branch and bound tree */
6250  )
6251 {
6252  int p;
6253 
6254  for( p = 0; p < 2; ++p )
6255  tree->ndivebdchanges[p] = 0;
6256 }
6257 
6258 /** creates a probing child node of the current node, which must be the focus node, the current refocused node,
6259  * or another probing node; if the current node is the focus or a refocused node, the created probing node is
6260  * installed as probing root node
6261  */
6262 static
6264  SCIP_TREE* tree, /**< branch and bound tree */
6265  BMS_BLKMEM* blkmem, /**< block memory */
6266  SCIP_SET* set, /**< global SCIP settings */
6267  SCIP_LP* lp /**< current LP data */
6268  )
6269 {
6270  SCIP_NODE* currentnode;
6271  SCIP_NODE* node;
6272  SCIP_RETCODE retcode;
6273 
6274  assert(tree != NULL);
6275  assert(SCIPtreeIsPathComplete(tree));
6276  assert(tree->pathlen > 0);
6277  assert(blkmem != NULL);
6278  assert(set != NULL);
6279 
6280  /* get the current node */
6281  currentnode = SCIPtreeGetCurrentNode(tree);
6282  assert(SCIPnodeGetType(currentnode) == SCIP_NODETYPE_FOCUSNODE
6283  || SCIPnodeGetType(currentnode) == SCIP_NODETYPE_REFOCUSNODE
6284  || SCIPnodeGetType(currentnode) == SCIP_NODETYPE_PROBINGNODE);
6285  assert((SCIPnodeGetType(currentnode) == SCIP_NODETYPE_PROBINGNODE) == SCIPtreeProbing(tree));
6286 
6287  /* create the node data structure */
6288  SCIP_CALL( nodeCreate(&node, blkmem, set) );
6289  assert(node != NULL);
6290 
6291  /* mark node to be a probing node */
6292  node->nodetype = SCIP_NODETYPE_PROBINGNODE; /*lint !e641*/
6293 
6294  /* create the probingnode data */
6295  SCIP_CALL( probingnodeCreate(&node->data.probingnode, blkmem, lp) );
6296 
6297  /* make the current node the parent of the new probing node */
6298  retcode = nodeAssignParent(node, blkmem, set, tree, currentnode, 0.0);
6299 
6300  /* if we reached the maximal depth level we clean up the allocated memory and stop */
6301  if( retcode == SCIP_MAXDEPTHLEVEL )
6302  {
6303  SCIP_CALL( probingnodeFree(&(node->data.probingnode), blkmem, lp) );
6304  BMSfreeBlockMemory(blkmem, &node);
6305  }
6306  SCIP_CALL( retcode );
6307  assert(SCIPnodeGetDepth(node) == tree->pathlen);
6308 
6309  /* check, if the node is the probing root node */
6310  if( tree->probingroot == NULL )
6311  {
6312  tree->probingroot = node;
6313  SCIPsetDebugMsg(set, "created probing root node #%" SCIP_LONGINT_FORMAT " at depth %d\n",
6314  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node));
6315  }
6316  else
6317  {
6319  assert(SCIPnodeGetDepth(tree->probingroot) < SCIPnodeGetDepth(node));
6320 
6321  SCIPsetDebugMsg(set, "created probing child node #%" SCIP_LONGINT_FORMAT " at depth %d, probing depth %d\n",
6323  }
6324 
6325  /* create the new active path */
6326  SCIP_CALL( treeEnsurePathMem(tree, set, tree->pathlen+1) );
6327  node->active = TRUE;
6328  tree->path[tree->pathlen] = node;
6329  tree->pathlen++;
6330 
6331  /* update the path LP size for the previous node and set the (initial) path LP size for the newly created node */
6332  SCIP_CALL( treeUpdatePathLPSize(tree, tree->pathlen-2) );
6333 
6334  /* mark the LP's size */
6335  SCIPlpMarkSize(lp);
6336  assert(tree->pathlen >= 2);
6337  assert(lp->firstnewrow == tree->pathnlprows[tree->pathlen-1]); /* marked LP size should be initial size of new node */
6338  assert(lp->firstnewcol == tree->pathnlpcols[tree->pathlen-1]);
6339 
6340  /* the current probing node does not yet have a solved LP */
6341  tree->probingnodehaslp = FALSE;
6342 
6343  return SCIP_OKAY;
6344 }
6345 
6346 /** switches to probing mode and creates a probing root */
6348  SCIP_TREE* tree, /**< branch and bound tree */
6349  BMS_BLKMEM* blkmem, /**< block memory */
6350  SCIP_SET* set, /**< global SCIP settings */
6351  SCIP_LP* lp, /**< current LP data */
6352  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6353  SCIP_PROB* transprob, /**< transformed problem after presolve */
6354  SCIP_Bool strongbranching /**< is the probing mode used for strongbranching? */
6355  )
6356 {
6357  assert(tree != NULL);
6358  assert(tree->probinglpistate == NULL);
6359  assert(tree->probinglpinorms == NULL);
6360  assert(!SCIPtreeProbing(tree));
6361  assert(lp != NULL);
6362 
6363  SCIPsetDebugMsg(set, "probing started in depth %d (LP flushed: %u, LP solved: %u, solstat: %d), probing root in depth %d\n",
6364  tree->pathlen-1, lp->flushed, lp->solved, SCIPlpGetSolstat(lp), tree->pathlen);
6365 
6366  /* store all marked constraints for propagation */
6367  SCIP_CALL( SCIPconshdlrsStorePropagationStatus(set, set->conshdlrs, set->nconshdlrs) );
6368 
6369  /* inform LP about probing mode */
6371 
6372  assert(!lp->divingobjchg);
6373 
6374  /* remember, whether the LP was flushed and solved */
6375  tree->probinglpwasflushed = lp->flushed;
6376  tree->probinglpwassolved = lp->solved;
6377  tree->probingloadlpistate = FALSE;
6378  tree->probinglpwasrelax = lp->isrelax;
6379  lp->isrelax = TRUE;
6380  tree->probingsolvedlp = FALSE;
6381  tree->probingobjchanged = FALSE;
6382  lp->divingobjchg = FALSE;
6383  tree->probingsumchgdobjs = 0;
6384  tree->sbprobing = strongbranching;
6385 
6386  /* remember the LP state in order to restore the LP solution quickly after probing */
6387  /**@todo could the lp state be worth storing if the LP is not flushed (and hence not solved)? */
6388  if( lp->flushed && lp->solved )
6389  {
6390  SCIP_CALL( SCIPlpGetState(lp, blkmem, &tree->probinglpistate) );
6391  SCIP_CALL( SCIPlpGetNorms(lp, blkmem, &tree->probinglpinorms) );
6394  tree->probinglpwasdualfeas = lp->dualfeasible;
6396  }
6397 
6398  /* remember the relaxation solution to reset it later */
6399  if( SCIPrelaxationIsSolValid(relaxation) )
6400  {
6401  SCIP_CALL( SCIPtreeStoreRelaxSol(tree, set, relaxation, transprob) );
6402  }
6403 
6404  /* create temporary probing root node */
6405  SCIP_CALL( treeCreateProbingNode(tree, blkmem, set, lp) );
6406  assert(SCIPtreeProbing(tree));
6407 
6408  return SCIP_OKAY;
6409 }
6410 
6411 /** creates a new probing child node in the probing path */
6413  SCIP_TREE* tree, /**< branch and bound tree */
6414  BMS_BLKMEM* blkmem, /**< block memory */
6415  SCIP_SET* set, /**< global SCIP settings */
6416  SCIP_LP* lp /**< current LP data */
6417  )
6418 {
6419  assert(SCIPtreeProbing(tree));
6420 
6421  SCIPsetDebugMsg(set, "new probing child in depth %d (probing depth: %d)\n", tree->pathlen, tree->pathlen-1 - SCIPnodeGetDepth(tree->probingroot));
6422 
6423  /* create temporary probing root node */
6424  SCIP_CALL( treeCreateProbingNode(tree, blkmem, set, lp) );
6425 
6426  return SCIP_OKAY;
6427 }
6428 
6429 /** sets the LP state for the current probing node
6430  *
6431  * @note state and norms are stored at the node and later released by SCIP; therefore, the pointers are set
6432  * to NULL by the method
6433  *
6434  * @note the pointers to state and norms must not be NULL; however, they may point to a NULL pointer if the
6435  * respective information should not be set
6436  */
6438  SCIP_TREE* tree, /**< branch and bound tree */
6439  BMS_BLKMEM* blkmem, /**< block memory */
6440  SCIP_LP* lp, /**< current LP data */
6441  SCIP_LPISTATE** lpistate, /**< pointer to LP state information (like basis information) */
6442  SCIP_LPINORMS** lpinorms, /**< pointer to LP pricing norms information */
6443  SCIP_Bool primalfeas, /**< primal feasibility when LP state information was stored */
6444  SCIP_Bool dualfeas /**< dual feasibility when LP state information was stored */
6445  )
6446 {
6447  SCIP_NODE* node;
6448 
6449  assert(tree != NULL);
6450  assert(SCIPtreeProbing(tree));
6451  assert(lpistate != NULL);
6452  assert(lpinorms != NULL);
6453 
6454  /* get the current probing node */
6455  node = SCIPtreeGetCurrentNode(tree);
6456 
6457  /* this check is necessary to avoid cppcheck warnings */
6458  if( node == NULL )
6459  return SCIP_INVALIDDATA;
6460 
6461  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6462  assert(node->data.probingnode != NULL);
6463 
6464  /* free already present LP state */
6465  if( node->data.probingnode->lpistate != NULL )
6466  {
6467  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &(node->data.probingnode->lpistate)) );
6468  }
6469 
6470  /* free already present LP pricing norms */
6471  if( node->data.probingnode->lpinorms != NULL )
6472  {
6473  SCIP_CALL( SCIPlpFreeNorms(lp, blkmem, &(node->data.probingnode->lpinorms)) );
6474  }
6475 
6476  node->data.probingnode->lpistate = *lpistate;
6477  node->data.probingnode->lpinorms = *lpinorms;
6478  node->data.probingnode->lpwasprimfeas = primalfeas;
6479  node->data.probingnode->lpwasdualfeas = dualfeas;
6480 
6481  /* set the pointers to NULL to avoid that they are still used and modified by the caller */
6482  *lpistate = NULL;
6483  *lpinorms = NULL;
6484 
6485  tree->probingloadlpistate = TRUE;
6486 
6487  return SCIP_OKAY;
6488 }
6489 
6490 /** loads the LP state for the current probing node */
6492  SCIP_TREE* tree, /**< branch and bound tree */
6493  BMS_BLKMEM* blkmem, /**< block memory buffers */
6494  SCIP_SET* set, /**< global SCIP settings */
6495  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6496  SCIP_LP* lp /**< current LP data */
6497  )
6498 {
6499  assert(tree != NULL);
6500  assert(SCIPtreeProbing(tree));
6501 
6502  /* loading the LP state is only necessary if we backtracked */
6503  if( tree->probingloadlpistate )
6504  {
6505  SCIP_NODE* node;
6506  SCIP_LPISTATE* lpistate;
6507  SCIP_LPINORMS* lpinorms;
6508  SCIP_Bool lpwasprimfeas = FALSE;
6509  SCIP_Bool lpwasprimchecked = FALSE;
6510  SCIP_Bool lpwasdualfeas = FALSE;
6511  SCIP_Bool lpwasdualchecked = FALSE;
6512 
6513  /* get the current probing node */
6514  node = SCIPtreeGetCurrentNode(tree);
6515  assert(node != NULL);
6516  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6517 
6518  /* search the last node where an LP state information was attached */
6519  lpistate = NULL;
6520  lpinorms = NULL;
6521  do
6522  {
6523  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6524  assert(node->data.probingnode != NULL);
6525  if( node->data.probingnode->lpistate != NULL )
6526  {
6527  lpistate = node->data.probingnode->lpistate;
6528  lpinorms = node->data.probingnode->lpinorms;
6529  lpwasprimfeas = node->data.probingnode->lpwasprimfeas;
6530  lpwasprimchecked = node->data.probingnode->lpwasprimchecked;
6531  lpwasdualfeas = node->data.probingnode->lpwasdualfeas;
6532  lpwasdualchecked = node->data.probingnode->lpwasdualchecked;
6533  break;
6534  }
6535  node = node->parent;
6536  assert(node != NULL); /* the root node cannot be a probing node! */
6537  }
6538  while( SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE );
6539 
6540  /* if there was no LP information stored in the probing nodes, use the one stored before probing started */
6541  if( lpistate == NULL )
6542  {
6543  lpistate = tree->probinglpistate;
6544  lpinorms = tree->probinglpinorms;
6545  lpwasprimfeas = tree->probinglpwasprimfeas;
6546  lpwasprimchecked = tree->probinglpwasprimchecked;
6547  lpwasdualfeas = tree->probinglpwasdualfeas;
6548  lpwasdualchecked = tree->probinglpwasdualchecked;
6549  }
6550 
6551  /* set the LP state */
6552  if( lpistate != NULL )
6553  {
6554  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, lpistate,
6555  lpwasprimfeas, lpwasprimchecked, lpwasdualfeas, lpwasdualchecked) );
6556  }
6557 
6558  /* set the LP pricing norms */
6559  if( lpinorms != NULL )
6560  {
6561  SCIP_CALL( SCIPlpSetNorms(lp, blkmem, lpinorms) );
6562  }
6563 
6564  /* now we don't need to load the LP state again until the next backtracking */
6565  tree->probingloadlpistate = FALSE;
6566  }
6567 
6568  return SCIP_OKAY;
6569 }
6570 
6571 /** marks the probing node to have a solved LP relaxation */
6573  SCIP_TREE* tree, /**< branch and bound tree */
6574  BMS_BLKMEM* blkmem, /**< block memory */
6575  SCIP_LP* lp /**< current LP data */
6576  )
6577 {
6578  SCIP_NODE* node;
6579 
6580  assert(tree != NULL);
6581  assert(SCIPtreeProbing(tree));
6582 
6583  /* mark the probing node to have an LP */
6584  tree->probingnodehaslp = TRUE;
6585 
6586  /* get current probing node */
6587  node = SCIPtreeGetCurrentNode(tree);
6588  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6589  assert(node != NULL && node->data.probingnode != NULL);
6590 
6591  /* update LP information in probingnode data */
6592  /* cppcheck-suppress nullPointer */
6593  SCIP_CALL( probingnodeUpdate(node->data.probingnode, blkmem, tree, lp) );
6594 
6595  return SCIP_OKAY;
6596 }
6597 
6598 /** undoes all changes to the problem applied in probing up to the given probing depth */
6599 static
6601  SCIP_TREE* tree, /**< branch and bound tree */
6602  SCIP_REOPT* reopt, /**< reoptimization data structure */
6603  BMS_BLKMEM* blkmem, /**< block memory buffers */
6604  SCIP_SET* set, /**< global SCIP settings */
6605  SCIP_STAT* stat, /**< problem statistics */
6606  SCIP_PROB* transprob, /**< transformed problem after presolve */
6607  SCIP_PROB* origprob, /**< original problem */
6608  SCIP_LP* lp, /**< current LP data */
6609  SCIP_PRIMAL* primal, /**< primal data structure */
6610  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6611  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6612  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
6613  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
6614  int probingdepth /**< probing depth of the node in the probing path that should be reactivated,
6615  * -1 to even deactivate the probing root, thus exiting probing mode */
6616  )
6617 {
6618  int newpathlen;
6619  int i;
6620 
6621  assert(tree != NULL);
6622  assert(SCIPtreeProbing(tree));
6623  assert(tree->probingroot != NULL);
6624  assert(tree->focusnode != NULL);
6628  assert(tree->probingroot->parent == tree->focusnode);
6629  assert(SCIPnodeGetDepth(tree->probingroot) == SCIPnodeGetDepth(tree->focusnode)+1);
6630  assert(tree->pathlen >= 2);
6631  assert(SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_PROBINGNODE);
6632  assert(-1 <= probingdepth && probingdepth <= SCIPtreeGetProbingDepth(tree));
6633 
6634  treeCheckPath(tree);
6635 
6636  newpathlen = SCIPnodeGetDepth(tree->probingroot) + probingdepth + 1;
6637  assert(newpathlen >= 1); /* at least root node of the tree remains active */
6638 
6639  /* check if we have to do any backtracking */
6640  if( newpathlen < tree->pathlen )
6641  {
6642  int ncols;
6643  int nrows;
6644 
6645  /* the correct LP size of the node to which we backtracked is stored as initial LP size for its child */
6646  assert(SCIPnodeGetType(tree->path[newpathlen]) == SCIP_NODETYPE_PROBINGNODE);
6647  ncols = tree->path[newpathlen]->data.probingnode->ninitialcols;
6648  nrows = tree->path[newpathlen]->data.probingnode->ninitialrows;
6649  assert(ncols >= tree->pathnlpcols[newpathlen-1] || !tree->focuslpconstructed);
6650  assert(nrows >= tree->pathnlprows[newpathlen-1] || !tree->focuslpconstructed);
6651 
6652  while( tree->pathlen > newpathlen )
6653  {
6654  SCIP_NODE* node;
6655 
6656  node = tree->path[tree->pathlen-1];
6657 
6658  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6659  assert(tree->pathlen-1 == SCIPnodeGetDepth(node));
6660  assert(tree->pathlen-1 >= SCIPnodeGetDepth(tree->probingroot));
6661 
6662  if( node->data.probingnode->nchgdobjs > 0 )
6663  {
6664  /* @todo only do this if we don't backtrack to the root node - in that case, we can just restore the unchanged
6665  * objective values
6666  */
6667  for( i = node->data.probingnode->nchgdobjs - 1; i >= 0; --i )
6668  {
6669  assert(tree->probingobjchanged);
6670 
6671  SCIP_CALL( SCIPvarChgObj(node->data.probingnode->origobjvars[i], blkmem, set, transprob, primal, lp,
6672  eventqueue, node->data.probingnode->origobjvals[i]) );
6673  }
6674  tree->probingsumchgdobjs -= node->data.probingnode->nchgdobjs;
6675  assert(tree->probingsumchgdobjs >= 0);
6676 
6677  /* reset probingobjchanged flag and cutoff bound */
6678  if( tree->probingsumchgdobjs == 0 )
6679  {
6681  tree->probingobjchanged = FALSE;
6682 
6683  SCIP_CALL( SCIPlpSetCutoffbound(lp, set, transprob, primal->cutoffbound) );
6684  }
6685 
6686  /* recompute global and local pseudo objective values */
6687  SCIPlpRecomputeLocalAndGlobalPseudoObjval(lp, set, transprob);
6688  }
6689 
6690  /* undo bound changes by deactivating the probing node */
6691  SCIP_CALL( nodeDeactivate(node, blkmem, set, stat, tree, lp, branchcand, eventqueue) );
6692 
6693  /* free the probing node */
6694  SCIP_CALL( SCIPnodeFree(&tree->path[tree->pathlen-1], blkmem, set, stat, eventqueue, tree, lp) );
6695  tree->pathlen--;
6696  }
6697  assert(tree->pathlen == newpathlen);
6698 
6699  /* reset the path LP size to the initial size of the probing node */
6700  if( SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_PROBINGNODE )
6701  {
6702  tree->pathnlpcols[tree->pathlen-1] = tree->path[tree->pathlen-1]->data.probingnode->ninitialcols;
6703  tree->pathnlprows[tree->pathlen-1] = tree->path[tree->pathlen-1]->data.probingnode->ninitialrows;
6704  }
6705  else
6706  assert(SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_FOCUSNODE);
6707  treeCheckPath(tree);
6708 
6709  /* undo LP extensions */
6710  SCIP_CALL( SCIPlpShrinkCols(lp, set, ncols) );
6711  SCIP_CALL( SCIPlpShrinkRows(lp, blkmem, set, eventqueue, eventfilter, nrows) );
6712  tree->probingloadlpistate = TRUE; /* LP state must be reloaded if the next LP is solved */
6713 
6714  /* reset the LP's marked size to the initial size of the LP at the node stored in the path */
6715  assert(lp->nrows >= tree->pathnlprows[tree->pathlen-1] || !tree->focuslpconstructed);
6716  assert(lp->ncols >= tree->pathnlpcols[tree->pathlen-1] || !tree->focuslpconstructed);
6717  SCIPlpSetSizeMark(lp, tree->pathnlprows[tree->pathlen-1], tree->pathnlpcols[tree->pathlen-1]);
6718 
6719  /* if the highest cutoff or repropagation depth is inside the deleted part of the probing path,
6720  * reset them to infinity
6721  */
6722  if( tree->cutoffdepth >= tree->pathlen )
6723  {
6724  /* apply the pending bound changes */
6725  SCIP_CALL( treeApplyPendingBdchgs(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, cliquetable) );
6726 
6727  /* applying the pending bound changes might have changed the cutoff depth; so the highest cutoff depth might
6728  * be outside of the deleted part of the probing path now
6729  */
6730  if( tree->cutoffdepth >= tree->pathlen )
6731  tree->cutoffdepth = INT_MAX;
6732  }
6733  if( tree->repropdepth >= tree->pathlen )
6734  tree->repropdepth = INT_MAX;
6735  }
6736 
6737  SCIPsetDebugMsg(set, "probing backtracked to depth %d (%d cols, %d rows)\n", tree->pathlen-1, SCIPlpGetNCols(lp), SCIPlpGetNRows(lp));
6738 
6739  return SCIP_OKAY;
6740 }
6741 
6742 /** undoes all changes to the problem applied in probing up to the given probing depth;
6743  * the changes of the probing node of the given probing depth are the last ones that remain active;
6744  * changes that were applied before calling SCIPtreeCreateProbingNode() cannot be undone
6745  */
6747  SCIP_TREE* tree, /**< branch and bound tree */
6748  SCIP_REOPT* reopt, /**< reoptimization data structure */
6749  BMS_BLKMEM* blkmem, /**< block memory buffers */
6750  SCIP_SET* set, /**< global SCIP settings */
6751  SCIP_STAT* stat, /**< problem statistics */
6752  SCIP_PROB* transprob, /**< transformed problem */
6753  SCIP_PROB* origprob, /**< original problem */
6754  SCIP_LP* lp, /**< current LP data */
6755  SCIP_PRIMAL* primal, /**< primal data structure */
6756  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6757  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6758  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
6759  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
6760  int probingdepth /**< probing depth of the node in the probing path that should be reactivated */
6761  )
6762 {
6763  assert(tree != NULL);
6764  assert(SCIPtreeProbing(tree));
6765  assert(0 <= probingdepth && probingdepth <= SCIPtreeGetProbingDepth(tree));
6766 
6767  /* undo the domain and constraint set changes and free the temporary probing nodes below the given probing depth */
6768  SCIP_CALL( treeBacktrackProbing(tree, reopt, blkmem, set, stat, transprob, origprob, lp, primal, branchcand,
6769  eventqueue, eventfilter, cliquetable, probingdepth) );
6770 
6771  assert(SCIPtreeProbing(tree));
6773 
6774  return SCIP_OKAY;
6775 }
6776 
6777 /** switches back from probing to normal operation mode, frees all nodes on the probing path, restores bounds of all
6778  * variables and restores active constraints arrays of focus node
6779  */
6781  SCIP_TREE* tree, /**< branch and bound tree */
6782  SCIP_REOPT* reopt, /**< reoptimization data structure */
6783  BMS_BLKMEM* blkmem, /**< block memory buffers */
6784  SCIP_SET* set, /**< global SCIP settings */
6785  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
6786  SCIP_STAT* stat, /**< problem statistics */
6787  SCIP_PROB* transprob, /**< transformed problem after presolve */
6788  SCIP_PROB* origprob, /**< original problem */
6789  SCIP_LP* lp, /**< current LP data */
6790  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6791  SCIP_PRIMAL* primal, /**< Primal LP data */
6792  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6793  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6794  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
6795  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
6796  )
6797 {
6798  assert(tree != NULL);
6799  assert(SCIPtreeProbing(tree));
6800  assert(tree->probingroot != NULL);
6801  assert(tree->focusnode != NULL);
6805  assert(tree->probingroot->parent == tree->focusnode);
6806  assert(SCIPnodeGetDepth(tree->probingroot) == SCIPnodeGetDepth(tree->focusnode)+1);
6807  assert(tree->pathlen >= 2);
6808  assert(SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_PROBINGNODE);
6809  assert(set != NULL);
6810 
6811  /* undo the domain and constraint set changes of the temporary probing nodes and free the probing nodes */
6812  SCIP_CALL( treeBacktrackProbing(tree, reopt, blkmem, set, stat, transprob, origprob, lp, primal, branchcand,
6813  eventqueue, eventfilter, cliquetable, -1) );
6814  assert(tree->probingsumchgdobjs == 0);
6815  assert(!tree->probingobjchanged);
6816  assert(!lp->divingobjchg);
6817  assert(lp->cutoffbound == primal->cutoffbound); /*lint !e777*/
6818  assert(SCIPtreeGetCurrentNode(tree) == tree->focusnode);
6819  assert(!SCIPtreeProbing(tree));
6820 
6821  /* if the LP was flushed before probing starts, flush it again */
6822  if( tree->probinglpwasflushed )
6823  {
6824  SCIP_CALL( SCIPlpFlush(lp, blkmem, set, eventqueue) );
6825 
6826  /* if the LP was solved before probing starts, solve it again to restore the LP solution */
6827  if( tree->probinglpwassolved )
6828  {
6829  SCIP_Bool lperror;
6830 
6831  /* reset the LP state before probing started */
6832  if( tree->probinglpistate == NULL )
6833  {
6834  assert(tree->probinglpinorms == NULL);
6836  lp->primalfeasible = (lp->nlpicols == 0 && lp->nlpirows == 0);
6837  lp->primalchecked = (lp->nlpicols == 0 && lp->nlpirows == 0);
6838  lp->dualfeasible = (lp->nlpicols == 0 && lp->nlpirows == 0);
6839  lp->dualchecked = (lp->nlpicols == 0 && lp->nlpirows == 0);
6840  lp->solisbasic = FALSE;
6841  }
6842  else
6843  {
6844  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, tree->probinglpistate,
6846  tree->probinglpwasdualchecked) );
6847  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &tree->probinglpistate) );
6848 
6849  if( tree->probinglpinorms != NULL )
6850  {
6851  SCIP_CALL( SCIPlpSetNorms(lp, blkmem, tree->probinglpinorms) );
6852  SCIP_CALL( SCIPlpFreeNorms(lp, blkmem, &tree->probinglpinorms) );
6853  tree->probinglpinorms = NULL;
6854  }
6855  }
6857 
6858  /* resolve LP to reset solution */
6859  SCIP_CALL( SCIPlpSolveAndEval(lp, set, messagehdlr, blkmem, stat, eventqueue, eventfilter, transprob, -1LL, FALSE, FALSE, FALSE, &lperror) );
6860  if( lperror )
6861  {
6862  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
6863  "(node %" SCIP_LONGINT_FORMAT ") unresolved numerical troubles while resolving LP %" SCIP_LONGINT_FORMAT " after probing\n",
6864  stat->nnodes, stat->nlps);
6865  lp->resolvelperror = TRUE;
6866  tree->focusnodehaslp = FALSE;
6867  }
6868  else if( SCIPlpGetSolstat(lp) != SCIP_LPSOLSTAT_OPTIMAL
6872  {
6873  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
6874  "LP was not resolved to a sufficient status after probing\n");
6875  lp->resolvelperror = TRUE;
6876  tree->focusnodehaslp = FALSE;
6877  }
6878  else if( tree->focuslpconstructed && SCIPlpIsRelax(lp) && SCIPprobAllColsInLP(transprob, set, lp))
6879  {
6880  SCIP_CALL( SCIPnodeUpdateLowerboundLP(tree->focusnode, set, stat, tree, transprob, origprob, lp) );
6881  }
6882  }
6883  }
6884  else
6885  lp->flushed = FALSE;
6886 
6887  assert(tree->probinglpistate == NULL);
6888 
6889  /* if no LP was solved during probing and the LP before probing was not solved, then it should not be solved now */
6890  assert(tree->probingsolvedlp || tree->probinglpwassolved || !lp->solved);
6891 
6892  /* if the LP was solved (and hence flushed) before probing, then lp->solved should be TRUE unless we occured an error
6893  * during resolving right above
6894  */
6895  assert(!tree->probinglpwassolved || !tree->probinglpwasflushed || lp->solved || lp->resolvelperror);
6896 
6897  /* if the LP was not solved before probing it should be marked unsolved now; this can occur if a probing LP was
6898  * solved in between
6899  */
6900  if( !tree->probinglpwassolved )
6901  {
6902  lp->solved = FALSE;
6904  }
6905 
6906  /* if the LP was solved during probing, but had been unsolved before probing started, we discard the LP state */
6907  if( set->lp_clearinitialprobinglp && tree->probingsolvedlp && !tree->probinglpwassolved )
6908  {
6909  SCIPsetDebugMsg(set, "clearing lp state at end of probing mode because LP was initially unsolved\n");
6911  }
6912 
6913  /* if a relaxation was stored before probing, restore it now */
6914  if( tree->probdiverelaxstored )
6915  {
6916  SCIP_CALL( SCIPtreeRestoreRelaxSol(tree, set, relaxation, transprob) );
6917  }
6918 
6919  assert(tree->probingobjchanged == SCIPlpDivingObjChanged(lp));
6920 
6921  /* reset flags */
6922  tree->probinglpwasflushed = FALSE;
6923  tree->probinglpwassolved = FALSE;
6924  tree->probingloadlpistate = FALSE;
6925  tree->probinglpwasrelax = FALSE;
6926  tree->probingsolvedlp = FALSE;
6927  tree->sbprobing = FALSE;
6928 
6929  /* inform LP about end of probing mode */
6930  SCIP_CALL( SCIPlpEndProbing(lp) );
6931 
6932  /* reset all marked constraints for propagation */
6933  SCIP_CALL( SCIPconshdlrsResetPropagationStatus(set, blkmem, set->conshdlrs, set->nconshdlrs) );
6934 
6935  SCIPsetDebugMsg(set, "probing ended in depth %d (LP flushed: %u, solstat: %d)\n", tree->pathlen-1, lp->flushed, SCIPlpGetSolstat(lp));
6936 
6937  return SCIP_OKAY;
6938 }
6939 
6940 /** stores relaxation solution before diving or probing */
6942  SCIP_TREE* tree, /**< branch and bound tree */
6943  SCIP_SET* set, /**< global SCIP settings */
6944  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6945  SCIP_PROB* transprob /**< transformed problem after presolve */
6946  )
6947 {
6948  SCIP_VAR** vars;
6949  int nvars;
6950  int v;
6951 
6952  assert(tree != NULL);
6953  assert(set != NULL);
6954  assert(relaxation != NULL);
6955  assert(transprob != NULL);
6956  assert(SCIPrelaxationIsSolValid(relaxation));
6957 
6958  nvars = transprob->nvars;
6959  vars = transprob->vars;
6960 
6961  /* check if memory still needs to be allocated */
6962  if( tree->probdiverelaxsol == NULL )
6963  {
6964  SCIP_ALLOC( BMSallocMemoryArray(&(tree->probdiverelaxsol), nvars) );
6965  }
6966 
6967  /* iterate over all variables to save the relaxation solution */
6968  for( v = 0; v < nvars; ++v )
6969  tree->probdiverelaxsol[v] = SCIPvarGetRelaxSol(vars[v], set);
6970 
6971  tree->probdiverelaxstored = TRUE;
6973 
6974  return SCIP_OKAY;
6975 }
6976 
6977 /** restores relaxation solution after diving or probing */
6979  SCIP_TREE* tree, /**< branch and bound tree */
6980  SCIP_SET* set, /**< global SCIP settings */
6981  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6982  SCIP_PROB* transprob /**< transformed problem after presolve */
6983  )
6984 {
6985  SCIP_VAR** vars;
6986  int nvars;
6987  int v;
6988 
6989  assert(tree != NULL);
6990  assert(set != NULL);
6991  assert(tree->probdiverelaxstored);
6992  assert(tree->probdiverelaxsol != NULL);
6993 
6994  nvars = transprob->nvars;
6995  vars = transprob->vars;
6996 
6997  /* iterate over all variables to restore the relaxation solution */
6998  for( v = 0; v < nvars; ++v )
6999  {
7000  SCIP_CALL( SCIPvarSetRelaxSol(vars[v], set, relaxation, tree->probdiverelaxsol[v], TRUE) );
7001  }
7002 
7003  tree->probdiverelaxstored = FALSE;
7005 
7006  return SCIP_OKAY;
7007 }
7008 
7009 /** gets the best child of the focus node w.r.t. the node selection priority assigned by the branching rule */
7011  SCIP_TREE* tree /**< branch and bound tree */
7012  )
7013 {
7014  SCIP_NODE* bestnode;
7015  SCIP_Real bestprio;
7016  int i;
7017 
7018  assert(tree != NULL);
7019 
7020  bestnode = NULL;
7021  bestprio = SCIP_REAL_MIN;
7022  for( i = 0; i < tree->nchildren; ++i )
7023  {
7024  if( tree->childrenprio[i] > bestprio )
7025  {
7026  bestnode = tree->children[i];
7027  bestprio = tree->childrenprio[i];
7028  }
7029  }
7030  assert((tree->nchildren == 0) == (bestnode == NULL));
7031 
7032  return bestnode;
7033 }
7034 
7035 /** gets the best sibling of the focus node w.r.t. the node selection priority assigned by the branching rule */
7037  SCIP_TREE* tree /**< branch and bound tree */
7038  )
7039 {
7040  SCIP_NODE* bestnode;
7041  SCIP_Real bestprio;
7042  int i;
7043 
7044  assert(tree != NULL);
7045 
7046  bestnode = NULL;
7047  bestprio = SCIP_REAL_MIN;
7048  for( i = 0; i < tree->nsiblings; ++i )
7049  {
7050  if( tree->siblingsprio[i] > bestprio )
7051  {
7052  bestnode = tree->siblings[i];
7053  bestprio = tree->siblingsprio[i];
7054  }
7055  }
7056  assert((tree->nsiblings == 0) == (bestnode == NULL));
7057 
7058  return bestnode;
7059 }
7060 
7061 /** gets the best child of the focus node w.r.t. the node selection strategy */
7063  SCIP_TREE* tree, /**< branch and bound tree */
7064  SCIP_SET* set /**< global SCIP settings */
7065  )
7066 {
7067  SCIP_NODESEL* nodesel;
7068  SCIP_NODE* bestnode;
7069  int i;
7070 
7071  assert(tree != NULL);
7072 
7073  nodesel = SCIPnodepqGetNodesel(tree->leaves);
7074  assert(nodesel != NULL);
7075 
7076  bestnode = NULL;
7077  for( i = 0; i < tree->nchildren; ++i )
7078  {
7079  if( bestnode == NULL || SCIPnodeselCompare(nodesel, set, tree->children[i], bestnode) < 0 )
7080  {
7081  bestnode = tree->children[i];
7082  }
7083  }
7084 
7085  return bestnode;
7086 }
7087 
7088 /** gets the best sibling of the focus node w.r.t. the node selection strategy */
7090  SCIP_TREE* tree, /**< branch and bound tree */
7091  SCIP_SET* set /**< global SCIP settings */
7092  )
7093 {
7094  SCIP_NODESEL* nodesel;
7095  SCIP_NODE* bestnode;
7096  int i;
7097 
7098  assert(tree != NULL);
7099 
7100  nodesel = SCIPnodepqGetNodesel(tree->leaves);
7101  assert(nodesel != NULL);
7102 
7103  bestnode = NULL;
7104  for( i = 0; i < tree->nsiblings; ++i )
7105  {
7106  if( bestnode == NULL || SCIPnodeselCompare(nodesel, set, tree->siblings[i], bestnode) < 0 )
7107  {
7108  bestnode = tree->siblings[i];
7109  }
7110  }
7111 
7112  return bestnode;
7113 }
7114 
7115 /** gets the best leaf from the node queue w.r.t. the node selection strategy */
7117  SCIP_TREE* tree /**< branch and bound tree */
7118  )
7119 {
7120  assert(tree != NULL);
7121 
7122  return SCIPnodepqFirst(tree->leaves);
7123 }
7124 
7125 /** gets the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy */
7127  SCIP_TREE* tree, /**< branch and bound tree */
7128  SCIP_SET* set /**< global SCIP settings */
7129  )
7130 {
7131  SCIP_NODESEL* nodesel;
7132  SCIP_NODE* bestchild;
7133  SCIP_NODE* bestsibling;
7134  SCIP_NODE* bestleaf;
7135  SCIP_NODE* bestnode;
7136 
7137  assert(tree != NULL);
7138 
7139  nodesel = SCIPnodepqGetNodesel(tree->leaves);
7140  assert(nodesel != NULL);
7141 
7142  /* get the best child, sibling, and leaf */
7143  bestchild = SCIPtreeGetBestChild(tree, set);
7144  bestsibling = SCIPtreeGetBestSibling(tree, set);
7145  bestleaf = SCIPtreeGetBestLeaf(tree);
7146 
7147  /* return the best of the three */
7148  bestnode = bestchild;
7149  if( bestsibling != NULL && (bestnode == NULL || SCIPnodeselCompare(nodesel, set, bestsibling, bestnode) < 0) )
7150  bestnode = bestsibling;
7151  if( bestleaf != NULL && (bestnode == NULL || SCIPnodeselCompare(nodesel, set, bestleaf, bestnode) < 0) )
7152  bestnode = bestleaf;
7153 
7154  assert(SCIPtreeGetNLeaves(tree) == 0 || bestnode != NULL);
7155 
7156  return bestnode;
7157 }
7158 
7159 /** gets the minimal lower bound of all nodes in the tree */
7161  SCIP_TREE* tree, /**< branch and bound tree */
7162  SCIP_SET* set /**< global SCIP settings */
7163  )
7164 {
7165  SCIP_Real lowerbound;
7166  int i;
7167 
7168  assert(tree != NULL);
7169  assert(set != NULL);
7170 
7171  /* get the lower bound from the queue */
7172  lowerbound = SCIPnodepqGetLowerbound(tree->leaves, set);
7173 
7174  /* compare lower bound with children */
7175  for( i = 0; i < tree->nchildren; ++i )
7176  {
7177  assert(tree->children[i] != NULL);
7178  lowerbound = MIN(lowerbound, tree->children[i]->lowerbound);
7179  }
7180 
7181  /* compare lower bound with siblings */
7182  for( i = 0; i < tree->nsiblings; ++i )
7183  {
7184  assert(tree->siblings[i] != NULL);
7185  lowerbound = MIN(lowerbound, tree->siblings[i]->lowerbound);
7186  }
7187 
7188  /* compare lower bound with focus node */
7189  if( tree->focusnode != NULL )
7190  {
7191  lowerbound = MIN(lowerbound, tree->focusnode->lowerbound);
7192  }
7193 
7194  return lowerbound;
7195 }
7196 
7197 /** gets the node with minimal lower bound of all nodes in the tree (child, sibling, or leaf) */
7199  SCIP_TREE* tree, /**< branch and bound tree */
7200  SCIP_SET* set /**< global SCIP settings */
7201  )
7202 {
7203  SCIP_NODE* lowerboundnode;
7204  SCIP_Real lowerbound;
7205  SCIP_Real bestprio;
7206  int i;
7207 
7208  assert(tree != NULL);
7209  assert(set != NULL);
7210 
7211  /* get the lower bound from the queue */
7212  lowerboundnode = SCIPnodepqGetLowerboundNode(tree->leaves, set);
7213  lowerbound = lowerboundnode != NULL ? lowerboundnode->lowerbound : SCIPsetInfinity(set);
7214  bestprio = -SCIPsetInfinity(set);
7215 
7216  /* compare lower bound with children */
7217  for( i = 0; i < tree->nchildren; ++i )
7218  {
7219  assert(tree->children[i] != NULL);
7220  if( SCIPsetIsLE(set, tree->children[i]->lowerbound, lowerbound) )
7221  {
7222  if( SCIPsetIsLT(set, tree->children[i]->lowerbound, lowerbound) || tree->childrenprio[i] > bestprio )
7223  {
7224  lowerboundnode = tree->children[i];
7225  lowerbound = lowerboundnode->lowerbound;
7226  bestprio = tree->childrenprio[i];
7227  }
7228  }
7229  }
7230 
7231  /* compare lower bound with siblings */
7232  for( i = 0; i < tree->nsiblings; ++i )
7233  {
7234  assert(tree->siblings[i] != NULL);
7235  if( SCIPsetIsLE(set, tree->siblings[i]->lowerbound, lowerbound) )
7236  {
7237  if( SCIPsetIsLT(set, tree->siblings[i]->lowerbound, lowerbound) || tree->siblingsprio[i] > bestprio )
7238  {
7239  lowerboundnode = tree->siblings[i];
7240  lowerbound = lowerboundnode->lowerbound;
7241  bestprio = tree->siblingsprio[i];
7242  }
7243  }
7244  }
7245 
7246  return lowerboundnode;
7247 }
7248 
7249 /** gets the average lower bound of all nodes in the tree */
7251  SCIP_TREE* tree, /**< branch and bound tree */
7252  SCIP_Real cutoffbound /**< global cutoff bound */
7253  )
7254 {
7255  SCIP_Real lowerboundsum;
7256  int nnodes;
7257  int i;
7258 
7259  assert(tree != NULL);
7260 
7261  /* get sum of lower bounds from nodes in the queue */
7262  lowerboundsum = SCIPnodepqGetLowerboundSum(tree->leaves);
7263  nnodes = SCIPtreeGetNLeaves(tree);
7264 
7265  /* add lower bound of focus node */
7266  if( tree->focusnode != NULL && tree->focusnode->lowerbound < cutoffbound )
7267  {
7268  lowerboundsum += tree->focusnode->lowerbound;
7269  nnodes++;
7270  }
7271 
7272  /* add lower bounds of siblings */
7273  for( i = 0; i < tree->nsiblings; ++i )
7274  {
7275  assert(tree->siblings[i] != NULL);
7276  lowerboundsum += tree->siblings[i]->lowerbound;
7277  }
7278  nnodes += tree->nsiblings;
7279 
7280  /* add lower bounds of children */
7281  for( i = 0; i < tree->nchildren; ++i )
7282  {
7283  assert(tree->children[i] != NULL);
7284  lowerboundsum += tree->children[i]->lowerbound;
7285  }
7286  nnodes += tree->nchildren;
7287 
7288  return nnodes == 0 ? 0.0 : lowerboundsum/nnodes;
7289 }
7290 
7291 
7292 
7293 
7294 /*
7295  * simple functions implemented as defines
7296  */
7297 
7298 /* In debug mode, the following methods are implemented as function calls to ensure
7299  * type validity.
7300  * In optimized mode, the methods are implemented as defines to improve performance.
7301  * However, we want to have them in the library anyways, so we have to undef the defines.
7302  */
7303 
7304 #undef SCIPnodeGetType
7305 #undef SCIPnodeGetNumber
7306 #undef SCIPnodeGetDepth
7307 #undef SCIPnodeGetLowerbound
7308 #undef SCIPnodeGetEstimate
7309 #undef SCIPnodeGetDomchg
7310 #undef SCIPnodeGetParent
7311 #undef SCIPnodeGetConssetchg
7312 #undef SCIPnodeIsActive
7313 #undef SCIPnodeIsPropagatedAgain
7314 #undef SCIPtreeGetNLeaves
7315 #undef SCIPtreeGetNChildren
7316 #undef SCIPtreeGetNSiblings
7317 #undef SCIPtreeGetNNodes
7318 #undef SCIPtreeIsPathComplete
7319 #undef SCIPtreeProbing
7320 #undef SCIPtreeGetProbingRoot
7321 #undef SCIPtreeGetProbingDepth
7322 #undef SCIPtreeGetFocusNode
7323 #undef SCIPtreeGetFocusDepth
7324 #undef SCIPtreeHasFocusNodeLP
7325 #undef SCIPtreeSetFocusNodeLP
7326 #undef SCIPtreeIsFocusNodeLPConstructed
7327 #undef SCIPtreeInRepropagation
7328 #undef SCIPtreeGetCurrentNode
7329 #undef SCIPtreeGetCurrentDepth
7330 #undef SCIPtreeHasCurrentNodeLP
7331 #undef SCIPtreeGetEffectiveRootDepth
7332 #undef SCIPtreeGetRootNode
7333 #undef SCIPtreeProbingObjChanged
7334 #undef SCIPtreeMarkProbingObjChanged
7335 
7336 /** gets the type of the node */
7338  SCIP_NODE* node /**< node */
7339  )
7340 {
7341  assert(node != NULL);
7342 
7343  return (SCIP_NODETYPE)(node->nodetype);
7344 }
7345 
7346 /** gets successively assigned number of the node */
7348  SCIP_NODE* node /**< node */
7349  )
7350 {
7351  assert(node != NULL);
7352 
7353  return node->number;
7354 }
7355 
7356 /** gets the depth of the node */
7358  SCIP_NODE* node /**< node */
7359  )
7360 {
7361  assert(node != NULL);
7362 
7363  return (int) node->depth;
7364 }
7365 
7366 /** gets the lower bound of the node */
7368  SCIP_NODE* node /**< node */
7369  )
7370 {
7371  assert(node != NULL);
7372 
7373  return node->lowerbound;
7374 }
7375 
7376 /** gets the estimated value of the best feasible solution in subtree of the node */
7378  SCIP_NODE* node /**< node */
7379  )
7380 {
7381  assert(node != NULL);
7382 
7383  return node->estimate;
7384 }
7385 
7386 /** gets the reoptimization type of this node */
7388  SCIP_NODE* node /**< node */
7389  )
7390 {
7391  assert(node != NULL);
7392 
7393  return (SCIP_REOPTTYPE)node->reopttype;
7394 }
7395 
7396 /** sets the reoptimization type of this node */
7398  SCIP_NODE* node, /**< node */
7399  SCIP_REOPTTYPE reopttype /**< reoptimization type */
7400  )
7401 {
7402  assert(node != NULL);
7403  assert(reopttype == SCIP_REOPTTYPE_NONE
7404  || reopttype == SCIP_REOPTTYPE_TRANSIT
7405  || reopttype == SCIP_REOPTTYPE_INFSUBTREE
7406  || reopttype == SCIP_REOPTTYPE_STRBRANCHED
7407  || reopttype == SCIP_REOPTTYPE_LOGICORNODE
7408  || reopttype == SCIP_REOPTTYPE_LEAF
7409  || reopttype == SCIP_REOPTTYPE_PRUNED
7410  || reopttype == SCIP_REOPTTYPE_FEASIBLE);
7411 
7412  node->reopttype = (unsigned int) reopttype;
7413 }
7414 
7415 /** gets the unique id to identify the node during reoptimization; the id is 0 if the node is the root or not part of
7416  * the reoptimization tree
7417  */
7418 unsigned int SCIPnodeGetReoptID(
7419  SCIP_NODE* node /**< node */
7420  )
7421 {
7422  assert(node != NULL);
7423 
7424  return node->reoptid; /*lint !e732*/
7425 }
7426 
7427 /** set a unique id to identify the node during reoptimization */
7429  SCIP_NODE* node, /**< node */
7430  unsigned int id /**< unique id */
7431  )
7432 {
7433  assert(node != NULL);
7434  assert(id <= 536870911); /* id has only 29 bits and needs to be smaller than 2^29 */
7435 
7436  node->reoptid = id;
7437 }
7438 
7439 /** gets the domain change information of the node, i.e., the information about the differences in the
7440  * variables domains to the parent node
7441  */
7443  SCIP_NODE* node /**< node */
7444  )
7445 {
7446  assert(node != NULL);
7447 
7448  return node->domchg;
7449 }
7450 
7451 /** counts the number of bound changes due to branching, constraint propagation, and propagation */
7453  SCIP_NODE* node, /**< node */
7454  int* nbranchings, /**< pointer to store number of branchings (or NULL if not needed) */
7455  int* nconsprop, /**< pointer to store number of constraint propagations (or NULL if not needed) */
7456  int* nprop /**< pointer to store number of propagations (or NULL if not needed) */
7457  )
7458 { /*lint --e{641}*/
7459  SCIP_Bool count_branchings;
7460  SCIP_Bool count_consprop;
7461  SCIP_Bool count_prop;
7462  int i;
7463 
7464  assert(node != NULL);
7465 
7466  count_branchings = (nbranchings != NULL);
7467  count_consprop = (nconsprop != NULL);
7468  count_prop = (nprop != NULL);
7469 
7470  /* set counter to zero */
7471  if( count_branchings )
7472  *nbranchings = 0;
7473  if( count_consprop )
7474  *nconsprop = 0;
7475  if( count_prop )
7476  *nprop = 0;
7477 
7478  if( node->domchg != NULL )
7479  {
7480  for( i = 0; i < (int) node->domchg->domchgbound.nboundchgs; i++ )
7481  {
7482  if( count_branchings && node->domchg->domchgbound.boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING )
7483  (*nbranchings)++;
7484  else if( count_consprop && node->domchg->domchgbound.boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER )
7485  (*nconsprop)++;
7486  else if( count_prop && node->domchg->domchgbound.boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER )
7487  (*nprop)++;
7488  }
7489  }
7490 }
7491 
7492 /* return the number of bound changes based on dual information.
7493  *
7494  * currently, this methods works only for bound changes made by strong branching on binary variables. we need this
7495  * method to ensure optimality within reoptimization.
7496  *
7497  * since the bound changes made by strong branching are stored as SCIP_BOUNDCHGTYPE_CONSINFER or SCIP_BOUNDCHGTYPE_PROPINFER
7498  * with no constraint or propagator, resp., we are are interested in bound changes with these attributes.
7499  *
7500  * all bound changes of type SCIP_BOUNDCHGTYPE_BRANCHING are stored in the beginning of the bound change array, afterwards,
7501  * we can find the other two types. thus, we start the search at the end of the list and stop when reaching the first
7502  * bound change of type SCIP_BOUNDCHGTYPE_BRANCHING.
7503  */
7505  SCIP_NODE* node /**< node */
7506  )
7507 { /*lint --e{641}*/
7508  SCIP_BOUNDCHG* boundchgs;
7509  int i;
7510  int nboundchgs;
7511  int npseudobranchvars;
7512 
7513  assert(node != NULL);
7514 
7515  if( node->domchg == NULL )
7516  return 0;
7517 
7518  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7519  boundchgs = node->domchg->domchgbound.boundchgs;
7520 
7521  npseudobranchvars = 0;
7522 
7523  assert(boundchgs != NULL);
7524  assert(nboundchgs >= 0);
7525 
7526  /* count the number of pseudo-branching decisions; pseudo-branching decisions have to be in the ending of the bound change
7527  * array
7528  */
7529  for( i = nboundchgs-1; i >= 0; i--)
7530  {
7531  SCIP_Bool isint;
7532 
7533  isint = boundchgs[i].var->vartype == SCIP_VARTYPE_BINARY || boundchgs[i].var->vartype == SCIP_VARTYPE_INTEGER
7534  || boundchgs[i].var->vartype == SCIP_VARTYPE_IMPLINT;
7535 
7536  if( isint && ((boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER
7537  && boundchgs[i].data.inferencedata.reason.cons == NULL)
7538  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER
7539  && boundchgs[i].data.inferencedata.reason.prop == NULL)) )
7540  npseudobranchvars++;
7541  else if( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING )
7542  break;
7543  }
7544 
7545  return npseudobranchvars;
7546 }
7547 
7548 /** returns the set of variable branchings that were performed in the parent node to create this node */
7550  SCIP_NODE* node, /**< node data */
7551  SCIP_VAR** vars, /**< array of variables on which the bound change is based on dual information */
7552  SCIP_Real* bounds, /**< array of bounds which are based on dual information */
7553  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which are based on dual information */
7554  int* nvars, /**< number of variables on which the bound change is based on dual information
7555  * if this is larger than the array size, arrays should be reallocated and method
7556  * should be called again */
7557  int varssize /**< available slots in arrays */
7558  )
7559 { /*lint --e{641}*/
7560  SCIP_BOUNDCHG* boundchgs;
7561  int nboundchgs;
7562  int i;
7563 
7564  assert(node != NULL);
7565  assert(vars != NULL);
7566  assert(bounds != NULL);
7567  assert(boundtypes != NULL);
7568  assert(nvars != NULL);
7569  assert(varssize >= 0);
7570 
7571  (*nvars) = 0;
7572 
7573  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7574  return;
7575 
7576  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7577  boundchgs = node->domchg->domchgbound.boundchgs;
7578 
7579  assert(boundchgs != NULL);
7580  assert(nboundchgs >= 0);
7581 
7582  /* count the number of pseudo-branching decisions; pseudo-branching decisions have to be in the ending of the bound change
7583  * array
7584  */
7585  for( i = nboundchgs-1; i >= 0; i--)
7586  {
7587  if( boundchgs[i].var->vartype == SCIP_VARTYPE_BINARY || boundchgs[i].var->vartype == SCIP_VARTYPE_INTEGER
7588  || boundchgs[i].var->vartype == SCIP_VARTYPE_IMPLINT )
7589  {
7590  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER
7591  && boundchgs[i].data.inferencedata.reason.cons == NULL)
7592  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER
7593  && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7594  (*nvars)++;
7595  else if( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING )
7596  break;
7597  }
7598  }
7599 
7600  /* if the arrays have enough space store the branching decisions */
7601  if( varssize >= *nvars )
7602  {
7603  int j;
7604  j = 0;
7605  for( i = i+1; i < nboundchgs; i++)
7606  {
7607  assert( boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING );
7608  if( boundchgs[i].var->vartype == SCIP_VARTYPE_BINARY || boundchgs[i].var->vartype == SCIP_VARTYPE_INTEGER
7609  || boundchgs[i].var->vartype == SCIP_VARTYPE_IMPLINT )
7610  {
7611  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER
7612  && boundchgs[i].data.inferencedata.reason.cons == NULL)
7613  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER
7614  && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7615  {
7616  vars[j] = boundchgs[i].var;
7617  bounds[j] = boundchgs[i].newbound;
7618  boundtypes[j] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7619  j++;
7620  }
7621  }
7622  }
7623  }
7624 }
7625 
7626 /** gets the parent node of a node in the branch-and-bound tree, if any */
7628  SCIP_NODE* node /**< node */
7629  )
7630 {
7631  assert(node != NULL);
7632 
7633  return node->parent;
7634 }
7635 
7636 /** returns the set of variable branchings that were performed in the parent node to create this node */
7638  SCIP_NODE* node, /**< node data */
7639  SCIP_VAR** branchvars, /**< array of variables on which the branching has been performed in the parent node */
7640  SCIP_Real* branchbounds, /**< array of bounds which the branching in the parent node set */
7641  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branching in the parent node set */
7642  int* nbranchvars, /**< number of variables on which branching has been performed in the parent node
7643  * if this is larger than the array size, arrays should be reallocated and method
7644  * should be called again */
7645  int branchvarssize /**< available slots in arrays */
7646  )
7647 {
7648  SCIP_BOUNDCHG* boundchgs;
7649  int nboundchgs;
7650  int i;
7651 
7652  assert(node != NULL);
7653  assert(branchvars != NULL);
7654  assert(branchbounds != NULL);
7655  assert(boundtypes != NULL);
7656  assert(nbranchvars != NULL);
7657  assert(branchvarssize >= 0);
7658 
7659  (*nbranchvars) = 0;
7660 
7661  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7662  return;
7663 
7664  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7665  boundchgs = node->domchg->domchgbound.boundchgs;
7666 
7667  assert(boundchgs != NULL);
7668  assert(nboundchgs >= 0);
7669 
7670  /* count the number of branching decisions; branching decisions have to be in the beginning of the bound change
7671  * array
7672  */
7673  for( i = 0; i < nboundchgs; i++)
7674  {
7675  if( boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING ) /*lint !e641*/
7676  break;
7677 
7678  (*nbranchvars)++;
7679  }
7680 
7681 #ifndef NDEBUG
7682  /* check that the remaining bound change are no branching decisions */
7683  for( ; i < nboundchgs; i++)
7684  assert(boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING); /*lint !e641*/
7685 #endif
7686 
7687  /* if the arrays have enough space store the branching decisions */
7688  if( branchvarssize >= *nbranchvars )
7689  {
7690  for( i = 0; i < *nbranchvars; i++)
7691  {
7692  assert( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING ); /*lint !e641*/
7693  branchvars[i] = boundchgs[i].var;
7694  boundtypes[i] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7695  branchbounds[i] = boundchgs[i].newbound;
7696  }
7697  }
7698 }
7699 
7700 /** returns the set of variable branchings that were performed in all ancestor nodes (nodes on the path to the root) to create this node */
7702  SCIP_NODE* node, /**< node data */
7703  SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
7704  SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
7705  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
7706  int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
7707  * if this is larger than the array size, arrays should be reallocated and method
7708  * should be called again */
7709  int branchvarssize /**< available slots in arrays */
7710  )
7711 {
7712  assert(node != NULL);
7713  assert(branchvars != NULL);
7714  assert(branchbounds != NULL);
7715  assert(boundtypes != NULL);
7716  assert(nbranchvars != NULL);
7717  assert(branchvarssize >= 0);
7718 
7719  (*nbranchvars) = 0;
7720 
7721  while( SCIPnodeGetDepth(node) != 0 )
7722  {
7723  int nodenbranchvars;
7724  int start;
7725  int size;
7726 
7727  start = *nbranchvars < branchvarssize - 1 ? *nbranchvars : branchvarssize - 1;
7728  size = *nbranchvars > branchvarssize ? 0 : branchvarssize-(*nbranchvars);
7729 
7730  SCIPnodeGetParentBranchings(node, &branchvars[start], &branchbounds[start], &boundtypes[start], &nodenbranchvars, size);
7731  *nbranchvars += nodenbranchvars;
7732 
7733  node = node->parent;
7734  }
7735 }
7736 
7737 /** returns the set of variable branchings that were performed between the given @p node and the given @p parent node. */
7739  SCIP_NODE* node, /**< node data */
7740  SCIP_NODE* parent, /**< node data of the last ancestor node */
7741  SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
7742  SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
7743  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
7744  int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
7745  * if this is larger than the array size, arrays should be reallocated and method
7746  * should be called again */
7747  int branchvarssize /**< available slots in arrays */
7748  )
7749 {
7750  assert(node != NULL);
7751  assert(parent != NULL);
7752  assert(branchvars != NULL);
7753  assert(branchbounds != NULL);
7754  assert(boundtypes != NULL);
7755  assert(nbranchvars != NULL);
7756  assert(branchvarssize >= 0);
7757 
7758  (*nbranchvars) = 0;
7759 
7760  while( node != parent )
7761  {
7762  int nodenbranchvars;
7763  int start;
7764  int size;
7765 
7766  start = *nbranchvars < branchvarssize - 1 ? *nbranchvars : branchvarssize - 1;
7767  size = *nbranchvars > branchvarssize ? 0 : branchvarssize-(*nbranchvars);
7768 
7769  SCIPnodeGetParentBranchings(node, &branchvars[start], &branchbounds[start], &boundtypes[start], &nodenbranchvars, size);
7770  *nbranchvars += nodenbranchvars;
7771 
7772  node = node->parent;
7773  }
7774 }
7775 
7776 /** return all bound changes based on constraint propagation; stop saving the bound changes if we reach a branching
7777  * decision based on a dual information
7778  */
7780  SCIP_NODE* node, /**< node */
7781  SCIP_VAR** vars, /**< array of variables on which constraint propagation triggers a bound change */
7782  SCIP_Real* varbounds, /**< array of bounds set by constraint propagation */
7783  SCIP_BOUNDTYPE* varboundtypes, /**< array of boundtypes set by constraint propagation */
7784  int* nconspropvars, /**< number of variables on which constraint propagation triggers a bound change
7785  * if this is larger than the array size, arrays should be reallocated and method
7786  * should be called again */
7787  int conspropvarssize /**< available slots in arrays */
7788  )
7789 { /*lint --e{641}*/
7790  SCIP_BOUNDCHG* boundchgs;
7791  int nboundchgs;
7792  int first_dual;
7793  int nskip;
7794  int i;
7795 
7796  assert(node != NULL);
7797  assert(vars != NULL);
7798  assert(varbounds != NULL);
7799  assert(varboundtypes != NULL);
7800  assert(nconspropvars != NULL);
7801  assert(conspropvarssize >= 0);
7802 
7803  (*nconspropvars) = 0;
7804 
7805  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7806  return;
7807 
7808  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7809  boundchgs = node->domchg->domchgbound.boundchgs;
7810 
7811  assert(boundchgs != NULL);
7812  assert(nboundchgs >= 0);
7813 
7814  SCIPnodeGetNDomchg(node, &nskip, NULL, NULL);
7815  i = nskip;
7816 
7817  while( i < nboundchgs
7818  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons == NULL)
7819  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7820  i++;
7821 
7822  first_dual = i;
7823 
7824  /* count the number of bound changes because of constraint propagation and propagation */
7825  for(i = nskip; i < first_dual; i++)
7826  {
7827  assert(boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING);
7828 
7829  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL)
7830  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop != NULL) )
7831  {
7832  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7833  (*nconspropvars)++;
7834  }
7835  else if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons == NULL)
7836  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop == NULL))
7837  break;
7838  }
7839 
7840  /* if the arrays have enough space store the branching decisions */
7841  if( conspropvarssize >= *nconspropvars )
7842  {
7843  int pos;
7844 
7845  for(i = nskip, pos = 0; i < first_dual; i++)
7846  {
7847  if( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL )
7848  {
7849  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7850  {
7851  vars[pos] = boundchgs[i].var;
7852  varboundtypes[pos] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7853  varbounds[pos] = boundchgs[i].newbound;
7854  pos++;
7855  }
7856  }
7857  }
7858  }
7859 
7860  return;
7861 }
7862 
7863 /** gets all bound changes applied after the first bound change based on dual information.
7864  *
7865  * @note: currently, we can only detect bound changes based in dual information if they arise from strong branching.
7866  */
7868  SCIP_NODE* node, /**< node */
7869  SCIP_VAR** vars, /**< array of variables on which the branching has been performed in the parent node */
7870  SCIP_Real* varbounds, /**< array of bounds which the branching in the parent node set */
7871  SCIP_BOUNDTYPE* varboundtypes, /**< array of boundtypes which the branching in the parent node set */
7872  int start, /**< first free slot in the arrays */
7873  int* nbranchvars, /**< number of variables on which branching has been performed in the parent node
7874  * if this is larger than the array size, arrays should be reallocated and method
7875  * should be called again */
7876  int branchvarssize /**< available slots in arrays */
7877  )
7878 { /*lint --e{641}*/
7879  SCIP_BOUNDCHG* boundchgs;
7880  int nboundchgs;
7881  int first_dual;
7882  int i;
7883 
7884  assert(node != NULL);
7885  assert(vars != NULL);
7886  assert(varbounds != NULL);
7887  assert(varboundtypes != NULL);
7888  assert(nbranchvars != NULL);
7889  assert(branchvarssize >= 0);
7890 
7891  (*nbranchvars) = 0;
7892 
7893  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7894  return;
7895 
7896  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7897  boundchgs = node->domchg->domchgbound.boundchgs;
7898 
7899  assert(boundchgs != NULL);
7900  assert(nboundchgs >= 0);
7901 
7902  /* find the first based on dual information */
7903  i = 0;
7904  while( i < nboundchgs
7905  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons == NULL)
7906  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7907  i++;
7908 
7909  first_dual = i;
7910 
7911  /* count the number of branching decisions; branching decisions have to be in the beginning of the bound change array */
7912  for( ; i < nboundchgs; i++)
7913  {
7914  assert(boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING);
7915 
7916  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL)
7917  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop != NULL) )
7918  {
7919  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7920  (*nbranchvars)++;
7921  }
7922  }
7923 
7924  /* if the arrays have enough space store the branching decisions */
7925  if( branchvarssize >= *nbranchvars )
7926  {
7927  int p;
7928  for(i = first_dual, p = start; i < nboundchgs; i++)
7929  {
7930  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL)
7931  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop != NULL) )
7932  {
7933  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7934  {
7935  vars[p] = boundchgs[i].var;
7936  varboundtypes[p] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7937  varbounds[p] = boundchgs[i].newbound;
7938  p++;
7939  }
7940  }
7941  }
7942  }
7943 }
7944 
7945 /** outputs the path into given file stream in GML format */
7947  SCIP_NODE* node, /**< node data */
7948  FILE* file /**< file to output the path */
7949  )
7950 {
7951  int nbranchings;
7952 
7953  nbranchings = 0;
7954 
7955  /* print opening in GML format */
7956  SCIPgmlWriteOpening(file, TRUE);
7957 
7958  while( SCIPnodeGetDepth(node) != 0 )
7959  {
7960  SCIP_BOUNDCHG* boundchgs;
7961  char label[SCIP_MAXSTRLEN];
7962  int nboundchgs;
7963  int i;
7964 
7965  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7966  boundchgs = node->domchg->domchgbound.boundchgs;
7967 
7968  for( i = 0; i < nboundchgs; i++)
7969  {
7970  if( boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING ) /*lint !e641*/
7971  break;
7972 
7973  (void) SCIPsnprintf(label, SCIP_MAXSTRLEN, "%s %s %g", SCIPvarGetName(boundchgs[i].var),
7974  (SCIP_BOUNDTYPE) boundchgs[i].boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", boundchgs[i].newbound);
7975 
7976  SCIPgmlWriteNode(file, (unsigned int)nbranchings, label, "circle", NULL, NULL);
7977 
7978  if( nbranchings > 0 )
7979  {
7980  SCIPgmlWriteArc(file, (unsigned int)nbranchings, (unsigned int)(nbranchings-1), NULL, NULL);
7981  }
7982 
7983  nbranchings++;
7984  }
7985 
7986  node = node->parent;
7987  }
7988 
7989  /* print closing in GML format */
7990  SCIPgmlWriteClosing(file);
7991 
7992  return SCIP_OKAY;
7993 }
7994 
7995 /** returns the set of variable branchings that were performed in all ancestor nodes (nodes on the path to the root) to create this node
7996  * sorted by the nodes, starting from the current node going up to the root
7997  */
7999  SCIP_NODE* node, /**< node data */
8000  SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
8001  SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
8002  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
8003  int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
8004  * if this is larger than the array size, arrays should be reallocated and method
8005  * should be called again */
8006  int branchvarssize, /**< available slots in arrays */
8007  int* nodeswitches, /**< marks, where in the arrays the branching decisions of the next node on the path
8008  * start branchings performed at the parent of node always start at position 0.
8009  * For single variable branching, nodeswitches[i] = i holds */
8010  int* nnodes, /**< number of nodes in the nodeswitch array */
8011  int nodeswitchsize /**< available slots in node switch array */
8012  )
8013 {
8014  assert(node != NULL);
8015  assert(branchvars != NULL);
8016  assert(branchbounds != NULL);
8017  assert(boundtypes != NULL);
8018  assert(nbranchvars != NULL);
8019  assert(branchvarssize >= 0);
8020 
8021  (*nbranchvars) = 0;
8022  (*nnodes) = 0;
8023 
8024  /* go up to the root, in the root no domains were changed due to branching */
8025  while( SCIPnodeGetDepth(node) != 0 )
8026  {
8027  int nodenbranchvars;
8028  int start;
8029  int size;
8030 
8031  /* calculate the start position for the current node and the maximum remaining slots in the arrays */
8032  start = *nbranchvars < branchvarssize - 1 ? *nbranchvars : branchvarssize - 1;
8033  size = *nbranchvars > branchvarssize ? 0 : branchvarssize-(*nbranchvars);
8034  if( *nnodes < nodeswitchsize )
8035  nodeswitches[*nnodes] = start;
8036 
8037  /* get branchings for a single node */
8038  SCIPnodeGetParentBranchings(node, &branchvars[start], &branchbounds[start], &boundtypes[start], &nodenbranchvars, size);
8039  *nbranchvars += nodenbranchvars;
8040  (*nnodes)++;
8041 
8042  node = node->parent;
8043  }
8044 }
8045 
8046 /** checks for two nodes whether they share the same root path, i.e., whether one is an ancestor of the other */
8048  SCIP_NODE* node1, /**< node data */
8049  SCIP_NODE* node2 /**< node data */
8050  )
8051 {
8052  assert(node1 != NULL);
8053  assert(node2 != NULL);
8054  assert(SCIPnodeGetDepth(node1) >= 0);
8055  assert(SCIPnodeGetDepth(node2) >= 0);
8056 
8057  /* if node2 is deeper than node1, follow the path until the level of node2 */
8058  while( SCIPnodeGetDepth(node1) < SCIPnodeGetDepth(node2) )
8059  node2 = node2->parent;
8060 
8061  /* if node1 is deeper than node2, follow the path until the level of node1 */
8062  while( SCIPnodeGetDepth(node2) < SCIPnodeGetDepth(node1) )
8063  node1 = node1->parent;
8064 
8065  assert(SCIPnodeGetDepth(node2) == SCIPnodeGetDepth(node1));
8066 
8067  return (node1 == node2);
8068 }
8069 
8070 /** finds the common ancestor node of two given nodes */
8072  SCIP_NODE* node1, /**< node data */
8073  SCIP_NODE* node2 /**< node data */
8074  )
8075 {
8076  assert(node1 != NULL);
8077  assert(node2 != NULL);
8078  assert(SCIPnodeGetDepth(node1) >= 0);
8079  assert(SCIPnodeGetDepth(node2) >= 0);
8080 
8081  /* if node2 is deeper than node1, follow the path until the level of node2 */
8082  while( SCIPnodeGetDepth(node1) < SCIPnodeGetDepth(node2) )
8083  node2 = node2->parent;
8084 
8085  /* if node1 is deeper than node2, follow the path until the level of node1 */
8086  while( SCIPnodeGetDepth(node2) < SCIPnodeGetDepth(node1) )
8087  node1 = node1->parent;
8088 
8089  /* move up level by level until you found a common ancestor */
8090  while( node1 != node2 )
8091  {
8092  node1 = node1->parent;
8093  node2 = node2->parent;
8094  assert(SCIPnodeGetDepth(node1) == SCIPnodeGetDepth(node2));
8095  }
8096  assert(SCIPnodeGetDepth(node1) >= 0);
8097 
8098  return node1;
8099 }
8100 
8101 /** returns whether node is in the path to the current node */
8103  SCIP_NODE* node /**< node */
8104  )
8105 {
8106  assert(node != NULL);
8107 
8108  return node->active;
8109 }
8110 
8111 /** returns whether the node is marked to be propagated again */
8113  SCIP_NODE* node /**< node data */
8114  )
8115 {
8116  assert(node != NULL);
8117 
8118  return node->reprop;
8119 }
8120 
8121 /* returns the set of changed constraints for a particular node */
8123  SCIP_NODE* node /**< node data */
8124  )
8125 {
8126  assert(node != NULL);
8127 
8128  return node->conssetchg;
8129 }
8130 
8131 /** gets number of children of the focus node */
8133  SCIP_TREE* tree /**< branch and bound tree */
8134  )
8135 {
8136  assert(tree != NULL);
8137 
8138  return tree->nchildren;
8139 }
8140 
8141 /** gets number of siblings of the focus node */
8143  SCIP_TREE* tree /**< branch and bound tree */
8144  )
8145 {
8146  assert(tree != NULL);
8147 
8148  return tree->nsiblings;
8149 }
8150 
8151 /** gets number of leaves in the tree (excluding children and siblings of focus nodes) */
8153  SCIP_TREE* tree /**< branch and bound tree */
8154  )
8155 {
8156  assert(tree != NULL);
8157 
8158  return SCIPnodepqLen(tree->leaves);
8159 }
8160 
8161 /** gets number of open nodes in the tree (children + siblings + leaves) */
8163  SCIP_TREE* tree /**< branch and bound tree */
8164  )
8165 {
8166  assert(tree != NULL);
8167 
8168  return tree->nchildren + tree->nsiblings + SCIPtreeGetNLeaves(tree);
8169 }
8170 
8171 /** returns whether the active path goes completely down to the focus node */
8173  SCIP_TREE* tree /**< branch and bound tree */
8174  )
8175 {
8176  assert(tree != NULL);
8177  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8178  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8179  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8180  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8181  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8182  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8183  || tree->path[tree->focusnode->depth] == tree->focusnode);
8184 
8185  return (tree->focusnode == NULL || (int)tree->focusnode->depth < tree->pathlen);
8186 }
8187 
8188 /** returns whether the current node is a temporary probing node */
8190  SCIP_TREE* tree /**< branch and bound tree */
8191  )
8192 {
8193  assert(tree != NULL);
8195  assert(tree->probingroot == NULL || tree->pathlen > SCIPnodeGetDepth(tree->probingroot));
8196  assert(tree->probingroot == NULL || tree->path[SCIPnodeGetDepth(tree->probingroot)] == tree->probingroot);
8197 
8198  return (tree->probingroot != NULL);
8199 }
8200 
8201 /** returns the temporary probing root node, or NULL if the we are not in probing mode */
8203  SCIP_TREE* tree /**< branch and bound tree */
8204  )
8205 {
8206  assert(tree != NULL);
8208  assert(tree->probingroot == NULL || tree->pathlen > SCIPnodeGetDepth(tree->probingroot));
8209  assert(tree->probingroot == NULL || tree->path[SCIPnodeGetDepth(tree->probingroot)] == tree->probingroot);
8210 
8211  return tree->probingroot;
8212 }
8213 
8214 /** gets focus node of the tree */
8216  SCIP_TREE* tree /**< branch and bound tree */
8217  )
8218 {
8219  assert(tree != NULL);
8220  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8221  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8222  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8223  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8224  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8225  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8226  || tree->path[tree->focusnode->depth] == tree->focusnode);
8227 
8228  return tree->focusnode;
8229 }
8230 
8231 /** gets depth of focus node in the tree */
8233  SCIP_TREE* tree /**< branch and bound tree */
8234  )
8235 {
8236  assert(tree != NULL);
8237  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8238  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8239  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8240  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8241  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8242  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8243  || tree->path[tree->focusnode->depth] == tree->focusnode);
8244 
8245  return tree->focusnode != NULL ? (int)tree->focusnode->depth : -1;
8246 }
8247 
8248 /** returns, whether the LP was or is to be solved in the focus node */
8250  SCIP_TREE* tree /**< branch and bound tree */
8251  )
8252 {
8253  assert(tree != NULL);
8254 
8255  return tree->focusnodehaslp;
8256 }
8257 
8258 /** sets mark to solve or to ignore the LP while processing the focus node */
8260  SCIP_TREE* tree, /**< branch and bound tree */
8261  SCIP_Bool solvelp /**< should the LP be solved in focus node? */
8262  )
8263 {
8264  assert(tree != NULL);
8265 
8266  tree->focusnodehaslp = solvelp;
8267 }
8268 
8269 /** returns whether the LP of the focus node is already constructed */
8271  SCIP_TREE* tree /**< branch and bound tree */
8272  )
8273 {
8274  assert(tree != NULL);
8275 
8276  return tree->focuslpconstructed;
8277 }
8278 
8279 /** returns whether the focus node is already solved and only propagated again */
8281  SCIP_TREE* tree /**< branch and bound tree */
8282  )
8283 {
8284  assert(tree != NULL);
8285 
8286  return (tree->focusnode != NULL && SCIPnodeGetType(tree->focusnode) == SCIP_NODETYPE_REFOCUSNODE);
8287 }
8288 
8289 /** gets current node of the tree, i.e. the last node in the active path, or NULL if no current node exists */
8291  SCIP_TREE* tree /**< branch and bound tree */
8292  )
8293 {
8294  assert(tree != NULL);
8295  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8296  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8297  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8298  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8299  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8300  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8301  || tree->path[tree->focusnode->depth] == tree->focusnode);
8302 
8303  return (tree->pathlen > 0 ? tree->path[tree->pathlen-1] : NULL);
8304 }
8305 
8306 /** gets depth of current node in the tree, i.e. the length of the active path minus 1, or -1 if no current node exists */
8308  SCIP_TREE* tree /**< branch and bound tree */
8309  )
8310 {
8311  assert(tree != NULL);
8312  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8313  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8314  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8315  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8316  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8317  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8318  || tree->path[tree->focusnode->depth] == tree->focusnode);
8319 
8320  return tree->pathlen-1;
8321 }
8322 
8323 /** returns, whether the LP was or is to be solved in the current node */
8325  SCIP_TREE* tree /**< branch and bound tree */
8326  )
8327 {
8328  assert(tree != NULL);
8329  assert(SCIPtreeIsPathComplete(tree));
8330 
8331  return SCIPtreeProbing(tree) ? tree->probingnodehaslp : SCIPtreeHasFocusNodeLP(tree);
8332 }
8333 
8334 /** returns the current probing depth, i.e. the number of probing sub nodes existing in the probing path */
8336  SCIP_TREE* tree /**< branch and bound tree */
8337  )
8338 {
8339  assert(tree != NULL);
8340  assert(SCIPtreeProbing(tree));
8341 
8343 }
8344 
8345 /** returns the depth of the effective root node (i.e. the first depth level of a node with at least two children) */
8347  SCIP_TREE* tree /**< branch and bound tree */
8348  )
8349 {
8350  assert(tree != NULL);
8351  assert(tree->effectiverootdepth >= 0);
8352 
8353  return tree->effectiverootdepth;
8354 }
8355 
8356 /** gets the root node of the tree */
8358  SCIP_TREE* tree /**< branch and bound tree */
8359  )
8360 {
8361  assert(tree != NULL);
8362 
8363  return tree->root;
8364 }
8365 
8366 /** returns whether we are in probing and the objective value of at least one column was changed */
8367 
8369  SCIP_TREE* tree /**< branch and bound tree */
8370  )
8371 {
8372  assert(tree != NULL);
8373  assert(SCIPtreeProbing(tree) || !tree->probingobjchanged);
8374 
8375  return tree->probingobjchanged;
8376 }
8377 
8378 /** marks the current probing node to have a changed objective function */
8380  SCIP_TREE* tree /**< branch and bound tree */
8381  )
8382 {
8383  assert(tree != NULL);
8384  assert(SCIPtreeProbing(tree));
8385 
8386  tree->probingobjchanged = TRUE;
8387 }
SCIP_Real cutoffbound
Definition: struct_primal.h:46
SCIP_NODE * node
Definition: struct_tree.h:164
SCIP_RETCODE SCIPtreeClear(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: tree.c:4828
SCIP_Bool solisbasic
Definition: struct_lp.h:357
static SCIP_RETCODE forkAddLP(SCIP_NODE *fork, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_LP *lp)
Definition: tree.c:3184
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
SCIP_RETCODE SCIPtreeAddDiveBoundChange(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_VAR *var, SCIP_BRANCHDIR dir, SCIP_Real value, SCIP_Bool preferred)
Definition: tree.c:6193
int firstnewrow
Definition: struct_lp.h:321
SCIP_RETCODE SCIPlpGetProvedLowerbound(SCIP_LP *lp, SCIP_SET *set, SCIP_Real *bound)
Definition: lp.c:16198
SCIP_RETCODE SCIPtreeCreatePresolvingRoot(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable)
Definition: tree.c:4933
void SCIPnodeGetDualBoundchgs(SCIP_NODE *node, SCIP_VAR **vars, SCIP_Real *bounds, SCIP_BOUNDTYPE *boundtypes, int *nvars, int varssize)
Definition: tree.c:7549
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5953
SCIP_RETCODE SCIPtreeEndProbing(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_LP *lp, SCIP_RELAXATION *relaxation, SCIP_PRIMAL *primal, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_CLIQUETABLE *cliquetable)
Definition: tree.c:6780
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
Definition: memory.h:457
#define NULL
Definition: def.h:253
internal methods for managing events
SCIP_RETCODE SCIPlpFreeNorms(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
Definition: lp.c:10052
SCIP_RETCODE SCIPnodepqBound(SCIP_NODEPQ *nodepq, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real cutoffbound)
Definition: nodesel.c:626
SCIP_Bool lpwasdualchecked
Definition: struct_tree.h:60
SCIP_RETCODE SCIPnodeCreateChild(SCIP_NODE **node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_Real nodeselprio, SCIP_Real estimate)
Definition: tree.c:980
SCIP_RETCODE SCIPtreeSetProbingLPState(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_LP *lp, SCIP_LPISTATE **lpistate, SCIP_LPINORMS **lpinorms, SCIP_Bool primalfeas, SCIP_Bool dualfeas)
Definition: tree.c:6437
SCIP_VAR ** SCIPcliqueGetVars(SCIP_CLIQUE *clique)
Definition: implics.c:3343
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6011
SCIP_PSEUDOFORK * pseudofork
Definition: struct_tree.h:144
SCIP_RETCODE SCIPtreeBranchVar(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Real val, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
Definition: tree.c:5349
int SCIPlpGetNNewrows(SCIP_LP *lp)
Definition: lp.c:17292
SCIP_Bool SCIPsetIsFeasZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6461
void SCIPvisualRepropagatedNode(SCIP_VISUAL *visual, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:641
static SCIP_RETCODE treeEnsurePendingbdchgsMem(SCIP_TREE *tree, SCIP_SET *set, int num)
Definition: tree.c:112
SCIP_NODE * focussubroot
Definition: struct_tree.h:188
unsigned int lpwasdualfeas
Definition: struct_tree.h:127
SCIP_Bool SCIPtreeHasFocusNodeLP(SCIP_TREE *tree)
Definition: tree.c:8249
static SCIP_RETCODE junctionInit(SCIP_JUNCTION *junction, SCIP_TREE *tree)
Definition: tree.c:407
SCIP_Bool SCIPlpDiving(SCIP_LP *lp)
Definition: lp.c:17474
SCIP_RETCODE SCIPconssetchgFree(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:5297
#define SCIPdebugRemoveNode(blkmem, set, node)
Definition: debug.h:248
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:138
SCIP_Real * origobjvals
Definition: struct_tree.h:55
SCIP_RETCODE SCIPlpShrinkRows(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, int newnrows)
Definition: lp.c:9597
void SCIPlpSetIsRelax(SCIP_LP *lp, SCIP_Bool relax)
Definition: lp.c:17411
union SCIP_BoundChg::@12 data
static SCIP_RETCODE probingnodeUpdate(SCIP_PROBINGNODE *probingnode, BMS_BLKMEM *blkmem, SCIP_TREE *tree, SCIP_LP *lp)
Definition: tree.c:315
internal methods for branch and bound tree
SCIP_Real SCIPtreeCalcChildEstimate(SCIP_TREE *tree, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var, SCIP_Real targetvalue)
Definition: tree.c:5290
int naddedcols
Definition: struct_tree.h:104
SCIP_RETCODE SCIPtreeBranchVarHole(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Real left, SCIP_Real right, SCIP_NODE **downchild, SCIP_NODE **upchild)
Definition: tree.c:5680
SCIP_Longint ndeactivatednodes
Definition: struct_stat.h:84
void SCIPtreeSetFocusNodeLP(SCIP_TREE *tree, SCIP_Bool solvelp)
Definition: tree.c:8259
SCIP_EXPORT SCIP_Bool SCIPvarIsInLP(SCIP_VAR *var)
Definition: var.c:17077
SCIP_CONSSETCHG * SCIPnodeGetConssetchg(SCIP_NODE *node)
Definition: tree.c:8122
SCIP_Bool primalfeasible
Definition: struct_lp.h:353
SCIP_RETCODE SCIPeventqueueProcess(SCIP_EVENTQUEUE *eventqueue, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter)
Definition: event.c:2404
SCIP_CONS ** addedconss
Definition: struct_cons.h:108
SCIP_RETCODE SCIPlpFlush(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue)
Definition: lp.c:8578
SCIP_NODE * SCIPtreeGetLowerboundNode(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7198
SCIP_Real SCIPsetFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6140
int nlpicols
Definition: struct_lp.h:302
SCIP_Bool SCIPsetIsFeasEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6351
SCIP_RETCODE SCIPlpRemoveAllObsoletes(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter)
Definition: lp.c:15389
SCIP_Longint nlps
Definition: struct_stat.h:176
methods for implications, variable bounds, and cliques
int SCIPnodepqCompare(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node1, SCIP_NODE *node2)
Definition: nodesel.c:251
SCIP_Longint focuslpstateforklpcount
Definition: struct_tree.h:206
#define SCIP_MAXSTRLEN
Definition: def.h:274
static SCIP_RETCODE pseudoforkCreate(SCIP_PSEUDOFORK **pseudofork, BMS_BLKMEM *blkmem, SCIP_TREE *tree, SCIP_LP *lp)
Definition: tree.c:431
int * pathnlprows
Definition: struct_tree.h:199
SCIP_Real rootlowerbound
Definition: struct_stat.h:119
SCIP_RETCODE SCIPtreeSetNodesel(SCIP_TREE *tree, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_NODESEL *nodesel)
Definition: tree.c:5027
unsigned int active
Definition: struct_tree.h:153
int validdepth
Definition: struct_cons.h:60
static SCIP_RETCODE treeEnsurePathMem(SCIP_TREE *tree, SCIP_SET *set, int num)
Definition: tree.c:86
internal methods for clocks and timing issues
SCIPInterval pow(const SCIPInterval &x, const SCIPInterval &y)
SCIP_REOPTTYPE SCIPnodeGetReopttype(SCIP_NODE *node)
Definition: tree.c:7387
SCIP_BRANCHDIR * divebdchgdirs[2]
Definition: struct_tree.h:195
SCIP_BOUNDCHG * boundchgs
Definition: struct_var.h:125
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6076
static long bound
int SCIPtreeGetProbingDepth(SCIP_TREE *tree)
Definition: tree.c:8335
SCIP_RETCODE SCIPnodeDelCons(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_CONS *cons)
Definition: tree.c:1608
SCIP_NODE * SCIPnodesGetCommonAncestor(SCIP_NODE *node1, SCIP_NODE *node2)
Definition: tree.c:8071
SCIP_RETCODE SCIPnodeAddBoundinfer(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype, SCIP_CONS *infercons, SCIP_PROP *inferprop, int inferinfo, SCIP_Bool probingchange)
Definition: tree.c:1769
SCIP_EXPORT SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:17726
void SCIProwCapture(SCIP_ROW *row)
Definition: lp.c:5246
SCIP_PROBINGNODE * probingnode
Definition: struct_tree.h:139
SCIP_RETCODE SCIPtreeCreate(SCIP_TREE **tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_NODESEL *nodesel)
Definition: tree.c:4701
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:7347
unsigned int repropsubtreemark
Definition: struct_tree.h:156
SCIP_RETCODE SCIPvarAddHoleGlobal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_Real left, SCIP_Real right, SCIP_Bool *added)
Definition: var.c:8590
SCIP_RETCODE SCIPtreeBacktrackProbing(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_LP *lp, SCIP_PRIMAL *primal, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_CLIQUETABLE *cliquetable, int probingdepth)
Definition: tree.c:6746
interface methods for specific LP solvers
SCIP_NODE * SCIPtreeGetBestNode(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7126
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5813
SCIP_Longint nactiveconssadded
Definition: struct_stat.h:115
int naddedrows
Definition: struct_tree.h:105
SCIP_Bool probingchange
Definition: struct_tree.h:171
SCIP_NODE * SCIPtreeGetProbingRoot(SCIP_TREE *tree)
Definition: tree.c:8202
SCIP_NODE * SCIPtreeGetBestChild(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7062
SCIP_Real * divebdchgvals[2]
Definition: struct_tree.h:196
int SCIPnodepqLen(const SCIP_NODEPQ *nodepq)
Definition: nodesel.c:558
SCIP_VAR * var
Definition: struct_tree.h:165
SCIP_RETCODE SCIPlpFreeState(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
Definition: lp.c:9991
int nlpirows
Definition: struct_lp.h:305
SCIP_Real newbound
Definition: struct_tree.h:166
unsigned int nboundchgs
Definition: struct_var.h:123
SCIP_EXPORT SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:16918
unsigned int lpwasdualchecked
Definition: struct_tree.h:111
SCIP_EXPORT SCIP_VAR ** SCIPvarGetImplVars(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17647
unsigned int cutoff
Definition: struct_tree.h:154
SCIP_Longint nholechgs
Definition: struct_stat.h:107
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:8137
static SCIP_RETCODE subrootFree(SCIP_SUBROOT **subroot, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp)
Definition: tree.c:671
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:350
static void forkCaptureLPIState(SCIP_FORK *fork, int nuses)
Definition: tree.c:157
SCIP_Bool probdiverelaxstored
Definition: struct_tree.h:240
unsigned int nodetype
Definition: struct_tree.h:152
#define FALSE
Definition: def.h:73
SCIP_LPINORMS * probinglpinorms
Definition: struct_tree.h:203
static SCIP_RETCODE focusnodeToLeaf(BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_NODE *lpstatefork, SCIP_Real cutoffbound)
Definition: tree.c:3816
static void treeRemoveSibling(SCIP_TREE *tree, SCIP_NODE *sibling)
Definition: tree.c:704
SCIP_Bool SCIPsetIsFeasIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6494
SCIP_RETCODE SCIPdomchgUndo(SCIP_DOMCHG *domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue)
Definition: var.c:1274
SCIP_EXPORT SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17200
SCIP_Bool solved
Definition: struct_lp.h:352
SCIP_Bool probinglpwasdualchecked
Definition: struct_tree.h:239
struct SCIP_LPiNorms SCIP_LPINORMS
Definition: type_lpi.h:98
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:280
SCIP_Longint ncreatednodes
Definition: struct_stat.h:81
unsigned int reprop
Definition: struct_tree.h:155
SCIP_EXPORT int SCIPdomchgGetNBoundchgs(SCIP_DOMCHG *domchg)
Definition: var.c:16685
int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7357
SCIP_Bool dualchecked
Definition: struct_lp.h:356
SCIP_Bool sbprobing
Definition: struct_tree.h:235
SCIP_EXPORT SCIP_RETCODE SCIPvarGetProbvarBound(SCIP_VAR **var, SCIP_Real *bound, SCIP_BOUNDTYPE *boundtype)
Definition: var.c:11963
SCIP_Bool SCIPsetIsZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6065
SCIP_RETCODE SCIPeventqueueDelay(SCIP_EVENTQUEUE *eventqueue)
Definition: event.c:2389
SCIP_EXPORT SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16903
#define TRUE
Definition: def.h:72
SCIP_NODE * SCIPnodepqGetLowerboundNode(SCIP_NODEPQ *nodepq, SCIP_SET *set)
Definition: nodesel.c:592
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPtreeLoadLPState(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: tree.c:3475
unsigned int enabled
Definition: struct_cons.h:82
SCIP_RETCODE SCIPlpGetState(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
Definition: lp.c:9925
SCIP_Longint nbacktracks
Definition: struct_stat.h:87
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8307
SCIP_Real SCIPnodepqGetLowerboundSum(SCIP_NODEPQ *nodepq)
Definition: nodesel.c:616
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5503
SCIP_Real estimate
Definition: struct_tree.h:136
SCIP_FORK * fork
Definition: struct_tree.h:145
SCIP_NODE * SCIPtreeGetFocusNode(SCIP_TREE *tree)
Definition: tree.c:8215
SCIP_EXPORT SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:17025
#define BMSallocMemoryArray(ptr, num)
Definition: memory.h:113
SCIP_Bool probinglpwasflushed
Definition: struct_tree.h:228
static SCIP_RETCODE treeBacktrackProbing(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_LP *lp, SCIP_PRIMAL *primal, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_CLIQUETABLE *cliquetable, int probingdepth)
Definition: tree.c:6600
SCIP_Real SCIPvarGetAvgInferences(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:15555
SCIP_EXPORT void SCIPvarMarkNotDeletable(SCIP_VAR *var)
Definition: var.c:16982
SCIP_RETCODE SCIPlpSolveAndEval(SCIP_LP *lp, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_PROB *prob, SCIP_Longint itlim, SCIP_Bool limitresolveiters, SCIP_Bool aging, SCIP_Bool keepsol, SCIP_Bool *lperror)
Definition: lp.c:12222
SCIP_EXPORT SCIP_Real * SCIPvarGetImplBounds(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17676
void SCIPnodeSetReoptID(SCIP_NODE *node, unsigned int id)
Definition: tree.c:7428
SCIP_ROW ** SCIPlpGetRows(SCIP_LP *lp)
Definition: lp.c:17239
#define SCIPdebugMessage
Definition: pub_message.h:77
SCIP_COL ** addedcols
Definition: struct_tree.h:100
SCIP_EXPORT SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16857
int firstnewcol
Definition: struct_lp.h:317
SCIP_RETCODE SCIPlpCleanupAll(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_Bool root)
Definition: lp.c:15597
void SCIPrelaxationSetSolValid(SCIP_RELAXATION *relaxation, SCIP_Bool isvalid, SCIP_Bool includeslp)
Definition: relax.c:672
SCIP_Bool probingsolvedlp
Definition: struct_tree.h:232
SCIP_Bool SCIPrelaxationIsSolValid(SCIP_RELAXATION *relaxation)
Definition: relax.c:685
SCIP_RETCODE SCIPlpSetNorms(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPINORMS *lpinorms)
Definition: lp.c:10032
unsigned int domchgtype
Definition: struct_var.h:142
SCIP_NODE ** siblings
Definition: struct_tree.h:191
methods for creating output for visualization tools (VBC, BAK)
int divebdchgsize[2]
Definition: struct_tree.h:207
static SCIP_RETCODE treeAddChild(SCIP_TREE *tree, SCIP_SET *set, SCIP_NODE *child, SCIP_Real nodeselprio)
Definition: tree.c:730
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
Definition: tree.c:7367
SCIP_Bool SCIPnodeIsPropagatedAgain(SCIP_NODE *node)
Definition: tree.c:8112
int SCIPvarGetConflictingBdchgDepth(SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_Real bound)
Definition: var.c:16366
#define BMSfreeMemory(ptr)
Definition: memory.h:135
SCIP_RETCODE SCIPlpEndProbing(SCIP_LP *lp)
Definition: lp.c:16037
SCIP_NODESEL * SCIPnodepqGetNodesel(SCIP_NODEPQ *nodepq)
Definition: nodesel.c:193
void SCIPvarAdjustLb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *lb)
Definition: var.c:6235
SCIP_JUNCTION junction
Definition: struct_tree.h:143
SCIP_NODE * SCIPnodeGetParent(SCIP_NODE *node)
Definition: tree.c:7627
static void treeChildrenToSiblings(SCIP_TREE *tree)
Definition: tree.c:4204
unsigned int lpwasdualfeas
Definition: struct_tree.h:110
SCIP_CONS ** disabledconss
Definition: struct_cons.h:109
int childrensize
Definition: struct_tree.h:211
static SCIP_RETCODE probingnodeFree(SCIP_PROBINGNODE **probingnode, BMS_BLKMEM *blkmem, SCIP_LP *lp)
Definition: tree.c:370
SCIP_LPSOLSTAT SCIPlpGetSolstat(SCIP_LP *lp)
Definition: lp.c:12902
SCIP_VISUAL * visual
Definition: struct_stat.h:168
SCIP_Real SCIPsetCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6151
unsigned int reoptid
Definition: struct_tree.h:157
int pathsize
Definition: struct_tree.h:216
static SCIP_RETCODE treeCreateProbingNode(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp)
Definition: tree.c:6263
#define SCIPstatIncrement(stat, set, field)
Definition: stat.h:232
int npendingbdchgs
Definition: struct_tree.h:210
internal methods for LP management
SCIP_Bool SCIPtreeIsPathComplete(SCIP_TREE *tree)
Definition: tree.c:8172
void SCIPvisualLowerbound(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_Real lowerbound)
Definition: visual.c:758
SCIP_Longint number
Definition: struct_tree.h:134
SCIP_Bool SCIPtreeIsFocusNodeLPConstructed(SCIP_TREE *tree)
Definition: tree.c:8270
unsigned int SCIPnodeGetReoptID(SCIP_NODE *node)
Definition: tree.c:7418
SCIP_Bool primalchecked
Definition: struct_lp.h:354
SCIP_ROW ** rows
Definition: struct_tree.h:118
internal methods for collecting primal CIP solutions and primal informations
void SCIPgmlWriteOpening(FILE *file, SCIP_Bool directed)
Definition: misc.c:671
void SCIPgmlWriteArc(FILE *file, unsigned int source, unsigned int target, const char *label, const char *color)
Definition: misc.c:627
int SCIPlpGetNCols(SCIP_LP *lp)
Definition: lp.c:17229
void SCIPnodeGetAncestorBranchings(SCIP_NODE *node, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:7701
unsigned int lpwasprimchecked
Definition: struct_tree.h:109
SCIP_DECL_SORTPTRCOMP(SCIPnodeCompLowerbound)
Definition: tree.c:142
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6047
int nlpistateref
Definition: struct_tree.h:106
internal methods for propagators
SCIP_EXPORT SCIP_Real SCIPvarGetRootSol(SCIP_VAR *var)
Definition: var.c:12842
SCIP_Bool SCIPclockIsRunning(SCIP_CLOCK *clck)
Definition: clock.c:417
int pendingbdchgssize
Definition: struct_tree.h:209
SCIP_RETCODE SCIPnodepqInsert(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
Definition: nodesel.c:267
int SCIPtreeGetFocusDepth(SCIP_TREE *tree)
Definition: tree.c:8232
SCIP_Real * siblingsprio
Definition: struct_tree.h:193
static SCIP_RETCODE pseudoforkAddLP(SCIP_NODE *pseudofork, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_LP *lp)
Definition: tree.c:3229
enum SCIP_BranchDir SCIP_BRANCHDIR
Definition: type_history.h:39
SCIP_LPISTATE * lpistate
Definition: struct_tree.h:102
int SCIPtreeGetNChildren(SCIP_TREE *tree)
Definition: tree.c:8132
int SCIPnodeGetNAddedConss(SCIP_NODE *node)
Definition: tree.c:1668
SCIP_NODE * SCIPtreeGetBestLeaf(SCIP_TREE *tree)
Definition: tree.c:7116
static SCIP_RETCODE nodeRepropagate(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CONFLICT *conflict, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *cutoff)
Definition: tree.c:1274
SCIP_RETCODE SCIPnodeCutoff(SCIP_NODE *node, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_REOPT *reopt, SCIP_LP *lp, BMS_BLKMEM *blkmem)
Definition: tree.c:1146
unsigned int lpwasprimchecked
Definition: struct_tree.h:126
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5993
SCIP_Bool probinglpwassolved
Definition: struct_tree.h:229
SCIP_RETCODE SCIPlpCleanupNew(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_Bool root)
Definition: lp.c:15558
SCIP_Real SCIPtreeCalcNodeselPriority(SCIP_TREE *tree, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var, SCIP_BRANCHDIR branchdir, SCIP_Real targetvalue)
Definition: tree.c:5140
SCIP_Bool probingloadlpistate
Definition: struct_tree.h:230
SCIP_DOMCHG * domchg
Definition: struct_tree.h:150
static SCIP_RETCODE subrootConstructLP(SCIP_NODE *subroot, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_LP *lp)
Definition: tree.c:3139
SCIP_EXPORT SCIP_Bool SCIPboundchgIsRedundant(SCIP_BOUNDCHG *boundchg)
Definition: var.c:16675
SCIP_Bool SCIPtreeProbing(SCIP_TREE *tree)
Definition: tree.c:8189
SCIP_RETCODE SCIPprobPerformVarDeletions(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand)
Definition: prob.c:1059
SCIP_RETCODE SCIPlpSetState(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LPISTATE *lpistate, SCIP_Bool wasprimfeas, SCIP_Bool wasprimchecked, SCIP_Bool wasdualfeas, SCIP_Bool wasdualchecked)
Definition: lp.c:9949
int nsiblings
Definition: struct_tree.h:214
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
Definition: misc.c:10571
SCIP_RETCODE SCIPvisualNewChild(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:256
SCIP_EXPORT SCIP_BOUNDCHG * SCIPdomchgGetBoundchg(SCIP_DOMCHG *domchg, int pos)
Definition: var.c:16693
int cutoffdepth
Definition: struct_tree.h:220
SCIP_Real * childrenprio
Definition: struct_tree.h:192
void SCIPnodeUpdateLowerbound(SCIP_NODE *node, SCIP_STAT *stat, SCIP_SET *set, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_Real newbound)
Definition: tree.c:2299
SCIP_Real SCIPvarGetPseudocost(SCIP_VAR *var, SCIP_STAT *stat, SCIP_Real solvaldelta)
Definition: var.c:13965
SCIP_EXPORT SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
Definition: var.c:12749
int SCIPlpGetNNewcols(SCIP_LP *lp)
Definition: lp.c:17270
#define BMSduplicateBlockMemoryArray(mem, ptr, source, num)
Definition: memory.h:451
SCIP_SUBROOT * subroot
Definition: struct_tree.h:146
SCIP_RETCODE SCIPconssetchgApply(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, int depth, SCIP_Bool focusnode)
Definition: cons.c:5535
SCIP_Bool probingobjchanged
Definition: struct_tree.h:234
unsigned int reopttype
Definition: struct_tree.h:158
SCIP_DOMCHG * SCIPnodeGetDomchg(SCIP_NODE *node)
Definition: tree.c:7442
SCIP_RETCODE SCIPlpStartProbing(SCIP_LP *lp)
Definition: lp.c:16022
SCIP_EXPORT const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16738
SCIP_EXPORT SCIP_Bool SCIPvarIsDeletable(SCIP_VAR *var)
Definition: var.c:17015
SCIP_RETCODE SCIPdomchgApplyGlobal(SCIP_DOMCHG *domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *cutoff)
Definition: var.c:1309
int repropsubtreecount
Definition: struct_tree.h:222
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:137
static SCIP_RETCODE forkReleaseLPIState(SCIP_FORK *fork, BMS_BLKMEM *blkmem, SCIP_LP *lp)
Definition: tree.c:172
SCIP_EXPORT SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:16929
static void treeFindSwitchForks(SCIP_TREE *tree, SCIP_NODE *node, SCIP_NODE **commonfork, SCIP_NODE **newlpfork, SCIP_NODE **newlpstatefork, SCIP_NODE **newsubroot, SCIP_Bool *cutoff)
Definition: tree.c:2702
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
void SCIPmessagePrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, const char *formatstr,...)
Definition: message.c:668
SCIP_RETCODE SCIPdomchgMakeStatic(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:1087
static SCIP_RETCODE pseudoforkFree(SCIP_PSEUDOFORK **pseudofork, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp)
Definition: tree.c:484
SCIP_RETCODE SCIPdomchgFree(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:986
SCIP_Longint lpcount
Definition: struct_stat.h:174
SCIP_EXPORT int SCIPvarGetNImpls(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17630
SCIP_RETCODE SCIPvarChgObj(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_Real newobj)
Definition: var.c:5984
static SCIP_RETCODE treeAddPendingBdchg(SCIP_TREE *tree, SCIP_SET *set, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype, SCIP_CONS *infercons, SCIP_PROP *inferprop, int inferinfo, SCIP_Bool probingchange)
Definition: tree.c:1682
SCIP_RETCODE SCIPlpAddCol(SCIP_LP *lp, SCIP_SET *set, SCIP_COL *col, int depth)
Definition: lp.c:9342
int siblingssize
Definition: struct_tree.h:213
SCIP_Bool SCIPtreeInRepropagation(SCIP_TREE *tree)
Definition: tree.c:8280
SCIP_RETCODE SCIPnodeFocus(SCIP_NODE **node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *cutoff, SCIP_Bool postponed, SCIP_Bool exitsolve)
Definition: tree.c:4241
#define SCIPdebugCheckInference(blkmem, set, node, var, newbound, boundtype)
Definition: debug.h:247
SCIP_EXPORT int SCIPvarGetBranchPriority(SCIP_VAR *var)
Definition: var.c:17524
SCIP_Bool SCIPsetIsRelEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6830
SCIP_RETCODE SCIPvarRelease(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:2782
SCIP_RETCODE SCIPlpShrinkCols(SCIP_LP *lp, SCIP_SET *set, int newncols)
Definition: lp.c:9525
SCIP_COL ** SCIPlpGetCols(SCIP_LP *lp)
Definition: lp.c:17219
void SCIPnodeSetReopttype(SCIP_NODE *node, SCIP_REOPTTYPE reopttype)
Definition: tree.c:7397
SCIP_LPISTATE * probinglpistate
Definition: struct_tree.h:201
SCIP_RETCODE SCIPnodepqSetNodesel(SCIP_NODEPQ **nodepq, SCIP_SET *set, SCIP_NODESEL *nodesel)
Definition: nodesel.c:203
void SCIPnodeMarkPropagated(SCIP_NODE *node, SCIP_TREE *tree)
Definition: tree.c:1232
static SCIP_RETCODE focusnodeToPseudofork(BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CLIQUETABLE *cliquetable)
Definition: tree.c:3882
SCIP_NODE ** path
Definition: struct_tree.h:179
int repropdepth
Definition: struct_tree.h:221
SCIP_NODE * focuslpstatefork
Definition: struct_tree.h:187
const char * SCIPpropGetName(SCIP_PROP *prop)
Definition: prop.c:931
void SCIPlpMarkSize(SCIP_LP *lp)
Definition: lp.c:9682
SCIP_DOMCHGDYN domchgdyn
Definition: struct_var.h:155
SCIP_NODE * SCIPtreeGetBestSibling(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7089
SCIP_Real SCIPsetFeasCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6529
struct SCIP_LPiState SCIP_LPISTATE
Definition: type_lpi.h:97
static void treeCheckPath(SCIP_TREE *tree)
Definition: tree.c:3275
SCIP_Real cutoffbound
Definition: struct_lp.h:274
SCIP_RETCODE SCIPlpAddRow(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_ROW *row, int depth)
Definition: lp.c:9401
SCIP_RETCODE SCIPtreeLoadLP(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_LP *lp, SCIP_Bool *initroot)
Definition: tree.c:3347
SCIP_EXPORT SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
enum SCIP_ReoptType SCIP_REOPTTYPE
Definition: type_reopt.h:58
SCIP_Bool isrelax
Definition: struct_lp.h:359
SCIP_RETCODE SCIPvarSetRelaxSol(SCIP_VAR *var, SCIP_SET *set, SCIP_RELAXATION *relaxation, SCIP_Real solval, SCIP_Bool updateobj)
Definition: var.c:13352
int appliedeffectiverootdepth
Definition: struct_tree.h:218
static SCIP_RETCODE focusnodeToFork(BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CLIQUETABLE *cliquetable)
Definition: tree.c:3933
SCIP_Bool SCIPsetIsRelGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6896
static void subrootCaptureLPIState(SCIP_SUBROOT *subroot, int nuses)
Definition: tree.c:196
internal methods for node selectors and node priority queues
SCIP_Real * probdiverelaxsol
Definition: struct_tree.h:205
static SCIP_RETCODE treeEnsureChildrenMem(SCIP_TREE *tree, SCIP_SET *set, int num)
Definition: tree.c:61
#define SCIP_PROPTIMING_ALWAYS
Definition: type_timing.h:64
int correctlpdepth
Definition: struct_tree.h:219
SCIP_RETCODE SCIPnodePrintAncestorBranchings(SCIP_NODE *node, FILE *file)
Definition: tree.c:7946
SCIP_SIBLING sibling
Definition: struct_tree.h:140
SCIP_NODEPQ * leaves
Definition: struct_tree.h:178
internal methods for global SCIP settings
internal methods for storing conflicts
SCIP * scip
Definition: struct_cons.h:40
#define SCIP_CALL(x)
Definition: def.h:365
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6439
int SCIPlpGetNRows(SCIP_LP *lp)
Definition: lp.c:17249
int SCIPnodeselCompare(SCIP_NODESEL *nodesel, SCIP_SET *set, SCIP_NODE *node1, SCIP_NODE *node2)
Definition: nodesel.c:1021
SCIP_RETCODE SCIPconsDisable(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:6832
SCIP_Bool resolvelperror
Definition: struct_lp.h:368
SCIP_Bool probinglpwasprimchecked
Definition: struct_tree.h:237
SCIP_COL ** cols
Definition: struct_tree.h:117
internal methods for relaxators
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5975
SCIP_CONS * infercons
Definition: struct_tree.h:168
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:245
unsigned int nboundchgs
Definition: struct_var.h:141
SCIP_Real SCIPlpGetObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:12918
SCIP_LPI * lpi
Definition: struct_lp.h:282
SCIP_Longint ncreatednodesrun
Definition: struct_stat.h:82
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6395
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:246
SCIP_BOUNDTYPE boundtype
Definition: struct_tree.h:167
SCIP_RETCODE SCIProwRelease(SCIP_ROW **row, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp)
Definition: lp.c:5259
SCIP_RETCODE SCIPnodepqFree(SCIP_NODEPQ **nodepq, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_LP *lp)
Definition: nodesel.c:130
SCIP_Real SCIPtreeGetAvgLowerbound(SCIP_TREE *tree, SCIP_Real cutoffbound)
Definition: tree.c:7250
SCIP_LPINORMS * lpinorms
Definition: struct_tree.h:49
void SCIPvarAdjustBd(SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_Real *bd)
Definition: var.c:6269
void SCIPtreeClearDiveBoundChanges(SCIP_TREE *tree)
Definition: tree.c:6248
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:454
data structures and methods for collecting reoptimization information
internal methods for problem variables
void SCIPnodeSetEstimate(SCIP_NODE *node, SCIP_SET *set, SCIP_Real newestimate)
Definition: tree.c:2395
int SCIPnodeGetNDualBndchgs(SCIP_NODE *node)
Definition: tree.c:7504
static SCIP_RETCODE nodeReleaseParent(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_LP *lp)
Definition: tree.c:836
unsigned int vartype
Definition: struct_var.h:273
unsigned int boundchgtype
Definition: struct_var.h:91
void SCIPnodePropagateAgain(SCIP_NODE *node, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: tree.c:1206
SCIP_VAR * var
Definition: struct_var.h:90
SCIP_INFERENCEDATA inferencedata
Definition: struct_var.h:88
SCIP_RETCODE SCIPlpClear(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter)
Definition: lp.c:9663
SCIP_Bool lpwasdualfeas
Definition: struct_tree.h:59
static SCIP_RETCODE treeUpdatePathLPSize(SCIP_TREE *tree, int startdepth)
Definition: tree.c:2594
int SCIPtreeGetEffectiveRootDepth(SCIP_TREE *tree)
Definition: tree.c:8346
#define SCIP_Bool
Definition: def.h:70
void SCIPlpRecomputeLocalAndGlobalPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13001
static SCIP_RETCODE treeSwitchPath(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CONFLICT *conflict, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_NODE *fork, SCIP_NODE *focusnode, SCIP_Bool *cutoff)
Definition: tree.c:3002
void SCIPvarCapture(SCIP_VAR *var)
Definition: var.c:2770
SCIP_RETCODE SCIPreoptCheckCutoff(SCIP_REOPT *reopt, SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_NODE *node, SCIP_EVENTTYPE eventtype, SCIP_LP *lp, SCIP_LPSOLSTAT lpsolstat, SCIP_Bool isrootnode, SCIP_Bool isfocusnode, SCIP_Real lowerbound, int effectiverootdepth)
Definition: reopt.c:5973
#define BMSallocBlockMemoryArray(mem, ptr, num)
Definition: memory.h:443
int arraypos
Definition: struct_tree.h:72
char * name
Definition: struct_cons.h:43
SCIP_Bool lpwasprimchecked
Definition: struct_tree.h:58
int SCIPsetCalcPathGrowSize(SCIP_SET *set, int num)
Definition: set.c:5521
SCIP_Bool focuslpconstructed
Definition: struct_tree.h:226
SCIP_EXPORT SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
Definition: var.c:11712
unsigned int depth
Definition: struct_tree.h:151
SCIP_NODE ** children
Definition: struct_tree.h:190
#define MAXREPROPMARK
Definition: tree.c:52
SCIP_VAR ** origobjvars
Definition: struct_tree.h:54
SCIP_Bool SCIPnodeIsActive(SCIP_NODE *node)
Definition: tree.c:8102
SCIP_Longint nearlybacktracks
Definition: struct_stat.h:85
SCIP_RETCODE SCIPtreeStartProbing(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp, SCIP_RELAXATION *relaxation, SCIP_PROB *transprob, SCIP_Bool strongbranching)
Definition: tree.c:6347
SCIP_RETCODE SCIPtreeCreateRoot(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: tree.c:4888
SCIP_EXPORT SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17362
static SCIP_RETCODE nodeAssignParent(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_TREE *tree, SCIP_NODE *parent, SCIP_Real nodeselprio)
Definition: tree.c:781
SCIP_ROW ** SCIPlpGetNewrows(SCIP_LP *lp)
Definition: lp.c:17281
void SCIPnodeGetAncestorBranchingsPart(SCIP_NODE *node, SCIP_NODE *parent, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:7738
SCIP_Real lastlowerbound
Definition: struct_stat.h:137
#define ARRAYGROWTH
Definition: tree.c:6192
SCIP_RETCODE SCIPnodepqRemove(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
Definition: nodesel.c:511
SCIP_Bool divingobjchg
Definition: struct_lp.h:366
void SCIPtreeGetDiveBoundChangeData(SCIP_TREE *tree, SCIP_VAR ***variables, SCIP_BRANCHDIR **directions, SCIP_Real **values, int *ndivebdchgs, SCIP_Bool preferred)
Definition: tree.c:6225
unsigned int lpwasdualchecked
Definition: struct_tree.h:128
static SCIP_RETCODE focusnodeCleanupVars(BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool inlp)
Definition: tree.c:3675
#define BMSfreeBlockMemoryArray(mem, ptr, num)
Definition: memory.h:456
SCIP_Bool SCIPlpDivingObjChanged(SCIP_LP *lp)
Definition: lp.c:17484
SCIP_Longint nrepropcutoffs
Definition: struct_stat.h:91
SCIP_EXPORT SCIP_Real SCIPvarGetWorstBoundLocal(SCIP_VAR *var)
Definition: var.c:17451
int probingsumchgdobjs
Definition: struct_tree.h:223
static SCIP_RETCODE probingnodeCreate(SCIP_PROBINGNODE **probingnode, BMS_BLKMEM *blkmem, SCIP_LP *lp)
Definition: tree.c:288
SCIP_RETCODE SCIPnodepqCreate(SCIP_NODEPQ **nodepq, SCIP_SET *set, SCIP_NODESEL *nodesel)
Definition: nodesel.c:95
static SCIP_RETCODE forkCreate(SCIP_FORK **fork, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: tree.c:514
SCIP_RETCODE SCIPboundchgApply(SCIP_BOUNDCHG *boundchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, int depth, int pos, SCIP_Bool *cutoff)
Definition: var.c:554
SCIP_Bool lpwasprimfeas
Definition: struct_tree.h:57
#define MIN(x, y)
Definition: def.h:223
methods for debugging
SCIP_Bool * SCIPcliqueGetValues(SCIP_CLIQUE *clique)
Definition: implics.c:3355
SCIP_RETCODE SCIPnodeAddHolechg(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Real left, SCIP_Real right, SCIP_Bool probingchange, SCIP_Bool *added)
Definition: tree.c:2171
SCIP_ROW ** addedrows
Definition: struct_tree.h:91
#define SCIPsetDebugMsg
Definition: set.h:1720
void SCIPgmlWriteClosing(FILE *file)
Definition: misc.c:687
#define SCIP_EVENTTYPE_NODEINFEASIBLE
Definition: type_event.h:79
SCIP_Bool SCIPsetIsRelLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6852
SCIP_NODE * SCIPnodepqFirst(const SCIP_NODEPQ *nodepq)
Definition: nodesel.c:532
int * pathnlpcols
Definition: struct_tree.h:197
SCIP_Bool SCIPprobAllColsInLP(SCIP_PROB *prob, SCIP_SET *set, SCIP_LP *lp)
Definition: prob.c:2267
SCIP_RETCODE SCIPconshdlrsResetPropagationStatus(SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_CONSHDLR **conshdlrs, int nconshdlrs)
Definition: cons.c:7855
SCIP_RETCODE SCIPpropagateDomains(BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CONFLICT *conflict, SCIP_CLIQUETABLE *cliquetable, int depth, int maxproprounds, SCIP_PROPTIMING timingmask, SCIP_Bool *cutoff)
Definition: solve.c:636
SCIP_Bool probinglpwasrelax
Definition: struct_tree.h:231
SCIP_Bool SCIPtreeHasCurrentNodeLP(SCIP_TREE *tree)
Definition: tree.c:8324
SCIP_RETCODE SCIPvisualUpdateChild(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:331
SCIP_Real SCIPnodeGetEstimate(SCIP_NODE *node)
Definition: tree.c:7377
SCIP_RETCODE SCIPnodeCaptureLPIState(SCIP_NODE *node, int nuses)
Definition: tree.c:235
void SCIPlpSetSizeMark(SCIP_LP *lp, int nrows, int ncols)
Definition: lp.c:9694
static SCIP_RETCODE forkFree(SCIP_FORK **fork, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp)
Definition: tree.c:577
void SCIPnodeGetBdChgsAfterDual(SCIP_NODE *node, SCIP_VAR **vars, SCIP_Real *varbounds, SCIP_BOUNDTYPE *varboundtypes, int start, int *nbranchvars, int branchvarssize)
Definition: tree.c:7867
SCIP_NODESEL * SCIPtreeGetNodesel(SCIP_TREE *tree)
Definition: tree.c:5017
SCIP_Real SCIPvarGetRelaxSol(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:13413
SCIP_EXPORT SCIP_CLIQUE ** SCIPvarGetCliques(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17715
SCIP_Bool cutoffdelayed
Definition: struct_tree.h:227
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6373
SCIP_Bool probdiverelaxincludeslp
Definition: struct_tree.h:241
SCIP_EXPORT SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17408
SCIP_RETCODE SCIPlpGetNorms(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
Definition: lp.c:10008
#define SCIP_MAXTREEDEPTH
Definition: def.h:301
SCIP_RETCODE SCIPnodeReleaseLPIState(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_LP *lp)
Definition: tree.c:263
SCIP_CONSSETCHG * conssetchg
Definition: struct_tree.h:149
#define SCIP_REAL_MAX
Definition: def.h:165
int ndivebdchanges[2]
Definition: struct_tree.h:208
SCIP_NODE * probingroot
Definition: struct_tree.h:189
SCIP_RETCODE SCIPtreeFree(SCIP_TREE **tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: tree.c:4780
SCIP_Bool SCIPconsIsGlobal(SCIP_CONS *cons)
Definition: cons.c:8305
SCIP_Real SCIPlpGetModifiedPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob, SCIP_VAR *var, SCIP_Real oldbound, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype)
Definition: lp.c:13131
SCIP_Real * r
Definition: circlepacking.c:50
enum SCIP_NodeType SCIP_NODETYPE
Definition: type_tree.h:44
SCIP_Real newbound
Definition: struct_var.h:84
#define SCIP_REAL_MIN
Definition: def.h:166
static SCIP_RETCODE nodeToLeaf(SCIP_NODE **node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_NODE *lpstatefork, SCIP_Real cutoffbound)
Definition: tree.c:3594
SCIP_EXPORT SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17418
SCIP_Real SCIPsetFeasFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6518
#define SCIP_LONGINT_FORMAT
Definition: def.h:156
SCIP_DOMCHGBOUND domchgbound
Definition: struct_var.h:153
SCIP_RETCODE SCIPvarChgBdGlobal(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype)
Definition: var.c:7236
int SCIPtreeGetNSiblings(SCIP_TREE *tree)
Definition: tree.c:8142
const char * SCIPnodeselGetName(SCIP_NODESEL *nodesel)
Definition: nodesel.c:1038
#define MAX(x, y)
Definition: def.h:222
SCIP_Bool SCIPtreeProbingObjChanged(SCIP_TREE *tree)
Definition: tree.c:8368
SCIP_RETCODE SCIPtreeBranchVarNary(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Real val, int n, SCIP_Real minwidth, SCIP_Real widthfactor, int *nchildren)
Definition: tree.c:5822
static void treeNextRepropsubtreecount(SCIP_TREE *tree)
Definition: tree.c:1262
SCIP_NODE * parent
Definition: struct_tree.h:148
SCIP_Real SCIPnodepqGetLowerbound(SCIP_NODEPQ *nodepq, SCIP_SET *set)
Definition: nodesel.c:569
SCIP_LPISTATE * lpistate
Definition: struct_tree.h:48
SCIP_RETCODE SCIPlpSetCutoffbound(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob, SCIP_Real cutoffbound)
Definition: lp.c:10076
SCIP_NODE * SCIPtreeGetRootNode(SCIP_TREE *tree)
Definition: tree.c:8357
internal methods for main solving loop and node processing
SCIP_RETCODE SCIPconssetchgUndo(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:5622
static SCIP_RETCODE nodeDeactivate(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue)
Definition: tree.c:1494
SCIP_RETCODE SCIPnodeAddBoundchg(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype, SCIP_Bool probingchange)
Definition: tree.c:2021
SCIP_RETCODE SCIPnodeAddHoleinfer(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Real left, SCIP_Real right, SCIP_CONS *infercons, SCIP_PROP *inferprop, int inferinfo, SCIP_Bool probingchange, SCIP_Bool *added)
Definition: tree.c:2050
SCIP_RETCODE SCIPconssetchgAddAddedCons(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons, int depth, SCIP_Bool focusnode, SCIP_Bool active)
Definition: cons.c:5371
SCIP_EXPORT SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17352
SCIP_RETCODE SCIPtreeMarkProbingNodeHasLP(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_LP *lp)
Definition: tree.c:6572
SCIP_NODE * SCIPtreeGetCurrentNode(SCIP_TREE *tree)
Definition: tree.c:8290
SCIP_Bool flushed
Definition: struct_lp.h:351
SCIP_EXPORT SCIP_RETCODE SCIPvarGetProbvarHole(SCIP_VAR **var, SCIP_Real *left, SCIP_Real *right)
Definition: var.c:12056
unsigned int updatedisable
Definition: struct_cons.h:91
int nrows
Definition: struct_lp.h:319
SCIP_NODE * focuslpfork
Definition: struct_tree.h:186
SCIP_Bool SCIPnodesSharePath(SCIP_NODE *node1, SCIP_NODE *node2)
Definition: tree.c:8047
public methods for message output
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10263
SCIP_Real lowerbound
Definition: struct_tree.h:135
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6029
SCIP_Longint nboundchgs
Definition: struct_stat.h:106
SCIP_LPISTATE * lpistate
Definition: struct_tree.h:119
SCIP_RETCODE SCIPnodepqClear(SCIP_NODEPQ *nodepq, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_LP *lp)
Definition: nodesel.c:153
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8076
static SCIP_RETCODE subrootReleaseLPIState(SCIP_SUBROOT *subroot, BMS_BLKMEM *blkmem, SCIP_LP *lp)
Definition: tree.c:212
SCIP_RETCODE SCIPtreeFreePresolvingRoot(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CONFLICT *conflict, SCIP_CONFLICTSTORE *conflictstore, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable)
Definition: tree.c:4974
static SCIP_RETCODE nodeCreate(SCIP_NODE **node, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: tree.c:953
#define SCIP_Real
Definition: def.h:164
void SCIPvisualCutoffNode(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node, SCIP_Bool infeasible)
Definition: visual.c:523
internal methods for problem statistics
SCIP_VAR ** vars
Definition: struct_prob.h:55
void SCIPstatUpdatePrimalDualIntegral(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_Real upperbound, SCIP_Real lowerbound)
Definition: stat.c:402
SCIP_VAR ** divebdchgvars[2]
Definition: struct_tree.h:194
SCIP_RETCODE SCIPdomchgApply(SCIP_DOMCHG *domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, int depth, SCIP_Bool *cutoff)
Definition: var.c:1225
SCIP_RETCODE SCIPtreeStoreRelaxSol(SCIP_TREE *tree, SCIP_SET *set, SCIP_RELAXATION *relaxation, SCIP_PROB *transprob)
Definition: tree.c:6941
SCIP_Real referencebound
Definition: struct_stat.h:140
SCIP_Bool SCIPsetIsFeasPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6472
SCIP_RETCODE SCIPtreeLoadProbingLPState(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: tree.c:6491
SCIP_Longint nrepropboundchgs
Definition: struct_stat.h:90
void SCIPnodeGetNDomchg(SCIP_NODE *node, int *nbranchings, int *nconsprop, int *nprop)
Definition: tree.c:7452
int effectiverootdepth
Definition: struct_tree.h:217
#define BMSallocMemory(ptr)
Definition: memory.h:109
#define SCIP_INVALID
Definition: def.h:184
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:117
internal methods for constraints and constraint handlers
SCIP_NODE * SCIPtreeGetPrioChild(SCIP_TREE *tree)
Definition: tree.c:7010
SCIP_Bool SCIPlpIsRelax(SCIP_LP *lp)
Definition: lp.c:17424
static SCIP_RETCODE treeApplyPendingBdchgs(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable)
Definition: tree.c:2204
SCIP_RETCODE SCIPnodeAddCons(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_CONS *cons)
Definition: tree.c:1565
SCIP_EXPORT SCIP_BOUNDTYPE * SCIPvarGetImplTypes(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17662
#define SCIP_Longint
Definition: def.h:149
SCIP_Longint nactivatednodes
Definition: struct_stat.h:83
SCIP_Longint nreprops
Definition: struct_stat.h:89
SCIP_COL ** addedcols
Definition: struct_tree.h:90
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6417
void SCIPnodeGetAddedConss(SCIP_NODE *node, SCIP_CONS **addedconss, int *naddedconss, int addedconsssize)
Definition: tree.c:1638
SCIP_RETCODE SCIPnodeUpdateLowerboundLP(SCIP_NODE *node, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_LP *lp)
Definition: tree.c:2343
static SCIP_RETCODE treeNodesToQueue(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp, SCIP_NODE **nodes, int *nnodes, SCIP_NODE *lpstatefork, SCIP_Real cutoffbound)
Definition: tree.c:4170
SCIP_RETCODE SCIPconssetchgMakeGlobal(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_REOPT *reopt)
Definition: cons.c:5708
SCIP_CLOCK * nodeactivationtime
Definition: struct_stat.h:160
SCIP_Real SCIPsetEpsilon(SCIP_SET *set)
Definition: set.c:5835
SCIP_Bool dualfeasible
Definition: struct_lp.h:355
SCIP_EXPORT SCIP_VAR * SCIPboundchgGetVar(SCIP_BOUNDCHG *boundchg)
Definition: var.c:16645
SCIP_RETCODE SCIPconssetchgAddDisabledCons(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:5417
SCIP_EXPORT int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17045
SCIP_Bool probinglpwasprimfeas
Definition: struct_tree.h:236
int nchildren
Definition: struct_tree.h:212
#define nnodes
Definition: gastrans.c:65
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
Definition: tree.c:7337
SCIP_Real SCIPtreeGetLowerbound(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7160
int SCIPcliqueGetNVars(SCIP_CLIQUE *clique)
Definition: implics.c:3333
void SCIPvarAdjustUb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *ub)
Definition: var.c:6252
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:441
int plungedepth
Definition: struct_stat.h:221
SCIP_RETCODE SCIPtreeCutoff(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp, SCIP_Real cutoffbound)
Definition: tree.c:5055
SCIP_RETCODE SCIPtreeRestoreRelaxSol(SCIP_TREE *tree, SCIP_SET *set, SCIP_RELAXATION *relaxation, SCIP_PROB *transprob)
Definition: tree.c:6978
unsigned int lpwasprimfeas
Definition: struct_tree.h:125
SCIP_Bool SCIPeventqueueIsDelayed(SCIP_EVENTQUEUE *eventqueue)
Definition: event.c:2476
SCIP_RETCODE SCIPprobDelVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Bool *deleted)
Definition: prob.c:998
common defines and data types used in all packages of SCIP
SCIP_Longint nnodes
Definition: struct_stat.h:73
SCIP_Real SCIPlpGetModifiedProvedPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_VAR *var, SCIP_Real oldbound, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype)
Definition: lp.c:13171
void SCIPvisualMarkedRepropagateNode(SCIP_VISUAL *visual, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:620
SCIP_PENDINGBDCHG * pendingbdchgs
Definition: struct_tree.h:204
SCIP_Bool probingnodehaslp
Definition: struct_tree.h:225
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:427
SCIP_EXPORT int SCIPvarGetNCliques(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17704
int SCIPtreeGetNLeaves(SCIP_TREE *tree)
Definition: tree.c:8152
SCIP_RETCODE SCIPvarGetProbvarSum(SCIP_VAR **var, SCIP_SET *set, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12141
static void treeRemoveChild(SCIP_TREE *tree, SCIP_NODE *child)
Definition: tree.c:753
SCIP_EXPORT SCIP_BOUNDTYPE SCIPboundchgGetBoundtype(SCIP_BOUNDCHG *boundchg)
Definition: var.c:16665
SCIP_NODE * root
Definition: struct_tree.h:177
SCIP_RETCODE SCIPconshdlrsStorePropagationStatus(SCIP_SET *set, SCIP_CONSHDLR **conshdlrs, int nconshdlrs)
Definition: cons.c:7815
SCIP_COL ** SCIPlpGetNewcols(SCIP_LP *lp)
Definition: lp.c:17259
void SCIPgmlWriteNode(FILE *file, unsigned int id, const char *label, const char *nodetype, const char *fillcolor, const char *bordercolor)
Definition: misc.c:485
SCIP_RETCODE SCIPnodePropagateImplics(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *cutoff)
Definition: tree.c:2409
SCIP_CHILD child
Definition: struct_tree.h:141
unsigned int nchildren
Definition: struct_tree.h:124
static SCIP_RETCODE nodeActivate(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CONFLICT *conflict, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_Bool *cutoff)
Definition: tree.c:1425
#define SCIP_ALLOC(x)
Definition: def.h:376
void SCIPnodeGetAncestorBranchingPath(SCIP_NODE *node, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize, int *nodeswitches, int *nnodes, int nodeswitchsize)
Definition: tree.c:7998
int SCIPtreeGetNNodes(SCIP_TREE *tree)
Definition: tree.c:8162
#define SCIPABORT()
Definition: def.h:337
void SCIPnodeGetParentBranchings(SCIP_NODE *node, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:7637
SCIP_Bool SCIPsetIsRelGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6918
static SCIP_RETCODE focusnodeToDeadend(BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_CLIQUETABLE *cliquetable)
Definition: tree.c:3776
SCIP_LPSOLSTAT lpsolstat
Definition: struct_lp.h:338
SCIP_Longint nprobholechgs
Definition: struct_stat.h:109
SCIP_EXPORT SCIP_BRANCHDIR SCIPvarGetBranchDirection(SCIP_VAR *var)
Definition: var.c:17534
void SCIPchildChgNodeselPrio(SCIP_TREE *tree, SCIP_NODE *child, SCIP_Real priority)
Definition: tree.c:2377
SCIP_PROP * inferprop
Definition: struct_tree.h:169
SCIP_ROW ** addedrows
Definition: struct_tree.h:101
int ncols
Definition: struct_lp.h:313
union SCIP_Node::@10 data
unsigned int lpwasprimfeas
Definition: struct_tree.h:108
void SCIPnodeGetConsProps(SCIP_NODE *node, SCIP_VAR **vars, SCIP_Real *varbounds, SCIP_BOUNDTYPE *varboundtypes, int *nconspropvars, int conspropvarssize)
Definition: tree.c:7779
SCIP_RETCODE SCIPnodeFree(SCIP_NODE **node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_LP *lp)
Definition: tree.c:1027
unsigned int nchildren
Definition: struct_tree.h:107
SCIP_RETCODE SCIPtreeCreateProbingNode(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp)
Definition: tree.c:6412
void SCIPlpUnmarkDivingObjChanged(SCIP_LP *lp)
Definition: lp.c:17505
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
Definition: memory.h:447
SCIP_BOUNDCHG * boundchgs
Definition: struct_var.h:143
SCIP_RETCODE SCIPdomchgAddBoundchg(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_VAR *var, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype, SCIP_BOUNDCHGTYPE boundchgtype, SCIP_Real lpsolval, SCIP_VAR *infervar, SCIP_CONS *infercons, SCIP_PROP *inferprop, int inferinfo, SCIP_BOUNDTYPE inferboundtype)
Definition: var.c:1348
static SCIP_RETCODE focusnodeToJunction(BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_LP *lp)
Definition: tree.c:3845
void SCIPtreeMarkProbingObjChanged(SCIP_TREE *tree)
Definition: tree.c:8379
SCIP_Bool SCIPrelaxationIsLpIncludedForSol(SCIP_RELAXATION *relaxation)
Definition: relax.c:695
SCIP callable library.
SCIP_Bool SCIPsetIsFeasNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6483
SCIP_Bool probinglpwasdualfeas
Definition: struct_tree.h:238
SCIP_NODE * SCIPtreeGetPrioSibling(SCIP_TREE *tree)
Definition: tree.c:7036
SCIP_NODE * focusnode
Definition: struct_tree.h:182
SCIP_Bool focusnodehaslp
Definition: struct_tree.h:224