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-2017 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 email to 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  return SCIP_OKAY;
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  {
2265  /* release the variable */
2266  SCIP_CALL( SCIPvarRelease(&var, blkmem, set, eventqueue, lp) );
2267  continue;
2268  }
2269  }
2270  else
2271  {
2272  SCIP_Real ub;
2273 
2274  assert(tree->pendingbdchgs[i].boundtype == SCIP_BOUNDTYPE_UPPER);
2275  ub = SCIPvarGetUbLocal(var);
2276  if( !SCIPsetIsLT(set, tree->pendingbdchgs[i].newbound, ub) )
2277  {
2278  /* release the variable */
2279  SCIP_CALL( SCIPvarRelease(&var, blkmem, set, eventqueue, lp) );
2280  continue;
2281  }
2282  }
2283 
2284  SCIP_CALL( SCIPnodeAddBoundinfer(tree->pendingbdchgs[i].node, blkmem, set, stat, transprob, origprob, tree, reopt,
2285  lp, branchcand, eventqueue, cliquetable, var, tree->pendingbdchgs[i].newbound, tree->pendingbdchgs[i].boundtype,
2287  tree->pendingbdchgs[i].probingchange) );
2288  assert(tree->npendingbdchgs == npendingbdchgs); /* this time, the bound change can be applied! */
2289 
2290  /* release the variable */
2291  SCIP_CALL( SCIPvarRelease(&var, blkmem, set, eventqueue, lp) );
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  if( node->depth == 0 )
2320  {
2321  stat->rootlowerbound = newbound;
2322  if( set->misc_calcintegral )
2323  SCIPstatUpdatePrimalDualIntegral(stat, set, transprob, origprob, SCIPsetInfinity(set), newbound);
2324  }
2325  else if( set->misc_calcintegral && SCIPsetIsEQ(set, oldbound, stat->lastlowerbound) )
2326  {
2327  SCIP_Real lowerbound;
2328  lowerbound = SCIPtreeGetLowerbound(tree, set);
2329  assert(newbound >= lowerbound);
2330 
2331  /* updating the primal integral is only necessary if dual bound has increased since last evaluation */
2332  if( lowerbound > stat->lastlowerbound )
2333  SCIPstatUpdatePrimalDualIntegral(stat, set, transprob, origprob, SCIPsetInfinity(set), lowerbound);
2334  }
2335  }
2336 }
2337 
2338 /** updates lower bound of node using lower bound of LP */
2340  SCIP_NODE* node, /**< node to set lower bound for */
2341  SCIP_SET* set, /**< global SCIP settings */
2342  SCIP_STAT* stat, /**< problem statistics */
2343  SCIP_TREE* tree, /**< branch and bound tree */
2344  SCIP_PROB* transprob, /**< transformed problem after presolve */
2345  SCIP_PROB* origprob, /**< original problem */
2346  SCIP_LP* lp /**< LP data */
2347  )
2348 {
2349  SCIP_Real lpobjval;
2350 
2351  assert(set != NULL);
2352  assert(lp->flushed);
2353 
2354  /* in case of iteration or time limit, the LP value may not be a valid dual bound */
2355  /* @todo check for dual feasibility of LP solution and use sub-optimal solution if they are dual feasible */
2357  return SCIP_OKAY;
2358 
2359  if( set->misc_exactsolve )
2360  {
2361  SCIP_CALL( SCIPlpGetProvedLowerbound(lp, set, &lpobjval) );
2362  }
2363  else
2364  lpobjval = SCIPlpGetObjval(lp, set, transprob);
2365 
2366  SCIPnodeUpdateLowerbound(node, stat, set, tree, transprob, origprob, lpobjval);
2367 
2368  return SCIP_OKAY;
2369 }
2370 
2371 
2372 /** change the node selection priority of the given child */
2374  SCIP_TREE* tree, /**< branch and bound tree */
2375  SCIP_NODE* child, /**< child to update the node selection priority */
2376  SCIP_Real priority /**< node selection priority value */
2377  )
2378 {
2379  int pos;
2380 
2381  assert( SCIPnodeGetType(child) == SCIP_NODETYPE_CHILD );
2382 
2383  pos = child->data.child.arraypos;
2384  assert( pos >= 0 );
2385 
2386  tree->childrenprio[pos] = priority;
2387 }
2388 
2389 
2390 /** sets the node's estimated bound to the new value */
2392  SCIP_NODE* node, /**< node to update lower bound for */
2393  SCIP_SET* set, /**< global SCIP settings */
2394  SCIP_Real newestimate /**< new estimated bound for the node */
2395  )
2396 {
2397  assert(node != NULL);
2398  assert(set != NULL);
2399  assert(SCIPsetIsRelGE(set, newestimate, node->lowerbound));
2400 
2401  node->estimate = newestimate;
2402 }
2403 
2404 /** propagates implications of binary fixings at the given node triggered by the implication graph and the clique table */
2406  SCIP_NODE* node, /**< node to propagate implications on */
2407  BMS_BLKMEM* blkmem, /**< block memory */
2408  SCIP_SET* set, /**< global SCIP settings */
2409  SCIP_STAT* stat, /**< problem statistics */
2410  SCIP_PROB* transprob, /**< transformed problem after presolve */
2411  SCIP_PROB* origprob, /**< original problem */
2412  SCIP_TREE* tree, /**< branch and bound tree */
2413  SCIP_REOPT* reopt, /**< reoptimization data structure */
2414  SCIP_LP* lp, /**< current LP data */
2415  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
2416  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2417  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
2418  SCIP_Bool* cutoff /**< pointer to store whether the node can be cut off */
2419  )
2420 {
2421  int nboundchgs;
2422  int i;
2423 
2424  assert(node != NULL);
2425  assert(SCIPnodeIsActive(node));
2429  assert(cutoff != NULL);
2430 
2431  SCIPsetDebugMsg(set, "implication graph propagation of node #%" SCIP_LONGINT_FORMAT " in depth %d\n",
2432  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node));
2433 
2434  *cutoff = FALSE;
2435 
2436  /* propagate all fixings of binary variables performed at this node */
2437  nboundchgs = SCIPdomchgGetNBoundchgs(node->domchg);
2438  for( i = 0; i < nboundchgs && !(*cutoff); ++i )
2439  {
2440  SCIP_BOUNDCHG* boundchg;
2441  SCIP_VAR* var;
2442 
2443  boundchg = SCIPdomchgGetBoundchg(node->domchg, i);
2444 
2445  /* ignore redundant bound changes */
2446  if( SCIPboundchgIsRedundant(boundchg) )
2447  continue;
2448 
2449  var = SCIPboundchgGetVar(boundchg);
2450  if( SCIPvarIsBinary(var) )
2451  {
2452  SCIP_Bool varfixing;
2453  int nimpls;
2454  SCIP_VAR** implvars;
2455  SCIP_BOUNDTYPE* impltypes;
2456  SCIP_Real* implbounds;
2457  SCIP_CLIQUE** cliques;
2458  int ncliques;
2459  int j;
2460 
2461  varfixing = (SCIPboundchgGetBoundtype(boundchg) == SCIP_BOUNDTYPE_LOWER);
2462  nimpls = SCIPvarGetNImpls(var, varfixing);
2463  implvars = SCIPvarGetImplVars(var, varfixing);
2464  impltypes = SCIPvarGetImplTypes(var, varfixing);
2465  implbounds = SCIPvarGetImplBounds(var, varfixing);
2466 
2467  /* apply implications */
2468  for( j = 0; j < nimpls; ++j )
2469  {
2470  SCIP_Real lb;
2471  SCIP_Real ub;
2472 
2473  /* @note should this be checked here (because SCIPnodeAddBoundinfer fails for multi-aggregated variables)
2474  * or should SCIPnodeAddBoundinfer() just return for multi-aggregated variables?
2475  */
2477  continue;
2478 
2479  /* check for infeasibility */
2480  lb = SCIPvarGetLbLocal(implvars[j]);
2481  ub = SCIPvarGetUbLocal(implvars[j]);
2482  if( impltypes[j] == SCIP_BOUNDTYPE_LOWER )
2483  {
2484  if( SCIPsetIsFeasGT(set, implbounds[j], ub) )
2485  {
2486  *cutoff = TRUE;
2487  return SCIP_OKAY;
2488  }
2489  if( SCIPsetIsFeasLE(set, implbounds[j], lb) )
2490  continue;
2491  }
2492  else
2493  {
2494  if( SCIPsetIsFeasLT(set, implbounds[j], lb) )
2495  {
2496  *cutoff = TRUE;
2497  return SCIP_OKAY;
2498  }
2499  if( SCIPsetIsFeasGE(set, implbounds[j], ub) )
2500  continue;
2501  }
2502 
2503  /* @note the implication might affect a fixed variable (after resolving (multi-)aggregations);
2504  * normally, the implication should have been deleted in that case, but this is only possible
2505  * if the implied variable has the reverse implication stored as a variable bound;
2506  * due to numerics, the variable bound may not be present and so the implication is not deleted
2507  */
2509  continue;
2510 
2511  /* apply the implication */
2512  SCIP_CALL( SCIPnodeAddBoundinfer(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
2513  eventqueue, cliquetable, implvars[j], implbounds[j], impltypes[j], NULL, NULL, 0, FALSE) );
2514  }
2515 
2516  /* apply cliques */
2517  ncliques = SCIPvarGetNCliques(var, varfixing);
2518  cliques = SCIPvarGetCliques(var, varfixing);
2519  for( j = 0; j < ncliques; ++j )
2520  {
2521  SCIP_VAR** vars;
2522  SCIP_Bool* values;
2523  int nvars;
2524  int k;
2525 
2526  nvars = SCIPcliqueGetNVars(cliques[j]);
2527  vars = SCIPcliqueGetVars(cliques[j]);
2528  values = SCIPcliqueGetValues(cliques[j]);
2529  for( k = 0; k < nvars; ++k )
2530  {
2531  SCIP_Real lb;
2532  SCIP_Real ub;
2533 
2534  assert(SCIPvarIsBinary(vars[k]));
2535 
2536  if( SCIPvarGetStatus(vars[k]) == SCIP_VARSTATUS_MULTAGGR )
2537  continue;
2538 
2539  if( vars[k] == var && values[k] == varfixing )
2540  continue;
2541 
2542  /* check for infeasibility */
2543  lb = SCIPvarGetLbLocal(vars[k]);
2544  ub = SCIPvarGetUbLocal(vars[k]);
2545  if( values[k] == FALSE )
2546  {
2547  if( ub < 0.5 )
2548  {
2549  *cutoff = TRUE;
2550  return SCIP_OKAY;
2551  }
2552  if( lb > 0.5 )
2553  continue;
2554  }
2555  else
2556  {
2557  if( lb > 0.5 )
2558  {
2559  *cutoff = TRUE;
2560  return SCIP_OKAY;
2561  }
2562  if( ub < 0.5 )
2563  continue;
2564  }
2565 
2567  continue;
2568 
2569  /* apply the clique implication */
2570  SCIP_CALL( SCIPnodeAddBoundinfer(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
2571  eventqueue, cliquetable, vars[k], (SCIP_Real)(!values[k]), values[k] ? SCIP_BOUNDTYPE_UPPER : SCIP_BOUNDTYPE_LOWER,
2572  NULL, NULL, 0, FALSE) );
2573  }
2574  }
2575  }
2576  }
2577 
2578  return SCIP_OKAY;
2579 }
2580 
2581 
2582 
2583 
2584 /*
2585  * Path Switching
2586  */
2587 
2588 /** updates the LP sizes of the active path starting at the given depth */
2589 static
2591  SCIP_TREE* tree, /**< branch and bound tree */
2592  int startdepth /**< depth to start counting */
2593  )
2594 {
2595  SCIP_NODE* node;
2596  int ncols;
2597  int nrows;
2598  int i;
2599 
2600  assert(tree != NULL);
2601  assert(startdepth >= 0);
2602  assert(startdepth <= tree->pathlen);
2603 
2604  if( startdepth == 0 )
2605  {
2606  ncols = 0;
2607  nrows = 0;
2608  }
2609  else
2610  {
2611  ncols = tree->pathnlpcols[startdepth-1];
2612  nrows = tree->pathnlprows[startdepth-1];
2613  }
2614 
2615  for( i = startdepth; i < tree->pathlen; ++i )
2616  {
2617  node = tree->path[i];
2618  assert(node != NULL);
2619  assert(node->active);
2620  assert((int)(node->depth) == i);
2621 
2622  switch( SCIPnodeGetType(node) )
2623  {
2625  assert(i == tree->pathlen-1 || SCIPtreeProbing(tree));
2626  break;
2628  assert(SCIPtreeProbing(tree));
2629  assert(i >= 1);
2630  assert(SCIPnodeGetType(tree->path[i-1]) == SCIP_NODETYPE_FOCUSNODE
2631  || (ncols == node->data.probingnode->ninitialcols && nrows == node->data.probingnode->ninitialrows));
2632  assert(ncols <= node->data.probingnode->ncols || !tree->focuslpconstructed);
2633  assert(nrows <= node->data.probingnode->nrows || !tree->focuslpconstructed);
2634  if( i < tree->pathlen-1 )
2635  {
2636  ncols = node->data.probingnode->ncols;
2637  nrows = node->data.probingnode->nrows;
2638  }
2639  else
2640  {
2641  /* for the current probing node, the initial LP size is stored in the path */
2642  ncols = node->data.probingnode->ninitialcols;
2643  nrows = node->data.probingnode->ninitialrows;
2644  }
2645  break;
2646  case SCIP_NODETYPE_SIBLING:
2647  SCIPerrorMessage("sibling cannot be in the active path\n");
2648  SCIPABORT();
2649  return SCIP_INVALIDDATA; /*lint !e527*/
2650  case SCIP_NODETYPE_CHILD:
2651  SCIPerrorMessage("child cannot be in the active path\n");
2652  SCIPABORT();
2653  return SCIP_INVALIDDATA; /*lint !e527*/
2654  case SCIP_NODETYPE_LEAF:
2655  SCIPerrorMessage("leaf cannot be in the active path\n");
2656  SCIPABORT();
2657  return SCIP_INVALIDDATA; /*lint !e527*/
2658  case SCIP_NODETYPE_DEADEND:
2659  SCIPerrorMessage("dead-end cannot be in the active path\n");
2660  SCIPABORT();
2661  return SCIP_INVALIDDATA; /*lint !e527*/
2663  break;
2665  assert(node->data.pseudofork != NULL);
2666  ncols += node->data.pseudofork->naddedcols;
2667  nrows += node->data.pseudofork->naddedrows;
2668  break;
2669  case SCIP_NODETYPE_FORK:
2670  assert(node->data.fork != NULL);
2671  ncols += node->data.fork->naddedcols;
2672  nrows += node->data.fork->naddedrows;
2673  break;
2674  case SCIP_NODETYPE_SUBROOT:
2675  assert(node->data.subroot != NULL);
2676  ncols = node->data.subroot->ncols;
2677  nrows = node->data.subroot->nrows;
2678  break;
2680  SCIPerrorMessage("node cannot be of type REFOCUSNODE at this point\n");
2681  SCIPABORT();
2682  return SCIP_INVALIDDATA; /*lint !e527*/
2683  default:
2684  SCIPerrorMessage("unknown node type %d\n", SCIPnodeGetType(node));
2685  SCIPABORT();
2686  return SCIP_INVALIDDATA; /*lint !e527*/
2687  }
2688  tree->pathnlpcols[i] = ncols;
2689  tree->pathnlprows[i] = nrows;
2690  }
2691  return SCIP_OKAY;
2692 }
2693 
2694 /** finds the common fork node, the new LP state defining fork, and the new focus subroot, if the path is switched to
2695  * the given node
2696  */
2697 static
2699  SCIP_TREE* tree, /**< branch and bound tree */
2700  SCIP_NODE* node, /**< new focus node, or NULL */
2701  SCIP_NODE** commonfork, /**< pointer to store common fork node of old and new focus node */
2702  SCIP_NODE** newlpfork, /**< pointer to store the new LP defining fork node */
2703  SCIP_NODE** newlpstatefork, /**< pointer to store the new LP state defining fork node */
2704  SCIP_NODE** newsubroot, /**< pointer to store the new subroot node */
2705  SCIP_Bool* cutoff /**< pointer to store whether the given node can be cut off and no path switching
2706  * should be performed */
2707  )
2708 {
2709  SCIP_NODE* fork;
2710  SCIP_NODE* lpfork;
2711  SCIP_NODE* lpstatefork;
2712  SCIP_NODE* subroot;
2713 
2714  assert(tree != NULL);
2715  assert(tree->root != NULL);
2716  assert((tree->focusnode == NULL) == !tree->root->active);
2717  assert(tree->focuslpfork == NULL || tree->focusnode != NULL);
2718  assert(tree->focuslpfork == NULL || tree->focuslpfork->depth < tree->focusnode->depth);
2719  assert(tree->focuslpstatefork == NULL || tree->focuslpfork != NULL);
2720  assert(tree->focuslpstatefork == NULL || tree->focuslpstatefork->depth <= tree->focuslpfork->depth);
2721  assert(tree->focussubroot == NULL || tree->focuslpstatefork != NULL);
2722  assert(tree->focussubroot == NULL || tree->focussubroot->depth <= tree->focuslpstatefork->depth);
2723  assert(tree->cutoffdepth >= 0);
2724  assert(tree->cutoffdepth == INT_MAX || tree->cutoffdepth < tree->pathlen);
2725  assert(tree->cutoffdepth == INT_MAX || tree->path[tree->cutoffdepth]->cutoff);
2726  assert(tree->repropdepth >= 0);
2727  assert(tree->repropdepth == INT_MAX || tree->repropdepth < tree->pathlen);
2728  assert(tree->repropdepth == INT_MAX || tree->path[tree->repropdepth]->reprop);
2729  assert(commonfork != NULL);
2730  assert(newlpfork != NULL);
2731  assert(newlpstatefork != NULL);
2732  assert(newsubroot != NULL);
2733  assert(cutoff != NULL);
2734 
2735  *commonfork = NULL;
2736  *newlpfork = NULL;
2737  *newlpstatefork = NULL;
2738  *newsubroot = NULL;
2739  *cutoff = FALSE;
2740 
2741  /* if the new focus node is NULL, there is no common fork node, and the new LP fork, LP state fork, and subroot
2742  * are NULL
2743  */
2744  if( node == NULL )
2745  {
2746  tree->cutoffdepth = INT_MAX;
2747  tree->repropdepth = INT_MAX;
2748  return;
2749  }
2750 
2751  /* check if the new node is marked to be cut off */
2752  if( node->cutoff )
2753  {
2754  *cutoff = TRUE;
2755  return;
2756  }
2757 
2758  /* 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
2759  * and subroot
2760  */
2761  if( tree->focusnode == NULL )
2762  {
2763  assert(!tree->root->active);
2764  assert(tree->pathlen == 0);
2765  assert(tree->cutoffdepth == INT_MAX);
2766  assert(tree->repropdepth == INT_MAX);
2767 
2768  lpfork = node;
2769  while( SCIPnodeGetType(lpfork) != SCIP_NODETYPE_PSEUDOFORK
2771  {
2772  lpfork = lpfork->parent;
2773  if( lpfork == NULL )
2774  return;
2775  if( lpfork->cutoff )
2776  {
2777  *cutoff = TRUE;
2778  return;
2779  }
2780  }
2781  *newlpfork = lpfork;
2782 
2783  lpstatefork = lpfork;
2784  while( SCIPnodeGetType(lpstatefork) != SCIP_NODETYPE_FORK && SCIPnodeGetType(lpstatefork) != SCIP_NODETYPE_SUBROOT )
2785  {
2786  lpstatefork = lpstatefork->parent;
2787  if( lpstatefork == NULL )
2788  return;
2789  if( lpstatefork->cutoff )
2790  {
2791  *cutoff = TRUE;
2792  return;
2793  }
2794  }
2795  *newlpstatefork = lpstatefork;
2796 
2797  subroot = lpstatefork;
2798  while( SCIPnodeGetType(subroot) != SCIP_NODETYPE_SUBROOT )
2799  {
2800  subroot = subroot->parent;
2801  if( subroot == NULL )
2802  return;
2803  if( subroot->cutoff )
2804  {
2805  *cutoff = TRUE;
2806  return;
2807  }
2808  }
2809  *newsubroot = subroot;
2810 
2811  fork = subroot;
2812  while( fork->parent != NULL )
2813  {
2814  fork = fork->parent;
2815  if( fork->cutoff )
2816  {
2817  *cutoff = TRUE;
2818  return;
2819  }
2820  }
2821  return;
2822  }
2823 
2824  /* find the common fork node, the new LP defining fork, the new LP state defining fork, and the new focus subroot */
2825  fork = node;
2826  lpfork = NULL;
2827  lpstatefork = NULL;
2828  subroot = NULL;
2829  assert(fork != NULL);
2830 
2831  while( !fork->active )
2832  {
2833  fork = fork->parent;
2834  assert(fork != NULL); /* because the root is active, there must be a common fork node */
2835 
2836  if( fork->cutoff )
2837  {
2838  *cutoff = TRUE;
2839  return;
2840  }
2841  if( lpfork == NULL
2844  lpfork = fork;
2845  if( lpstatefork == NULL
2847  lpstatefork = fork;
2848  if( subroot == NULL && SCIPnodeGetType(fork) == SCIP_NODETYPE_SUBROOT )
2849  subroot = fork;
2850  }
2851  assert(lpfork == NULL || !lpfork->active || lpfork == fork);
2852  assert(lpstatefork == NULL || !lpstatefork->active || lpstatefork == fork);
2853  assert(subroot == NULL || !subroot->active || subroot == fork);
2854  SCIPdebugMessage("find switch forks: forkdepth=%u\n", fork->depth);
2855 
2856  /* if the common fork node is below the current cutoff depth, the cutoff node is an ancestor of the common fork
2857  * and thus an ancestor of the new focus node, s.t. the new node can also be cut off
2858  */
2859  assert((int)fork->depth != tree->cutoffdepth);
2860  if( (int)fork->depth > tree->cutoffdepth )
2861  {
2862 #ifndef NDEBUG
2863  while( !fork->cutoff )
2864  {
2865  fork = fork->parent;
2866  assert(fork != NULL);
2867  }
2868  assert((int)fork->depth >= tree->cutoffdepth);
2869 #endif
2870  *cutoff = TRUE;
2871  return;
2872  }
2873  tree->cutoffdepth = INT_MAX;
2874 
2875  /* if not already found, continue searching the LP defining fork; it cannot be deeper than the common fork */
2876  if( lpfork == NULL )
2877  {
2878  if( tree->focuslpfork != NULL && (int)(tree->focuslpfork->depth) > fork->depth )
2879  {
2880  /* focuslpfork is not on the same active path as the new node: we have to continue searching */
2881  lpfork = fork;
2882  while( lpfork != NULL
2884  && SCIPnodeGetType(lpfork) != SCIP_NODETYPE_FORK
2885  && SCIPnodeGetType(lpfork) != SCIP_NODETYPE_SUBROOT )
2886  {
2887  assert(lpfork->active);
2888  lpfork = lpfork->parent;
2889  }
2890  }
2891  else
2892  {
2893  /* focuslpfork is on the same active path as the new node: old and new node have the same lpfork */
2894  lpfork = tree->focuslpfork;
2895  }
2896  assert(lpfork == NULL || (int)(lpfork->depth) <= fork->depth);
2897  assert(lpfork == NULL || lpfork->active);
2898  }
2899  assert(lpfork == NULL
2901  || SCIPnodeGetType(lpfork) == SCIP_NODETYPE_FORK
2902  || SCIPnodeGetType(lpfork) == SCIP_NODETYPE_SUBROOT);
2903  SCIPdebugMessage("find switch forks: lpforkdepth=%d\n", lpfork == NULL ? -1 : (int)(lpfork->depth));
2904 
2905  /* if not already found, continue searching the LP state defining fork; it cannot be deeper than the
2906  * LP defining fork and the common fork
2907  */
2908  if( lpstatefork == NULL )
2909  {
2910  if( tree->focuslpstatefork != NULL && (int)(tree->focuslpstatefork->depth) > fork->depth )
2911  {
2912  /* focuslpstatefork is not on the same active path as the new node: we have to continue searching */
2913  if( lpfork != NULL && lpfork->depth < fork->depth )
2914  lpstatefork = lpfork;
2915  else
2916  lpstatefork = fork;
2917  while( lpstatefork != NULL
2918  && SCIPnodeGetType(lpstatefork) != SCIP_NODETYPE_FORK
2919  && SCIPnodeGetType(lpstatefork) != SCIP_NODETYPE_SUBROOT )
2920  {
2921  assert(lpstatefork->active);
2922  lpstatefork = lpstatefork->parent;
2923  }
2924  }
2925  else
2926  {
2927  /* focuslpstatefork is on the same active path as the new node: old and new node have the same lpstatefork */
2928  lpstatefork = tree->focuslpstatefork;
2929  }
2930  assert(lpstatefork == NULL || (int)(lpstatefork->depth) <= fork->depth);
2931  assert(lpstatefork == NULL || lpstatefork->active);
2932  }
2933  assert(lpstatefork == NULL
2934  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK
2935  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT);
2936  assert(lpstatefork == NULL || (lpfork != NULL && lpstatefork->depth <= lpfork->depth));
2937  SCIPdebugMessage("find switch forks: lpstateforkdepth=%d\n", lpstatefork == NULL ? -1 : (int)(lpstatefork->depth));
2938 
2939  /* if not already found, continue searching the subroot; it cannot be deeper than the LP defining fork, the
2940  * LP state fork and the common fork
2941  */
2942  if( subroot == NULL )
2943  {
2944  if( tree->focussubroot != NULL && (int)(tree->focussubroot->depth) > fork->depth )
2945  {
2946  /* focussubroot is not on the same active path as the new node: we have to continue searching */
2947  if( lpstatefork != NULL && lpstatefork->depth < fork->depth )
2948  subroot = lpstatefork;
2949  else if( lpfork != NULL && lpfork->depth < fork->depth )
2950  subroot = lpfork;
2951  else
2952  subroot = fork;
2953  while( subroot != NULL && SCIPnodeGetType(subroot) != SCIP_NODETYPE_SUBROOT )
2954  {
2955  assert(subroot->active);
2956  subroot = subroot->parent;
2957  }
2958  }
2959  else
2960  subroot = tree->focussubroot;
2961  assert(subroot == NULL || subroot->depth <= fork->depth);
2962  assert(subroot == NULL || subroot->active);
2963  }
2964  assert(subroot == NULL || SCIPnodeGetType(subroot) == SCIP_NODETYPE_SUBROOT);
2965  assert(subroot == NULL || (lpstatefork != NULL && subroot->depth <= lpstatefork->depth));
2966  SCIPdebugMessage("find switch forks: subrootdepth=%d\n", subroot == NULL ? -1 : (int)(subroot->depth));
2967 
2968  /* if a node prior to the common fork should be repropagated, we select the node to be repropagated as common
2969  * fork in order to undo all bound changes up to this node, repropagate the node, and redo the bound changes
2970  * afterwards
2971  */
2972  if( (int)fork->depth > tree->repropdepth )
2973  {
2974  fork = tree->path[tree->repropdepth];
2975  assert(fork->active);
2976  assert(fork->reprop);
2977  }
2978 
2979  *commonfork = fork;
2980  *newlpfork = lpfork;
2981  *newlpstatefork = lpstatefork;
2982  *newsubroot = subroot;
2983 
2984 #ifndef NDEBUG
2985  while( fork != NULL )
2986  {
2987  assert(fork->active);
2988  assert(!fork->cutoff);
2989  assert(fork->parent == NULL || !fork->parent->reprop);
2990  fork = fork->parent;
2991  }
2992 #endif
2993  tree->repropdepth = INT_MAX;
2994 }
2995 
2996 /** switches the active path to the new focus node, applies domain and constraint set changes */
2997 static
2999  SCIP_TREE* tree, /**< branch and bound tree */
3000  SCIP_REOPT* reopt, /**< reoptimization data structure */
3001  BMS_BLKMEM* blkmem, /**< block memory buffers */
3002  SCIP_SET* set, /**< global SCIP settings */
3003  SCIP_STAT* stat, /**< problem statistics */
3004  SCIP_PROB* transprob, /**< transformed problem after presolve */
3005  SCIP_PROB* origprob, /**< original problem */
3006  SCIP_PRIMAL* primal, /**< primal data */
3007  SCIP_LP* lp, /**< current LP data */
3008  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3009  SCIP_CONFLICT* conflict, /**< conflict analysis data */
3010  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
3011  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3012  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
3013  SCIP_NODE* fork, /**< common fork node of old and new focus node, or NULL */
3014  SCIP_NODE* focusnode, /**< new focus node, or NULL */
3015  SCIP_Bool* cutoff /**< pointer to store whether the new focus node can be cut off */
3016  )
3017 {
3018  int focusnodedepth; /* depth of the new focus node, or -1 if focusnode == NULL */
3019  int forkdepth; /* depth of the common subroot/fork/pseudofork/junction node, or -1 if no common fork exists */
3020  int i;
3021 
3022  assert(tree != NULL);
3023  assert(fork == NULL || (fork->active && !fork->cutoff));
3024  assert(fork == NULL || focusnode != NULL);
3025  assert(focusnode == NULL || (!focusnode->active && !focusnode->cutoff));
3026  assert(focusnode == NULL || SCIPnodeGetType(focusnode) == SCIP_NODETYPE_FOCUSNODE);
3027  assert(cutoff != NULL);
3028 
3029  *cutoff = FALSE;
3030 
3031  SCIPsetDebugMsg(set, "switch path: old pathlen=%d\n", tree->pathlen);
3032 
3033  /* get the nodes' depths */
3034  focusnodedepth = (focusnode != NULL ? (int)focusnode->depth : -1);
3035  forkdepth = (fork != NULL ? (int)fork->depth : -1);
3036  assert(forkdepth <= focusnodedepth);
3037  assert(forkdepth < tree->pathlen);
3038 
3039  /* delay events in path switching */
3040  SCIP_CALL( SCIPeventqueueDelay(eventqueue) );
3041 
3042  /* undo the domain and constraint set changes of the old active path by deactivating the path's nodes */
3043  for( i = tree->pathlen-1; i > forkdepth; --i )
3044  {
3045  SCIP_CALL( nodeDeactivate(tree->path[i], blkmem, set, stat, tree, lp, branchcand, eventqueue) );
3046  }
3047  tree->pathlen = forkdepth+1;
3048 
3049  /* apply the pending bound changes */
3050  SCIP_CALL( treeApplyPendingBdchgs(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, cliquetable) );
3051 
3052  /* create the new active path */
3053  SCIP_CALL( treeEnsurePathMem(tree, set, focusnodedepth+1) );
3054  while( focusnode != fork )
3055  {
3056  assert(focusnode != NULL);
3057  assert(!focusnode->active);
3058  assert(!focusnode->cutoff);
3059  tree->path[focusnode->depth] = focusnode;
3060  focusnode = focusnode->parent;
3061  }
3062 
3063  /* fork might be cut off when applying the pending bound changes */
3064  if( fork != NULL && fork->cutoff )
3065  *cutoff = TRUE;
3066  else if( fork != NULL && fork->reprop )
3067  {
3068  /* propagate common fork again, if the reprop flag is set */
3069  assert(tree->path[forkdepth] == fork);
3070  assert(fork->active);
3071  assert(!fork->cutoff);
3072 
3073  SCIP_CALL( nodeRepropagate(fork, blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand, conflict,
3074  eventfilter, eventqueue, cliquetable, cutoff) );
3075  }
3076  assert(fork != NULL || !(*cutoff));
3077 
3078  /* Apply domain and constraint set changes of the new path by activating the path's nodes;
3079  * on the way, domain propagation might be applied again to the path's nodes, which can result in the cutoff of
3080  * the node (and its subtree).
3081  * We only activate all nodes down to the parent of the new focus node, because the events in this process are
3082  * delayed, which means that multiple changes of a bound of a variable are merged (and might even be cancelled out,
3083  * if the bound is first relaxed when deactivating a node on the old path and then tightened to the same value
3084  * when activating a node on the new path).
3085  * This is valid for all nodes down to the parent of the new focus node, since they have already been propagated.
3086  * Bound change events on the new focus node, however, must not be cancelled out, since they need to be propagated
3087  * and thus, the event must be thrown and catched by the constraint handlers to mark constraints for propagation.
3088  */
3089  for( i = forkdepth+1; i < focusnodedepth && !(*cutoff); ++i )
3090  {
3091  assert(!tree->path[i]->cutoff);
3092  assert(tree->pathlen == i);
3093 
3094  /* activate the node, and apply domain propagation if the reprop flag is set */
3095  tree->pathlen++;
3096  SCIP_CALL( nodeActivate(tree->path[i], blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
3097  conflict, eventfilter, eventqueue, cliquetable, cutoff) );
3098  }
3099 
3100  /* process the delayed events */
3101  SCIP_CALL( SCIPeventqueueProcess(eventqueue, blkmem, set, primal, lp, branchcand, eventfilter) );
3102 
3103  /* activate the new focus node; there is no need to delay these events */
3104  if( !(*cutoff) && (i == focusnodedepth) )
3105  {
3106  assert(!tree->path[focusnodedepth]->cutoff);
3107  assert(tree->pathlen == focusnodedepth);
3108 
3109  /* activate the node, and apply domain propagation if the reprop flag is set */
3110  tree->pathlen++;
3111  SCIP_CALL( nodeActivate(tree->path[focusnodedepth], blkmem, set, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
3112  conflict, eventfilter, eventqueue, cliquetable, cutoff) );
3113  }
3114 
3115  /* mark last node of path to be cut off, if a cutoff was found */
3116  if( *cutoff )
3117  {
3118  assert(tree->pathlen > 0);
3119  assert(tree->path[tree->pathlen-1]->active);
3120  SCIP_CALL( SCIPnodeCutoff(tree->path[tree->pathlen-1], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
3121  }
3122 
3123  /* count the new LP sizes of the path */
3124  SCIP_CALL( treeUpdatePathLPSize(tree, forkdepth+1) );
3125 
3126  SCIPsetDebugMsg(set, "switch path: new pathlen=%d\n", tree->pathlen);
3127 
3128  return SCIP_OKAY;
3129 }
3130 
3131 /** loads the subroot's LP data */
3132 static
3134  SCIP_NODE* subroot, /**< subroot node to construct LP for */
3135  BMS_BLKMEM* blkmem, /**< block memory buffers */
3136  SCIP_SET* set, /**< global SCIP settings */
3137  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3138  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3139  SCIP_LP* lp /**< current LP data */
3140  )
3141 {
3142  SCIP_COL** cols;
3143  SCIP_ROW** rows;
3144  int ncols;
3145  int nrows;
3146  int c;
3147  int r;
3148 
3149  assert(subroot != NULL);
3150  assert(SCIPnodeGetType(subroot) == SCIP_NODETYPE_SUBROOT);
3151  assert(subroot->data.subroot != NULL);
3152  assert(blkmem != NULL);
3153  assert(set != NULL);
3154  assert(lp != NULL);
3155 
3156  cols = subroot->data.subroot->cols;
3157  rows = subroot->data.subroot->rows;
3158  ncols = subroot->data.subroot->ncols;
3159  nrows = subroot->data.subroot->nrows;
3160 
3161  assert(ncols == 0 || cols != NULL);
3162  assert(nrows == 0 || rows != NULL);
3163 
3164  for( c = 0; c < ncols; ++c )
3165  {
3166  SCIP_CALL( SCIPlpAddCol(lp, set, cols[c], subroot->depth) );
3167  }
3168  for( r = 0; r < nrows; ++r )
3169  {
3170  SCIP_CALL( SCIPlpAddRow(lp, blkmem, set, eventqueue, eventfilter, rows[r], subroot->depth) );
3171  }
3172 
3173  return SCIP_OKAY;
3174 }
3175 
3176 /** loads the fork's additional LP data */
3177 static
3179  SCIP_NODE* fork, /**< fork node to construct additional LP for */
3180  BMS_BLKMEM* blkmem, /**< block memory buffers */
3181  SCIP_SET* set, /**< global SCIP settings */
3182  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3183  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3184  SCIP_LP* lp /**< current LP data */
3185  )
3186 {
3187  SCIP_COL** cols;
3188  SCIP_ROW** rows;
3189  int ncols;
3190  int nrows;
3191  int c;
3192  int r;
3193 
3194  assert(fork != NULL);
3195  assert(SCIPnodeGetType(fork) == SCIP_NODETYPE_FORK);
3196  assert(fork->data.fork != NULL);
3197  assert(blkmem != NULL);
3198  assert(set != NULL);
3199  assert(lp != NULL);
3200 
3201  cols = fork->data.fork->addedcols;
3202  rows = fork->data.fork->addedrows;
3203  ncols = fork->data.fork->naddedcols;
3204  nrows = fork->data.fork->naddedrows;
3205 
3206  assert(ncols == 0 || cols != NULL);
3207  assert(nrows == 0 || rows != NULL);
3208 
3209  for( c = 0; c < ncols; ++c )
3210  {
3211  SCIP_CALL( SCIPlpAddCol(lp, set, cols[c], fork->depth) );
3212  }
3213  for( r = 0; r < nrows; ++r )
3214  {
3215  SCIP_CALL( SCIPlpAddRow(lp, blkmem, set, eventqueue, eventfilter, rows[r], fork->depth) );
3216  }
3217 
3218  return SCIP_OKAY;
3219 }
3220 
3221 /** loads the pseudofork's additional LP data */
3222 static
3224  SCIP_NODE* pseudofork, /**< pseudofork node to construct additional LP for */
3225  BMS_BLKMEM* blkmem, /**< block memory buffers */
3226  SCIP_SET* set, /**< global SCIP settings */
3227  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3228  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3229  SCIP_LP* lp /**< current LP data */
3230  )
3231 {
3232  SCIP_COL** cols;
3233  SCIP_ROW** rows;
3234  int ncols;
3235  int nrows;
3236  int c;
3237  int r;
3238 
3239  assert(pseudofork != NULL);
3240  assert(SCIPnodeGetType(pseudofork) == SCIP_NODETYPE_PSEUDOFORK);
3241  assert(pseudofork->data.pseudofork != NULL);
3242  assert(blkmem != NULL);
3243  assert(set != NULL);
3244  assert(lp != NULL);
3245 
3246  cols = pseudofork->data.pseudofork->addedcols;
3247  rows = pseudofork->data.pseudofork->addedrows;
3248  ncols = pseudofork->data.pseudofork->naddedcols;
3249  nrows = pseudofork->data.pseudofork->naddedrows;
3250 
3251  assert(ncols == 0 || cols != NULL);
3252  assert(nrows == 0 || rows != NULL);
3253 
3254  for( c = 0; c < ncols; ++c )
3255  {
3256  SCIP_CALL( SCIPlpAddCol(lp, set, cols[c], pseudofork->depth) );
3257  }
3258  for( r = 0; r < nrows; ++r )
3259  {
3260  SCIP_CALL( SCIPlpAddRow(lp, blkmem, set, eventqueue, eventfilter, rows[r], pseudofork->depth) );
3261  }
3262 
3263  return SCIP_OKAY;
3264 }
3265 
3266 #ifndef NDEBUG
3267 /** checks validity of active path */
3268 static
3270  SCIP_TREE* tree /**< branch and bound tree */
3271  )
3272 {
3273  SCIP_NODE* node;
3274  int ncols;
3275  int nrows;
3276  int d;
3277 
3278  assert(tree != NULL);
3279  assert(tree->path != NULL);
3280 
3281  ncols = 0;
3282  nrows = 0;
3283  for( d = 0; d < tree->pathlen; ++d )
3284  {
3285  node = tree->path[d];
3286  assert(node != NULL);
3287  assert((int)(node->depth) == d);
3288  switch( SCIPnodeGetType(node) )
3289  {
3291  assert(SCIPtreeProbing(tree));
3292  assert(d >= 1);
3293  assert(SCIPnodeGetType(tree->path[d-1]) == SCIP_NODETYPE_FOCUSNODE
3294  || (ncols == node->data.probingnode->ninitialcols && nrows == node->data.probingnode->ninitialrows));
3295  assert(ncols <= node->data.probingnode->ncols || !tree->focuslpconstructed);
3296  assert(nrows <= node->data.probingnode->nrows || !tree->focuslpconstructed);
3297  if( d < tree->pathlen-1 )
3298  {
3299  ncols = node->data.probingnode->ncols;
3300  nrows = node->data.probingnode->nrows;
3301  }
3302  else
3303  {
3304  /* for the current probing node, the initial LP size is stored in the path */
3305  ncols = node->data.probingnode->ninitialcols;
3306  nrows = node->data.probingnode->ninitialrows;
3307  }
3308  break;
3310  break;
3312  ncols += node->data.pseudofork->naddedcols;
3313  nrows += node->data.pseudofork->naddedrows;
3314  break;
3315  case SCIP_NODETYPE_FORK:
3316  ncols += node->data.fork->naddedcols;
3317  nrows += node->data.fork->naddedrows;
3318  break;
3319  case SCIP_NODETYPE_SUBROOT:
3320  ncols = node->data.subroot->ncols;
3321  nrows = node->data.subroot->nrows;
3322  break;
3325  assert(d == tree->pathlen-1 || SCIPtreeProbing(tree));
3326  break;
3327  default:
3328  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",
3329  d, SCIPnodeGetType(node));
3330  SCIPABORT();
3331  } /*lint !e788*/
3332  assert(tree->pathnlpcols[d] == ncols);
3333  assert(tree->pathnlprows[d] == nrows);
3334  }
3335 }
3336 #else
3337 #define treeCheckPath(tree) /**/
3338 #endif
3339 
3340 /** constructs the LP relaxation of the focus node */
3342  SCIP_TREE* tree, /**< branch and bound tree */
3343  BMS_BLKMEM* blkmem, /**< block memory buffers */
3344  SCIP_SET* set, /**< global SCIP settings */
3345  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3346  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3347  SCIP_LP* lp, /**< current LP data */
3348  SCIP_Bool* initroot /**< pointer to store whether the root LP relaxation has to be initialized */
3349  )
3350 {
3351  SCIP_NODE* lpfork;
3352  int lpforkdepth;
3353  int d;
3354 
3355  assert(tree != NULL);
3356  assert(!tree->focuslpconstructed);
3357  assert(tree->path != NULL);
3358  assert(tree->pathlen > 0);
3359  assert(tree->focusnode != NULL);
3361  assert(SCIPnodeGetDepth(tree->focusnode) == tree->pathlen-1);
3362  assert(!SCIPtreeProbing(tree));
3363  assert(tree->focusnode == tree->path[tree->pathlen-1]);
3364  assert(blkmem != NULL);
3365  assert(set != NULL);
3366  assert(lp != NULL);
3367  assert(initroot != NULL);
3368 
3369  SCIPsetDebugMsg(set, "load LP for current fork node #%" SCIP_LONGINT_FORMAT " at depth %d\n",
3370  tree->focuslpfork == NULL ? -1 : SCIPnodeGetNumber(tree->focuslpfork),
3371  tree->focuslpfork == NULL ? -1 : SCIPnodeGetDepth(tree->focuslpfork));
3372  SCIPsetDebugMsg(set, "-> old LP has %d cols and %d rows\n", SCIPlpGetNCols(lp), SCIPlpGetNRows(lp));
3373  SCIPsetDebugMsg(set, "-> correct LP has %d cols and %d rows\n",
3374  tree->correctlpdepth >= 0 ? tree->pathnlpcols[tree->correctlpdepth] : 0,
3375  tree->correctlpdepth >= 0 ? tree->pathnlprows[tree->correctlpdepth] : 0);
3376  SCIPsetDebugMsg(set, "-> old correctlpdepth: %d\n", tree->correctlpdepth);
3377 
3378  treeCheckPath(tree);
3379 
3380  lpfork = tree->focuslpfork;
3381 
3382  /* find out the lpfork's depth (or -1, if lpfork is NULL) */
3383  if( lpfork == NULL )
3384  {
3385  assert(tree->correctlpdepth == -1 || tree->pathnlpcols[tree->correctlpdepth] == 0);
3386  assert(tree->correctlpdepth == -1 || tree->pathnlprows[tree->correctlpdepth] == 0);
3387  assert(tree->focuslpstatefork == NULL);
3388  assert(tree->focussubroot == NULL);
3389  lpforkdepth = -1;
3390  }
3391  else
3392  {
3393  assert(SCIPnodeGetType(lpfork) == SCIP_NODETYPE_PSEUDOFORK
3395  assert(lpfork->active);
3396  assert(tree->path[lpfork->depth] == lpfork);
3397  lpforkdepth = lpfork->depth;
3398  }
3399  assert(lpforkdepth < tree->pathlen-1); /* lpfork must not be the last (the focus) node of the active path */
3400 
3401  /* find out, if we are in the same subtree */
3402  if( tree->correctlpdepth >= 0 )
3403  {
3404  /* same subtree: shrink LP to the deepest node with correct LP */
3405  assert(lpforkdepth == -1 || tree->pathnlpcols[tree->correctlpdepth] <= tree->pathnlpcols[lpforkdepth]);
3406  assert(lpforkdepth == -1 || tree->pathnlprows[tree->correctlpdepth] <= tree->pathnlprows[lpforkdepth]);
3407  assert(lpforkdepth >= 0 || tree->pathnlpcols[tree->correctlpdepth] == 0);
3408  assert(lpforkdepth >= 0 || tree->pathnlprows[tree->correctlpdepth] == 0);
3409  SCIP_CALL( SCIPlpShrinkCols(lp, set, tree->pathnlpcols[tree->correctlpdepth]) );
3410  SCIP_CALL( SCIPlpShrinkRows(lp, blkmem, set, eventqueue, eventfilter, tree->pathnlprows[tree->correctlpdepth]) );
3411  }
3412  else
3413  {
3414  /* other subtree: fill LP with the subroot LP data */
3415  SCIP_CALL( SCIPlpClear(lp, blkmem, set, eventqueue, eventfilter) );
3416  if( tree->focussubroot != NULL )
3417  {
3418  SCIP_CALL( subrootConstructLP(tree->focussubroot, blkmem, set, eventqueue, eventfilter, lp) );
3419  tree->correctlpdepth = tree->focussubroot->depth;
3420  }
3421  }
3422 
3423  assert(lpforkdepth < tree->pathlen);
3424 
3425  /* add the missing columns and rows */
3426  for( d = tree->correctlpdepth+1; d <= lpforkdepth; ++d )
3427  {
3428  SCIP_NODE* pathnode;
3429 
3430  pathnode = tree->path[d];
3431  assert(pathnode != NULL);
3432  assert((int)(pathnode->depth) == d);
3433  assert(SCIPnodeGetType(pathnode) == SCIP_NODETYPE_JUNCTION
3435  || SCIPnodeGetType(pathnode) == SCIP_NODETYPE_FORK);
3436  if( SCIPnodeGetType(pathnode) == SCIP_NODETYPE_FORK )
3437  {
3438  SCIP_CALL( forkAddLP(pathnode, blkmem, set, eventqueue, eventfilter, lp) );
3439  }
3440  else if( SCIPnodeGetType(pathnode) == SCIP_NODETYPE_PSEUDOFORK )
3441  {
3442  SCIP_CALL( pseudoforkAddLP(pathnode, blkmem, set, eventqueue, eventfilter, lp) );
3443  }
3444  }
3445  tree->correctlpdepth = MAX(tree->correctlpdepth, lpforkdepth);
3446  assert(lpforkdepth == -1 || tree->pathnlpcols[tree->correctlpdepth] == tree->pathnlpcols[lpforkdepth]);
3447  assert(lpforkdepth == -1 || tree->pathnlprows[tree->correctlpdepth] == tree->pathnlprows[lpforkdepth]);
3448  assert(lpforkdepth == -1 || SCIPlpGetNCols(lp) == tree->pathnlpcols[lpforkdepth]);
3449  assert(lpforkdepth == -1 || SCIPlpGetNRows(lp) == tree->pathnlprows[lpforkdepth]);
3450  assert(lpforkdepth >= 0 || SCIPlpGetNCols(lp) == 0);
3451  assert(lpforkdepth >= 0 || SCIPlpGetNRows(lp) == 0);
3452 
3453  /* mark the LP's size, such that we know which rows and columns were added in the new node */
3454  SCIPlpMarkSize(lp);
3455 
3456  SCIPsetDebugMsg(set, "-> new correctlpdepth: %d\n", tree->correctlpdepth);
3457  SCIPsetDebugMsg(set, "-> new LP has %d cols and %d rows\n", SCIPlpGetNCols(lp), SCIPlpGetNRows(lp));
3458 
3459  /* if the correct LP depth is still -1, the root LP relaxation has to be initialized */
3460  *initroot = (tree->correctlpdepth == -1);
3461 
3462  /* mark the LP of the focus node constructed */
3463  tree->focuslpconstructed = TRUE;
3464 
3465  return SCIP_OKAY;
3466 }
3467 
3468 /** loads LP state for fork/subroot of the focus node */
3470  SCIP_TREE* tree, /**< branch and bound tree */
3471  BMS_BLKMEM* blkmem, /**< block memory buffers */
3472  SCIP_SET* set, /**< global SCIP settings */
3473  SCIP_STAT* stat, /**< dynamic problem statistics */
3474  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3475  SCIP_LP* lp /**< current LP data */
3476  )
3477 {
3478  SCIP_NODE* lpstatefork;
3479  SCIP_Bool updatefeas;
3480  SCIP_Bool checkbdchgs;
3481  int lpstateforkdepth;
3482  int d;
3483 
3484  assert(tree != NULL);
3485  assert(tree->focuslpconstructed);
3486  assert(tree->path != NULL);
3487  assert(tree->pathlen > 0);
3488  assert(tree->focusnode != NULL);
3489  assert(tree->correctlpdepth < tree->pathlen);
3491  assert(SCIPnodeGetDepth(tree->focusnode) == tree->pathlen-1);
3492  assert(!SCIPtreeProbing(tree));
3493  assert(tree->focusnode == tree->path[tree->pathlen-1]);
3494  assert(blkmem != NULL);
3495  assert(set != NULL);
3496  assert(lp != NULL);
3497 
3498  SCIPsetDebugMsg(set, "load LP state for current fork node #%" SCIP_LONGINT_FORMAT " at depth %d\n",
3499  tree->focuslpstatefork == NULL ? -1 : SCIPnodeGetNumber(tree->focuslpstatefork),
3500  tree->focuslpstatefork == NULL ? -1 : SCIPnodeGetDepth(tree->focuslpstatefork));
3501 
3502  lpstatefork = tree->focuslpstatefork;
3503 
3504  /* if there is no LP state defining fork, nothing can be done */
3505  if( lpstatefork == NULL )
3506  return SCIP_OKAY;
3507 
3508  /* get the lpstatefork's depth */
3509  assert(SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT);
3510  assert(lpstatefork->active);
3511  assert(tree->path[lpstatefork->depth] == lpstatefork);
3512  lpstateforkdepth = lpstatefork->depth;
3513  assert(lpstateforkdepth < tree->pathlen-1); /* lpstatefork must not be the last (the focus) node of the active path */
3514  assert(lpstateforkdepth <= tree->correctlpdepth); /* LP must have been constructed at least up to the fork depth */
3515  assert(tree->pathnlpcols[tree->correctlpdepth] >= tree->pathnlpcols[lpstateforkdepth]); /* LP can only grow */
3516  assert(tree->pathnlprows[tree->correctlpdepth] >= tree->pathnlprows[lpstateforkdepth]); /* LP can only grow */
3517 
3518  /* load LP state */
3519  if( tree->focuslpstateforklpcount != stat->lpcount )
3520  {
3521  if( SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK )
3522  {
3523  assert(lpstatefork->data.fork != NULL);
3524  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, lpstatefork->data.fork->lpistate,
3525  lpstatefork->data.fork->lpwasprimfeas, lpstatefork->data.fork->lpwasprimchecked,
3526  lpstatefork->data.fork->lpwasdualfeas, lpstatefork->data.fork->lpwasdualchecked) );
3527  }
3528  else
3529  {
3530  assert(SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT);
3531  assert(lpstatefork->data.subroot != NULL);
3532  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, lpstatefork->data.subroot->lpistate,
3533  lpstatefork->data.subroot->lpwasprimfeas, lpstatefork->data.subroot->lpwasprimchecked,
3534  lpstatefork->data.subroot->lpwasdualfeas, lpstatefork->data.subroot->lpwasdualchecked) );
3535  }
3536  updatefeas = !lp->solved || !lp->solisbasic;
3537  checkbdchgs = TRUE;
3538  }
3539  else
3540  {
3541  updatefeas = TRUE;
3542 
3543  /* we do not need to check the bounds, since primalfeasible is updated anyway when flushing the LP */
3544  checkbdchgs = FALSE;
3545  }
3546 
3547  if( updatefeas )
3548  {
3549  /* check whether the size of the LP increased (destroying primal/dual feasibility) */
3550  lp->primalfeasible = lp->primalfeasible
3551  && (tree->pathnlprows[tree->correctlpdepth] == tree->pathnlprows[lpstateforkdepth]);
3552  lp->primalchecked = lp->primalchecked
3553  && (tree->pathnlprows[tree->correctlpdepth] == tree->pathnlprows[lpstateforkdepth]);
3554  lp->dualfeasible = lp->dualfeasible
3555  && (tree->pathnlpcols[tree->correctlpdepth] == tree->pathnlpcols[lpstateforkdepth]);
3556  lp->dualchecked = lp->dualchecked
3557  && (tree->pathnlpcols[tree->correctlpdepth] == tree->pathnlpcols[lpstateforkdepth]);
3558 
3559  /* check the path from LP fork to focus node for domain changes (destroying primal feasibility of LP basis) */
3560  if( checkbdchgs )
3561  {
3562  for( d = lpstateforkdepth; d < (int)(tree->focusnode->depth) && lp->primalfeasible; ++d )
3563  {
3564  assert(d < tree->pathlen);
3565  lp->primalfeasible = (tree->path[d]->domchg == NULL || tree->path[d]->domchg->domchgbound.nboundchgs == 0);
3566  lp->primalchecked = lp->primalfeasible;
3567  }
3568  }
3569  }
3570 
3571  SCIPsetDebugMsg(set, "-> primalfeasible=%u, dualfeasible=%u\n", lp->primalfeasible, lp->dualfeasible);
3572 
3573  return SCIP_OKAY;
3574 }
3575 
3576 
3577 
3578 
3579 /*
3580  * Node Conversion
3581  */
3582 
3583 /** converts node into LEAF and moves it into the array of the node queue
3584  * if node's lower bound is greater or equal than the given upper bound, the node is deleted;
3585  * otherwise, it is moved to the node queue; anyways, the given pointer is NULL after the call
3586  */
3587 static
3589  SCIP_NODE** node, /**< pointer to child or sibling node to convert */
3590  BMS_BLKMEM* blkmem, /**< block memory buffers */
3591  SCIP_SET* set, /**< global SCIP settings */
3592  SCIP_STAT* stat, /**< dynamic problem statistics */
3593  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3594  SCIP_TREE* tree, /**< branch and bound tree */
3595  SCIP_REOPT* reopt, /**< reoptimization data structure */
3596  SCIP_LP* lp, /**< current LP data */
3597  SCIP_NODE* lpstatefork, /**< LP state defining fork of the node */
3598  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
3599  )
3600 {
3603  assert(stat != NULL);
3604  assert(lpstatefork == NULL || lpstatefork->depth < (*node)->depth);
3605  assert(lpstatefork == NULL || lpstatefork->active || SCIPsetIsGE(set, (*node)->lowerbound, cutoffbound));
3606  assert(lpstatefork == NULL
3607  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK
3608  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT);
3609 
3610  /* convert node into leaf */
3611  SCIPsetDebugMsg(set, "convert node #%" SCIP_LONGINT_FORMAT " at depth %d to leaf with lpstatefork #%" SCIP_LONGINT_FORMAT " at depth %d\n",
3612  SCIPnodeGetNumber(*node), SCIPnodeGetDepth(*node),
3613  lpstatefork == NULL ? -1 : SCIPnodeGetNumber(lpstatefork),
3614  lpstatefork == NULL ? -1 : SCIPnodeGetDepth(lpstatefork));
3615  (*node)->nodetype = SCIP_NODETYPE_LEAF; /*lint !e641*/
3616  (*node)->data.leaf.lpstatefork = lpstatefork;
3617 
3618 #ifndef NDEBUG
3619  /* check, if the LP state fork is the first node with LP state information on the path back to the root */
3620  if( !SCIPsetIsInfinity(set, -cutoffbound) ) /* if the node was cut off in SCIPnodeFocus(), the lpstatefork is invalid */
3621  {
3622  SCIP_NODE* pathnode;
3623  pathnode = (*node)->parent;
3624  while( pathnode != NULL && pathnode != lpstatefork )
3625  {
3626  assert(SCIPnodeGetType(pathnode) == SCIP_NODETYPE_JUNCTION
3627  || SCIPnodeGetType(pathnode) == SCIP_NODETYPE_PSEUDOFORK);
3628  pathnode = pathnode->parent;
3629  }
3630  assert(pathnode == lpstatefork);
3631  }
3632 #endif
3633 
3634  /* if node is good enough to keep, put it on the node queue */
3635  if( SCIPsetIsLT(set, (*node)->lowerbound, cutoffbound) )
3636  {
3637  /* insert leaf in node queue */
3638  SCIP_CALL( SCIPnodepqInsert(tree->leaves, set, *node) );
3639 
3640  /* make the domain change data static to save memory */
3641  SCIP_CALL( SCIPdomchgMakeStatic(&(*node)->domchg, blkmem, set, eventqueue, lp) );
3642 
3643  /* node is now member of the node queue: delete the pointer to forbid further access */
3644  *node = NULL;
3645  }
3646  else
3647  {
3648  if( set->reopt_enable )
3649  {
3650  assert(reopt != NULL);
3651  /* check if the node should be stored for reoptimization */
3653  tree->root == *node, tree->focusnode == *node, (*node)->lowerbound, tree->effectiverootdepth) );
3654  }
3655 
3656  /* delete node due to bound cut off */
3657  SCIPvisualCutoffNode(stat->visual, set, stat, *node, FALSE);
3658  SCIP_CALL( SCIPnodeFree(node, blkmem, set, stat, eventqueue, tree, lp) );
3659  }
3660  assert(*node == NULL);
3661 
3662  return SCIP_OKAY;
3663 }
3664 
3665 /** removes variables from the problem, that are marked to be deletable, and were created at the focusnode;
3666  * only removes variables that were created at the focusnode, unless inlp is TRUE (e.g., when the node is cut off, anyway)
3667  */
3668 static
3670  BMS_BLKMEM* blkmem, /**< block memory buffers */
3671  SCIP_SET* set, /**< global SCIP settings */
3672  SCIP_STAT* stat, /**< dynamic problem statistics */
3673  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3674  SCIP_PROB* transprob, /**< transformed problem after presolve */
3675  SCIP_PROB* origprob, /**< original problem */
3676  SCIP_TREE* tree, /**< branch and bound tree */
3677  SCIP_REOPT* reopt, /**< reoptimization data structure */
3678  SCIP_LP* lp, /**< current LP data */
3679  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3680  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
3681  SCIP_Bool inlp /**< should variables in the LP be deleted, too?*/
3682  )
3683 {
3684  SCIP_VAR* var;
3685  int i;
3686  int ndelvars;
3687  SCIP_Bool needdel;
3688  SCIP_Bool deleted;
3689 
3690  assert(blkmem != NULL);
3691  assert(set != NULL);
3692  assert(stat != NULL);
3693  assert(tree != NULL);
3694  assert(!SCIPtreeProbing(tree));
3695  assert(tree->focusnode != NULL);
3697  assert(lp != NULL);
3698 
3699  /* check the settings, whether variables should be deleted */
3700  needdel = (tree->focusnode == tree->root ? set->price_delvarsroot : set->price_delvars);
3701 
3702  if( !needdel )
3703  return SCIP_OKAY;
3704 
3705  ndelvars = 0;
3706 
3707  /* also delete variables currently in the LP, thus remove all new variables from the LP, first */
3708  if( inlp )
3709  {
3710  /* remove all additions to the LP at this node */
3712 
3713  SCIP_CALL( SCIPlpFlush(lp, blkmem, set, eventqueue) );
3714  }
3715 
3716  /* mark variables as deleted */
3717  for( i = 0; i < transprob->nvars; i++ )
3718  {
3719  var = transprob->vars[i];
3720  assert(var != NULL);
3721 
3722  /* check whether variable is deletable */
3723  if( SCIPvarIsDeletable(var) )
3724  {
3725  if( !SCIPvarIsInLP(var) )
3726  {
3727  /* fix the variable to 0, first */
3728  assert(!SCIPsetIsFeasPositive(set, SCIPvarGetLbGlobal(var)));
3729  assert(!SCIPsetIsFeasNegative(set, SCIPvarGetUbGlobal(var)));
3730 
3731  if( !SCIPsetIsFeasZero(set, SCIPvarGetLbGlobal(var)) )
3732  {
3733  SCIP_CALL( SCIPnodeAddBoundchg(tree->root, blkmem, set, stat, transprob, origprob,
3734  tree, reopt, lp, branchcand, eventqueue, cliquetable, var, 0.0, SCIP_BOUNDTYPE_LOWER, FALSE) );
3735  }
3736  if( !SCIPsetIsFeasZero(set, SCIPvarGetUbGlobal(var)) )
3737  {
3738  SCIP_CALL( SCIPnodeAddBoundchg(tree->root, blkmem, set, stat, transprob, origprob,
3739  tree, reopt, lp, branchcand, eventqueue, cliquetable, var, 0.0, SCIP_BOUNDTYPE_UPPER, FALSE) );
3740  }
3741 
3742  SCIP_CALL( SCIPprobDelVar(transprob, blkmem, set, eventqueue, var, &deleted) );
3743 
3744  if( deleted )
3745  ndelvars++;
3746  }
3747  else
3748  {
3749  /* mark variable to be non-deletable, because it will be contained in the basis information
3750  * at this node and must not be deleted from now on
3751  */
3753  }
3754  }
3755  }
3756 
3757  SCIPsetDebugMsg(set, "delvars at node %" SCIP_LONGINT_FORMAT ", deleted %d vars\n", stat->nnodes, ndelvars);
3758 
3759  if( ndelvars > 0 )
3760  {
3761  /* perform the variable deletions from the problem */
3762  SCIP_CALL( SCIPprobPerformVarDeletions(transprob, blkmem, set, stat, eventqueue, cliquetable, lp, branchcand) );
3763  }
3764 
3765  return SCIP_OKAY;
3766 }
3767 
3768 /** converts the focus node into a dead-end node */
3769 static
3771  BMS_BLKMEM* blkmem, /**< block memory buffers */
3772  SCIP_SET* set, /**< global SCIP settings */
3773  SCIP_STAT* stat, /**< dynamic problem statistics */
3774  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3775  SCIP_PROB* transprob, /**< transformed problem after presolve */
3776  SCIP_PROB* origprob, /**< original problem */
3777  SCIP_TREE* tree, /**< branch and bound tree */
3778  SCIP_REOPT* reopt, /**< reoptimization data structure */
3779  SCIP_LP* lp, /**< current LP data */
3780  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3781  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3782  )
3783 {
3784  assert(blkmem != NULL);
3785  assert(tree != NULL);
3786  assert(!SCIPtreeProbing(tree));
3787  assert(tree->focusnode != NULL);
3789  assert(tree->nchildren == 0);
3790 
3791  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to dead-end at depth %d\n",
3793 
3794  /* remove variables from the problem that are marked as deletable and were created at this node */
3795  SCIP_CALL( focusnodeCleanupVars(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand, cliquetable, TRUE) );
3796 
3797  tree->focusnode->nodetype = SCIP_NODETYPE_DEADEND; /*lint !e641*/
3798 
3799  /* release LPI state */
3800  if( tree->focuslpstatefork != NULL )
3801  {
3802  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
3803  }
3804 
3805  return SCIP_OKAY;
3806 }
3807 
3808 /** converts the focus node into a leaf node (if it was postponed) */
3809 static
3811  BMS_BLKMEM* blkmem, /**< block memory buffers */
3812  SCIP_SET* set, /**< global SCIP settings */
3813  SCIP_STAT* stat, /**< dynamic problem statistics */
3814  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3815  SCIP_TREE* tree, /**< branch and bound tree */
3816  SCIP_REOPT* reopt, /**< reoptimization data structure */
3817  SCIP_LP* lp, /**< current LP data */
3818  SCIP_NODE* lpstatefork, /**< LP state defining fork of the node */
3819  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
3820 
3821  )
3822 {
3823  assert(tree != NULL);
3824  assert(!SCIPtreeProbing(tree));
3825  assert(tree->focusnode != NULL);
3826  assert(tree->focusnode->active);
3828 
3829  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to leaf at depth %d\n",
3831 
3832  SCIP_CALL( nodeToLeaf(&tree->focusnode, blkmem, set, stat, eventqueue, tree, reopt, lp, lpstatefork, cutoffbound));
3833 
3834  return SCIP_OKAY;
3835 }
3836 
3837 /** converts the focus node into a junction node */
3838 static
3840  BMS_BLKMEM* blkmem, /**< block memory buffers */
3841  SCIP_SET* set, /**< global SCIP settings */
3842  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3843  SCIP_TREE* tree, /**< branch and bound tree */
3844  SCIP_LP* lp /**< current LP data */
3845  )
3846 {
3847  assert(tree != NULL);
3848  assert(!SCIPtreeProbing(tree));
3849  assert(tree->focusnode != NULL);
3850  assert(tree->focusnode->active); /* otherwise, no children could be created at the focus node */
3852  assert(SCIPlpGetNNewcols(lp) == 0);
3853 
3854  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to junction at depth %d\n",
3856 
3857  /* convert node into junction */
3858  tree->focusnode->nodetype = SCIP_NODETYPE_JUNCTION; /*lint !e641*/
3859 
3860  SCIP_CALL( junctionInit(&tree->focusnode->data.junction, tree) );
3861 
3862  /* release LPI state */
3863  if( tree->focuslpstatefork != NULL )
3864  {
3865  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
3866  }
3867 
3868  /* make the domain change data static to save memory */
3869  SCIP_CALL( SCIPdomchgMakeStatic(&tree->focusnode->domchg, blkmem, set, eventqueue, lp) );
3870 
3871  return SCIP_OKAY;
3872 }
3873 
3874 /** converts the focus node into a pseudofork node */
3875 static
3877  BMS_BLKMEM* blkmem, /**< block memory buffers */
3878  SCIP_SET* set, /**< global SCIP settings */
3879  SCIP_STAT* stat, /**< dynamic problem statistics */
3880  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3881  SCIP_PROB* transprob, /**< transformed problem after presolve */
3882  SCIP_PROB* origprob, /**< original problem */
3883  SCIP_TREE* tree, /**< branch and bound tree */
3884  SCIP_REOPT* reopt, /**< reoptimization data structure */
3885  SCIP_LP* lp, /**< current LP data */
3886  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3887  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3888  )
3889 {
3890  SCIP_PSEUDOFORK* pseudofork;
3891 
3892  assert(blkmem != NULL);
3893  assert(tree != NULL);
3894  assert(!SCIPtreeProbing(tree));
3895  assert(tree->focusnode != NULL);
3896  assert(tree->focusnode->active); /* otherwise, no children could be created at the focus node */
3898  assert(tree->nchildren > 0);
3899  assert(lp != NULL);
3900 
3901  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to pseudofork at depth %d\n",
3903 
3904  /* remove variables from the problem that are marked as deletable and were created at this node */
3905  SCIP_CALL( focusnodeCleanupVars(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand, cliquetable, FALSE) );
3906 
3907  /* create pseudofork data */
3908  SCIP_CALL( pseudoforkCreate(&pseudofork, blkmem, tree, lp) );
3909 
3910  tree->focusnode->nodetype = SCIP_NODETYPE_PSEUDOFORK; /*lint !e641*/
3911  tree->focusnode->data.pseudofork = pseudofork;
3912 
3913  /* release LPI state */
3914  if( tree->focuslpstatefork != NULL )
3915  {
3916  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
3917  }
3918 
3919  /* make the domain change data static to save memory */
3920  SCIP_CALL( SCIPdomchgMakeStatic(&tree->focusnode->domchg, blkmem, set, eventqueue, lp) );
3921 
3922  return SCIP_OKAY;
3923 }
3924 
3925 /** converts the focus node into a fork node */
3926 static
3928  BMS_BLKMEM* blkmem, /**< block memory buffers */
3929  SCIP_SET* set, /**< global SCIP settings */
3930  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
3931  SCIP_STAT* stat, /**< dynamic problem statistics */
3932  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
3933  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
3934  SCIP_PROB* transprob, /**< transformed problem after presolve */
3935  SCIP_PROB* origprob, /**< original problem */
3936  SCIP_TREE* tree, /**< branch and bound tree */
3937  SCIP_REOPT* reopt, /**< reoptimization data structure */
3938  SCIP_LP* lp, /**< current LP data */
3939  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3940  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
3941  )
3942 {
3943  SCIP_FORK* fork;
3944  SCIP_Bool lperror;
3945 
3946  assert(blkmem != NULL);
3947  assert(tree != NULL);
3948  assert(!SCIPtreeProbing(tree));
3949  assert(tree->focusnode != NULL);
3950  assert(tree->focusnode->active); /* otherwise, no children could be created at the focus node */
3952  assert(tree->nchildren > 0);
3953  assert(lp != NULL);
3954  assert(lp->flushed);
3955  assert(lp->solved || lp->resolvelperror);
3956 
3957  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to fork at depth %d\n",
3959 
3960  /* usually, the LP should be solved to optimality; otherwise, numerical troubles occured,
3961  * and we have to forget about the LP and transform the node into a junction (see below)
3962  */
3963  lperror = FALSE;
3965  {
3966  /* clean up newly created part of LP to keep only necessary columns and rows */
3967  SCIP_CALL( SCIPlpCleanupNew(lp, blkmem, set, stat, eventqueue, eventfilter, (tree->focusnode->depth == 0)) );
3968 
3969  /* resolve LP after cleaning up */
3970  if( !lp->solved || !lp->flushed )
3971  {
3972  SCIPsetDebugMsg(set, "resolving LP after cleanup\n");
3973  SCIP_CALL( SCIPlpSolveAndEval(lp, set, messagehdlr, blkmem, stat, eventqueue, eventfilter, transprob, -1LL, FALSE, FALSE, TRUE, &lperror) );
3974  }
3975  }
3976  assert(lp->flushed);
3977  assert(lp->solved || lperror || lp->resolvelperror);
3978 
3979  /* There are two reasons, that the (reduced) LP is not solved to optimality:
3980  * - The primal heuristics (called after the current node's LP was solved) found a new
3981  * solution, that is better than the current node's lower bound.
3982  * (But in this case, all children should be cut off and the node should be converted
3983  * into a dead-end instead of a fork.)
3984  * - Something numerically weird happened after cleaning up or after resolving a diving or probing LP.
3985  * The only thing we can do, is to completely forget about the LP and treat the node as
3986  * if it was only a pseudo-solution node. Therefore we have to remove all additional
3987  * columns and rows from the LP and convert the node into a junction.
3988  * However, the node's lower bound is kept, thus automatically throwing away nodes that
3989  * were cut off due to a primal solution.
3990  */
3991  if( lperror || lp->resolvelperror || SCIPlpGetSolstat(lp) != SCIP_LPSOLSTAT_OPTIMAL )
3992  {
3993  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
3994  "(node %" SCIP_LONGINT_FORMAT ") numerical troubles: LP %" SCIP_LONGINT_FORMAT " not optimal -- convert node into junction instead of fork\n",
3995  stat->nnodes, stat->nlps);
3996 
3997  /* remove all additions to the LP at this node */
3999  SCIP_CALL( SCIPlpShrinkRows(lp, blkmem, set, eventqueue, eventfilter, SCIPlpGetNRows(lp) - SCIPlpGetNNewrows(lp)) );
4000 
4001  /* convert node into a junction */
4002  SCIP_CALL( focusnodeToJunction(blkmem, set, eventqueue, tree, lp) );
4003 
4004  return SCIP_OKAY;
4005  }
4006  assert(lp->flushed);
4007  assert(lp->solved);
4009 
4010  /* remove variables from the problem that are marked as deletable, were created at this node and are not contained in the LP */
4011  SCIP_CALL( focusnodeCleanupVars(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand, cliquetable, FALSE) );
4012 
4013  assert(lp->flushed);
4014  assert(lp->solved);
4015 
4016  /* create fork data */
4017  SCIP_CALL( forkCreate(&fork, blkmem, set, transprob, tree, lp) );
4018 
4019  tree->focusnode->nodetype = SCIP_NODETYPE_FORK; /*lint !e641*/
4020  tree->focusnode->data.fork = fork;
4021 
4022  /* capture the LPI state of the root node to ensure that the LPI state of the root stays for the whole solving
4023  * process
4024  */
4025  if( tree->focusnode == tree->root )
4026  forkCaptureLPIState(fork, 1);
4027 
4028  /* release LPI state */
4029  if( tree->focuslpstatefork != NULL )
4030  {
4031  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
4032  }
4033 
4034  /* make the domain change data static to save memory */
4035  SCIP_CALL( SCIPdomchgMakeStatic(&tree->focusnode->domchg, blkmem, set, eventqueue, lp) );
4036 
4037  return SCIP_OKAY;
4038 }
4039 
4040 #ifdef WITHSUBROOTS /** @todo test whether subroots should be created */
4041 /** converts the focus node into a subroot node */
4042 static
4043 SCIP_RETCODE focusnodeToSubroot(
4044  BMS_BLKMEM* blkmem, /**< block memory buffers */
4045  SCIP_SET* set, /**< global SCIP settings */
4046  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4047  SCIP_STAT* stat, /**< dynamic problem statistics */
4048  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4049  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
4050  SCIP_PROB* transprob, /**< transformed problem after presolve */
4051  SCIP_PROB* origprob, /**< original problem */
4052  SCIP_TREE* tree, /**< branch and bound tree */
4053  SCIP_LP* lp, /**< current LP data */
4054  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4055  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
4056  )
4057 {
4058  SCIP_SUBROOT* subroot;
4059  SCIP_Bool lperror;
4060 
4061  assert(blkmem != NULL);
4062  assert(tree != NULL);
4063  assert(!SCIPtreeProbing(tree));
4064  assert(tree->focusnode != NULL);
4066  assert(tree->focusnode->active); /* otherwise, no children could be created at the focus node */
4067  assert(tree->nchildren > 0);
4068  assert(lp != NULL);
4069  assert(lp->flushed);
4070  assert(lp->solved);
4071 
4072  SCIPsetDebugMsg(set, "focusnode #%" SCIP_LONGINT_FORMAT " to subroot at depth %d\n",
4074 
4075  /* usually, the LP should be solved to optimality; otherwise, numerical troubles occured,
4076  * and we have to forget about the LP and transform the node into a junction (see below)
4077  */
4078  lperror = FALSE;
4080  {
4081  /* clean up whole LP to keep only necessary columns and rows */
4082 #ifdef SCIP_DISABLED_CODE
4083  if( tree->focusnode->depth == 0 )
4084  {
4085  SCIP_CALL( SCIPlpCleanupAll(lp, blkmem, set, stat, eventqueue, eventfilter, (tree->focusnode->depth == 0)) );
4086  }
4087  else
4088 #endif
4089  {
4090  SCIP_CALL( SCIPlpRemoveAllObsoletes(lp, blkmem, set, stat, eventqueue, eventfilter) );
4091  }
4092 
4093  /* resolve LP after cleaning up */
4094  if( !lp->solved || !lp->flushed )
4095  {
4096  SCIPsetDebugMsg(set, "resolving LP after cleanup\n");
4097  SCIP_CALL( SCIPlpSolveAndEval(lp, set, messagehdlr, blkmem, stat, eventqueue, eventfilter, transprob, -1LL, FALSE, FALSE, TRUE, &lperror) );
4098  }
4099  }
4100  assert(lp->flushed);
4101  assert(lp->solved || lperror);
4102 
4103  /* There are two reasons, that the (reduced) LP is not solved to optimality:
4104  * - The primal heuristics (called after the current node's LP was solved) found a new
4105  * solution, that is better than the current node's lower bound.
4106  * (But in this case, all children should be cut off and the node should be converted
4107  * into a dead-end instead of a subroot.)
4108  * - Something numerically weird happened after cleaning up.
4109  * The only thing we can do, is to completely forget about the LP and treat the node as
4110  * if it was only a pseudo-solution node. Therefore we have to remove all additional
4111  * columns and rows from the LP and convert the node into a junction.
4112  * However, the node's lower bound is kept, thus automatically throwing away nodes that
4113  * were cut off due to a primal solution.
4114  */
4115  if( lperror || SCIPlpGetSolstat(lp) != SCIP_LPSOLSTAT_OPTIMAL )
4116  {
4117  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
4118  "(node %" SCIP_LONGINT_FORMAT ") numerical troubles: LP %" SCIP_LONGINT_FORMAT " not optimal -- convert node into junction instead of subroot\n",
4119  stat->nnodes, stat->nlps);
4120 
4121  /* remove all additions to the LP at this node */
4123  SCIP_CALL( SCIPlpShrinkRows(lp, blkmem, set, eventqueue, eventfilter, SCIPlpGetNRows(lp) - SCIPlpGetNNewrows(lp)) );
4124 
4125  /* convert node into a junction */
4126  SCIP_CALL( focusnodeToJunction(blkmem, set, eventqueue, tree, lp) );
4127 
4128  return SCIP_OKAY;
4129  }
4130  assert(lp->flushed);
4131  assert(lp->solved);
4133 
4134  /* remove variables from the problem that are marked as deletable, were created at this node and are not contained in the LP */
4135  SCIP_CALL( focusnodeCleanupVars(blkmem, set, stat, eventqueue, transprob, origprob, tree, lp, branchcand, cliquetable, FALSE) );
4136 
4137  assert(lp->flushed);
4138  assert(lp->solved);
4139 
4140 
4141  /* create subroot data */
4142  SCIP_CALL( subrootCreate(&subroot, blkmem, set, transprob, tree, lp) );
4143 
4144  tree->focusnode->nodetype = SCIP_NODETYPE_SUBROOT; /*lint !e641*/
4145  tree->focusnode->data.subroot = subroot;
4146 
4147  /* update the LP column and row counter for the converted node */
4148  SCIP_CALL( treeUpdatePathLPSize(tree, tree->focusnode->depth) );
4149 
4150  /* release LPI state */
4151  if( tree->focuslpstatefork != NULL )
4152  {
4153  SCIP_CALL( SCIPnodeReleaseLPIState(tree->focuslpstatefork, blkmem, lp) );
4154  }
4155 
4156  /* make the domain change data static to save memory */
4157  SCIP_CALL( SCIPdomchgMakeStatic(&tree->focusnode->domchg, blkmem, set, eventqueue, lp) );
4158 
4159  return SCIP_OKAY;
4160 }
4161 #endif
4162 
4163 /** puts all nodes in the array on the node queue and makes them LEAFs */
4164 static
4166  SCIP_TREE* tree, /**< branch and bound tree */
4167  SCIP_REOPT* reopt, /**< reoptimization data structure */
4168  BMS_BLKMEM* blkmem, /**< block memory buffers */
4169  SCIP_SET* set, /**< global SCIP settings */
4170  SCIP_STAT* stat, /**< dynamic problem statistics */
4171  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4172  SCIP_LP* lp, /**< current LP data */
4173  SCIP_NODE** nodes, /**< array of nodes to put on the queue */
4174  int* nnodes, /**< pointer to number of nodes in the array */
4175  SCIP_NODE* lpstatefork, /**< LP state defining fork of the nodes */
4176  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
4177  )
4178 {
4179  int i;
4180 
4181  assert(tree != NULL);
4182  assert(set != NULL);
4183  assert(nnodes != NULL);
4184  assert(*nnodes == 0 || nodes != NULL);
4185 
4186  for( i = 0; i < *nnodes; ++i )
4187  {
4188  /* convert node to LEAF and put it into leaves queue, or delete it if it's lower bound exceeds the cutoff bound */
4189  SCIP_CALL( nodeToLeaf(&nodes[i], blkmem, set, stat, eventqueue, tree, reopt, lp, lpstatefork, cutoffbound) );
4190  assert(nodes[i] == NULL);
4191  }
4192  *nnodes = 0;
4193 
4194  return SCIP_OKAY;
4195 }
4196 
4197 /** converts children into siblings, clears children array */
4198 static
4200  SCIP_TREE* tree /**< branch and bound tree */
4201  )
4202 {
4203  SCIP_NODE** tmpnodes;
4204  SCIP_Real* tmpprios;
4205  int tmpnodessize;
4206  int i;
4207 
4208  assert(tree != NULL);
4209  assert(tree->nsiblings == 0);
4210 
4211  tmpnodes = tree->siblings;
4212  tmpprios = tree->siblingsprio;
4213  tmpnodessize = tree->siblingssize;
4214 
4215  tree->siblings = tree->children;
4216  tree->siblingsprio = tree->childrenprio;
4217  tree->nsiblings = tree->nchildren;
4218  tree->siblingssize = tree->childrensize;
4219 
4220  tree->children = tmpnodes;
4221  tree->childrenprio = tmpprios;
4222  tree->nchildren = 0;
4223  tree->childrensize = tmpnodessize;
4224 
4225  for( i = 0; i < tree->nsiblings; ++i )
4226  {
4227  assert(SCIPnodeGetType(tree->siblings[i]) == SCIP_NODETYPE_CHILD);
4228  tree->siblings[i]->nodetype = SCIP_NODETYPE_SIBLING; /*lint !e641*/
4229 
4230  /* because CHILD and SIBLING structs contain the same data in the same order, we do not have to copy it */
4231  assert(&(tree->siblings[i]->data.sibling.arraypos) == &(tree->siblings[i]->data.child.arraypos));
4232  }
4233 }
4234 
4235 /** installs a child, a sibling, or a leaf node as the new focus node */
4237  SCIP_NODE** node, /**< pointer to node to focus (or NULL to remove focus); the node
4238  * is freed, if it was cut off due to a cut off subtree */
4239  BMS_BLKMEM* blkmem, /**< block memory buffers */
4240  SCIP_SET* set, /**< global SCIP settings */
4241  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4242  SCIP_STAT* stat, /**< problem statistics */
4243  SCIP_PROB* transprob, /**< transformed problem */
4244  SCIP_PROB* origprob, /**< original problem */
4245  SCIP_PRIMAL* primal, /**< primal data */
4246  SCIP_TREE* tree, /**< branch and bound tree */
4247  SCIP_REOPT* reopt, /**< reoptimization data structure */
4248  SCIP_LP* lp, /**< current LP data */
4249  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4250  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4251  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
4252  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4253  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4254  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
4255  SCIP_Bool* cutoff, /**< pointer to store whether the given node can be cut off */
4256  SCIP_Bool postponed, /**< was the current focus node postponed? */
4257  SCIP_Bool exitsolve /**< are we in exitsolve stage, so we only need to loose the children */
4258  )
4259 { /*lint --e{715}*/
4260  SCIP_NODE* oldfocusnode;
4261  SCIP_NODE* fork;
4262  SCIP_NODE* lpfork;
4263  SCIP_NODE* lpstatefork;
4264  SCIP_NODE* subroot;
4265  SCIP_NODE* childrenlpstatefork;
4266  int oldcutoffdepth;
4267 
4268  assert(node != NULL);
4269  assert(*node == NULL
4272  || SCIPnodeGetType(*node) == SCIP_NODETYPE_LEAF);
4273  assert(*node == NULL || !(*node)->active);
4274  assert(stat != NULL);
4275  assert(tree != NULL);
4276  assert(!postponed || *node == NULL);
4277  assert(!postponed || tree->focusnode != NULL);
4278  assert(!SCIPtreeProbing(tree));
4279  assert(lp != NULL);
4280  assert(cutoff != NULL);
4281 
4282  SCIPsetDebugMsg(set, "focusing node #%" SCIP_LONGINT_FORMAT " of type %d in depth %d\n",
4283  *node != NULL ? SCIPnodeGetNumber(*node) : -1, *node != NULL ? (int)SCIPnodeGetType(*node) : 0,
4284  *node != NULL ? SCIPnodeGetDepth(*node) : -1);
4285 
4286  /* remember old cutoff depth in order to know, whether the children and siblings can be deleted */
4287  oldcutoffdepth = tree->cutoffdepth;
4288 
4289  /* find the common fork node, the new LP defining fork, and the new focus subroot,
4290  * thereby checking, if the new node can be cut off
4291  */
4292  treeFindSwitchForks(tree, *node, &fork, &lpfork, &lpstatefork, &subroot, cutoff);
4293  SCIPsetDebugMsg(set, "focus node: focusnodedepth=%d, forkdepth=%d, lpforkdepth=%d, lpstateforkdepth=%d, subrootdepth=%d, cutoff=%u\n",
4294  *node != NULL ? (*node)->depth : -1, fork != NULL ? fork->depth : -1, /*lint !e705 */
4295  lpfork != NULL ? lpfork->depth : -1, lpstatefork != NULL ? lpstatefork->depth : -1, /*lint !e705 */
4296  subroot != NULL ? subroot->depth : -1, *cutoff); /*lint !e705 */
4297 
4298  /* free the new node, if it is located in a cut off subtree */
4299  if( *cutoff )
4300  {
4301  assert(*node != NULL);
4302  assert(tree->cutoffdepth == oldcutoffdepth);
4303  if( SCIPnodeGetType(*node) == SCIP_NODETYPE_LEAF )
4304  {
4305  SCIP_CALL( SCIPnodepqRemove(tree->leaves, set, *node) );
4306  }
4307  SCIPvisualCutoffNode(stat->visual, set, stat, *node, FALSE);
4308 
4309  if( set->reopt_enable )
4310  {
4311  assert(reopt != NULL);
4312  /* check if the node should be stored for reoptimization */
4314  tree->root == (*node), tree->focusnode == (*node), (*node)->lowerbound, tree->effectiverootdepth) );
4315  }
4316 
4317  SCIP_CALL( SCIPnodeFree(node, blkmem, set, stat, eventqueue, tree, lp) );
4318 
4319  return SCIP_OKAY;
4320  }
4321 
4322  assert(tree->cutoffdepth == INT_MAX);
4323  assert(fork == NULL || fork->active);
4324  assert(lpstatefork == NULL || lpfork != NULL);
4325  assert(subroot == NULL || lpstatefork != NULL);
4326 
4327  /* remember the depth of the common fork node for LP updates */
4328  SCIPsetDebugMsg(set, "focus node: old correctlpdepth=%d\n", tree->correctlpdepth);
4329  if( subroot == tree->focussubroot && fork != NULL && lpfork != NULL )
4330  {
4331  /* we are in the same subtree with valid LP fork: the LP is correct at most upto the common fork depth */
4332  assert(subroot == NULL || subroot->active);
4333  tree->correctlpdepth = MIN(tree->correctlpdepth, (int)fork->depth);
4334  }
4335  else
4336  {
4337  /* we are in a different subtree, or no valid LP fork exists: the LP is completely incorrect */
4338  assert(subroot == NULL || !subroot->active
4339  || (tree->focussubroot != NULL && (int)(tree->focussubroot->depth) > subroot->depth));
4340  tree->correctlpdepth = -1;
4341  }
4342 
4343  /* if the LP state fork changed, the lpcount information for the new LP state fork is unknown */
4344  if( lpstatefork != tree->focuslpstatefork )
4345  tree->focuslpstateforklpcount = -1;
4346 
4347  /* in exitsolve we only need to take care of open children
4348  *
4349  * @note because we might do a 'newstart' and converted cuts to constraints might have rendered the LP in the current
4350  * focusnode unsolved the latter code would have resolved the LP unnecessarily
4351  */
4352  if( exitsolve && tree->nchildren > 0 )
4353  {
4354  SCIPsetDebugMsg(set, " -> deleting the %d children (in exitsolve) of the old focus node\n", tree->nchildren);
4355  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, NULL, -SCIPsetInfinity(set)) );
4356  assert(tree->nchildren == 0);
4357  }
4358 
4359  /* if the old focus node was cut off, we can delete its children;
4360  * if the old focus node's parent was cut off, we can also delete the focus node's siblings
4361  */
4362  if( tree->focusnode != NULL && oldcutoffdepth <= (int)tree->focusnode->depth )
4363  {
4364  SCIPsetDebugMsg(set, "path to old focus node of depth %u was cut off at depth %d\n", tree->focusnode->depth, oldcutoffdepth);
4365 
4366  /* delete the focus node's children by converting them to leaves with a cutoffbound of -SCIPsetInfinity(set);
4367  * we cannot delete them directly, because in SCIPnodeFree(), the children array is changed, which is the
4368  * same array we would have to iterate over here;
4369  * the children don't have an LP fork, because the old focus node is not yet converted into a fork or subroot
4370  */
4371  SCIPsetDebugMsg(set, " -> deleting the %d children of the old focus node\n", tree->nchildren);
4372  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, NULL, -SCIPsetInfinity(set)) );
4373  assert(tree->nchildren == 0);
4374 
4375  if( oldcutoffdepth < (int)tree->focusnode->depth )
4376  {
4377  /* delete the focus node's siblings by converting them to leaves with a cutoffbound of -SCIPsetInfinity(set);
4378  * we cannot delete them directly, because in SCIPnodeFree(), the siblings array is changed, which is the
4379  * same array we would have to iterate over here;
4380  * the siblings have the same LP state fork as the old focus node
4381  */
4382  SCIPsetDebugMsg(set, " -> deleting the %d siblings of the old focus node\n", tree->nsiblings);
4383  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4384  -SCIPsetInfinity(set)) );
4385  assert(tree->nsiblings == 0);
4386  }
4387  }
4388 
4389  /* convert the old focus node into a fork or subroot node, if it has children;
4390  * otherwise, convert it into a dead-end, which will be freed later in treeSwitchPath();
4391  * if the node was postponed, make it a leaf.
4392  */
4393  childrenlpstatefork = tree->focuslpstatefork;
4394  if( postponed )
4395  {
4396  assert(tree->nchildren == 0);
4397  assert(*node == NULL);
4398 
4399  /* if the node is infeasible, convert it into a deadend; otherwise, put it into the LEAF queue */
4400  if( SCIPsetIsGE(set, tree->focusnode->lowerbound, primal->cutoffbound) )
4401  {
4402  /* in case the LP was not constructed (due to the parameter settings for example) we have the finally remember the
4403  * old size of the LP (if it was constructed in an earlier node) before we change the current node into a deadend
4404  */
4405  if( !tree->focuslpconstructed )
4406  SCIPlpMarkSize(lp);
4407 
4408  /* convert old focus node into deadend */
4409  SCIP_CALL( focusnodeToDeadend(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand,
4410  cliquetable) );
4411  }
4412  else
4413  {
4414  SCIP_CALL( focusnodeToLeaf(blkmem, set, stat, eventqueue, tree, reopt, lp, tree->focuslpstatefork,
4415  SCIPsetInfinity(set)) );
4416  }
4417  }
4418  else if( tree->nchildren > 0 )
4419  {
4420  SCIP_Bool selectedchild;
4421 
4422  assert(tree->focusnode != NULL);
4424  assert(oldcutoffdepth == INT_MAX);
4425 
4426  /* check whether the next focus node is a child of the old focus node */
4427  selectedchild = (*node != NULL && SCIPnodeGetType(*node) == SCIP_NODETYPE_CHILD);
4428 
4429  if( tree->focusnodehaslp && lp->isrelax )
4430  {
4431  assert(tree->focuslpconstructed);
4432 
4433 #ifdef WITHSUBROOTS /** @todo test whether subroots should be created, decide: old focus node becomes fork or subroot */
4434  if( tree->focusnode->depth > 0 && tree->focusnode->depth % 25 == 0 )
4435  {
4436  /* convert old focus node into a subroot node */
4437  SCIP_CALL( focusnodeToSubroot(blkmem, set, messagehdlr, stat, eventqueue, eventfilter, transprob, origprob, tree, lp, branchcand) );
4438  if( *node != NULL && SCIPnodeGetType(*node) == SCIP_NODETYPE_CHILD
4440  subroot = tree->focusnode;
4441  }
4442  else
4443 #endif
4444  {
4445  /* convert old focus node into a fork node */
4446  SCIP_CALL( focusnodeToFork(blkmem, set, messagehdlr, stat, eventqueue, eventfilter, transprob, origprob, tree,
4447  reopt, lp, branchcand, cliquetable) );
4448  }
4449 
4450  /* check, if the conversion into a subroot or fork was successful */
4453  {
4454  childrenlpstatefork = tree->focusnode;
4455 
4456  /* if a child of the old focus node was selected as new focus node, the old node becomes the new focus
4457  * LP fork and LP state fork
4458  */
4459  if( selectedchild )
4460  {
4461  lpfork = tree->focusnode;
4462  tree->correctlpdepth = tree->focusnode->depth;
4463  lpstatefork = tree->focusnode;
4464  tree->focuslpstateforklpcount = stat->lpcount;
4465  }
4466  }
4467 
4468  /* update the path's LP size */
4469  tree->pathnlpcols[tree->focusnode->depth] = SCIPlpGetNCols(lp);
4470  tree->pathnlprows[tree->focusnode->depth] = SCIPlpGetNRows(lp);
4471  }
4472  else if( tree->focuslpconstructed && (SCIPlpGetNNewcols(lp) > 0 || SCIPlpGetNNewrows(lp) > 0) )
4473  {
4474  /* convert old focus node into pseudofork */
4475  SCIP_CALL( focusnodeToPseudofork(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp,
4476  branchcand, cliquetable) );
4478 
4479  /* update the path's LP size */
4480  tree->pathnlpcols[tree->focusnode->depth] = SCIPlpGetNCols(lp);
4481  tree->pathnlprows[tree->focusnode->depth] = SCIPlpGetNRows(lp);
4482 
4483  /* if a child of the old focus node was selected as new focus node, the old node becomes the new focus LP fork */
4484  if( selectedchild )
4485  {
4486  lpfork = tree->focusnode;
4487  tree->correctlpdepth = tree->focusnode->depth;
4488  }
4489  }
4490  else
4491  {
4492  /* in case the LP was not constructed (due to the parameter settings for example) we have the finally remember the
4493  * old size of the LP (if it was constructed in an earlier node) before we change the current node into a junction
4494  */
4495  SCIPlpMarkSize(lp);
4496 
4497  /* convert old focus node into junction */
4498  SCIP_CALL( focusnodeToJunction(blkmem, set, eventqueue, tree, lp) );
4499  }
4500  }
4501  else if( tree->focusnode != NULL )
4502  {
4503  /* in case the LP was not constructed (due to the parameter settings for example) we have the finally remember the
4504  * old size of the LP (if it was constructed in an earlier node) before we change the current node into a deadend
4505  */
4506  if( !tree->focuslpconstructed )
4507  SCIPlpMarkSize(lp);
4508 
4509  /* convert old focus node into deadend */
4510  SCIP_CALL( focusnodeToDeadend(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand, cliquetable) );
4511  }
4512  assert(subroot == NULL || SCIPnodeGetType(subroot) == SCIP_NODETYPE_SUBROOT);
4513  assert(lpstatefork == NULL
4514  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT
4515  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK);
4516  assert(childrenlpstatefork == NULL
4517  || SCIPnodeGetType(childrenlpstatefork) == SCIP_NODETYPE_SUBROOT
4518  || SCIPnodeGetType(childrenlpstatefork) == SCIP_NODETYPE_FORK);
4519  assert(lpfork == NULL
4521  || SCIPnodeGetType(lpfork) == SCIP_NODETYPE_FORK
4523  SCIPsetDebugMsg(set, "focus node: new correctlpdepth=%d\n", tree->correctlpdepth);
4524 
4525  /* set up the new lists of siblings and children */
4526  oldfocusnode = tree->focusnode;
4527  if( *node == NULL )
4528  {
4529  /* move siblings to the queue, make them LEAFs */
4530  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4531  primal->cutoffbound) );
4532 
4533  /* move children to the queue, make them LEAFs */
4534  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, childrenlpstatefork,
4535  primal->cutoffbound) );
4536  }
4537  else
4538  {
4539  SCIP_NODE* bestleaf;
4540 
4541  switch( SCIPnodeGetType(*node) )
4542  {
4543  case SCIP_NODETYPE_SIBLING:
4544  /* reset plunging depth, if the selected node is better than all leaves */
4545  bestleaf = SCIPtreeGetBestLeaf(tree);
4546  if( bestleaf == NULL || SCIPnodepqCompare(tree->leaves, set, *node, bestleaf) <= 0 )
4547  stat->plungedepth = 0;
4548 
4549  /* move children to the queue, make them LEAFs */
4550  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, childrenlpstatefork,
4551  primal->cutoffbound) );
4552 
4553  /* remove selected sibling from the siblings array */
4554  treeRemoveSibling(tree, *node);
4555 
4556  SCIPsetDebugMsg(set, "selected sibling node, lowerbound=%g, plungedepth=%d\n", (*node)->lowerbound, stat->plungedepth);
4557  break;
4558 
4559  case SCIP_NODETYPE_CHILD:
4560  /* reset plunging depth, if the selected node is better than all leaves; otherwise, increase plunging depth */
4561  bestleaf = SCIPtreeGetBestLeaf(tree);
4562  if( bestleaf == NULL || SCIPnodepqCompare(tree->leaves, set, *node, bestleaf) <= 0 )
4563  stat->plungedepth = 0;
4564  else
4565  stat->plungedepth++;
4566 
4567  /* move siblings to the queue, make them LEAFs */
4568  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4569  primal->cutoffbound) );
4570 
4571  /* remove selected child from the children array */
4572  treeRemoveChild(tree, *node);
4573 
4574  /* move remaining children to the siblings array, make them SIBLINGs */
4575  treeChildrenToSiblings(tree);
4576 
4577  SCIPsetDebugMsg(set, "selected child node, lowerbound=%g, plungedepth=%d\n", (*node)->lowerbound, stat->plungedepth);
4578  break;
4579 
4580  case SCIP_NODETYPE_LEAF:
4581  /* move siblings to the queue, make them LEAFs */
4582  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4583  primal->cutoffbound) );
4584 
4585  /* encounter an early backtrack if there is a child which does not exceed given reference bound */
4586  if( !SCIPsetIsInfinity(set, stat->referencebound) )
4587  {
4588  int c;
4589 
4590  /* loop over children and stop if we find a child with a lower bound below given reference bound */
4591  for( c = 0; c < tree->nchildren; ++c )
4592  {
4593  if( SCIPsetIsLT(set, SCIPnodeGetLowerbound(tree->children[c]), stat->referencebound) )
4594  {
4595  ++stat->nearlybacktracks;
4596  break;
4597  }
4598  }
4599  }
4600  /* move children to the queue, make them LEAFs */
4601  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, childrenlpstatefork,
4602  primal->cutoffbound) );
4603 
4604  /* remove node from the queue */
4605  SCIP_CALL( SCIPnodepqRemove(tree->leaves, set, *node) );
4606 
4607  stat->plungedepth = 0;
4608  if( SCIPnodeGetDepth(*node) > 0 )
4609  stat->nbacktracks++;
4610  SCIPsetDebugMsg(set, "selected leaf node, lowerbound=%g, plungedepth=%d\n", (*node)->lowerbound, stat->plungedepth);
4611  break;
4612 
4613  default:
4614  SCIPerrorMessage("selected node is neither sibling, child, nor leaf (nodetype=%d)\n", SCIPnodeGetType(*node));
4615  return SCIP_INVALIDDATA;
4616  } /*lint !e788*/
4617 
4618  /* convert node into the focus node */
4619  (*node)->nodetype = SCIP_NODETYPE_FOCUSNODE; /*lint !e641*/
4620  }
4621  assert(tree->nchildren == 0);
4622 
4623  /* set new focus node, LP fork, LP state fork, and subroot */
4624  assert(subroot == NULL || (lpstatefork != NULL && subroot->depth <= lpstatefork->depth));
4625  assert(lpstatefork == NULL || (lpfork != NULL && lpstatefork->depth <= lpfork->depth));
4626  assert(lpfork == NULL || (*node != NULL && lpfork->depth < (*node)->depth));
4627  tree->focusnode = *node;
4628  tree->focuslpfork = lpfork;
4629  tree->focuslpstatefork = lpstatefork;
4630  tree->focussubroot = subroot;
4631  tree->focuslpconstructed = FALSE;
4632  lp->resolvelperror = FALSE;
4633 
4634  /* track the path from the old focus node to the new node, and perform domain and constraint set changes */
4635  SCIP_CALL( treeSwitchPath(tree, reopt, blkmem, set, stat, transprob, origprob, primal, lp, branchcand, conflict,
4636  eventfilter, eventqueue, cliquetable, fork, *node, cutoff) );
4637  assert(tree->pathlen >= 0);
4638  assert(*node != NULL || tree->pathlen == 0);
4639  assert(*node == NULL || tree->pathlen-1 <= (int)(*node)->depth);
4640 
4641  /* if the old focus node is a dead end (has no children), delete it */
4642  if( oldfocusnode != NULL && SCIPnodeGetType(oldfocusnode) == SCIP_NODETYPE_DEADEND )
4643  {
4644  int appliedeffectiverootdepth;
4645 
4646  appliedeffectiverootdepth = tree->appliedeffectiverootdepth;
4647  assert(appliedeffectiverootdepth <= tree->effectiverootdepth);
4648 
4649  SCIP_CALL( SCIPnodeFree(&oldfocusnode, blkmem, set, stat, eventqueue, tree, lp) );
4650  assert(tree->effectiverootdepth < tree->pathlen || *node == NULL || *cutoff);
4651 
4652  if( tree->effectiverootdepth > appliedeffectiverootdepth && *node != NULL && !(*cutoff) )
4653  {
4654  int d;
4655 
4656  /* promote the constraint set and bound changes up to the new effective root to be global changes */
4657  SCIPsetDebugMsg(set, "effective root is now at depth %d: applying constraint set and bound changes to global problem\n",
4658  tree->effectiverootdepth);
4659 
4660  for( d = appliedeffectiverootdepth + 1; d <= tree->effectiverootdepth; ++d )
4661  {
4662  SCIP_Bool nodecutoff;
4663 
4664  SCIPsetDebugMsg(set, " -> applying constraint set changes of depth %d\n", d);
4665  SCIP_CALL( SCIPconssetchgMakeGlobal(&tree->path[d]->conssetchg, blkmem, set, stat, transprob, reopt) );
4666  SCIPsetDebugMsg(set, " -> applying bound changes of depth %d\n", d);
4667  SCIP_CALL( SCIPdomchgApplyGlobal(tree->path[d]->domchg, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
4668  &nodecutoff) );
4669 
4670  if( nodecutoff )
4671  {
4672  SCIP_CALL( SCIPnodeCutoff(tree->path[d], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
4673  *cutoff = TRUE;
4674  }
4675  }
4676 
4678  }
4679  }
4680  assert(*cutoff || SCIPtreeIsPathComplete(tree));
4681 
4682  return SCIP_OKAY;
4683 }
4684 
4685 
4686 
4687 
4688 /*
4689  * Tree methods
4690  */
4691 
4692 /** creates an initialized tree data structure */
4694  SCIP_TREE** tree, /**< pointer to tree data structure */
4695  BMS_BLKMEM* blkmem, /**< block memory buffers */
4696  SCIP_SET* set, /**< global SCIP settings */
4697  SCIP_NODESEL* nodesel /**< node selector to use for sorting leaves in the priority queue */
4698  )
4699 {
4700  int p;
4701 
4702  assert(tree != NULL);
4703  assert(blkmem != NULL);
4704 
4705  SCIP_ALLOC( BMSallocMemory(tree) );
4706 
4707  (*tree)->root = NULL;
4708 
4709  SCIP_CALL( SCIPnodepqCreate(&(*tree)->leaves, set, nodesel) );
4710 
4711  /* allocate one slot for the prioritized and the unprioritized bound change */
4712  for( p = 0; p <= 1; ++p )
4713  {
4714  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*tree)->divebdchgdirs[p], 1) ); /*lint !e866*/
4715  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*tree)->divebdchgvars[p], 1) ); /*lint !e866*/
4716  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*tree)->divebdchgvals[p], 1) ); /*lint !e866*/
4717  (*tree)->ndivebdchanges[p] = 0;
4718  (*tree)->divebdchgsize[p] = 1;
4719  }
4720 
4721  (*tree)->path = NULL;
4722  (*tree)->focusnode = NULL;
4723  (*tree)->focuslpfork = NULL;
4724  (*tree)->focuslpstatefork = NULL;
4725  (*tree)->focussubroot = NULL;
4726  (*tree)->children = NULL;
4727  (*tree)->siblings = NULL;
4728  (*tree)->probingroot = NULL;
4729  (*tree)->childrenprio = NULL;
4730  (*tree)->siblingsprio = NULL;
4731  (*tree)->pathnlpcols = NULL;
4732  (*tree)->pathnlprows = NULL;
4733  (*tree)->probinglpistate = NULL;
4734  (*tree)->probinglpinorms = NULL;
4735  (*tree)->pendingbdchgs = NULL;
4736  (*tree)->probdiverelaxsol = NULL;
4737  (*tree)->pendingbdchgssize = 0;
4738  (*tree)->npendingbdchgs = 0;
4739  (*tree)->focuslpstateforklpcount = -1;
4740  (*tree)->childrensize = 0;
4741  (*tree)->nchildren = 0;
4742  (*tree)->siblingssize = 0;
4743  (*tree)->nsiblings = 0;
4744  (*tree)->pathlen = 0;
4745  (*tree)->pathsize = 0;
4746  (*tree)->effectiverootdepth = 0;
4747  (*tree)->appliedeffectiverootdepth = 0;
4748  (*tree)->correctlpdepth = -1;
4749  (*tree)->cutoffdepth = INT_MAX;
4750  (*tree)->repropdepth = INT_MAX;
4751  (*tree)->repropsubtreecount = 0;
4752  (*tree)->focusnodehaslp = FALSE;
4753  (*tree)->probingnodehaslp = FALSE;
4754  (*tree)->focuslpconstructed = FALSE;
4755  (*tree)->cutoffdelayed = FALSE;
4756  (*tree)->probinglpwasflushed = FALSE;
4757  (*tree)->probinglpwassolved = FALSE;
4758  (*tree)->probingloadlpistate = FALSE;
4759  (*tree)->probinglpwasrelax = FALSE;
4760  (*tree)->probingsolvedlp = FALSE;
4761  (*tree)->forcinglpmessage = FALSE;
4762  (*tree)->sbprobing = FALSE;
4763  (*tree)->probinglpwasprimfeas = TRUE;
4764  (*tree)->probinglpwasdualfeas = TRUE;
4765  (*tree)->probdiverelaxstored = FALSE;
4766  (*tree)->probdiverelaxincludeslp = FALSE;
4767 
4768  return SCIP_OKAY;
4769 }
4770 
4771 /** frees tree data structure */
4773  SCIP_TREE** tree, /**< pointer to tree data structure */
4774  BMS_BLKMEM* blkmem, /**< block memory buffers */
4775  SCIP_SET* set, /**< global SCIP settings */
4776  SCIP_STAT* stat, /**< problem statistics */
4777  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4778  SCIP_LP* lp /**< current LP data */
4779  )
4780 {
4781  int p;
4782 
4783  assert(tree != NULL);
4784  assert(*tree != NULL);
4785  assert((*tree)->nchildren == 0);
4786  assert((*tree)->nsiblings == 0);
4787  assert((*tree)->focusnode == NULL);
4788  assert(!SCIPtreeProbing(*tree));
4789 
4790  SCIPsetDebugMsg(set, "free tree\n");
4791 
4792  /* free node queue */
4793  SCIP_CALL( SCIPnodepqFree(&(*tree)->leaves, blkmem, set, stat, eventqueue, *tree, lp) );
4794 
4795  /* free diving bound change storage */
4796  for( p = 0; p <= 1; ++p )
4797  {
4798  BMSfreeBlockMemoryArray(blkmem, &(*tree)->divebdchgdirs[p], (*tree)->divebdchgsize[p]); /*lint !e866*/
4799  BMSfreeBlockMemoryArray(blkmem, &(*tree)->divebdchgvals[p], (*tree)->divebdchgsize[p]); /*lint !e866*/
4800  BMSfreeBlockMemoryArray(blkmem, &(*tree)->divebdchgvars[p], (*tree)->divebdchgsize[p]); /*lint !e866*/
4801  }
4802 
4803  /* free pointer arrays */
4804  BMSfreeMemoryArrayNull(&(*tree)->path);
4805  BMSfreeMemoryArrayNull(&(*tree)->children);
4806  BMSfreeMemoryArrayNull(&(*tree)->siblings);
4807  BMSfreeMemoryArrayNull(&(*tree)->childrenprio);
4808  BMSfreeMemoryArrayNull(&(*tree)->siblingsprio);
4809  BMSfreeMemoryArrayNull(&(*tree)->pathnlpcols);
4810  BMSfreeMemoryArrayNull(&(*tree)->pathnlprows);
4811  BMSfreeMemoryArrayNull(&(*tree)->probdiverelaxsol);
4812  BMSfreeMemoryArrayNull(&(*tree)->pendingbdchgs);
4813 
4814  BMSfreeMemory(tree);
4815 
4816  return SCIP_OKAY;
4817 }
4818 
4819 /** clears and resets tree data structure and deletes all nodes */
4821  SCIP_TREE* tree, /**< tree data structure */
4822  BMS_BLKMEM* blkmem, /**< block memory buffers */
4823  SCIP_SET* set, /**< global SCIP settings */
4824  SCIP_STAT* stat, /**< problem statistics */
4825  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4826  SCIP_LP* lp /**< current LP data */
4827  )
4828 {
4829  int v;
4830 
4831  assert(tree != NULL);
4832  assert(tree->nchildren == 0);
4833  assert(tree->nsiblings == 0);
4834  assert(tree->focusnode == NULL);
4835  assert(!SCIPtreeProbing(tree));
4836 
4837  SCIPsetDebugMsg(set, "clearing tree\n");
4838 
4839  /* clear node queue */
4840  SCIP_CALL( SCIPnodepqClear(tree->leaves, blkmem, set, stat, eventqueue, tree, lp) );
4841  assert(tree->root == NULL);
4842 
4843  /* we have to remove the captures of the variables within the pending bound change data structure */
4844  for( v = tree->npendingbdchgs-1; v >= 0; --v )
4845  {
4846  SCIP_VAR* var;
4847 
4848  var = tree->pendingbdchgs[v].var;
4849  assert(var != NULL);
4850 
4851  /* release the variable */
4852  SCIP_CALL( SCIPvarRelease(&var, blkmem, set, eventqueue, lp) );
4853  }
4854 
4855  /* mark working arrays to be empty and reset data */
4856  tree->focuslpstateforklpcount = -1;
4857  tree->nchildren = 0;
4858  tree->nsiblings = 0;
4859  tree->pathlen = 0;
4860  tree->effectiverootdepth = 0;
4861  tree->appliedeffectiverootdepth = 0;
4862  tree->correctlpdepth = -1;
4863  tree->cutoffdepth = INT_MAX;
4864  tree->repropdepth = INT_MAX;
4865  tree->repropsubtreecount = 0;
4866  tree->npendingbdchgs = 0;
4867  tree->focusnodehaslp = FALSE;
4868  tree->probingnodehaslp = FALSE;
4869  tree->cutoffdelayed = FALSE;
4870  tree->probinglpwasflushed = FALSE;
4871  tree->probinglpwassolved = FALSE;
4872  tree->probingloadlpistate = FALSE;
4873  tree->probinglpwasrelax = FALSE;
4874  tree->probingsolvedlp = FALSE;
4875 
4876  return SCIP_OKAY;
4877 }
4878 
4879 /** creates the root node of the tree and puts it into the leaves queue */
4881  SCIP_TREE* tree, /**< tree data structure */
4882  SCIP_REOPT* reopt, /**< reoptimization data structure */
4883  BMS_BLKMEM* blkmem, /**< block memory buffers */
4884  SCIP_SET* set, /**< global SCIP settings */
4885  SCIP_STAT* stat, /**< problem statistics */
4886  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4887  SCIP_LP* lp /**< current LP data */
4888  )
4889 {
4890  assert(tree != NULL);
4891  assert(tree->nchildren == 0);
4892  assert(tree->nsiblings == 0);
4893  assert(tree->root == NULL);
4894  assert(tree->focusnode == NULL);
4895  assert(!SCIPtreeProbing(tree));
4896 
4897  /* create root node */
4898  SCIP_CALL( SCIPnodeCreateChild(&tree->root, blkmem, set, stat, tree, 0.0, -SCIPsetInfinity(set)) );
4899  assert(tree->nchildren == 1);
4900 
4901 #ifndef NDEBUG
4902  /* check, if the sizes in the data structures match the maximal numbers defined here */
4903  tree->root->depth = SCIP_MAXTREEDEPTH + 1;
4905  assert(tree->root->depth - 1 == SCIP_MAXTREEDEPTH); /*lint !e650*/
4906  assert(tree->root->repropsubtreemark == MAXREPROPMARK);
4907  tree->root->depth++; /* this should produce an overflow and reset the value to 0 */
4908  tree->root->repropsubtreemark++; /* this should produce an overflow and reset the value to 0 */
4909  assert(tree->root->depth == 0);
4910  assert((SCIP_NODETYPE)tree->root->nodetype == SCIP_NODETYPE_CHILD);
4911  assert(!tree->root->active);
4912  assert(!tree->root->cutoff);
4913  assert(!tree->root->reprop);
4914  assert(tree->root->repropsubtreemark == 0);
4915 #endif
4916 
4917  /* move root to the queue, convert it to LEAF */
4918  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, NULL,
4919  SCIPsetInfinity(set)) );
4920 
4921  return SCIP_OKAY;
4922 }
4923 
4924 /** creates a temporary presolving root node of the tree and installs it as focus node */
4926  SCIP_TREE* tree, /**< tree data structure */
4927  SCIP_REOPT* reopt, /**< reoptimization data structure */
4928  BMS_BLKMEM* blkmem, /**< block memory buffers */
4929  SCIP_SET* set, /**< global SCIP settings */
4930  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4931  SCIP_STAT* stat, /**< problem statistics */
4932  SCIP_PROB* transprob, /**< transformed problem */
4933  SCIP_PROB* origprob, /**< original problem */
4934  SCIP_PRIMAL* primal, /**< primal data */
4935  SCIP_LP* lp, /**< current LP data */
4936  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4937  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4938  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
4939  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4940  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4941  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
4942  )
4943 {
4944  SCIP_Bool cutoff;
4945 
4946  assert(tree != NULL);
4947  assert(tree->nchildren == 0);
4948  assert(tree->nsiblings == 0);
4949  assert(tree->root == NULL);
4950  assert(tree->focusnode == NULL);
4951  assert(!SCIPtreeProbing(tree));
4952 
4953  /* create temporary presolving root node */
4954  SCIP_CALL( SCIPtreeCreateRoot(tree, reopt, blkmem, set, stat, eventqueue, lp) );
4955  assert(tree->root != NULL);
4956 
4957  /* install the temporary root node as focus node */
4958  SCIP_CALL( SCIPnodeFocus(&tree->root, blkmem, set, messagehdlr, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4959  conflict, conflictstore, eventfilter, eventqueue, cliquetable, &cutoff, FALSE, FALSE) );
4960  assert(!cutoff);
4961 
4962  return SCIP_OKAY;
4963 }
4964 
4965 /** frees the temporary presolving root and resets tree data structure */
4967  SCIP_TREE* tree, /**< tree data structure */
4968  SCIP_REOPT* reopt, /**< reoptimization data structure */
4969  BMS_BLKMEM* blkmem, /**< block memory buffers */
4970  SCIP_SET* set, /**< global SCIP settings */
4971  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4972  SCIP_STAT* stat, /**< problem statistics */
4973  SCIP_PROB* transprob, /**< transformed problem */
4974  SCIP_PROB* origprob, /**< original problem */
4975  SCIP_PRIMAL* primal, /**< primal data */
4976  SCIP_LP* lp, /**< current LP data */
4977  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4978  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4979  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
4980  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4981  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4982  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
4983  )
4984 {
4985  SCIP_NODE* node;
4986  SCIP_Bool cutoff;
4987 
4988  assert(tree != NULL);
4989  assert(tree->root != NULL);
4990  assert(tree->focusnode == tree->root);
4991  assert(tree->pathlen == 1);
4992 
4993  /* unfocus the temporary root node */
4994  node = NULL;
4995  SCIP_CALL( SCIPnodeFocus(&node, blkmem, set, messagehdlr, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4996  conflict, conflictstore, eventfilter, eventqueue, cliquetable, &cutoff, FALSE, FALSE) );
4997  assert(!cutoff);
4998  assert(tree->root == NULL);
4999  assert(tree->focusnode == NULL);
5000  assert(tree->pathlen == 0);
5001 
5002  /* reset tree data structure */
5003  SCIP_CALL( SCIPtreeClear(tree, blkmem, set, stat, eventqueue, lp) );
5004 
5005  return SCIP_OKAY;
5006 }
5007 
5008 /** returns the node selector associated with the given node priority queue */
5010  SCIP_TREE* tree /**< branch and bound tree */
5011  )
5012 {
5013  assert(tree != NULL);
5014 
5015  return SCIPnodepqGetNodesel(tree->leaves);
5016 }
5017 
5018 /** sets the node selector used for sorting the nodes in the priority queue, and resorts the queue if necessary */
5020  SCIP_TREE* tree, /**< branch and bound tree */
5021  SCIP_SET* set, /**< global SCIP settings */
5022  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
5023  SCIP_STAT* stat, /**< problem statistics */
5024  SCIP_NODESEL* nodesel /**< node selector to use for sorting the nodes in the queue */
5025  )
5026 {
5027  assert(tree != NULL);
5028  assert(stat != NULL);
5029 
5030  if( SCIPnodepqGetNodesel(tree->leaves) != nodesel )
5031  {
5032  /* change the node selector used in the priority queue and resort the queue */
5033  SCIP_CALL( SCIPnodepqSetNodesel(&tree->leaves, set, nodesel) );
5034 
5035  /* issue message */
5036  if( stat->nnodes > 0 )
5037  {
5038  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
5039  "(node %" SCIP_LONGINT_FORMAT ") switching to node selector <%s>\n", stat->nnodes, SCIPnodeselGetName(nodesel));
5040  }
5041  }
5042 
5043  return SCIP_OKAY;
5044 }
5045 
5046 /** cuts off nodes with lower bound not better than given cutoff bound */
5048  SCIP_TREE* tree, /**< branch and bound tree */
5049  SCIP_REOPT* reopt, /**< reoptimization data structure */
5050  BMS_BLKMEM* blkmem, /**< block memory */
5051  SCIP_SET* set, /**< global SCIP settings */
5052  SCIP_STAT* stat, /**< dynamic problem statistics */
5053  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5054  SCIP_LP* lp, /**< current LP data */
5055  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
5056  )
5057 {
5058  SCIP_NODE* node;
5059  int i;
5060 
5061  assert(tree != NULL);
5062  assert(stat != NULL);
5063  assert(lp != NULL);
5064 
5065  /* if we are in diving mode, it is not allowed to cut off nodes, because this can lead to deleting LP rows which
5066  * would modify the currently unavailable (due to diving modifications) SCIP_LP
5067  * -> the cutoff must be delayed and executed after the diving ends
5068  */
5069  if( SCIPlpDiving(lp) )
5070  {
5071  tree->cutoffdelayed = TRUE;
5072  return SCIP_OKAY;
5073  }
5074 
5075  tree->cutoffdelayed = FALSE;
5076 
5077  /* cut off leaf nodes in the queue */
5078  SCIP_CALL( SCIPnodepqBound(tree->leaves, blkmem, set, stat, eventqueue, tree, reopt, lp, cutoffbound) );
5079 
5080  /* cut off siblings: we have to loop backwards, because a removal leads to moving the last node in empty slot */
5081  for( i = tree->nsiblings-1; i >= 0; --i )
5082  {
5083  node = tree->siblings[i];
5084  if( SCIPsetIsGE(set, node->lowerbound, cutoffbound) )
5085  {
5086  SCIPsetDebugMsg(set, "cut off sibling #%" SCIP_LONGINT_FORMAT " at depth %d with lowerbound=%g at position %d\n",
5087  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node), node->lowerbound, i);
5088 
5089  if( set->reopt_enable )
5090  {
5091  assert(reopt != NULL);
5092  /* check if the node should be stored for reoptimization */
5094  tree->root == node, tree->focusnode == node, node->lowerbound, tree->effectiverootdepth) );
5095  }
5096 
5097  SCIPvisualCutoffNode(stat->visual, set, stat, node, FALSE);
5098 
5099  SCIP_CALL( SCIPnodeFree(&node, blkmem, set, stat, eventqueue, tree, lp) );
5100  }
5101  }
5102 
5103  /* cut off children: we have to loop backwards, because a removal leads to moving the last node in empty slot */
5104  for( i = tree->nchildren-1; i >= 0; --i )
5105  {
5106  node = tree->children[i];
5107  if( SCIPsetIsGE(set, node->lowerbound, cutoffbound) )
5108  {
5109  SCIPsetDebugMsg(set, "cut off child #%" SCIP_LONGINT_FORMAT " at depth %d with lowerbound=%g at position %d\n",
5110  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node), node->lowerbound, i);
5111 
5112  if( set->reopt_enable )
5113  {
5114  assert(reopt != NULL);
5115  /* check if the node should be stored for reoptimization */
5117  tree->root == node, tree->focusnode == node, node->lowerbound, tree->effectiverootdepth) );
5118  }
5119 
5120  SCIPvisualCutoffNode(stat->visual, set, stat, node, FALSE);
5121 
5122  SCIP_CALL( SCIPnodeFree(&node, blkmem, set, stat, eventqueue, tree, lp) );
5123  }
5124  }
5125 
5126  return SCIP_OKAY;
5127 }
5128 
5129 /** calculates the node selection priority for moving the given variable's LP value to the given target value;
5130  * this node selection priority can be given to the SCIPcreateChild() call
5131  */
5133  SCIP_TREE* tree, /**< branch and bound tree */
5134  SCIP_SET* set, /**< global SCIP settings */
5135  SCIP_STAT* stat, /**< dynamic problem statistics */
5136  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
5137  SCIP_BRANCHDIR branchdir, /**< type of branching that was performed: upwards, downwards, or fixed
5138  * fixed should only be used, when both bounds changed
5139  */
5140  SCIP_Real targetvalue /**< new value of the variable in the child node */
5141  )
5142 {
5143  SCIP_Real prio;
5144  SCIP_Real varsol;
5145  SCIP_Real varrootsol;
5146  SCIP_Real downinfs;
5147  SCIP_Real upinfs;
5148  SCIP_Bool isroot;
5149  SCIP_Bool haslp;
5150 
5151  assert(set != NULL);
5152 
5153  /* extract necessary information */
5154  isroot = (SCIPtreeGetCurrentDepth(tree) == 0);
5155  haslp = SCIPtreeHasFocusNodeLP(tree);
5156  varsol = SCIPvarGetSol(var, haslp);
5157  varrootsol = SCIPvarGetRootSol(var);
5158  downinfs = SCIPvarGetAvgInferences(var, stat, SCIP_BRANCHDIR_DOWNWARDS);
5159  upinfs = SCIPvarGetAvgInferences(var, stat, SCIP_BRANCHDIR_UPWARDS);
5160 
5161  switch( branchdir )
5162  {
5164  switch( SCIPvarGetBranchDirection(var) )
5165  {
5167  prio = +1.0;
5168  break;
5170  prio = -1.0;
5171  break;
5172  case SCIP_BRANCHDIR_AUTO:
5173  switch( set->nodesel_childsel )
5174  {
5175  case 'd':
5176  prio = +1.0;
5177  break;
5178  case 'u':
5179  prio = -1.0;
5180  break;
5181  case 'p':
5182  prio = -SCIPvarGetPseudocost(var, stat, targetvalue - varsol);
5183  break;
5184  case 'i':
5185  prio = downinfs;
5186  break;
5187  case 'l':
5188  prio = targetvalue - varsol;
5189  break;
5190  case 'r':
5191  prio = varrootsol - varsol;
5192  break;
5193  case 'h':
5194  prio = downinfs + SCIPsetEpsilon(set);
5195  if( !isroot && haslp )
5196  prio *= (varrootsol - varsol + 1.0);
5197  break;
5198  default:
5199  SCIPerrorMessage("invalid child selection rule <%c>\n", set->nodesel_childsel);
5200  prio = 0.0;
5201  break;
5202  }
5203  break;
5204  default:
5205  SCIPerrorMessage("invalid preferred branching direction <%d> of variable <%s>\n",
5207  prio = 0.0;
5208  break;
5209  }
5210  break;
5212  /* the branch is directed upwards */
5213  switch( SCIPvarGetBranchDirection(var) )
5214  {
5216  prio = -1.0;
5217  break;
5219  prio = +1.0;
5220  break;
5221  case SCIP_BRANCHDIR_AUTO:
5222  switch( set->nodesel_childsel )
5223  {
5224  case 'd':
5225  prio = -1.0;
5226  break;
5227  case 'u':
5228  prio = +1.0;
5229  break;
5230  case 'p':
5231  prio = -SCIPvarGetPseudocost(var, stat, targetvalue - varsol);
5232  break;
5233  case 'i':
5234  prio = upinfs;
5235  break;
5236  case 'l':
5237  prio = varsol - targetvalue;
5238  break;
5239  case 'r':
5240  prio = varsol - varrootsol;
5241  break;
5242  case 'h':
5243  prio = upinfs + SCIPsetEpsilon(set);
5244  if( !isroot && haslp )
5245  prio *= (varsol - varrootsol + 1.0);
5246  break;
5247  default:
5248  SCIPerrorMessage("invalid child selection rule <%c>\n", set->nodesel_childsel);
5249  prio = 0.0;
5250  break;
5251  }
5252  /* since choosing the upwards direction is usually superior than the downwards direction (see results of
5253  * Achterberg's thesis (2007)), we break ties towards upwards branching
5254  */
5255  prio += SCIPsetEpsilon(set);
5256  break;
5257 
5258  default:
5259  SCIPerrorMessage("invalid preferred branching direction <%d> of variable <%s>\n",
5261  prio = 0.0;
5262  break;
5263  }
5264  break;
5265  case SCIP_BRANCHDIR_FIXED:
5266  prio = SCIPsetInfinity(set);
5267  break;
5268  case SCIP_BRANCHDIR_AUTO:
5269  default:
5270  SCIPerrorMessage("invalid branching direction <%d> of variable <%s>\n",
5272  prio = 0.0;
5273  break;
5274  }
5275 
5276  return prio;
5277 }
5278 
5279 /** calculates an estimate for the objective of the best feasible solution contained in the subtree after applying the given
5280  * branching; this estimate can be given to the SCIPcreateChild() call
5281  */
5283  SCIP_TREE* tree, /**< branch and bound tree */
5284  SCIP_SET* set, /**< global SCIP settings */
5285  SCIP_STAT* stat, /**< dynamic problem statistics */
5286  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
5287  SCIP_Real targetvalue /**< new value of the variable in the child node */
5288  )
5289 {
5290  SCIP_Real estimateinc;
5291  SCIP_Real estimate;
5292  SCIP_Real varsol;
5293 
5294  assert(tree != NULL);
5295  assert(var != NULL);
5296 
5297  estimate = SCIPnodeGetEstimate(tree->focusnode);
5298  varsol = SCIPvarGetSol(var, SCIPtreeHasFocusNodeLP(tree));
5299 
5300  /* compute increase above parent node's (i.e., focus node's) estimate value */
5302  estimateinc = SCIPvarGetPseudocost(var, stat, targetvalue - varsol);
5303  else
5304  {
5305  SCIP_Real pscdown;
5306  SCIP_Real pscup;
5307 
5308  /* calculate estimate based on pseudo costs:
5309  * estimate = lowerbound + sum(min{f_j * pscdown_j, (1-f_j) * pscup_j})
5310  * = parentestimate - min{f_b * pscdown_b, (1-f_b) * pscup_b} + (targetvalue-oldvalue)*{pscdown_b or pscup_b}
5311  */
5312  pscdown = SCIPvarGetPseudocost(var, stat, SCIPsetFeasFloor(set, varsol) - varsol);
5313  pscup = SCIPvarGetPseudocost(var, stat, SCIPsetFeasCeil(set, varsol) - varsol);
5314  estimateinc = SCIPvarGetPseudocost(var, stat, targetvalue - varsol) - MIN(pscdown, pscup);
5315  }
5316 
5317  /* due to rounding errors estimateinc might be slightly negative; in this case return the parent node's estimate */
5318  if( estimateinc > 0.0 )
5319  estimate += estimateinc;
5320 
5321  return estimate;
5322 }
5323 
5324 /** branches on a variable x
5325  * if x is a continuous variable, then two child nodes will be created
5326  * (x <= x', x >= x')
5327  * but if the bounds of x are such that their relative difference is smaller than epsilon,
5328  * the variable is fixed to val (if not SCIP_INVALID) or a well chosen alternative in the current node,
5329  * i.e., no children are created
5330  * if x is not a continuous variable, then:
5331  * if solution value x' is fractional, two child nodes will be created
5332  * (x <= floor(x'), x >= ceil(x')),
5333  * if solution value is integral, the x' is equal to lower or upper bound of the branching
5334  * variable and the bounds of x are finite, then two child nodes will be created
5335  * (x <= x", x >= x"+1 with x" = floor((lb + ub)/2)),
5336  * otherwise (up to) three child nodes will be created
5337  * (x <= x'-1, x == x', x >= x'+1)
5338  * if solution value is equal to one of the bounds and the other bound is infinite, only two child nodes
5339  * will be created (the third one would be infeasible anyway)
5340  */
5342  SCIP_TREE* tree, /**< branch and bound tree */
5343  SCIP_REOPT* reopt, /**< reoptimization data structure */
5344  BMS_BLKMEM* blkmem, /**< block memory */
5345  SCIP_SET* set, /**< global SCIP settings */
5346  SCIP_STAT* stat, /**< problem statistics data */
5347  SCIP_PROB* transprob, /**< transformed problem after presolve */
5348  SCIP_PROB* origprob, /**< original problem */
5349  SCIP_LP* lp, /**< current LP data */
5350  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5351  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5352  SCIP_VAR* var, /**< variable to branch on */
5353  SCIP_Real val, /**< value to branch on or SCIP_INVALID for branching on current LP/pseudo solution.
5354  * A branching value is required for branching on continuous variables */
5355  SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
5356  SCIP_NODE** eqchild, /**< pointer to return the middle child with variable fixed, or NULL */
5357  SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
5358  )
5359 {
5360  SCIP_NODE* node;
5361  SCIP_Real priority;
5362  SCIP_Real estimate;
5363 
5364  SCIP_Real downub;
5365  SCIP_Real fixval;
5366  SCIP_Real uplb;
5367  SCIP_Real lpval;
5368 
5369  SCIP_Bool validval;
5370 
5371  assert(tree != NULL);
5372  assert(set != NULL);
5373  assert(var != NULL);
5374 
5375  /* initialize children pointer */
5376  if( downchild != NULL )
5377  *downchild = NULL;
5378  if( eqchild != NULL )
5379  *eqchild = NULL;
5380  if( upchild != NULL )
5381  *upchild = NULL;
5382 
5383  /* store whether a valid value was given for branching */
5384  validval = (val != SCIP_INVALID); /*lint !e777 */
5385 
5386  /* get the corresponding active problem variable
5387  * if branching value is given, then transform it to the value of the active variable */
5388  if( validval )
5389  {
5390  SCIP_Real scalar;
5391  SCIP_Real constant;
5392 
5393  scalar = 1.0;
5394  constant = 0.0;
5395 
5396  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
5397 
5398  if( scalar == 0.0 )
5399  {
5400  SCIPerrorMessage("cannot branch on fixed variable <%s>\n", SCIPvarGetName(var));
5401  return SCIP_INVALIDDATA;
5402  }
5403 
5404  /* we should have givenvariable = scalar * activevariable + constant */
5405  val = (val - constant) / scalar;
5406  }
5407  else
5408  var = SCIPvarGetProbvar(var);
5409 
5411  {
5412  SCIPerrorMessage("cannot branch on fixed or multi-aggregated variable <%s>\n", SCIPvarGetName(var));
5413  SCIPABORT();
5414  return SCIP_INVALIDDATA; /*lint !e527*/
5415  }
5416 
5417  /* ensure, that branching on continuous variables will only be performed when a branching point is given. */
5418  if( SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS && !validval )
5419  {
5420  SCIPerrorMessage("Cannot branch on continuous variables without a given branching value.\n", SCIPvarGetName(var));
5421  SCIPABORT();
5422  return SCIP_INVALIDDATA; /*lint !e527*/
5423  }
5424 
5425  assert(SCIPvarIsActive(var));
5426  assert(SCIPvarGetProbindex(var) >= 0);
5430  assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
5431 
5432  /* update the information for the focus node before creating children */
5433  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, tree->focusnode) );
5434 
5435  /* get value of variable in current LP or pseudo solution */
5436  lpval = SCIPvarGetSol(var, tree->focusnodehaslp);
5437 
5438  /* if there was no explicit value given for branching, branch on current LP or pseudo solution value */
5439  if( !validval )
5440  {
5441  val = lpval;
5442 
5443  /* avoid branching on infinite values in pseudo solution */
5444  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5445  {
5446  val = SCIPvarGetWorstBoundLocal(var);
5447 
5448  /* if both bounds are infinite, choose zero as branching point */
5449  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5450  {
5451  assert(SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)));
5452  assert(SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)));
5453  val = 0.0;
5454  }
5455  }
5456  }
5457 
5458  assert(SCIPsetIsFeasGE(set, val, SCIPvarGetLbLocal(var)));
5459  assert(SCIPsetIsFeasLE(set, val, SCIPvarGetUbLocal(var)));
5460  /* see comment in SCIPbranchVarVal */
5461  assert(SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS ||
5462  SCIPrelDiff(SCIPvarGetUbLocal(var), SCIPvarGetLbLocal(var)) <= 2.02 * SCIPsetEpsilon(set) ||
5463  SCIPsetIsInfinity(set, -2.1*SCIPvarGetLbLocal(var)) || SCIPsetIsInfinity(set, 2.1*SCIPvarGetUbLocal(var)) ||
5464  (SCIPsetIsLT(set, 2.1*SCIPvarGetLbLocal(var), 2.1*val) && SCIPsetIsLT(set, 2.1*val, 2.1*SCIPvarGetUbLocal(var))) );
5465 
5466  downub = SCIP_INVALID;
5467  fixval = SCIP_INVALID;
5468  uplb = SCIP_INVALID;
5469 
5471  {
5472  if( SCIPsetIsRelEQ(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)) )
5473  {
5474  SCIPsetDebugMsg(set, "fixing continuous variable <%s> with value %g and bounds [%.15g, %.15g], priority %d (current lower bound: %g)\n",
5476 
5477  /* if val is at least epsilon away from both bounds, then we change both bounds to this value
5478  * otherwise, we fix the variable to its worst bound
5479  */
5480  if( SCIPsetIsGT(set, val, SCIPvarGetLbLocal(var)) && SCIPsetIsLT(set, val, SCIPvarGetUbLocal(var)) )
5481  {
5482  SCIP_CALL( SCIPnodeAddBoundchg(tree->focusnode, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
5483  branchcand, eventqueue, NULL, var, val, SCIP_BOUNDTYPE_LOWER, FALSE) );
5484  SCIP_CALL( SCIPnodeAddBoundchg(tree->focusnode, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
5485  branchcand, eventqueue, NULL, var, val, SCIP_BOUNDTYPE_UPPER, FALSE) );
5486  }
5487  else if( SCIPvarGetObj(var) >= 0.0 )
5488  {
5489  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5490  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetUbLocal(var), SCIP_BOUNDTYPE_LOWER, FALSE) );
5491  }
5492  else
5493  {
5494  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5495  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetLbLocal(var), SCIP_BOUNDTYPE_UPPER, FALSE) );
5496  }
5497  }
5498  else if( SCIPrelDiff(SCIPvarGetUbLocal(var), SCIPvarGetLbLocal(var)) <= 2.02 * SCIPsetEpsilon(set) )
5499  {
5500  /* if the only way to branch is such that in both sides the relative domain width becomes smaller epsilon,
5501  * then fix the variable in both branches right away
5502  *
5503  * 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),
5504  * then fix the variable to the non-infinite value, as we cannot fix a variable to infinity
5505  */
5506  SCIPsetDebugMsg(set, "continuous branch on variable <%s> with bounds [%.15g, %.15g], priority %d (current lower bound: %g), node %p\n",
5508  if( SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)) )
5509  {
5510  assert(!SCIPsetIsInfinity(set, -SCIPvarGetUbLocal(var)));
5511  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5512  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetUbLocal(var), SCIP_BOUNDTYPE_LOWER, FALSE) );
5513  }
5514  else if( SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)) )
5515  {
5516  assert(!SCIPsetIsInfinity(set, SCIPvarGetLbLocal(var)));
5517  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5518  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetLbLocal(var), SCIP_BOUNDTYPE_UPPER, FALSE) );
5519  }
5520  else
5521  {
5522  downub = SCIPvarGetLbLocal(var);
5523  uplb = SCIPvarGetUbLocal(var);
5524  }
5525  }
5526  else
5527  {
5528  /* in the general case, there is enough space for two branches
5529  * a sophisticated user should have also chosen the branching value such that it is not very close to the bounds
5530  * so here we only ensure that it is at least epsilon away from both bounds
5531  */
5532  SCIPsetDebugMsg(set, "continuous branch on variable <%s> with value %g, priority %d (current lower bound: %g)\n",
5534  downub = MIN(val, SCIPvarGetUbLocal(var) - SCIPsetEpsilon(set)); /*lint !e666*/
5535  uplb = MAX(val, SCIPvarGetLbLocal(var) + SCIPsetEpsilon(set)); /*lint !e666*/
5536  }
5537  }
5538  else if( SCIPsetIsFeasIntegral(set, val) )
5539  {
5540  SCIP_Real lb;
5541  SCIP_Real ub;
5542 
5543  lb = SCIPvarGetLbLocal(var);
5544  ub = SCIPvarGetUbLocal(var);
5545 
5546  /* if there was no explicit value given for branching, the variable has a finite domain and the current LP/pseudo
5547  * solution is one of the bounds, we branch in the center of the domain */
5548  if( !validval && !SCIPsetIsInfinity(set, -lb) && !SCIPsetIsInfinity(set, ub)
5549  && (SCIPsetIsFeasEQ(set, val, lb) || SCIPsetIsFeasEQ(set, val, ub)) )
5550  {
5551  SCIP_Real center;
5552 
5553  /* create child nodes with x <= x", and x >= x"+1 with x" = floor((lb + ub)/2);
5554  * if x" is integral, make the interval smaller in the child in which the current solution x'
5555  * is still feasible
5556  */
5557  center = (ub + lb) / 2.0;
5558  if( val <= center )
5559  {
5560  downub = SCIPsetFeasFloor(set, center);
5561  uplb = downub + 1.0;
5562  }
5563  else
5564  {
5565  uplb = SCIPsetFeasCeil(set, center);
5566  downub = uplb - 1.0;
5567  }
5568  }
5569  else
5570  {
5571  /* create child nodes with x <= x'-1, x = x', and x >= x'+1 */
5572  assert(SCIPsetIsEQ(set, SCIPsetFeasCeil(set, val), SCIPsetFeasFloor(set, val)));
5573 
5574  fixval = SCIPsetFeasCeil(set, val); /* get rid of numerical issues */
5575 
5576  /* create child node with x <= x'-1, if this would be feasible */
5577  if( SCIPsetIsFeasGE(set, fixval-1.0, lb) )
5578  downub = fixval - 1.0;
5579 
5580  /* create child node with x >= x'+1, if this would be feasible */
5581  if( SCIPsetIsFeasLE(set, fixval+1.0, ub) )
5582  uplb = fixval + 1.0;
5583  }
5584  SCIPsetDebugMsg(set, "integral branch on variable <%s> with value %g, priority %d (current lower bound: %g)\n",
5586  }
5587  else
5588  {
5589  /* create child nodes with x <= floor(x'), and x >= ceil(x') */
5590  downub = SCIPsetFeasFloor(set, val);
5591  uplb = downub + 1.0;
5592  assert( SCIPsetIsRelEQ(set, SCIPsetCeil(set, val), uplb) );
5593  SCIPsetDebugMsg(set, "fractional branch on variable <%s> with value %g, root value %g, priority %d (current lower bound: %g)\n",
5595  }
5596 
5597  /* perform the branching;
5598  * set the node selection priority in a way, s.t. a node is preferred whose branching goes in the same direction
5599  * as the deviation from the variable's root solution
5600  */
5601  if( downub != SCIP_INVALID ) /*lint !e777*/
5602  {
5603  /* create child node x <= downub */
5604  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_DOWNWARDS, downub);
5605  /* if LP solution is cutoff in child, compute a new estimate
5606  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
5607  if( SCIPsetIsGT(set, lpval, downub) )
5608  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, downub);
5609  else
5610  estimate = SCIPnodeGetEstimate(tree->focusnode);
5611  SCIPsetDebugMsg(set, " -> creating child: <%s> <= %g (priority: %g, estimate: %g)\n",
5612  SCIPvarGetName(var), downub, priority, estimate);
5613  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5614  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5615  NULL, var, downub, SCIP_BOUNDTYPE_UPPER, FALSE) );
5616  /* output branching bound change to visualization file */
5617  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5618 
5619  if( downchild != NULL )
5620  *downchild = node;
5621  }
5622 
5623  if( fixval != SCIP_INVALID ) /*lint !e777*/
5624  {
5625  /* create child node with x = fixval */
5626  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_FIXED, fixval);
5627  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, fixval);
5628  SCIPsetDebugMsg(set, " -> creating child: <%s> == %g (priority: %g, estimate: %g)\n",
5629  SCIPvarGetName(var), fixval, priority, estimate);
5630  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5631  if( !SCIPsetIsFeasEQ(set, SCIPvarGetLbLocal(var), fixval) )
5632  {
5633  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5634  NULL, var, fixval, SCIP_BOUNDTYPE_LOWER, FALSE) );
5635  }
5636  if( !SCIPsetIsFeasEQ(set, SCIPvarGetUbLocal(var), fixval) )
5637  {
5638  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5639  NULL, var, fixval, SCIP_BOUNDTYPE_UPPER, FALSE) );
5640  }
5641  /* output branching bound change to visualization file */
5642  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5643 
5644  if( eqchild != NULL )
5645  *eqchild = node;
5646  }
5647 
5648  if( uplb != SCIP_INVALID ) /*lint !e777*/
5649  {
5650  /* create child node with x >= uplb */
5651  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_UPWARDS, uplb);
5652  if( SCIPsetIsLT(set, lpval, uplb) )
5653  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, uplb);
5654  else
5655  estimate = SCIPnodeGetEstimate(tree->focusnode);
5656  SCIPsetDebugMsg(set, " -> creating child: <%s> >= %g (priority: %g, estimate: %g)\n",
5657  SCIPvarGetName(var), uplb, priority, estimate);
5658  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5659  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5660  NULL, var, uplb, SCIP_BOUNDTYPE_LOWER, FALSE) );
5661  /* output branching bound change to visualization file */
5662  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5663 
5664  if( upchild != NULL )
5665  *upchild = node;
5666  }
5667 
5668 
5669  return SCIP_OKAY;
5670 }
5671 
5672 /** branches a variable x using the given domain hole; two child nodes will be created (x <= left, x >= right) */
5674  SCIP_TREE* tree, /**< branch and bound tree */
5675  SCIP_REOPT* reopt, /**< reoptimization data structure */
5676  BMS_BLKMEM* blkmem, /**< block memory */
5677  SCIP_SET* set, /**< global SCIP settings */
5678  SCIP_STAT* stat, /**< problem statistics data */
5679  SCIP_PROB* transprob, /**< transformed problem after presolve */
5680  SCIP_PROB* origprob, /**< original problem */
5681  SCIP_LP* lp, /**< current LP data */
5682  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5683  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5684  SCIP_VAR* var, /**< variable to branch on */
5685  SCIP_Real left, /**< left side of the domain hole */
5686  SCIP_Real right, /**< right side of the domain hole */
5687  SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
5688  SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
5689  )
5690 {
5691  SCIP_NODE* node;
5692  SCIP_Real priority;
5693  SCIP_Real estimate;
5694  SCIP_Real lpval;
5695 
5696  assert(tree != NULL);
5697  assert(set != NULL);
5698  assert(var != NULL);
5699  assert(SCIPsetIsLT(set, left, SCIPvarGetUbLocal(var)));
5700  assert(SCIPsetIsGE(set, left, SCIPvarGetLbLocal(var)));
5701  assert(SCIPsetIsGT(set, right, SCIPvarGetLbLocal(var)));
5702  assert(SCIPsetIsLE(set, right, SCIPvarGetUbLocal(var)));
5703  assert(SCIPsetIsLE(set, left, right));
5704 
5705  /* initialize children pointer */
5706  if( downchild != NULL )
5707  *downchild = NULL;
5708  if( upchild != NULL )
5709  *upchild = NULL;
5710 
5711  /* get the corresponding active problem variable */
5712  SCIP_CALL( SCIPvarGetProbvarHole(&var, &left, &right) );
5713 
5715  {
5716  SCIPerrorMessage("cannot branch on fixed or multi-aggregated variable <%s>\n", SCIPvarGetName(var));
5717  SCIPABORT();
5718  return SCIP_INVALIDDATA; /*lint !e527*/
5719  }
5720 
5721  assert(SCIPvarIsActive(var));
5722  assert(SCIPvarGetProbindex(var) >= 0);
5726  assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
5727 
5728  assert(SCIPsetIsFeasGE(set, left, SCIPvarGetLbLocal(var)));
5729  assert(SCIPsetIsFeasLE(set, right, SCIPvarGetUbLocal(var)));
5730 
5731  /* adjust left and right side of the domain hole if the variable is integral */
5732  if( SCIPvarIsIntegral(var) )
5733  {
5734  left = SCIPsetFeasFloor(set, left);
5735  right = SCIPsetFeasCeil(set, right);
5736  }
5737 
5738  assert(SCIPsetIsLT(set, left, SCIPvarGetUbLocal(var)));
5739  assert(SCIPsetIsGE(set, left, SCIPvarGetLbLocal(var)));
5740  assert(SCIPsetIsGT(set, right, SCIPvarGetLbLocal(var)));
5741  assert(SCIPsetIsLE(set, right, SCIPvarGetUbLocal(var)));
5742  assert(SCIPsetIsLE(set, left, right));
5743 
5744  /* get value of variable in current LP or pseudo solution */
5745  lpval = SCIPvarGetSol(var, tree->focusnodehaslp);
5746 
5747  /* perform the branching;
5748  * set the node selection priority in a way, s.t. a node is preferred whose branching goes in the same direction
5749  * as the deviation from the variable's root solution
5750  */
5751 
5752  /* create child node x <= left */
5753  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_DOWNWARDS, left);
5754 
5755  /* if LP solution is cutoff in child, compute a new estimate
5756  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node
5757  */
5758  if( SCIPsetIsGT(set, lpval, left) )
5759  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, left);
5760  else
5761  estimate = SCIPnodeGetEstimate(tree->focusnode);
5762 
5763  SCIPsetDebugMsg(set, " -> creating child: <%s> <= %g (priority: %g, estimate: %g)\n",
5764  SCIPvarGetName(var), left, priority, estimate);
5765 
5766  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5767  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, NULL,
5768  var, left, SCIP_BOUNDTYPE_UPPER, FALSE) );
5769  /* output branching bound change to visualization file */
5770  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5771 
5772  if( downchild != NULL )
5773  *downchild = node;
5774 
5775  /* create child node with x >= right */
5776  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_UPWARDS, right);
5777 
5778  if( SCIPsetIsLT(set, lpval, right) )
5779  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, right);
5780  else
5781  estimate = SCIPnodeGetEstimate(tree->focusnode);
5782 
5783  SCIPsetDebugMsg(set, " -> creating child: <%s> >= %g (priority: %g, estimate: %g)\n",
5784  SCIPvarGetName(var), right, priority, estimate);
5785 
5786  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5787  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5788  NULL, var, right, SCIP_BOUNDTYPE_LOWER, FALSE) );
5789  /* output branching bound change to visualization file */
5790  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5791 
5792  if( upchild != NULL )
5793  *upchild = node;
5794 
5795  return SCIP_OKAY;
5796 }
5797 
5798 /** n-ary branching on a variable x
5799  * Branches on variable x such that up to n/2 children are created on each side of the usual branching value.
5800  * The branching value is selected as in SCIPtreeBranchVar().
5801  * If n is 2 or the variables local domain is too small for a branching into n pieces, SCIPtreeBranchVar() is called.
5802  * The parameters minwidth and widthfactor determine the domain width of the branching variable in the child nodes.
5803  * If n is odd, one child with domain width 'width' and having the branching value in the middle is created.
5804  * Otherwise, two children with domain width 'width' and being left and right of the branching value are created.
5805  * Next further nodes to the left and right are created, where width is multiplied by widthfactor with increasing distance from the first nodes.
5806  * The initial width is calculated such that n/2 nodes are created to the left and to the right of the branching value.
5807  * If this value is below minwidth, the initial width is set to minwidth, which may result in creating less than n nodes.
5808  *
5809  * Giving a large value for widthfactor results in creating children with small domain when close to the branching value
5810  * and large domain when closer to the current variable bounds. That is, setting widthfactor to a very large value and n to 3
5811  * results in a ternary branching where the branching variable is mostly fixed in the middle child.
5812  * Setting widthfactor to 1.0 results in children where the branching variable always has the same domain width
5813  * (except for one child if the branching value is not in the middle).
5814  */
5816  SCIP_TREE* tree, /**< branch and bound tree */
5817  SCIP_REOPT* reopt, /**< reoptimization data structure */
5818  BMS_BLKMEM* blkmem, /**< block memory */
5819  SCIP_SET* set, /**< global SCIP settings */
5820  SCIP_STAT* stat, /**< problem statistics data */
5821  SCIP_PROB* transprob, /**< transformed problem after presolve */
5822  SCIP_PROB* origprob, /**< original problem */
5823  SCIP_LP* lp, /**< current LP data */
5824  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5825  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5826  SCIP_VAR* var, /**< variable to branch on */
5827  SCIP_Real val, /**< value to branch on or SCIP_INVALID for branching on current LP/pseudo solution.
5828  * A branching value is required for branching on continuous variables */
5829  int n, /**< attempted number of children to be created, must be >= 2 */
5830  SCIP_Real minwidth, /**< minimal domain width in children */
5831  SCIP_Real widthfactor, /**< multiplier for children domain width with increasing distance from val, must be >= 1.0 */
5832  int* nchildren /**< buffer to store number of created children, or NULL */
5833  )
5834 {
5835  SCIP_NODE* node;
5836  SCIP_Real priority;
5837  SCIP_Real estimate;
5838  SCIP_Real lpval;
5839  SCIP_Real width;
5840  SCIP_Bool validval;
5841  SCIP_Real left;
5842  SCIP_Real right;
5843  SCIP_Real bnd;
5844  int i;
5845 
5846  assert(tree != NULL);
5847  assert(set != NULL);
5848  assert(var != NULL);
5849  assert(n >= 2);
5850  assert(minwidth >= 0.0);
5851 
5852  /* if binary branching is requested or we have not enough space for n children, delegate to SCIPtreeBranchVar */
5853  if( n == 2 ||
5854  2.0 * minwidth >= SCIPvarGetUbLocal(var) - SCIPvarGetLbLocal(var) ||
5856  {
5857  SCIP_NODE* downchild;
5858  SCIP_NODE* fixchild;
5859  SCIP_NODE* upchild;
5860 
5861  SCIP_CALL( SCIPtreeBranchVar(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, var, val,
5862  &downchild, &fixchild, &upchild) );
5863 
5864  if( nchildren != NULL )
5865  *nchildren = (downchild != NULL ? 1 : 0) + (fixchild != NULL ? 1 : 0) + (upchild != NULL ? 1 : 0);
5866 
5867  return SCIP_OKAY;
5868  }
5869 
5870  /* store whether a valid value was given for branching */
5871  validval = (val != SCIP_INVALID); /*lint !e777 */
5872 
5873  /* get the corresponding active problem variable
5874  * if branching value is given, then transform it to the value of the active variable */
5875  if( validval )
5876  {
5877  SCIP_Real scalar;
5878  SCIP_Real constant;
5879 
5880  scalar = 1.0;
5881  constant = 0.0;
5882 
5883  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
5884 
5885  if( scalar == 0.0 )
5886  {
5887  SCIPerrorMessage("cannot branch on fixed variable <%s>\n", SCIPvarGetName(var));
5888  return SCIP_INVALIDDATA;
5889  }
5890 
5891  /* we should have givenvariable = scalar * activevariable + constant */
5892  val = (val - constant) / scalar;
5893  }
5894  else
5895  var = SCIPvarGetProbvar(var);
5896 
5898  {
5899  SCIPerrorMessage("cannot branch on fixed or multi-aggregated variable <%s>\n", SCIPvarGetName(var));
5900  SCIPABORT();
5901  return SCIP_INVALIDDATA; /*lint !e527*/
5902  }
5903 
5904  /* ensure, that branching on continuous variables will only be performed when a branching point is given. */
5905  if( SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS && !validval )
5906  {
5907  SCIPerrorMessage("Cannot branch on continuous variables without a given branching value.\n", SCIPvarGetName(var));
5908  SCIPABORT();
5909  return SCIP_INVALIDDATA; /*lint !e527*/
5910  }
5911 
5912  assert(SCIPvarIsActive(var));
5913  assert(SCIPvarGetProbindex(var) >= 0);
5917  assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
5918 
5919  /* get value of variable in current LP or pseudo solution */
5920  lpval = SCIPvarGetSol(var, tree->focusnodehaslp);
5921 
5922  /* if there was no explicit value given for branching, branch on current LP or pseudo solution value */
5923  if( !validval )
5924  {
5925  val = lpval;
5926 
5927  /* avoid branching on infinite values in pseudo solution */
5928  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5929  {
5930  val = SCIPvarGetWorstBoundLocal(var);
5931 
5932  /* if both bounds are infinite, choose zero as branching point */
5933  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5934  {
5935  assert(SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)));
5936  assert(SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)));
5937  val = 0.0;
5938  }
5939  }
5940  }
5941 
5942  assert(SCIPsetIsFeasGE(set, val, SCIPvarGetLbLocal(var)));
5943  assert(SCIPsetIsFeasLE(set, val, SCIPvarGetUbLocal(var)));
5944  assert(SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS ||
5946  (SCIPsetIsLT(set, 2.1*SCIPvarGetLbLocal(var), 2.1*val) && SCIPsetIsLT(set, 2.1*val, 2.1*SCIPvarGetUbLocal(var))) ); /* see comment in SCIPbranchVarVal */
5947 
5948  /* calculate minimal distance of val from bounds */
5949  width = SCIP_REAL_MAX;
5950  if( !SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)) )
5951  {
5952  width = val - SCIPvarGetLbLocal(var);
5953  }
5954  if( !SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)) )
5955  {
5956  width = MIN(width, SCIPvarGetUbLocal(var) - val); /*lint !e666*/
5957  }
5958  /* calculate initial domain width of child nodes
5959  * 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
5960  */
5961  if( width == SCIP_REAL_MAX ) /*lint !e777*/
5962  {
5963  /* unbounded variable, let's create a child with a small domain */
5964  width = 1.0;
5965  }
5966  else if( widthfactor == 1.0 )
5967  {
5968  /* most domains get same size */
5969  width /= n/2; /*lint !e653*/ /* rounding is ok at this point */
5970  }
5971  else
5972  {
5973  /* width is increased by widthfactor for each child
5974  * if n is even, compute width such that we can create n/2 nodes with width
5975  * width, widthfactor*width, ..., widthfactor^(n/2)*width on each side, i.e.,
5976  * sum(width * widthfactor^(i-1), i = 1..n/2) = min(ub-val, val-lb)
5977  * <-> width * (widthfactor^(n/2) - 1) / (widthfactor - 1) = min(ub-val, val-lb)
5978  *
5979  * if n is odd, compute width such that we can create one middle node with width width
5980  * and n/2 nodes with width widthfactor*width, ..., widthfactor^(n/2)*width on each side, i.e.,
5981  * width/2 + sum(width * widthfactor^i, i = 1..n/2) = min(ub-val, val-lb)
5982  * <-> width * (1/2 + widthfactor * (widthfactor^(n/2) - 1) / (widthfactor - 1) = min(ub-val, val-lb)
5983  */
5984  assert(widthfactor > 1.0);
5985  if( n % 2 == 0 )
5986  width *= (widthfactor - 1.0) / (pow(widthfactor, (SCIP_Real)(n/2)) - 1.0); /*lint !e653*/
5987  else
5988  width /= 0.5 + widthfactor * (pow(widthfactor, (SCIP_Real)(n/2)) - 1.0) / (widthfactor - 1.0); /*lint !e653*/
5989  }
5991  minwidth = MAX(1.0, minwidth);
5992  if( width < minwidth )
5993  width = minwidth;
5994  assert(SCIPsetIsPositive(set, width));
5995 
5996  SCIPsetDebugMsg(set, "%d-ary branching on variable <%s> [%g, %g] around %g, initial width = %g\n",
5997  n, SCIPvarGetName(var), SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var), val, width);
5998 
5999  if( nchildren != NULL )
6000  *nchildren = 0;
6001 
6002  /* initialize upper bound on children left of val and children right of val
6003  * if we are supposed to create an odd number of children, then create a child that has val in the middle of its domain */
6004  if( n % 2 == 1 )
6005  {
6006  left = val - width/2.0;
6007  right = val + width/2.0;
6008  SCIPvarAdjustLb(var, set, &left);
6009  SCIPvarAdjustUb(var, set, &right);
6010 
6011  /* create child node left <= x <= right, if left <= right */
6012  if( left <= right )
6013  {
6014  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_FIXED, val); /* ????????????? how to compute priority for such a child? */
6015  /* if LP solution is cutoff in child, compute a new estimate
6016  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
6017  if( SCIPsetIsLT(set, lpval, left) )
6018  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, left);
6019  else if( SCIPsetIsGT(set, lpval, right) )
6020  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, right);
6021  else
6022  estimate = SCIPnodeGetEstimate(tree->focusnode);
6023 
6024  SCIPsetDebugMsg(set, " -> creating middle child: %g <= <%s> <= %g (priority: %g, estimate: %g, width: %g)\n",
6025  left, SCIPvarGetName(var), right, priority, estimate, right - left);
6026 
6027  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
6028  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
6029  eventqueue, NULL, var, left , SCIP_BOUNDTYPE_LOWER, FALSE) );
6030  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6031  NULL, var, right, SCIP_BOUNDTYPE_UPPER, FALSE) );
6032  /* output branching bound change to visualization file */
6033  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
6034 
6035  if( nchildren != NULL )
6036  ++*nchildren;
6037  }
6038  --n;
6039 
6041  {
6042  /* 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. */
6043  left -= 1.0;
6044  right += 1.0;
6045  }
6046 
6047  width *= widthfactor;
6048  }
6049  else
6050  {
6052  {
6053  left = SCIPsetFloor(set, val);
6054  right = SCIPsetCeil(set, val);
6055  if( right - left < 0.5 )
6056  left -= 1.0;
6057  }
6058  else if( SCIPsetIsZero(set, val) )
6059  {
6060  left = 0.0;
6061  right = 0.0;
6062  }
6063  else
6064  {
6065  left = val;
6066  right = val;
6067  }
6068  }
6069 
6070  assert(n % 2 == 0);
6071  n /= 2;
6072  for( i = 0; i < n; ++i )
6073  {
6074  /* create child node left - width <= x <= left, if left > lb(x) or x is discrete */
6076  {
6077  /* new lower bound should be variables lower bound, if we are in the last round or left - width is very close to lower bound
6078  * otherwise we take left - width
6079  */
6080  if( i == n-1 || SCIPsetIsRelEQ(set, SCIPvarGetLbLocal(var), left - width))
6081  {
6082  bnd = SCIPvarGetLbLocal(var);
6083  }
6084  else
6085  {
6086  bnd = left - width;
6087  SCIPvarAdjustLb(var, set, &bnd);
6088  bnd = MAX(SCIPvarGetLbLocal(var), bnd); /*lint !e666*/
6089  }
6090  assert(SCIPsetIsRelLT(set, bnd, left));
6091 
6092  /* the nodeselection priority of nodes is decreased as more as they are away from val */
6093  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_DOWNWARDS, bnd) / (i+1);
6094  /* if LP solution is cutoff in child, compute a new estimate
6095  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
6096  if( SCIPsetIsLT(set, lpval, bnd) )
6097  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, bnd);
6098  else if( SCIPsetIsGT(set, lpval, left) )
6099  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, left);
6100  else
6101  estimate = SCIPnodeGetEstimate(tree->focusnode);
6102 
6103  SCIPsetDebugMsg(set, " -> creating left child: %g <= <%s> <= %g (priority: %g, estimate: %g, width: %g)\n",
6104  bnd, SCIPvarGetName(var), left, priority, estimate, left - bnd);
6105 
6106  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
6107  if( SCIPsetIsGT(set, bnd, SCIPvarGetLbLocal(var)) )
6108  {
6109  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6110  NULL, var, bnd, SCIP_BOUNDTYPE_LOWER, FALSE) );
6111  }
6112  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6113  NULL, var, left, SCIP_BOUNDTYPE_UPPER, FALSE) );
6114  /* output branching bound change to visualization file */
6115  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
6116 
6117  if( nchildren != NULL )
6118  ++*nchildren;
6119 
6120  left = bnd;
6122  left -= 1.0;
6123  }
6124 
6125  /* create child node right <= x <= right + width, if right < ub(x) */
6126  if( SCIPsetIsRelGT(set, SCIPvarGetUbLocal(var), right) || SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS )
6127  {
6128  /* new upper bound should be variables upper bound, if we are in the last round or right + width is very close to upper bound
6129  * otherwise we take right + width
6130  */
6131  if( i == n-1 || SCIPsetIsRelEQ(set, SCIPvarGetUbLocal(var), right + width))
6132  {
6133  bnd = SCIPvarGetUbLocal(var);
6134  }
6135  else
6136  {
6137  bnd = right + width;
6138  SCIPvarAdjustUb(var, set, &bnd);
6139  bnd = MIN(SCIPvarGetUbLocal(var), bnd); /*lint !e666*/
6140  }
6141  assert(SCIPsetIsRelGT(set, bnd, right));
6142 
6143  /* the nodeselection priority of nodes is decreased as more as they are away from val */
6144  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_UPWARDS, bnd) / (i+1);
6145  /* if LP solution is cutoff in child, compute a new estimate
6146  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
6147  if( SCIPsetIsLT(set, lpval, right) )
6148  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, right);
6149  else if( SCIPsetIsGT(set, lpval, bnd) )
6150  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, bnd);
6151  else
6152  estimate = SCIPnodeGetEstimate(tree->focusnode);
6153 
6154  SCIPsetDebugMsg(set, " -> creating right child: %g <= <%s> <= %g (priority: %g, estimate: %g, width: %g)\n",
6155  right, SCIPvarGetName(var), bnd, priority, estimate, bnd - right);
6156 
6157  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
6158  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6159  NULL, var, right, SCIP_BOUNDTYPE_LOWER, FALSE) );
6160  if( SCIPsetIsLT(set, bnd, SCIPvarGetUbLocal(var)) )
6161  {
6162  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6163  NULL, var, bnd, SCIP_BOUNDTYPE_UPPER, FALSE) );
6164  }
6165  /* output branching bound change to visualization file */
6166  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
6167 
6168  if( nchildren != NULL )
6169  ++*nchildren;
6170 
6171  right = bnd;
6173  right += 1.0;
6174  }
6175 
6176  width *= widthfactor;
6177  }
6178 
6179  return SCIP_OKAY;
6180 }
6181 
6182 /** adds a diving bound change to the tree together with the information if this is a bound change
6183  * for the preferred direction or not
6184  */
6185 #define ARRAYGROWTH 5
6187  SCIP_TREE* tree, /**< branch and bound tree */
6188  BMS_BLKMEM* blkmem, /**< block memory buffers */
6189  SCIP_VAR* var, /**< variable to apply the bound change to */
6190  SCIP_BRANCHDIR dir, /**< direction of the bound change */
6191  SCIP_Real value, /**< value to adjust this variable bound to */
6192  SCIP_Bool preferred /**< is this a bound change for the preferred child? */
6193  )
6194 {
6195  int idx = preferred ? 0 : 1;
6196  int pos = tree->ndivebdchanges[idx];
6197 
6198  assert(pos < tree->divebdchgsize[idx]);
6199 
6200  if( pos == tree->divebdchgsize[idx] - 1 )
6201  {
6202  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tree->divebdchgdirs[idx], tree->divebdchgsize[idx], tree->divebdchgsize[idx] + ARRAYGROWTH) ); /*lint !e866*/
6203  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tree->divebdchgvars[idx], tree->divebdchgsize[idx], tree->divebdchgsize[idx] + ARRAYGROWTH) ); /*lint !e866*/
6204  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tree->divebdchgvals[idx], tree->divebdchgsize[idx], tree->divebdchgsize[idx] + ARRAYGROWTH) ); /*lint !e866*/
6205  tree->divebdchgsize[idx] += ARRAYGROWTH;
6206  }
6207 
6208  tree->divebdchgvars[idx][pos] = var;
6209  tree->divebdchgdirs[idx][pos] = dir;
6210  tree->divebdchgvals[idx][pos] = value;
6211 
6212  ++tree->ndivebdchanges[idx];
6213 
6214  return SCIP_OKAY;
6215 }
6216 
6217 /** get the dive bound change data for the preferred or the alternative direction */
6219  SCIP_TREE* tree, /**< branch and bound tree */
6220  SCIP_VAR*** variables, /**< pointer to store variables for the specified direction */
6221  SCIP_BRANCHDIR** directions, /**< pointer to store the branching directions */
6222  SCIP_Real** values, /**< pointer to store bound change values */
6223  int* ndivebdchgs, /**< pointer to store the number of dive bound changes */
6224  SCIP_Bool preferred /**< should the dive bound changes for the preferred child be output? */
6225  )
6226 {
6227  int idx = preferred ? 0 : 1;
6228 
6229  assert(variables != NULL);
6230  assert(directions != NULL);
6231  assert(values != NULL);
6232  assert(ndivebdchgs != NULL);
6233 
6234  *variables = tree->divebdchgvars[idx];
6235  *directions = tree->divebdchgdirs[idx];
6236  *values = tree->divebdchgvals[idx];
6237  *ndivebdchgs = tree->ndivebdchanges[idx];
6238 }
6239 
6240 /** clear the tree bound change data structure */
6242  SCIP_TREE* tree /**< branch and bound tree */
6243  )
6244 {
6245  int p;
6246 
6247  for( p = 0; p < 2; ++p )
6248  tree->ndivebdchanges[p] = 0;
6249 }
6250 
6251 /** creates a probing child node of the current node, which must be the focus node, the current refocused node,
6252  * or another probing node; if the current node is the focus or a refocused node, the created probing node is
6253  * installed as probing root node
6254  */
6255 static
6257  SCIP_TREE* tree, /**< branch and bound tree */
6258  BMS_BLKMEM* blkmem, /**< block memory */
6259  SCIP_SET* set, /**< global SCIP settings */
6260  SCIP_LP* lp /**< current LP data */
6261  )
6262 {
6263  SCIP_NODE* currentnode;
6264  SCIP_NODE* node;
6265  SCIP_RETCODE retcode;
6266 
6267  assert(tree != NULL);
6268  assert(SCIPtreeIsPathComplete(tree));
6269  assert(tree->pathlen > 0);
6270  assert(blkmem != NULL);
6271  assert(set != NULL);
6272 
6273  /* get the current node */
6274  currentnode = SCIPtreeGetCurrentNode(tree);
6275  assert(SCIPnodeGetType(currentnode) == SCIP_NODETYPE_FOCUSNODE
6276  || SCIPnodeGetType(currentnode) == SCIP_NODETYPE_REFOCUSNODE
6277  || SCIPnodeGetType(currentnode) == SCIP_NODETYPE_PROBINGNODE);
6278  assert((SCIPnodeGetType(currentnode) == SCIP_NODETYPE_PROBINGNODE) == SCIPtreeProbing(tree));
6279 
6280  /* create the node data structure */
6281  SCIP_CALL( nodeCreate(&node, blkmem, set) );
6282  assert(node != NULL);
6283 
6284  /* mark node to be a probing node */
6285  node->nodetype = SCIP_NODETYPE_PROBINGNODE; /*lint !e641*/
6286 
6287  /* create the probingnode data */
6288  SCIP_CALL( probingnodeCreate(&node->data.probingnode, blkmem, lp) );
6289 
6290  /* make the current node the parent of the new probing node */
6291  retcode = nodeAssignParent(node, blkmem, set, tree, currentnode, 0.0);
6292 
6293  /* if we reached the maximal depth level we clean up the allocated memory and stop */
6294  if( retcode == SCIP_MAXDEPTHLEVEL )
6295  {
6296  SCIP_CALL( probingnodeFree(&(node->data.probingnode), blkmem, lp) );
6297  BMSfreeBlockMemory(blkmem, &node);
6298  }
6299  SCIP_CALL( retcode );
6300  assert(SCIPnodeGetDepth(node) == tree->pathlen);
6301 
6302  /* check, if the node is the probing root node */
6303  if( tree->probingroot == NULL )
6304  {
6305  tree->probingroot = node;
6306  SCIPsetDebugMsg(set, "created probing root node #%" SCIP_LONGINT_FORMAT " at depth %d\n",
6307  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node));
6308  }
6309  else
6310  {
6312  assert(SCIPnodeGetDepth(tree->probingroot) < SCIPnodeGetDepth(node));
6313 
6314  SCIPsetDebugMsg(set, "created probing child node #%" SCIP_LONGINT_FORMAT " at depth %d, probing depth %d\n",
6316  }
6317 
6318  /* create the new active path */
6319  SCIP_CALL( treeEnsurePathMem(tree, set, tree->pathlen+1) );
6320  node->active = TRUE;
6321  tree->path[tree->pathlen] = node;
6322  tree->pathlen++;
6323 
6324  /* update the path LP size for the previous node and set the (initial) path LP size for the newly created node */
6325  SCIP_CALL( treeUpdatePathLPSize(tree, tree->pathlen-2) );
6326 
6327  /* mark the LP's size */
6328  SCIPlpMarkSize(lp);
6329  assert(tree->pathlen >= 2);
6330  assert(lp->firstnewrow == tree->pathnlprows[tree->pathlen-1]); /* marked LP size should be initial size of new node */
6331  assert(lp->firstnewcol == tree->pathnlpcols[tree->pathlen-1]);
6332 
6333  /* the current probing node does not yet have a solved LP */
6334  tree->probingnodehaslp = FALSE;
6335 
6336  return SCIP_OKAY;
6337 }
6338 
6339 /** switches to probing mode and creates a probing root */
6341  SCIP_TREE* tree, /**< branch and bound tree */
6342  BMS_BLKMEM* blkmem, /**< block memory */
6343  SCIP_SET* set, /**< global SCIP settings */
6344  SCIP_LP* lp, /**< current LP data */
6345  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6346  SCIP_PROB* transprob, /**< transformed problem after presolve */
6347  SCIP_Bool strongbranching /**< is the probing mode used for strongbranching? */
6348  )
6349 {
6350  assert(tree != NULL);
6351  assert(tree->probinglpistate == NULL);
6352  assert(tree->probinglpinorms == NULL);
6353  assert(!SCIPtreeProbing(tree));
6354  assert(lp != NULL);
6355 
6356  SCIPsetDebugMsg(set, "probing started in depth %d (LP flushed: %u, LP solved: %u, solstat: %d), probing root in depth %d\n",
6357  tree->pathlen-1, lp->flushed, lp->solved, SCIPlpGetSolstat(lp), tree->pathlen);
6358 
6359  /* store all marked constraints for propagation */
6360  SCIP_CALL( SCIPconshdlrsStorePropagationStatus(set, set->conshdlrs, set->nconshdlrs) );
6361 
6362  /* inform LP about probing mode */
6364 
6365  assert(!lp->divingobjchg);
6366 
6367  /* remember, whether the LP was flushed and solved */
6368  tree->probinglpwasflushed = lp->flushed;
6369  tree->probinglpwassolved = lp->solved;
6370  tree->probingloadlpistate = FALSE;
6371  tree->probinglpwasrelax = lp->isrelax;
6372  lp->isrelax = TRUE;
6373  tree->probingsolvedlp = FALSE;
6374  tree->probingobjchanged = FALSE;
6375  lp->divingobjchg = FALSE;
6376  tree->probingsumchgdobjs = 0;
6377  tree->sbprobing = strongbranching;
6378 
6379  /* remember the LP state in order to restore the LP solution quickly after probing */
6380  /**@todo could the lp state be worth storing if the LP is not flushed (and hence not solved)? */
6381  if( lp->flushed && lp->solved )
6382  {
6383  SCIP_CALL( SCIPlpGetState(lp, blkmem, &tree->probinglpistate) );
6384  SCIP_CALL( SCIPlpGetNorms(lp, blkmem, &tree->probinglpinorms) );
6387  tree->probinglpwasdualfeas = lp->dualfeasible;
6389  }
6390 
6391  /* remember the relaxation solution to reset it later */
6392  if( SCIPrelaxationIsSolValid(relaxation) )
6393  {
6394  SCIP_CALL( SCIPtreeStoreRelaxSol(tree, set, relaxation, transprob) );
6395  }
6396 
6397  /* create temporary probing root node */
6398  SCIP_CALL( treeCreateProbingNode(tree, blkmem, set, lp) );
6399  assert(SCIPtreeProbing(tree));
6400 
6401  return SCIP_OKAY;
6402 }
6403 
6404 /** creates a new probing child node in the probing path */
6406  SCIP_TREE* tree, /**< branch and bound tree */
6407  BMS_BLKMEM* blkmem, /**< block memory */
6408  SCIP_SET* set, /**< global SCIP settings */
6409  SCIP_LP* lp /**< current LP data */
6410  )
6411 {
6412  assert(SCIPtreeProbing(tree));
6413 
6414  SCIPsetDebugMsg(set, "new probing child in depth %d (probing depth: %d)\n", tree->pathlen, tree->pathlen-1 - SCIPnodeGetDepth(tree->probingroot));
6415 
6416  /* create temporary probing root node */
6417  SCIP_CALL( treeCreateProbingNode(tree, blkmem, set, lp) );
6418 
6419  return SCIP_OKAY;
6420 }
6421 
6422 /** sets the LP state for the current probing node
6423  *
6424  * @note state and norms are stored at the node and later released by SCIP; therefore, the pointers are set
6425  * to NULL by the method
6426  *
6427  * @note the pointers to state and norms must not be NULL; however, they may point to a NULL pointer if the
6428  * respective information should not be set
6429  */
6431  SCIP_TREE* tree, /**< branch and bound tree */
6432  BMS_BLKMEM* blkmem, /**< block memory */
6433  SCIP_LP* lp, /**< current LP data */
6434  SCIP_LPISTATE** lpistate, /**< pointer to LP state information (like basis information) */
6435  SCIP_LPINORMS** lpinorms, /**< pointer to LP pricing norms information */
6436  SCIP_Bool primalfeas, /**< primal feasibility when LP state information was stored */
6437  SCIP_Bool dualfeas /**< dual feasibility when LP state information was stored */
6438  )
6439 {
6440  SCIP_NODE* node;
6441 
6442  assert(tree != NULL);
6443  assert(SCIPtreeProbing(tree));
6444  assert(lpistate != NULL);
6445  assert(lpinorms != NULL);
6446 
6447  /* get the current probing node */
6448  node = SCIPtreeGetCurrentNode(tree);
6449 
6450  /* this check is necessary to avoid cppcheck warnings */
6451  if( node == NULL )
6452  return SCIP_INVALIDDATA;
6453 
6454  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6455  assert(node->data.probingnode != NULL);
6456 
6457  /* free already present LP state */
6458  if( node->data.probingnode->lpistate != NULL )
6459  {
6460  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &(node->data.probingnode->lpistate)) );
6461  }
6462 
6463  /* free already present LP pricing norms */
6464  if( node->data.probingnode->lpinorms != NULL )
6465  {
6466  SCIP_CALL( SCIPlpFreeNorms(lp, blkmem, &(node->data.probingnode->lpinorms)) );
6467  }
6468 
6469  node->data.probingnode->lpistate = *lpistate;
6470  node->data.probingnode->lpinorms = *lpinorms;
6471  node->data.probingnode->lpwasprimfeas = primalfeas;
6472  node->data.probingnode->lpwasdualfeas = dualfeas;
6473 
6474  /* set the pointers to NULL to avoid that they are still used and modified by the caller */
6475  *lpistate = NULL;
6476  *lpinorms = NULL;
6477 
6478  tree->probingloadlpistate = TRUE;
6479 
6480  return SCIP_OKAY;
6481 }
6482 
6483 /** loads the LP state for the current probing node */
6485  SCIP_TREE* tree, /**< branch and bound tree */
6486  BMS_BLKMEM* blkmem, /**< block memory buffers */
6487  SCIP_SET* set, /**< global SCIP settings */
6488  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6489  SCIP_LP* lp /**< current LP data */
6490  )
6491 {
6492  assert(tree != NULL);
6493  assert(SCIPtreeProbing(tree));
6494 
6495  /* loading the LP state is only necessary if we backtracked */
6496  if( tree->probingloadlpistate )
6497  {
6498  SCIP_NODE* node;
6499  SCIP_LPISTATE* lpistate;
6500  SCIP_LPINORMS* lpinorms;
6501  SCIP_Bool lpwasprimfeas = FALSE;
6502  SCIP_Bool lpwasprimchecked = FALSE;
6503  SCIP_Bool lpwasdualfeas = FALSE;
6504  SCIP_Bool lpwasdualchecked = FALSE;
6505 
6506  /* get the current probing node */
6507  node = SCIPtreeGetCurrentNode(tree);
6508  assert(node != NULL);
6509  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6510 
6511  /* search the last node where an LP state information was attached */
6512  lpistate = NULL;
6513  lpinorms = NULL;
6514  do
6515  {
6516  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6517  assert(node->data.probingnode != NULL);
6518  if( node->data.probingnode->lpistate != NULL )
6519  {
6520  lpistate = node->data.probingnode->lpistate;
6521  lpinorms = node->data.probingnode->lpinorms;
6522  lpwasprimfeas = node->data.probingnode->lpwasprimfeas;
6523  lpwasprimchecked = node->data.probingnode->lpwasprimchecked;
6524  lpwasdualfeas = node->data.probingnode->lpwasdualfeas;
6525  lpwasdualchecked = node->data.probingnode->lpwasdualchecked;
6526  break;
6527  }
6528  node = node->parent;
6529  assert(node != NULL); /* the root node cannot be a probing node! */
6530  }
6531  while( SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE );
6532 
6533  /* if there was no LP information stored in the probing nodes, use the one stored before probing started */
6534  if( lpistate == NULL )
6535  {
6536  lpistate = tree->probinglpistate;
6537  lpinorms = tree->probinglpinorms;
6538  lpwasprimfeas = tree->probinglpwasprimfeas;
6539  lpwasprimchecked = tree->probinglpwasprimchecked;
6540  lpwasdualfeas = tree->probinglpwasdualfeas;
6541  lpwasdualchecked = tree->probinglpwasdualchecked;
6542  }
6543 
6544  /* set the LP state */
6545  if( lpistate != NULL )
6546  {
6547  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, lpistate,
6548  lpwasprimfeas, lpwasprimchecked, lpwasdualfeas, lpwasdualchecked) );
6549  }
6550 
6551  /* set the LP pricing norms */
6552  if( lpinorms != NULL )
6553  {
6554  SCIP_CALL( SCIPlpSetNorms(lp, blkmem, lpinorms) );
6555  }
6556 
6557  /* now we don't need to load the LP state again until the next backtracking */
6558  tree->probingloadlpistate = FALSE;
6559  }
6560 
6561  return SCIP_OKAY;
6562 }
6563 
6564 /** marks the probing node to have a solved LP relaxation */
6566  SCIP_TREE* tree, /**< branch and bound tree */
6567  BMS_BLKMEM* blkmem, /**< block memory */
6568  SCIP_LP* lp /**< current LP data */
6569  )
6570 {
6571  SCIP_NODE* node;
6572 
6573  assert(tree != NULL);
6574  assert(SCIPtreeProbing(tree));
6575 
6576  /* mark the probing node to have an LP */
6577  tree->probingnodehaslp = TRUE;
6578 
6579  /* get current probing node */
6580  node = SCIPtreeGetCurrentNode(tree);
6581  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6582  assert(node != NULL && node->data.probingnode != NULL);
6583 
6584  /* update LP information in probingnode data */
6585  /* cppcheck-suppress nullPointer */
6586  SCIP_CALL( probingnodeUpdate(node->data.probingnode, blkmem, tree, lp) );
6587 
6588  return SCIP_OKAY;
6589 }
6590 
6591 /** undoes all changes to the problem applied in probing up to the given probing depth */
6592 static
6594  SCIP_TREE* tree, /**< branch and bound tree */
6595  SCIP_REOPT* reopt, /**< reoptimization data structure */
6596  BMS_BLKMEM* blkmem, /**< block memory buffers */
6597  SCIP_SET* set, /**< global SCIP settings */
6598  SCIP_STAT* stat, /**< problem statistics */
6599  SCIP_PROB* transprob, /**< transformed problem after presolve */
6600  SCIP_PROB* origprob, /**< original problem */
6601  SCIP_LP* lp, /**< current LP data */
6602  SCIP_PRIMAL* primal, /**< primal data structure */
6603  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6604  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6605  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
6606  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
6607  int probingdepth /**< probing depth of the node in the probing path that should be reactivated,
6608  * -1 to even deactivate the probing root, thus exiting probing mode */
6609  )
6610 {
6611  int newpathlen;
6612  int i;
6613 
6614  assert(tree != NULL);
6615  assert(SCIPtreeProbing(tree));
6616  assert(tree->probingroot != NULL);
6617  assert(tree->focusnode != NULL);
6621  assert(tree->probingroot->parent == tree->focusnode);
6622  assert(SCIPnodeGetDepth(tree->probingroot) == SCIPnodeGetDepth(tree->focusnode)+1);
6623  assert(tree->pathlen >= 2);
6624  assert(SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_PROBINGNODE);
6625  assert(-1 <= probingdepth && probingdepth <= SCIPtreeGetProbingDepth(tree));
6626 
6627  treeCheckPath(tree);
6628 
6629  newpathlen = SCIPnodeGetDepth(tree->probingroot) + probingdepth + 1;
6630  assert(newpathlen >= 1); /* at least root node of the tree remains active */
6631 
6632  /* check if we have to do any backtracking */
6633  if( newpathlen < tree->pathlen )
6634  {
6635  int ncols;
6636  int nrows;
6637 
6638  /* the correct LP size of the node to which we backtracked is stored as initial LP size for its child */
6639  assert(SCIPnodeGetType(tree->path[newpathlen]) == SCIP_NODETYPE_PROBINGNODE);
6640  ncols = tree->path[newpathlen]->data.probingnode->ninitialcols;
6641  nrows = tree->path[newpathlen]->data.probingnode->ninitialrows;
6642  assert(ncols >= tree->pathnlpcols[newpathlen-1] || !tree->focuslpconstructed);
6643  assert(nrows >= tree->pathnlprows[newpathlen-1] || !tree->focuslpconstructed);
6644 
6645  while( tree->pathlen > newpathlen )
6646  {
6647  SCIP_NODE* node;
6648 
6649  node = tree->path[tree->pathlen-1];
6650 
6651  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6652  assert(tree->pathlen-1 == SCIPnodeGetDepth(node));
6653  assert(tree->pathlen-1 >= SCIPnodeGetDepth(tree->probingroot));
6654 
6655  if( node->data.probingnode->nchgdobjs > 0 )
6656  {
6657  /* @todo only do this if we don't backtrack to the root node - in that case, we can just restore the unchanged
6658  * objective values
6659  */
6660  for( i = node->data.probingnode->nchgdobjs - 1; i >= 0; --i )
6661  {
6662  assert(tree->probingobjchanged);
6663 
6664  SCIP_CALL( SCIPvarChgObj(node->data.probingnode->origobjvars[i], blkmem, set, transprob, primal, lp,
6665  eventqueue, node->data.probingnode->origobjvals[i]) );
6666  }
6667  tree->probingsumchgdobjs -= node->data.probingnode->nchgdobjs;
6668  assert(tree->probingsumchgdobjs >= 0);
6669 
6670  /* reset probingobjchanged flag and cutoff bound */
6671  if( tree->probingsumchgdobjs == 0 )
6672  {
6674  tree->probingobjchanged = FALSE;
6675 
6676  SCIP_CALL( SCIPlpSetCutoffbound(lp, set, transprob, primal->cutoffbound) );
6677  }
6678 
6679  /* recompute global and local pseudo objective values */
6680  SCIPlpRecomputeLocalAndGlobalPseudoObjval(lp, set, transprob);
6681  }
6682 
6683  /* undo bound changes by deactivating the probing node */
6684  SCIP_CALL( nodeDeactivate(node, blkmem, set, stat, tree, lp, branchcand, eventqueue) );
6685 
6686  /* free the probing node */
6687  SCIP_CALL( SCIPnodeFree(&tree->path[tree->pathlen-1], blkmem, set, stat, eventqueue, tree, lp) );
6688  tree->pathlen--;
6689  }
6690  assert(tree->pathlen == newpathlen);
6691 
6692  /* reset the path LP size to the initial size of the probing node */
6693  if( SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_PROBINGNODE )
6694  {
6695  tree->pathnlpcols[tree->pathlen-1] = tree->path[tree->pathlen-1]->data.probingnode->ninitialcols;
6696  tree->pathnlprows[tree->pathlen-1] = tree->path[tree->pathlen-1]->data.probingnode->ninitialrows;
6697  }
6698  else
6699  assert(SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_FOCUSNODE);
6700  treeCheckPath(tree);
6701 
6702  /* undo LP extensions */
6703  SCIP_CALL( SCIPlpShrinkCols(lp, set, ncols) );
6704  SCIP_CALL( SCIPlpShrinkRows(lp, blkmem, set, eventqueue, eventfilter, nrows) );
6705  tree->probingloadlpistate = TRUE; /* LP state must be reloaded if the next LP is solved */
6706 
6707  /* reset the LP's marked size to the initial size of the LP at the node stored in the path */
6708  assert(lp->nrows >= tree->pathnlprows[tree->pathlen-1] || !tree->focuslpconstructed);
6709  assert(lp->ncols >= tree->pathnlpcols[tree->pathlen-1] || !tree->focuslpconstructed);
6710  SCIPlpSetSizeMark(lp, tree->pathnlprows[tree->pathlen-1], tree->pathnlpcols[tree->pathlen-1]);
6711 
6712  /* if the highest cutoff or repropagation depth is inside the deleted part of the probing path,
6713  * reset them to infinity
6714  */
6715  if( tree->cutoffdepth >= tree->pathlen )
6716  {
6717  /* apply the pending bound changes */
6718  SCIP_CALL( treeApplyPendingBdchgs(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, cliquetable) );
6719 
6720  /* applying the pending bound changes might have changed the cutoff depth; so the highest cutoff depth might
6721  * be outside of the deleted part of the probing path now
6722  */
6723  if( tree->cutoffdepth >= tree->pathlen )
6724  tree->cutoffdepth = INT_MAX;
6725  }
6726  if( tree->repropdepth >= tree->pathlen )
6727  tree->repropdepth = INT_MAX;
6728  }
6729 
6730  SCIPsetDebugMsg(set, "probing backtracked to depth %d (%d cols, %d rows)\n", tree->pathlen-1, SCIPlpGetNCols(lp), SCIPlpGetNRows(lp));
6731 
6732  return SCIP_OKAY;
6733 }
6734 
6735 /** undoes all changes to the problem applied in probing up to the given probing depth;
6736  * the changes of the probing node of the given probing depth are the last ones that remain active;
6737  * changes that were applied before calling SCIPtreeCreateProbingNode() cannot be undone
6738  */
6740  SCIP_TREE* tree, /**< branch and bound tree */
6741  SCIP_REOPT* reopt, /**< reoptimization data structure */
6742  BMS_BLKMEM* blkmem, /**< block memory buffers */
6743  SCIP_SET* set, /**< global SCIP settings */
6744  SCIP_STAT* stat, /**< problem statistics */
6745  SCIP_PROB* transprob, /**< transformed problem */
6746  SCIP_PROB* origprob, /**< original problem */
6747  SCIP_LP* lp, /**< current LP data */
6748  SCIP_PRIMAL* primal, /**< primal data structure */
6749  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6750  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6751  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
6752  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
6753  int probingdepth /**< probing depth of the node in the probing path that should be reactivated */
6754  )
6755 {
6756  assert(tree != NULL);
6757  assert(SCIPtreeProbing(tree));
6758  assert(0 <= probingdepth && probingdepth <= SCIPtreeGetProbingDepth(tree));
6759 
6760  /* undo the domain and constraint set changes and free the temporary probing nodes below the given probing depth */
6761  SCIP_CALL( treeBacktrackProbing(tree, reopt, blkmem, set, stat, transprob, origprob, lp, primal, branchcand,
6762  eventqueue, eventfilter, cliquetable, probingdepth) );
6763 
6764  assert(SCIPtreeProbing(tree));
6766 
6767  return SCIP_OKAY;
6768 }
6769 
6770 /** switches back from probing to normal operation mode, frees all nodes on the probing path, restores bounds of all
6771  * variables and restores active constraints arrays of focus node
6772  */
6774  SCIP_TREE* tree, /**< branch and bound tree */
6775  SCIP_REOPT* reopt, /**< reoptimization data structure */
6776  BMS_BLKMEM* blkmem, /**< block memory buffers */
6777  SCIP_SET* set, /**< global SCIP settings */
6778  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
6779  SCIP_STAT* stat, /**< problem statistics */
6780  SCIP_PROB* transprob, /**< transformed problem after presolve */
6781  SCIP_PROB* origprob, /**< original problem */
6782  SCIP_LP* lp, /**< current LP data */
6783  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6784  SCIP_PRIMAL* primal, /**< Primal LP data */
6785  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6786  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6787  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
6788  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
6789  )
6790 {
6791  assert(tree != NULL);
6792  assert(SCIPtreeProbing(tree));
6793  assert(tree->probingroot != NULL);
6794  assert(tree->focusnode != NULL);
6798  assert(tree->probingroot->parent == tree->focusnode);
6799  assert(SCIPnodeGetDepth(tree->probingroot) == SCIPnodeGetDepth(tree->focusnode)+1);
6800  assert(tree->pathlen >= 2);
6801  assert(SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_PROBINGNODE);
6802  assert(set != NULL);
6803 
6804  /* undo the domain and constraint set changes of the temporary probing nodes and free the probing nodes */
6805  SCIP_CALL( treeBacktrackProbing(tree, reopt, blkmem, set, stat, transprob, origprob, lp, primal, branchcand,
6806  eventqueue, eventfilter, cliquetable, -1) );
6807  assert(tree->probingsumchgdobjs == 0);
6808  assert(!tree->probingobjchanged);
6809  assert(!lp->divingobjchg);
6810  assert(lp->cutoffbound == primal->cutoffbound); /*lint !e777*/
6811  assert(SCIPtreeGetCurrentNode(tree) == tree->focusnode);
6812  assert(!SCIPtreeProbing(tree));
6813 
6814  /* if the LP was flushed before probing starts, flush it again */
6815  if( tree->probinglpwasflushed )
6816  {
6817  SCIP_CALL( SCIPlpFlush(lp, blkmem, set, eventqueue) );
6818 
6819  /* if the LP was solved before probing starts, solve it again to restore the LP solution */
6820  if( tree->probinglpwassolved )
6821  {
6822  SCIP_Bool lperror;
6823 
6824  /* reset the LP state before probing started */
6825  if( tree->probinglpistate == NULL )
6826  {
6827  assert(tree->probinglpinorms == NULL);
6829  lp->primalfeasible = (lp->nlpicols == 0 && lp->nlpirows == 0);
6830  lp->primalchecked = (lp->nlpicols == 0 && lp->nlpirows == 0);
6831  lp->dualfeasible = (lp->nlpicols == 0 && lp->nlpirows == 0);
6832  lp->dualchecked = (lp->nlpicols == 0 && lp->nlpirows == 0);
6833  lp->solisbasic = FALSE;
6834  }
6835  else
6836  {
6837  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, tree->probinglpistate,
6839  tree->probinglpwasdualchecked) );
6840  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &tree->probinglpistate) );
6841 
6842  if( tree->probinglpinorms != NULL )
6843  {
6844  SCIP_CALL( SCIPlpSetNorms(lp, blkmem, tree->probinglpinorms) );
6845  SCIP_CALL( SCIPlpFreeNorms(lp, blkmem, &tree->probinglpinorms) );
6846  tree->probinglpinorms = NULL;
6847  }
6848  }
6850 
6851  /* resolve LP to reset solution */
6852  SCIP_CALL( SCIPlpSolveAndEval(lp, set, messagehdlr, blkmem, stat, eventqueue, eventfilter, transprob, -1LL, FALSE, FALSE, FALSE, &lperror) );
6853  if( lperror )
6854  {
6855  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
6856  "(node %" SCIP_LONGINT_FORMAT ") unresolved numerical troubles while resolving LP %" SCIP_LONGINT_FORMAT " after probing\n",
6857  stat->nnodes, stat->nlps);
6858  lp->resolvelperror = TRUE;
6859  tree->focusnodehaslp = FALSE;
6860  }
6861  else if( SCIPlpGetSolstat(lp) != SCIP_LPSOLSTAT_OPTIMAL
6865  {
6866  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
6867  "LP was not resolved to a sufficient status after probing\n");
6868  lp->resolvelperror = TRUE;
6869  tree->focusnodehaslp = FALSE;
6870  }
6871  else if( tree->focuslpconstructed && SCIPlpIsRelax(lp) && SCIPprobAllColsInLP(transprob, set, lp))
6872  {
6873  SCIP_CALL( SCIPnodeUpdateLowerboundLP(tree->focusnode, set, stat, tree, transprob, origprob, lp) );
6874  }
6875  }
6876  }
6877  else
6878  lp->flushed = FALSE;
6879 
6880  assert(tree->probinglpistate == NULL);
6881 
6882  /* if no LP was solved during probing and the LP before probing was not solved, then it should not be solved now */
6883  assert(tree->probingsolvedlp || tree->probinglpwassolved || !lp->solved);
6884 
6885  /* if the LP was solved (and hence flushed) before probing, then lp->solved should be TRUE unless we occured an error
6886  * during resolving right above
6887  */
6888  assert(!tree->probinglpwassolved || lp->solved || lp->resolvelperror);
6889 
6890  /* if the LP was not solved before probing it should be marked unsolved now; this can occur if a probing LP was
6891  * solved in between
6892  */
6893  if( !tree->probinglpwassolved )
6894  {
6895  lp->solved = FALSE;
6897  }
6898 
6899  /* if the LP was solved during probing, but had been unsolved before probing started, we discard the LP state */
6900  if( set->lp_clearinitialprobinglp && tree->probingsolvedlp && !tree->probinglpwassolved )
6901  {
6902  SCIPsetDebugMsg(set, "clearing lp state at end of probing mode because LP was initially unsolved\n");
6904  }
6905 
6906  /* if a relaxation was stored before probing, restore it now */
6907  if( tree->probdiverelaxstored )
6908  {
6909  SCIP_CALL( SCIPtreeRestoreRelaxSol(tree, set, relaxation, transprob) );
6910  }
6911 
6912  assert(tree->probingobjchanged == SCIPlpDivingObjChanged(lp));
6913 
6914  /* reset flags */
6915  tree->probinglpwasflushed = FALSE;
6916  tree->probinglpwassolved = FALSE;
6917  tree->probingloadlpistate = FALSE;
6918  tree->probinglpwasrelax = FALSE;
6919  tree->probingsolvedlp = FALSE;
6920  tree->sbprobing = FALSE;
6921 
6922  /* inform LP about end of probing mode */
6923  SCIP_CALL( SCIPlpEndProbing(lp) );
6924 
6925  /* reset all marked constraints for propagation */
6926  SCIP_CALL( SCIPconshdlrsResetPropagationStatus(set, blkmem, set->conshdlrs, set->nconshdlrs) );
6927 
6928  SCIPsetDebugMsg(set, "probing ended in depth %d (LP flushed: %u, solstat: %d)\n", tree->pathlen-1, lp->flushed, SCIPlpGetSolstat(lp));
6929 
6930  return SCIP_OKAY;
6931 }
6932 
6933 /** stores relaxation solution before diving or probing */
6935  SCIP_TREE* tree, /**< branch and bound tree */
6936  SCIP_SET* set, /**< global SCIP settings */
6937  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6938  SCIP_PROB* transprob /**< transformed problem after presolve */
6939  )
6940 {
6941  SCIP_VAR** vars;
6942  int nvars;
6943  int v;
6944 
6945  assert(tree != NULL);
6946  assert(set != NULL);
6947  assert(relaxation != NULL);
6948  assert(transprob != NULL);
6949  assert(SCIPrelaxationIsSolValid(relaxation));
6950 
6951  nvars = transprob->nvars;
6952  vars = transprob->vars;
6953 
6954  /* check if memory still needs to be allocated */
6955  if( tree->probdiverelaxsol == NULL )
6956  {
6957  SCIP_ALLOC( BMSallocMemoryArray(&(tree->probdiverelaxsol), nvars) );
6958  }
6959 
6960  /* iterate over all variables to save the relaxation solution */
6961  for( v = 0; v < nvars; ++v )
6962  tree->probdiverelaxsol[v] = SCIPvarGetRelaxSol(vars[v], set);
6963 
6964  tree->probdiverelaxstored = TRUE;
6966 
6967  return SCIP_OKAY;
6968 }
6969 
6970 /** restores relaxation solution after diving or probing */
6972  SCIP_TREE* tree, /**< branch and bound tree */
6973  SCIP_SET* set, /**< global SCIP settings */
6974  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6975  SCIP_PROB* transprob /**< transformed problem after presolve */
6976  )
6977 {
6978  SCIP_VAR** vars;
6979  int nvars;
6980  int v;
6981 
6982  assert(tree != NULL);
6983  assert(set != NULL);
6984  assert(tree->probdiverelaxstored);
6985  assert(tree->probdiverelaxsol != NULL);
6986 
6987  nvars = transprob->nvars;
6988  vars = transprob->vars;
6989 
6990  /* iterate over all variables to restore the relaxation solution */
6991  for( v = 0; v < nvars; ++v )
6992  {
6993  SCIP_CALL( SCIPvarSetRelaxSol(vars[v], set, relaxation, tree->probdiverelaxsol[v], TRUE) );
6994  }
6995 
6996  tree->probdiverelaxstored = FALSE;
6998 
6999  return SCIP_OKAY;
7000 }
7001 
7002 /** gets the best child of the focus node w.r.t. the node selection priority assigned by the branching rule */
7004  SCIP_TREE* tree /**< branch and bound tree */
7005  )
7006 {
7007  SCIP_NODE* bestnode;
7008  SCIP_Real bestprio;
7009  int i;
7010 
7011  assert(tree != NULL);
7012 
7013  bestnode = NULL;
7014  bestprio = SCIP_REAL_MIN;
7015  for( i = 0; i < tree->nchildren; ++i )
7016  {
7017  if( tree->childrenprio[i] > bestprio )
7018  {
7019  bestnode = tree->children[i];
7020  bestprio = tree->childrenprio[i];
7021  }
7022  }
7023  assert((tree->nchildren == 0) == (bestnode == NULL));
7024 
7025  return bestnode;
7026 }
7027 
7028 /** gets the best sibling of the focus node w.r.t. the node selection priority assigned by the branching rule */
7030  SCIP_TREE* tree /**< branch and bound tree */
7031  )
7032 {
7033  SCIP_NODE* bestnode;
7034  SCIP_Real bestprio;
7035  int i;
7036 
7037  assert(tree != NULL);
7038 
7039  bestnode = NULL;
7040  bestprio = SCIP_REAL_MIN;
7041  for( i = 0; i < tree->nsiblings; ++i )
7042  {
7043  if( tree->siblingsprio[i] > bestprio )
7044  {
7045  bestnode = tree->siblings[i];
7046  bestprio = tree->siblingsprio[i];
7047  }
7048  }
7049  assert((tree->nsiblings == 0) == (bestnode == NULL));
7050 
7051  return bestnode;
7052 }
7053 
7054 /** gets the best child of the focus node w.r.t. the node selection strategy */
7056  SCIP_TREE* tree, /**< branch and bound tree */
7057  SCIP_SET* set /**< global SCIP settings */
7058  )
7059 {
7060  SCIP_NODESEL* nodesel;
7061  SCIP_NODE* bestnode;
7062  int i;
7063 
7064  assert(tree != NULL);
7065 
7066  nodesel = SCIPnodepqGetNodesel(tree->leaves);
7067  assert(nodesel != NULL);
7068 
7069  bestnode = NULL;
7070  for( i = 0; i < tree->nchildren; ++i )
7071  {
7072  if( bestnode == NULL || SCIPnodeselCompare(nodesel, set, tree->children[i], bestnode) < 0 )
7073  {
7074  bestnode = tree->children[i];
7075  }
7076  }
7077 
7078  return bestnode;
7079 }
7080 
7081 /** gets the best sibling of the focus node w.r.t. the node selection strategy */
7083  SCIP_TREE* tree, /**< branch and bound tree */
7084  SCIP_SET* set /**< global SCIP settings */
7085  )
7086 {
7087  SCIP_NODESEL* nodesel;
7088  SCIP_NODE* bestnode;
7089  int i;
7090 
7091  assert(tree != NULL);
7092 
7093  nodesel = SCIPnodepqGetNodesel(tree->leaves);
7094  assert(nodesel != NULL);
7095 
7096  bestnode = NULL;
7097  for( i = 0; i < tree->nsiblings; ++i )
7098  {
7099  if( bestnode == NULL || SCIPnodeselCompare(nodesel, set, tree->siblings[i], bestnode) < 0 )
7100  {
7101  bestnode = tree->siblings[i];
7102  }
7103  }
7104 
7105  return bestnode;
7106 }
7107 
7108 /** gets the best leaf from the node queue w.r.t. the node selection strategy */
7110  SCIP_TREE* tree /**< branch and bound tree */
7111  )
7112 {
7113  assert(tree != NULL);
7114 
7115  return SCIPnodepqFirst(tree->leaves);
7116 }
7117 
7118 /** gets the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy */
7120  SCIP_TREE* tree, /**< branch and bound tree */
7121  SCIP_SET* set /**< global SCIP settings */
7122  )
7123 {
7124  SCIP_NODESEL* nodesel;
7125  SCIP_NODE* bestchild;
7126  SCIP_NODE* bestsibling;
7127  SCIP_NODE* bestleaf;
7128  SCIP_NODE* bestnode;
7129 
7130  assert(tree != NULL);
7131 
7132  nodesel = SCIPnodepqGetNodesel(tree->leaves);
7133  assert(nodesel != NULL);
7134 
7135  /* get the best child, sibling, and leaf */
7136  bestchild = SCIPtreeGetBestChild(tree, set);
7137  bestsibling = SCIPtreeGetBestSibling(tree, set);
7138  bestleaf = SCIPtreeGetBestLeaf(tree);
7139 
7140  /* return the best of the three */
7141  bestnode = bestchild;
7142  if( bestsibling != NULL && (bestnode == NULL || SCIPnodeselCompare(nodesel, set, bestsibling, bestnode) < 0) )
7143  bestnode = bestsibling;
7144  if( bestleaf != NULL && (bestnode == NULL || SCIPnodeselCompare(nodesel, set, bestleaf, bestnode) < 0) )
7145  bestnode = bestleaf;
7146 
7147  assert(SCIPtreeGetNLeaves(tree) == 0 || bestnode != NULL);
7148 
7149  return bestnode;
7150 }
7151 
7152 /** gets the minimal lower bound of all nodes in the tree */
7154  SCIP_TREE* tree, /**< branch and bound tree */
7155  SCIP_SET* set /**< global SCIP settings */
7156  )
7157 {
7158  SCIP_Real lowerbound;
7159  int i;
7160 
7161  assert(tree != NULL);
7162  assert(set != NULL);
7163 
7164  /* get the lower bound from the queue */
7165  lowerbound = SCIPnodepqGetLowerbound(tree->leaves, set);
7166 
7167  /* compare lower bound with children */
7168  for( i = 0; i < tree->nchildren; ++i )
7169  {
7170  assert(tree->children[i] != NULL);
7171  lowerbound = MIN(lowerbound, tree->children[i]->lowerbound);
7172  }
7173 
7174  /* compare lower bound with siblings */
7175  for( i = 0; i < tree->nsiblings; ++i )
7176  {
7177  assert(tree->siblings[i] != NULL);
7178  lowerbound = MIN(lowerbound, tree->siblings[i]->lowerbound);
7179  }
7180 
7181  /* compare lower bound with focus node */
7182  if( tree->focusnode != NULL )
7183  {
7184  lowerbound = MIN(lowerbound, tree->focusnode->lowerbound);
7185  }
7186 
7187  return lowerbound;
7188 }
7189 
7190 /** gets the node with minimal lower bound of all nodes in the tree (child, sibling, or leaf) */
7192  SCIP_TREE* tree, /**< branch and bound tree */
7193  SCIP_SET* set /**< global SCIP settings */
7194  )
7195 {
7196  SCIP_NODE* lowerboundnode;
7197  SCIP_Real lowerbound;
7198  SCIP_Real bestprio;
7199  int i;
7200 
7201  assert(tree != NULL);
7202  assert(set != NULL);
7203 
7204  /* get the lower bound from the queue */
7205  lowerboundnode = SCIPnodepqGetLowerboundNode(tree->leaves, set);
7206  lowerbound = lowerboundnode != NULL ? lowerboundnode->lowerbound : SCIPsetInfinity(set);
7207  bestprio = -SCIPsetInfinity(set);
7208 
7209  /* compare lower bound with children */
7210  for( i = 0; i < tree->nchildren; ++i )
7211  {
7212  assert(tree->children[i] != NULL);
7213  if( SCIPsetIsLE(set, tree->children[i]->lowerbound, lowerbound) )
7214  {
7215  if( SCIPsetIsLT(set, tree->children[i]->lowerbound, lowerbound) || tree->childrenprio[i] > bestprio )
7216  {
7217  lowerboundnode = tree->children[i];
7218  lowerbound = lowerboundnode->lowerbound;
7219  bestprio = tree->childrenprio[i];
7220  }
7221  }
7222  }
7223 
7224  /* compare lower bound with siblings */
7225  for( i = 0; i < tree->nsiblings; ++i )
7226  {
7227  assert(tree->siblings[i] != NULL);
7228  if( SCIPsetIsLE(set, tree->siblings[i]->lowerbound, lowerbound) )
7229  {
7230  if( SCIPsetIsLT(set, tree->siblings[i]->lowerbound, lowerbound) || tree->siblingsprio[i] > bestprio )
7231  {
7232  lowerboundnode = tree->siblings[i];
7233  lowerbound = lowerboundnode->lowerbound;
7234  bestprio = tree->siblingsprio[i];
7235  }
7236  }
7237  }
7238 
7239  return lowerboundnode;
7240 }
7241 
7242 /** gets the average lower bound of all nodes in the tree */
7244  SCIP_TREE* tree, /**< branch and bound tree */
7245  SCIP_Real cutoffbound /**< global cutoff bound */
7246  )
7247 {
7248  SCIP_Real lowerboundsum;
7249  int nnodes;
7250  int i;
7251 
7252  assert(tree != NULL);
7253 
7254  /* get sum of lower bounds from nodes in the queue */
7255  lowerboundsum = SCIPnodepqGetLowerboundSum(tree->leaves);
7256  nnodes = SCIPtreeGetNLeaves(tree);
7257 
7258  /* add lower bound of focus node */
7259  if( tree->focusnode != NULL && tree->focusnode->lowerbound < cutoffbound )
7260  {
7261  lowerboundsum += tree->focusnode->lowerbound;
7262  nnodes++;
7263  }
7264 
7265  /* add lower bounds of siblings */
7266  for( i = 0; i < tree->nsiblings; ++i )
7267  {
7268  assert(tree->siblings[i] != NULL);
7269  lowerboundsum += tree->siblings[i]->lowerbound;
7270  }
7271  nnodes += tree->nsiblings;
7272 
7273  /* add lower bounds of children */
7274  for( i = 0; i < tree->nchildren; ++i )
7275  {
7276  assert(tree->children[i] != NULL);
7277  lowerboundsum += tree->children[i]->lowerbound;
7278  }
7279  nnodes += tree->nchildren;
7280 
7281  return nnodes == 0 ? 0.0 : lowerboundsum/nnodes;
7282 }
7283 
7284 
7285 
7286 
7287 /*
7288  * simple functions implemented as defines
7289  */
7290 
7291 /* In debug mode, the following methods are implemented as function calls to ensure
7292  * type validity.
7293  * In optimized mode, the methods are implemented as defines to improve performance.
7294  * However, we want to have them in the library anyways, so we have to undef the defines.
7295  */
7296 
7297 #undef SCIPnodeGetType
7298 #undef SCIPnodeGetNumber
7299 #undef SCIPnodeGetDepth
7300 #undef SCIPnodeGetLowerbound
7301 #undef SCIPnodeGetEstimate
7302 #undef SCIPnodeGetDomchg
7303 #undef SCIPnodeGetParent
7304 #undef SCIPnodeGetConssetchg
7305 #undef SCIPnodeIsActive
7306 #undef SCIPnodeIsPropagatedAgain
7307 #undef SCIPtreeGetNLeaves
7308 #undef SCIPtreeGetNChildren
7309 #undef SCIPtreeGetNSiblings
7310 #undef SCIPtreeGetNNodes
7311 #undef SCIPtreeIsPathComplete
7312 #undef SCIPtreeProbing
7313 #undef SCIPtreeGetProbingRoot
7314 #undef SCIPtreeGetProbingDepth
7315 #undef SCIPtreeGetFocusNode
7316 #undef SCIPtreeGetFocusDepth
7317 #undef SCIPtreeHasFocusNodeLP
7318 #undef SCIPtreeSetFocusNodeLP
7319 #undef SCIPtreeIsFocusNodeLPConstructed
7320 #undef SCIPtreeInRepropagation
7321 #undef SCIPtreeGetCurrentNode
7322 #undef SCIPtreeGetCurrentDepth
7323 #undef SCIPtreeHasCurrentNodeLP
7324 #undef SCIPtreeGetEffectiveRootDepth
7325 #undef SCIPtreeGetRootNode
7326 #undef SCIPtreeProbingObjChanged
7327 #undef SCIPtreeMarkProbingObjChanged
7328 
7329 /** gets the type of the node */
7331  SCIP_NODE* node /**< node */
7332  )
7333 {
7334  assert(node != NULL);
7335 
7336  return (SCIP_NODETYPE)(node->nodetype);
7337 }
7338 
7339 /** gets successively assigned number of the node */
7341  SCIP_NODE* node /**< node */
7342  )
7343 {
7344  assert(node != NULL);
7345 
7346  return node->number;
7347 }
7348 
7349 /** gets the depth of the node */
7351  SCIP_NODE* node /**< node */
7352  )
7353 {
7354  assert(node != NULL);
7355 
7356  return (int) node->depth;
7357 }
7358 
7359 /** gets the lower bound of the node */
7361  SCIP_NODE* node /**< node */
7362  )
7363 {
7364  assert(node != NULL);
7365 
7366  return node->lowerbound;
7367 }
7368 
7369 /** gets the estimated value of the best feasible solution in subtree of the node */
7371  SCIP_NODE* node /**< node */
7372  )
7373 {
7374  assert(node != NULL);
7375 
7376  return node->estimate;
7377 }
7378 
7379 /** gets the reoptimization type of this node */
7381  SCIP_NODE* node /**< node */
7382  )
7383 {
7384  assert(node != NULL);
7385 
7386  return (SCIP_REOPTTYPE)node->reopttype;
7387 }
7388 
7389 /** sets the reoptimization type of this node */
7391  SCIP_NODE* node, /**< node */
7392  SCIP_REOPTTYPE reopttype /**< reoptimization type */
7393  )
7394 {
7395  assert(node != NULL);
7396  assert(reopttype == SCIP_REOPTTYPE_NONE
7397  || reopttype == SCIP_REOPTTYPE_TRANSIT
7398  || reopttype == SCIP_REOPTTYPE_INFSUBTREE
7399  || reopttype == SCIP_REOPTTYPE_STRBRANCHED
7400  || reopttype == SCIP_REOPTTYPE_LOGICORNODE
7401  || reopttype == SCIP_REOPTTYPE_LEAF
7402  || reopttype == SCIP_REOPTTYPE_PRUNED
7403  || reopttype == SCIP_REOPTTYPE_FEASIBLE);
7404 
7405  node->reopttype = (unsigned int) reopttype;
7406 }
7407 
7408 /** gets the unique id to identify the node during reoptimization; the id is 0 if the node is the root or not part of
7409  * the reoptimization tree
7410  */
7411 unsigned int SCIPnodeGetReoptID(
7412  SCIP_NODE* node /**< node */
7413  )
7414 {
7415  assert(node != NULL);
7416 
7417  return node->reoptid; /*lint !e732*/
7418 }
7419 
7420 /** set a unique id to identify the node during reoptimization */
7422  SCIP_NODE* node, /**< node */
7423  unsigned int id /**< unique id */
7424  )
7425 {
7426  assert(node != NULL);
7427  assert(id <= 536870911); /* id has only 29 bits and needs to be smaller than 2^29 */
7428 
7429  node->reoptid = id;
7430 }
7431 
7432 /** gets the domain change information of the node, i.e., the information about the differences in the
7433  * variables domains to the parent node
7434  */
7436  SCIP_NODE* node /**< node */
7437  )
7438 {
7439  assert(node != NULL);
7440 
7441  return node->domchg;
7442 }
7443 
7444 /** counts the number of bound changes due to branching, constraint propagation, and propagation */
7446  SCIP_NODE* node, /**< node */
7447  int* nbranchings, /**< pointer to store number of branchings (or NULL if not needed) */
7448  int* nconsprop, /**< pointer to store number of constraint propagations (or NULL if not needed) */
7449  int* nprop /**< pointer to store number of propagations (or NULL if not needed) */
7450  )
7451 { /*lint --e{641}*/
7452  SCIP_Bool count_branchings;
7453  SCIP_Bool count_consprop;
7454  SCIP_Bool count_prop;
7455  int i;
7456 
7457  assert(node != NULL);
7458 
7459  count_branchings = (nbranchings != NULL);
7460  count_consprop = (nconsprop != NULL);
7461  count_prop = (nprop != NULL);
7462 
7463  /* set counter to zero */
7464  if( count_branchings )
7465  *nbranchings = 0;
7466  if( count_consprop )
7467  *nconsprop = 0;
7468  if( count_prop )
7469  *nprop = 0;
7470 
7471  if( node->domchg != NULL )
7472  {
7473  for( i = 0; i < (int) node->domchg->domchgbound.nboundchgs; i++ )
7474  {
7475  if( count_branchings && node->domchg->domchgbound.boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING )
7476  (*nbranchings)++;
7477  else if( count_consprop && node->domchg->domchgbound.boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER )
7478  (*nconsprop)++;
7479  else if( count_prop && node->domchg->domchgbound.boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER )
7480  (*nprop)++;
7481  }
7482  }
7483 }
7484 
7485 /* return the number of bound changes based on dual information.
7486  *
7487  * currently, this methods works only for bound changes made by strong branching on binary variables. we need this
7488  * method to ensure optimality within reoptimization.
7489  *
7490  * since the bound changes made by strong branching are stored as SCIP_BOUNDCHGTYPE_CONSINFER or SCIP_BOUNDCHGTYPE_PROPINFER
7491  * with no constraint or propagator, resp., we are are interested in bound changes with these attributes.
7492  *
7493  * all bound changes of type SCIP_BOUNDCHGTYPE_BRANCHING are stored in the beginning of the bound change array, afterwards,
7494  * we can find the other two types. thus, we start the search at the end of the list and stop when reaching the first
7495  * bound change of type SCIP_BOUNDCHGTYPE_BRANCHING.
7496  */
7498  SCIP_NODE* node /**< node */
7499  )
7500 { /*lint --e{641}*/
7501  SCIP_BOUNDCHG* boundchgs;
7502  int i;
7503  int nboundchgs;
7504  int npseudobranchvars;
7505 
7506  assert(node != NULL);
7507 
7508  if( node->domchg == NULL )
7509  return 0;
7510 
7511  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7512  boundchgs = node->domchg->domchgbound.boundchgs;
7513 
7514  npseudobranchvars = 0;
7515 
7516  assert(boundchgs != NULL);
7517  assert(nboundchgs >= 0);
7518 
7519  /* count the number of pseudo-branching decisions; pseudo-branching decisions have to be in the ending of the bound change
7520  * array
7521  */
7522  for( i = nboundchgs-1; i >= 0; i--)
7523  {
7524  SCIP_Bool isint;
7525 
7526  isint = boundchgs[i].var->vartype == SCIP_VARTYPE_BINARY || boundchgs[i].var->vartype == SCIP_VARTYPE_INTEGER
7527  || boundchgs[i].var->vartype == SCIP_VARTYPE_IMPLINT;
7528 
7529  if( isint && ((boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER
7530  && boundchgs[i].data.inferencedata.reason.cons == NULL)
7531  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER
7532  && boundchgs[i].data.inferencedata.reason.prop == NULL)) )
7533  npseudobranchvars++;
7534  else if( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING )
7535  break;
7536  }
7537 
7538  return npseudobranchvars;
7539 }
7540 
7541 /** returns the set of variable branchings that were performed in the parent node to create this node */
7543  SCIP_NODE* node, /**< node data */
7544  SCIP_VAR** vars, /**< array of variables on which the bound change is based on dual information */
7545  SCIP_Real* bounds, /**< array of bounds which are based on dual information */
7546  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which are based on dual information */
7547  int* nvars, /**< number of variables on which the bound change is based on dual information
7548  * if this is larger than the array size, arrays should be reallocated and method
7549  * should be called again */
7550  int varssize /**< available slots in arrays */
7551  )
7552 { /*lint --e{641}*/
7553  SCIP_BOUNDCHG* boundchgs;
7554  int nboundchgs;
7555  int i;
7556 
7557  assert(node != NULL);
7558  assert(vars != NULL);
7559  assert(bounds != NULL);
7560  assert(boundtypes != NULL);
7561  assert(nvars != NULL);
7562  assert(varssize >= 0);
7563 
7564  (*nvars) = 0;
7565 
7566  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7567  return;
7568 
7569  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7570  boundchgs = node->domchg->domchgbound.boundchgs;
7571 
7572  assert(boundchgs != NULL);
7573  assert(nboundchgs >= 0);
7574 
7575  /* count the number of pseudo-branching decisions; pseudo-branching decisions have to be in the ending of the bound change
7576  * array
7577  */
7578  for( i = nboundchgs-1; i >= 0; i--)
7579  {
7580  if( boundchgs[i].var->vartype == SCIP_VARTYPE_BINARY || boundchgs[i].var->vartype == SCIP_VARTYPE_INTEGER
7581  || boundchgs[i].var->vartype == SCIP_VARTYPE_IMPLINT )
7582  {
7583  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER
7584  && boundchgs[i].data.inferencedata.reason.cons == NULL)
7585  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER
7586  && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7587  (*nvars)++;
7588  else if( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING )
7589  break;
7590  }
7591  }
7592 
7593  /* if the arrays have enough space store the branching decisions */
7594  if( varssize >= *nvars )
7595  {
7596  int j;
7597  j = 0;
7598  for( i = i+1; i < nboundchgs; i++)
7599  {
7600  assert( boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING );
7601  if( boundchgs[i].var->vartype == SCIP_VARTYPE_BINARY || boundchgs[i].var->vartype == SCIP_VARTYPE_INTEGER
7602  || boundchgs[i].var->vartype == SCIP_VARTYPE_IMPLINT )
7603  {
7604  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER
7605  && boundchgs[i].data.inferencedata.reason.cons == NULL)
7606  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER
7607  && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7608  {
7609  vars[j] = boundchgs[i].var;
7610  bounds[j] = boundchgs[i].newbound;
7611  boundtypes[j] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7612  j++;
7613  }
7614  }
7615  }
7616  }
7617 }
7618 
7619 /** gets the parent node of a node in the branch-and-bound tree, if any */
7621  SCIP_NODE* node /**< node */
7622  )
7623 {
7624  assert(node != NULL);
7625 
7626  return node->parent;
7627 }
7628 
7629 /** returns the set of variable branchings that were performed in the parent node to create this node */
7631  SCIP_NODE* node, /**< node data */
7632  SCIP_VAR** branchvars, /**< array of variables on which the branching has been performed in the parent node */
7633  SCIP_Real* branchbounds, /**< array of bounds which the branching in the parent node set */
7634  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branching in the parent node set */
7635  int* nbranchvars, /**< number of variables on which branching has been performed in the parent node
7636  * if this is larger than the array size, arrays should be reallocated and method
7637  * should be called again */
7638  int branchvarssize /**< available slots in arrays */
7639  )
7640 {
7641  SCIP_BOUNDCHG* boundchgs;
7642  int nboundchgs;
7643  int i;
7644 
7645  assert(node != NULL);
7646  assert(branchvars != NULL);
7647  assert(branchbounds != NULL);
7648  assert(boundtypes != NULL);
7649  assert(nbranchvars != NULL);
7650  assert(branchvarssize >= 0);
7651 
7652  (*nbranchvars) = 0;
7653 
7654  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7655  return;
7656 
7657  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7658  boundchgs = node->domchg->domchgbound.boundchgs;
7659 
7660  assert(boundchgs != NULL);
7661  assert(nboundchgs >= 0);
7662 
7663  /* count the number of branching decisions; branching decisions have to be in the beginning of the bound change
7664  * array
7665  */
7666  for( i = 0; i < nboundchgs; i++)
7667  {
7668  if( boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING ) /*lint !e641*/
7669  break;
7670 
7671  (*nbranchvars)++;
7672  }
7673 
7674 #ifndef NDEBUG
7675  /* check that the remaining bound change are no branching decisions */
7676  for( ; i < nboundchgs; i++)
7677  assert(boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING); /*lint !e641*/
7678 #endif
7679 
7680  /* if the arrays have enough space store the branching decisions */
7681  if( branchvarssize >= *nbranchvars )
7682  {
7683  for( i = 0; i < *nbranchvars; i++)
7684  {
7685  assert( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING ); /*lint !e641*/
7686  branchvars[i] = boundchgs[i].var;
7687  boundtypes[i] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7688  branchbounds[i] = boundchgs[i].newbound;
7689  }
7690  }
7691 }
7692 
7693 /** returns the set of variable branchings that were performed in all ancestor nodes (nodes on the path to the root) to create this node */
7695  SCIP_NODE* node, /**< node data */
7696  SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
7697  SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
7698  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
7699  int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
7700  * if this is larger than the array size, arrays should be reallocated and method
7701  * should be called again */
7702  int branchvarssize /**< available slots in arrays */
7703  )
7704 {
7705  assert(node != NULL);
7706  assert(branchvars != NULL);
7707  assert(branchbounds != NULL);
7708  assert(boundtypes != NULL);
7709  assert(nbranchvars != NULL);
7710  assert(branchvarssize >= 0);
7711 
7712  (*nbranchvars) = 0;
7713 
7714  while( SCIPnodeGetDepth(node) != 0 )
7715  {
7716  int nodenbranchvars;
7717  int start;
7718  int size;
7719 
7720  start = *nbranchvars < branchvarssize - 1 ? *nbranchvars : branchvarssize - 1;
7721  size = *nbranchvars > branchvarssize ? 0 : branchvarssize-(*nbranchvars);
7722 
7723  SCIPnodeGetParentBranchings(node, &branchvars[start], &branchbounds[start], &boundtypes[start], &nodenbranchvars, size);
7724  *nbranchvars += nodenbranchvars;
7725 
7726  node = node->parent;
7727  }
7728 }
7729 
7730 /** returns the set of variable branchings that were performed between the given @p node and the given @p parent node. */
7732  SCIP_NODE* node, /**< node data */
7733  SCIP_NODE* parent, /**< node data of the last ancestor node */
7734  SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
7735  SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
7736  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
7737  int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
7738  * if this is larger than the array size, arrays should be reallocated and method
7739  * should be called again */
7740  int branchvarssize /**< available slots in arrays */
7741  )
7742 {
7743  assert(node != NULL);
7744  assert(parent != NULL);
7745  assert(branchvars != NULL);
7746  assert(branchbounds != NULL);
7747  assert(boundtypes != NULL);
7748  assert(nbranchvars != NULL);
7749  assert(branchvarssize >= 0);
7750 
7751  (*nbranchvars) = 0;
7752 
7753  while( node != parent )
7754  {
7755  int nodenbranchvars;
7756  int start;
7757  int size;
7758 
7759  start = *nbranchvars < branchvarssize - 1 ? *nbranchvars : branchvarssize - 1;
7760  size = *nbranchvars > branchvarssize ? 0 : branchvarssize-(*nbranchvars);
7761 
7762  SCIPnodeGetParentBranchings(node, &branchvars[start], &branchbounds[start], &boundtypes[start], &nodenbranchvars, size);
7763  *nbranchvars += nodenbranchvars;
7764 
7765  node = node->parent;
7766  }
7767 }
7768 
7769 /** return all bound changes based on constraint propagation; stop saving the bound changes if we reach a branching
7770  * decision based on a dual information
7771  */
7773  SCIP_NODE* node, /**< node */
7774  SCIP_VAR** vars, /**< array of variables on which constraint propagation triggers a bound change */
7775  SCIP_Real* varbounds, /**< array of bounds set by constraint propagation */
7776  SCIP_BOUNDTYPE* varboundtypes, /**< array of boundtypes set by constraint propagation */
7777  int* nconspropvars, /**< number of variables on which constraint propagation triggers a bound change
7778  * if this is larger than the array size, arrays should be reallocated and method
7779  * should be called again */
7780  int conspropvarssize /**< available slots in arrays */
7781  )
7782 { /*lint --e{641}*/
7783  SCIP_BOUNDCHG* boundchgs;
7784  int nboundchgs;
7785  int first_dual;
7786  int nskip;
7787  int i;
7788 
7789  assert(node != NULL);
7790  assert(vars != NULL);
7791  assert(varbounds != NULL);
7792  assert(varboundtypes != NULL);
7793  assert(nconspropvars != NULL);
7794  assert(conspropvarssize >= 0);
7795 
7796  (*nconspropvars) = 0;
7797 
7798  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7799  return;
7800 
7801  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7802  boundchgs = node->domchg->domchgbound.boundchgs;
7803 
7804  assert(boundchgs != NULL);
7805  assert(nboundchgs >= 0);
7806 
7807  SCIPnodeGetNDomchg(node, &nskip, NULL, NULL);
7808  i = nskip;
7809 
7810  while( i < nboundchgs
7811  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons == NULL)
7812  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7813  i++;
7814 
7815  first_dual = i;
7816 
7817  /* count the number of bound changes because of constraint propagation and propagation */
7818  for(i = nskip; i < first_dual; i++)
7819  {
7820  assert(boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING);
7821 
7822  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL)
7823  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop != NULL) )
7824  {
7825  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7826  (*nconspropvars)++;
7827  }
7828  else if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons == NULL)
7829  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop == NULL))
7830  break;
7831  }
7832 
7833  /* if the arrays have enough space store the branching decisions */
7834  if( conspropvarssize >= *nconspropvars )
7835  {
7836  int pos;
7837 
7838  for(i = nskip, pos = 0; i < first_dual; i++)
7839  {
7840  if( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL )
7841  {
7842  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7843  {
7844  vars[pos] = boundchgs[i].var;
7845  varboundtypes[pos] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7846  varbounds[pos] = boundchgs[i].newbound;
7847  pos++;
7848  }
7849  }
7850  }
7851  }
7852 
7853  return;
7854 }
7855 
7856 /** gets all bound changes applied after the first bound change based on dual information.
7857  *
7858  * @note: currently, we can only detect bound changes based in dual information if they arise from strong branching.
7859  */
7861  SCIP_NODE* node, /**< node */
7862  SCIP_VAR** vars, /**< array of variables on which the branching has been performed in the parent node */
7863  SCIP_Real* varbounds, /**< array of bounds which the branching in the parent node set */
7864  SCIP_BOUNDTYPE* varboundtypes, /**< array of boundtypes which the branching in the parent node set */
7865  int start, /**< first free slot in the arrays */
7866  int* nbranchvars, /**< number of variables on which branching has been performed in the parent node
7867  * if this is larger than the array size, arrays should be reallocated and method
7868  * should be called again */
7869  int branchvarssize /**< available slots in arrays */
7870  )
7871 { /*lint --e{641}*/
7872  SCIP_BOUNDCHG* boundchgs;
7873  int nboundchgs;
7874  int first_dual;
7875  int i;
7876 
7877  assert(node != NULL);
7878  assert(vars != NULL);
7879  assert(varbounds != NULL);
7880  assert(varboundtypes != NULL);
7881  assert(nbranchvars != NULL);
7882  assert(branchvarssize >= 0);
7883 
7884  (*nbranchvars) = 0;
7885 
7886  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7887  return;
7888 
7889  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7890  boundchgs = node->domchg->domchgbound.boundchgs;
7891 
7892  assert(boundchgs != NULL);
7893  assert(nboundchgs >= 0);
7894 
7895  /* find the first based on dual information */
7896  i = 0;
7897  while( i < nboundchgs
7898  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons == NULL)
7899  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7900  i++;
7901 
7902  first_dual = i;
7903 
7904  /* count the number of branching decisions; branching decisions have to be in the beginning of the bound change array */
7905  for( ; i < nboundchgs; i++)
7906  {
7907  assert(boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING);
7908 
7909  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL)
7910  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop != NULL) )
7911  {
7912  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7913  (*nbranchvars)++;
7914  }
7915  }
7916 
7917  /* if the arrays have enough space store the branching decisions */
7918  if( branchvarssize >= *nbranchvars )
7919  {
7920  int p;
7921  for(i = first_dual, p = start; i < nboundchgs; i++)
7922  {
7923  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL)
7924  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop != NULL) )
7925  {
7926  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7927  {
7928  vars[p] = boundchgs[i].var;
7929  varboundtypes[p] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7930  varbounds[p] = boundchgs[i].newbound;
7931  p++;
7932  }
7933  }
7934  }
7935  }
7936 }
7937 
7938 /** outputs the path into given file stream in GML format */
7940  SCIP_NODE* node, /**< node data */
7941  FILE* file /**< file to output the path */
7942  )
7943 {
7944  int nbranchings;
7945 
7946  nbranchings = 0;
7947 
7948  /* print opening in GML format */
7949  SCIPgmlWriteOpening(file, TRUE);
7950 
7951  while( SCIPnodeGetDepth(node) != 0 )
7952  {
7953  SCIP_BOUNDCHG* boundchgs;
7954  char label[SCIP_MAXSTRLEN];
7955  int nboundchgs;
7956  int i;
7957 
7958  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7959  boundchgs = node->domchg->domchgbound.boundchgs;
7960 
7961  for( i = 0; i < nboundchgs; i++)
7962  {
7963  if( boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING ) /*lint !e641*/
7964  break;
7965 
7966  (void) SCIPsnprintf(label, SCIP_MAXSTRLEN, "%s %s %g", SCIPvarGetName(boundchgs[i].var),
7967  (SCIP_BOUNDTYPE) boundchgs[i].boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", boundchgs[i].newbound);
7968 
7969  SCIPgmlWriteNode(file, (unsigned int)nbranchings, label, "circle", NULL, NULL);
7970 
7971  if( nbranchings > 0 )
7972  {
7973  SCIPgmlWriteArc(file, (unsigned int)nbranchings, (unsigned int)(nbranchings-1), NULL, NULL);
7974  }
7975 
7976  nbranchings++;
7977  }
7978 
7979  node = node->parent;
7980  }
7981 
7982  /* print closing in GML format */
7983  SCIPgmlWriteClosing(file);
7984 
7985  return SCIP_OKAY;
7986 }
7987 
7988 /** returns the set of variable branchings that were performed in all ancestor nodes (nodes on the path to the root) to create this node
7989  * sorted by the nodes, starting from the current node going up to the root
7990  */
7992  SCIP_NODE* node, /**< node data */
7993  SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
7994  SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
7995  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
7996  int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
7997  * if this is larger than the array size, arrays should be reallocated and method
7998  * should be called again */
7999  int branchvarssize, /**< available slots in arrays */
8000  int* nodeswitches, /**< marks, where in the arrays the branching decisions of the next node on the path
8001  * start branchings performed at the parent of node always start at position 0.
8002  * For single variable branching, nodeswitches[i] = i holds */
8003  int* nnodes, /**< number of nodes in the nodeswitch array */
8004  int nodeswitchsize /**< available slots in node switch array */
8005  )
8006 {
8007  assert(node != NULL);
8008  assert(branchvars != NULL);
8009  assert(branchbounds != NULL);
8010  assert(boundtypes != NULL);
8011  assert(nbranchvars != NULL);
8012  assert(branchvarssize >= 0);
8013 
8014  (*nbranchvars) = 0;
8015  (*nnodes) = 0;
8016 
8017  /* go up to the root, in the root no domains were changed due to branching */
8018  while( SCIPnodeGetDepth(node) != 0 )
8019  {
8020  int nodenbranchvars;
8021  int start;
8022  int size;
8023 
8024  /* calculate the start position for the current node and the maximum remaining slots in the arrays */
8025  start = *nbranchvars < branchvarssize - 1 ? *nbranchvars : branchvarssize - 1;
8026  size = *nbranchvars > branchvarssize ? 0 : branchvarssize-(*nbranchvars);
8027  if( *nnodes < nodeswitchsize )
8028  nodeswitches[*nnodes] = start;
8029 
8030  /* get branchings for a single node */
8031  SCIPnodeGetParentBranchings(node, &branchvars[start], &branchbounds[start], &boundtypes[start], &nodenbranchvars, size);
8032  *nbranchvars += nodenbranchvars;
8033  (*nnodes)++;
8034 
8035  node = node->parent;
8036  }
8037 }
8038 
8039 /** checks for two nodes whether they share the same root path, i.e., whether one is an ancestor of the other */
8041  SCIP_NODE* node1, /**< node data */
8042  SCIP_NODE* node2 /**< node data */
8043  )
8044 {
8045  assert(node1 != NULL);
8046  assert(node2 != NULL);
8047  assert(SCIPnodeGetDepth(node1) >= 0);
8048  assert(SCIPnodeGetDepth(node2) >= 0);
8049 
8050  /* if node2 is deeper than node1, follow the path until the level of node2 */
8051  while( SCIPnodeGetDepth(node1) < SCIPnodeGetDepth(node2) )
8052  node2 = node2->parent;
8053 
8054  /* if node1 is deeper than node2, follow the path until the level of node1 */
8055  while( SCIPnodeGetDepth(node2) < SCIPnodeGetDepth(node1) )
8056  node1 = node1->parent;
8057 
8058  assert(SCIPnodeGetDepth(node2) == SCIPnodeGetDepth(node1));
8059 
8060  return (node1 == node2);
8061 }
8062 
8063 /** finds the common ancestor node of two given nodes */
8065  SCIP_NODE* node1, /**< node data */
8066  SCIP_NODE* node2 /**< node data */
8067  )
8068 {
8069  assert(node1 != NULL);
8070  assert(node2 != NULL);
8071  assert(SCIPnodeGetDepth(node1) >= 0);
8072  assert(SCIPnodeGetDepth(node2) >= 0);
8073 
8074  /* if node2 is deeper than node1, follow the path until the level of node2 */
8075  while( SCIPnodeGetDepth(node1) < SCIPnodeGetDepth(node2) )
8076  node2 = node2->parent;
8077 
8078  /* if node1 is deeper than node2, follow the path until the level of node1 */
8079  while( SCIPnodeGetDepth(node2) < SCIPnodeGetDepth(node1) )
8080  node1 = node1->parent;
8081 
8082  /* move up level by level until you found a common ancestor */
8083  while( node1 != node2 )
8084  {
8085  node1 = node1->parent;
8086  node2 = node2->parent;
8087  assert(SCIPnodeGetDepth(node1) == SCIPnodeGetDepth(node2));
8088  }
8089  assert(SCIPnodeGetDepth(node1) >= 0);
8090 
8091  return node1;
8092 }
8093 
8094 /** returns whether node is in the path to the current node */
8096  SCIP_NODE* node /**< node */
8097  )
8098 {
8099  assert(node != NULL);
8100 
8101  return node->active;
8102 }
8103 
8104 /** returns whether the node is marked to be propagated again */
8106  SCIP_NODE* node /**< node data */
8107  )
8108 {
8109  assert(node != NULL);
8110 
8111  return node->reprop;
8112 }
8113 
8114 /* returns the set of changed constraints for a particular node */
8116  SCIP_NODE* node /**< node data */
8117  )
8118 {
8119  assert(node != NULL);
8120 
8121  return node->conssetchg;
8122 }
8123 
8124 /** gets number of children of the focus node */
8126  SCIP_TREE* tree /**< branch and bound tree */
8127  )
8128 {
8129  assert(tree != NULL);
8130 
8131  return tree->nchildren;
8132 }
8133 
8134 /** gets number of siblings of the focus node */
8136  SCIP_TREE* tree /**< branch and bound tree */
8137  )
8138 {
8139  assert(tree != NULL);
8140 
8141  return tree->nsiblings;
8142 }
8143 
8144 /** gets number of leaves in the tree (excluding children and siblings of focus nodes) */
8146  SCIP_TREE* tree /**< branch and bound tree */
8147  )
8148 {
8149  assert(tree != NULL);
8150 
8151  return SCIPnodepqLen(tree->leaves);
8152 }
8153 
8154 /** gets number of open nodes in the tree (children + siblings + leaves) */
8156  SCIP_TREE* tree /**< branch and bound tree */
8157  )
8158 {
8159  assert(tree != NULL);
8160 
8161  return tree->nchildren + tree->nsiblings + SCIPtreeGetNLeaves(tree);
8162 }
8163 
8164 /** returns whether the active path goes completely down to the focus node */
8166  SCIP_TREE* tree /**< branch and bound tree */
8167  )
8168 {
8169  assert(tree != NULL);
8170  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8171  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8172  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8173  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8174  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8175  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8176  || tree->path[tree->focusnode->depth] == tree->focusnode);
8177 
8178  return (tree->focusnode == NULL || (int)tree->focusnode->depth < tree->pathlen);
8179 }
8180 
8181 /** returns whether the current node is a temporary probing node */
8183  SCIP_TREE* tree /**< branch and bound tree */
8184  )
8185 {
8186  assert(tree != NULL);
8187  assert(tree->probingroot == NULL || (SCIP_NODETYPE)tree->probingroot->nodetype == SCIP_NODETYPE_PROBINGNODE);
8188  assert(tree->probingroot == NULL || tree->pathlen > SCIPnodeGetDepth(tree->probingroot));
8189  assert(tree->probingroot == NULL || tree->path[SCIPnodeGetDepth(tree->probingroot)] == tree->probingroot);
8190 
8191  return (tree->probingroot != NULL);
8192 }
8193 
8194 /** returns the temporary probing root node, or NULL if the we are not in probing mode */
8196  SCIP_TREE* tree /**< branch and bound tree */
8197  )
8198 {
8199  assert(tree != NULL);
8200  assert(tree->probingroot == NULL || (SCIP_NODETYPE)tree->probingroot->nodetype == SCIP_NODETYPE_PROBINGNODE);
8201  assert(tree->probingroot == NULL || tree->pathlen > SCIPnodeGetDepth(tree->probingroot));
8202  assert(tree->probingroot == NULL || tree->path[SCIPnodeGetDepth(tree->probingroot)] == tree->probingroot);
8203 
8204  return tree->probingroot;
8205 }
8206 
8207 /** gets focus node of the tree */
8209  SCIP_TREE* tree /**< branch and bound tree */
8210  )
8211 {
8212  assert(tree != NULL);
8213  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8214  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8215  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8216  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8217  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8218  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8219  || tree->path[tree->focusnode->depth] == tree->focusnode);
8220 
8221  return tree->focusnode;
8222 }
8223 
8224 /** gets depth of focus node in the tree */
8226  SCIP_TREE* tree /**< branch and bound tree */
8227  )
8228 {
8229  assert(tree != NULL);
8230  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8231  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8232  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8233  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8234  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8235  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8236  || tree->path[tree->focusnode->depth] == tree->focusnode);
8237 
8238  return tree->focusnode != NULL ? (int)tree->focusnode->depth : -1;
8239 }
8240 
8241 /** returns, whether the LP was or is to be solved in the focus node */
8243  SCIP_TREE* tree /**< branch and bound tree */
8244  )
8245 {
8246  assert(tree != NULL);
8247 
8248  return tree->focusnodehaslp;
8249 }
8250 
8251 /** sets mark to solve or to ignore the LP while processing the focus node */
8253  SCIP_TREE* tree, /**< branch and bound tree */
8254  SCIP_Bool solvelp /**< should the LP be solved in focus node? */
8255  )
8256 {
8257  assert(tree != NULL);
8258 
8259  tree->focusnodehaslp = solvelp;
8260 }
8261 
8262 /** returns whether the LP of the focus node is already constructed */
8264  SCIP_TREE* tree /**< branch and bound tree */
8265  )
8266 {
8267  assert(tree != NULL);
8268 
8269  return tree->focuslpconstructed;
8270 }
8271 
8272 /** returns whether the focus node is already solved and only propagated again */
8274  SCIP_TREE* tree /**< branch and bound tree */
8275  )
8276 {
8277  assert(tree != NULL);
8278 
8279  return (tree->focusnode != NULL && SCIPnodeGetType(tree->focusnode) == SCIP_NODETYPE_REFOCUSNODE);
8280 }
8281 
8282 /** gets current node of the tree, i.e. the last node in the active path, or NULL if no current node exists */
8284  SCIP_TREE* tree /**< branch and bound tree */
8285  )
8286 {
8287  assert(tree != NULL);
8288  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8289  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8290  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8291  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8292  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8293  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8294  || tree->path[tree->focusnode->depth] == tree->focusnode);
8295 
8296  return (tree->pathlen > 0 ? tree->path[tree->pathlen-1] : NULL);
8297 }
8298 
8299 /** 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 */
8301  SCIP_TREE* tree /**< branch and bound tree */
8302  )
8303 {
8304  assert(tree != NULL);
8305  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8306  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8307  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8308  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8309  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8310  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8311  || tree->path[tree->focusnode->depth] == tree->focusnode);
8312 
8313  return tree->pathlen-1;
8314 }
8315 
8316 /** returns, whether the LP was or is to be solved in the current node */
8318  SCIP_TREE* tree /**< branch and bound tree */
8319  )
8320 {
8321  assert(tree != NULL);
8322  assert(SCIPtreeIsPathComplete(tree));
8323 
8324  return SCIPtreeProbing(tree) ? tree->probingnodehaslp : SCIPtreeHasFocusNodeLP(tree);
8325 }
8326 
8327 /** returns the current probing depth, i.e. the number of probing sub nodes existing in the probing path */
8329  SCIP_TREE* tree /**< branch and bound tree */
8330  )
8331 {
8332  assert(tree != NULL);
8333  assert(SCIPtreeProbing(tree));
8334 
8336 }
8337 
8338 /** returns the depth of the effective root node (i.e. the first depth level of a node with at least two children) */
8340  SCIP_TREE* tree /**< branch and bound tree */
8341  )
8342 {
8343  assert(tree != NULL);
8344  assert(tree->effectiverootdepth >= 0);
8345 
8346  return tree->effectiverootdepth;
8347 }
8348 
8349 /** gets the root node of the tree */
8351  SCIP_TREE* tree /**< branch and bound tree */
8352  )
8353 {
8354  assert(tree != NULL);
8355 
8356  return tree->root;
8357 }
8358 
8359 /** returns whether we are in probing and the objective value of at least one column was changed */
8360 
8362  SCIP_TREE* tree /**< branch and bound tree */
8363  )
8364 {
8365  assert(tree != NULL);
8366  assert(SCIPtreeProbing(tree) || !tree->probingobjchanged);
8367 
8368  return tree->probingobjchanged;
8369 }
8370 
8371 /** marks the current probing node to have a changed objective function */
8373  SCIP_TREE* tree /**< branch and bound tree */
8374  )
8375 {
8376  assert(tree != NULL);
8377  assert(SCIPtreeProbing(tree));
8378 
8379  tree->probingobjchanged = TRUE;
8380 }
SCIP_Real cutoffbound
Definition: struct_primal.h:46
SCIP_NODE * node
Definition: struct_tree.h:162
SCIP_RETCODE SCIPtreeClear(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: tree.c:4820
SCIP_Bool solisbasic
Definition: struct_lp.h:353
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:3178
SCIP_DECL_SORTPTRCOMP(SCIPnodeCompLowerbound)
Definition: tree.c:142
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:6186
int firstnewrow
Definition: struct_lp.h:317
SCIP_RETCODE SCIPlpGetProvedLowerbound(SCIP_LP *lp, SCIP_SET *set, SCIP_Real *bound)
Definition: lp.c:15713
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:4925
void SCIPnodeGetParentBranchings(SCIP_NODE *node, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:7630
void SCIPnodeGetDualBoundchgs(SCIP_NODE *node, SCIP_VAR **vars, SCIP_Real *bounds, SCIP_BOUNDTYPE *boundtypes, int *nvars, int varssize)
Definition: tree.c:7542
SCIP_Real SCIPvarGetWorstBoundLocal(SCIP_VAR *var)
Definition: var.c:17375
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5776
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:6773
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
Definition: memory.h:449
internal methods for managing events
SCIP_RETCODE SCIPlpFreeNorms(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
Definition: lp.c:9941
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:58
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:6430
SCIP_VAR ** SCIPcliqueGetVars(SCIP_CLIQUE *clique)
Definition: implics.c:3353
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5834
SCIP_PSEUDOFORK * pseudofork
Definition: struct_tree.h:142
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:5341
int SCIPlpGetNNewrows(SCIP_LP *lp)
Definition: lp.c:16807
SCIP_Bool SCIPsetIsFeasZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6284
void SCIPvisualRepropagatedNode(SCIP_VISUAL *visual, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:638
static SCIP_RETCODE treeEnsurePendingbdchgsMem(SCIP_TREE *tree, SCIP_SET *set, int num)
Definition: tree.c:112
SCIP_NODE * focussubroot
Definition: struct_tree.h:186
unsigned int lpwasdualfeas
Definition: struct_tree.h:125
void SCIPvarMarkNotDeletable(SCIP_VAR *var)
Definition: var.c:16906
SCIP_Bool SCIPtreeHasFocusNodeLP(SCIP_TREE *tree)
Definition: tree.c:8242
static SCIP_RETCODE junctionInit(SCIP_JUNCTION *junction, SCIP_TREE *tree)
Definition: tree.c:407
SCIP_Bool SCIPlpDiving(SCIP_LP *lp)
Definition: lp.c:16989
SCIP_RETCODE SCIPconssetchgFree(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:5219
#define SCIPdebugRemoveNode(blkmem, set, node)
Definition: debug.h:254
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:130
SCIP_Real * origobjvals
Definition: struct_tree.h:53
SCIP_RETCODE SCIPlpShrinkRows(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, int newnrows)
Definition: lp.c:9486
void SCIPlpSetIsRelax(SCIP_LP *lp, SCIP_Bool relax)
Definition: lp.c:16926
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:5282
int naddedcols
Definition: struct_tree.h:102
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:5673
SCIP_Longint ndeactivatednodes
Definition: struct_stat.h:82
void SCIPtreeSetFocusNodeLP(SCIP_TREE *tree, SCIP_Bool solvelp)
Definition: tree.c:8252
SCIP_Bool primalfeasible
Definition: struct_lp.h:349
SCIP_NODE * SCIPnodesGetCommonAncestor(SCIP_NODE *node1, SCIP_NODE *node2)
Definition: tree.c:8064
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:2368
SCIP_BRANCHDIR SCIPvarGetBranchDirection(SCIP_VAR *var)
Definition: var.c:17458
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:8477
SCIP_NODE * SCIPtreeGetLowerboundNode(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7191
SCIP_Real SCIPsetFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5963
int nlpicols
Definition: struct_lp.h:299
SCIP_Bool SCIPsetIsFeasEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6174
SCIP_RETCODE SCIPlpRemoveAllObsoletes(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter)
Definition: lp.c:14904
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
Definition: tree.c:7360
SCIP_Longint nlps
Definition: struct_stat.h:173
methods for implications, variable bounds, and cliques
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17276
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:204
#define SCIP_MAXSTRLEN
Definition: def.h:259
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:197
SCIP_Real rootlowerbound
Definition: struct_stat.h:117
SCIP_RETCODE SCIPtreeSetNodesel(SCIP_TREE *tree, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_NODESEL *nodesel)
Definition: tree.c:5019
unsigned int active
Definition: struct_tree.h:151
void SCIPgmlWriteArc(FILE *file, unsigned int source, unsigned int target, const char *label, const char *color)
Definition: misc.c:627
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_BRANCHDIR * divebdchgdirs[2]
Definition: struct_tree.h:193
SCIP_BOUNDCHG * boundchgs
Definition: struct_var.h:125
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5899
static long bound
int SCIPtreeGetProbingDepth(SCIP_TREE *tree)
Definition: tree.c:8328
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_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_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17332
void SCIProwCapture(SCIP_ROW *row)
Definition: lp.c:5214
SCIP_CLIQUE ** SCIPvarGetCliques(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17639
SCIP_PROBINGNODE * probingnode
Definition: struct_tree.h:137
SCIP_RETCODE SCIPtreeCreate(SCIP_TREE **tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_NODESEL *nodesel)
Definition: tree.c:4693
unsigned int repropsubtreemark
Definition: struct_tree.h:154
SCIP_NODE * SCIPnodeGetParent(SCIP_NODE *node)
Definition: tree.c:7620
void SCIPgmlWriteNode(FILE *file, unsigned int id, const char *label, const char *nodetype, const char *fillcolor, const char *bordercolor)
Definition: misc.c:485
void SCIPnodeGetAddedConss(SCIP_NODE *node, SCIP_CONS **addedconss, int *naddedconss, int addedconsssize)
Definition: tree.c:1638
void SCIPnodeSetReoptID(SCIP_NODE *node, unsigned int id)
Definition: tree.c:7421
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:8507
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:6739
interface methods for specific LP solvers
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:16842
SCIP_NODE * SCIPtreeGetBestNode(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7119
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5636
SCIP_Longint nactiveconssadded
Definition: struct_stat.h:113
int naddedrows
Definition: struct_tree.h:103
SCIP_Bool probingchange
Definition: struct_tree.h:169
SCIP_NODE * SCIPtreeGetProbingRoot(SCIP_TREE *tree)
Definition: tree.c:8195
SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
Definition: var.c:12665
SCIP_NODE * SCIPtreeGetBestChild(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7055
SCIP_Real * divebdchgvals[2]
Definition: struct_tree.h:194
SCIP_Real SCIPvarGetRootSol(SCIP_VAR *var)
Definition: var.c:12758
int SCIPnodepqLen(const SCIP_NODEPQ *nodepq)
Definition: nodesel.c:558
SCIP_VAR * var
Definition: struct_tree.h:163
SCIP_RETCODE SCIPlpFreeState(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
Definition: lp.c:9880
void SCIPgmlWriteClosing(FILE *file)
Definition: misc.c:687
int nlpirows
Definition: struct_lp.h:302
SCIP_Real newbound
Definition: struct_tree.h:164
SCIP_BOUNDTYPE SCIPboundchgGetBoundtype(SCIP_BOUNDCHG *boundchg)
Definition: var.c:16589
unsigned int nboundchgs
Definition: struct_var.h:123
unsigned int lpwasdualchecked
Definition: struct_tree.h:109
unsigned int cutoff
Definition: struct_tree.h:152
SCIP_Longint nholechgs
Definition: struct_stat.h:105
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:238
unsigned int nodetype
Definition: struct_tree.h:150
#define FALSE
Definition: def.h:64
SCIP_LPINORMS * probinglpinorms
Definition: struct_tree.h:201
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:3810
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:6317
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:1271
SCIP_Bool solved
Definition: struct_lp.h:348
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
Definition: misc.c:10289
SCIP_Bool probinglpwasdualchecked
Definition: struct_tree.h:237
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:79
unsigned int reprop
Definition: struct_tree.h:153
SCIP_Bool dualchecked
Definition: struct_lp.h:352
SCIP_Bool sbprobing
Definition: struct_tree.h:233
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10011
SCIP_Bool SCIPsetIsZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5888
SCIP_RETCODE SCIPeventqueueDelay(SCIP_EVENTQUEUE *eventqueue)
Definition: event.c:2353
#define TRUE
Definition: def.h:63
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:3469
unsigned int enabled
Definition: struct_cons.h:82
SCIP_RETCODE SCIPlpGetState(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
Definition: lp.c:9814
SCIP_Longint nbacktracks
Definition: struct_stat.h:85
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8300
SCIP_Real SCIPnodepqGetLowerboundSum(SCIP_NODEPQ *nodepq)
Definition: nodesel.c:616
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16969
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5326
SCIP_Real estimate
Definition: struct_tree.h:134
SCIP_FORK * fork
Definition: struct_tree.h:143
SCIP_NODE * SCIPtreeGetFocusNode(SCIP_TREE *tree)
Definition: tree.c:8208
#define BMSallocMemoryArray(ptr, num)
Definition: memory.h:105
SCIP_Bool probinglpwasflushed
Definition: struct_tree.h:226
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:6593
SCIP_Real SCIPvarGetAvgInferences(SCIP_VAR *var, SCIP_STAT *stat, SCIP_BRANCHDIR dir)
Definition: var.c:15471
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:12045
SCIP_ROW ** SCIPlpGetRows(SCIP_LP *lp)
Definition: lp.c:16754
#define SCIPdebugMessage
Definition: pub_message.h:77
SCIP_COL ** addedcols
Definition: struct_tree.h:98
int firstnewcol
Definition: struct_lp.h:313
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:15112
void SCIPrelaxationSetSolValid(SCIP_RELAXATION *relaxation, SCIP_Bool isvalid, SCIP_Bool includeslp)
Definition: relax.c:636
SCIP_Bool probingsolvedlp
Definition: struct_tree.h:230
SCIP_Bool SCIPrelaxationIsSolValid(SCIP_RELAXATION *relaxation)
Definition: relax.c:649
SCIP_RETCODE SCIPlpSetNorms(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPINORMS *lpinorms)
Definition: lp.c:9921
unsigned int domchgtype
Definition: struct_var.h:142
SCIP_NODE ** siblings
Definition: struct_tree.h:189
int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7350
methods for creating output for visualization tools (VBC, BAK)
int divebdchgsize[2]
Definition: struct_tree.h:205
static SCIP_RETCODE treeAddChild(SCIP_TREE *tree, SCIP_SET *set, SCIP_NODE *child, SCIP_Real nodeselprio)
Definition: tree.c:730
SCIP_Bool SCIPvarIsDeletable(SCIP_VAR *var)
Definition: var.c:16939
int SCIPvarGetConflictingBdchgDepth(SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_Real bound)
Definition: var.c:16290
#define BMSfreeMemory(ptr)
Definition: memory.h:127
SCIP_RETCODE SCIPlpEndProbing(SCIP_LP *lp)
Definition: lp.c:15552
SCIP_NODESEL * SCIPnodepqGetNodesel(SCIP_NODEPQ *nodepq)
Definition: nodesel.c:193
void SCIPvarAdjustLb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *lb)
Definition: var.c:6152
SCIP_JUNCTION junction
Definition: struct_tree.h:141
static void treeChildrenToSiblings(SCIP_TREE *tree)
Definition: tree.c:4199
unsigned int lpwasdualfeas
Definition: struct_tree.h:108
SCIP_CONS ** disabledconss
Definition: struct_cons.h:109
int childrensize
Definition: struct_tree.h:209
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:12612
SCIP_VISUAL * visual
Definition: struct_stat.h:165
SCIP_Real SCIPsetCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5974
unsigned int reoptid
Definition: struct_tree.h:155
int pathsize
Definition: struct_tree.h:214
SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
static SCIP_RETCODE treeCreateProbingNode(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp)
Definition: tree.c:6256
#define SCIPstatIncrement(stat, set, field)
Definition: stat.h:251
int npendingbdchgs
Definition: struct_tree.h:208
internal methods for LP management
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:8047
int SCIPvarGetNCliques(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17628
SCIP_Bool SCIPtreeIsPathComplete(SCIP_TREE *tree)
Definition: tree.c:8165
SCIP_Longint number
Definition: struct_tree.h:132
SCIP_Bool SCIPtreeIsFocusNodeLPConstructed(SCIP_TREE *tree)
Definition: tree.c:8263
SCIP_Bool primalchecked
Definition: struct_lp.h:350
void SCIPnodeGetAncestorBranchings(SCIP_NODE *node, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:7694
SCIP_ROW ** rows
Definition: struct_tree.h:116
internal methods for collecting primal CIP solutions and primal informations
SCIP_Bool SCIPconsIsGlobal(SCIP_CONS *cons)
Definition: cons.c:8215
int SCIPlpGetNCols(SCIP_LP *lp)
Definition: lp.c:16744
unsigned int lpwasprimchecked
Definition: struct_tree.h:107
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5870
int nlpistateref
Definition: struct_tree.h:104
internal methods for propagators
SCIP_Bool SCIPclockIsRunning(SCIP_CLOCK *clck)
Definition: clock.c:417
int pendingbdchgssize
Definition: struct_tree.h:207
SCIP_RETCODE SCIPnodepqInsert(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
Definition: nodesel.c:267
int SCIPtreeGetFocusDepth(SCIP_TREE *tree)
Definition: tree.c:8225
SCIP_Real * siblingsprio
Definition: struct_tree.h:191
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:3223
enum SCIP_BranchDir SCIP_BRANCHDIR
Definition: type_history.h:39
SCIP_LPISTATE * lpistate
Definition: struct_tree.h:100
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:7340
int SCIPtreeGetNChildren(SCIP_TREE *tree)
Definition: tree.c:8125
SCIP_NODE * SCIPtreeGetBestLeaf(SCIP_TREE *tree)
Definition: tree.c:7109
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:124
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17286
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5816
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
Definition: var.c:11628
SCIP_Bool probinglpwassolved
Definition: struct_tree.h:227
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:15073
SCIP_Real SCIPtreeCalcNodeselPriority(SCIP_TREE *tree, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var, SCIP_BRANCHDIR branchdir, SCIP_Real targetvalue)
Definition: tree.c:5132
SCIP_REOPTTYPE SCIPnodeGetReopttype(SCIP_NODE *node)
Definition: tree.c:7380
SCIP_Bool probingloadlpistate
Definition: struct_tree.h:228
SCIP_DOMCHG * domchg
Definition: struct_tree.h:148
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:3133
SCIP_Bool SCIPtreeProbing(SCIP_TREE *tree)
Definition: tree.c:8182
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:1054
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:9838
int nsiblings
Definition: struct_tree.h:212
SCIP_RETCODE SCIPvisualNewChild(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:253
int cutoffdepth
Definition: struct_tree.h:218
SCIP_Real * childrenprio
Definition: struct_tree.h:190
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:13881
int SCIPlpGetNNewcols(SCIP_LP *lp)
Definition: lp.c:16785
#define BMSduplicateBlockMemoryArray(mem, ptr, source, num)
Definition: memory.h:443
SCIP_SUBROOT * subroot
Definition: struct_tree.h:144
SCIP_RETCODE SCIPconssetchgApply(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, int depth, SCIP_Bool focusnode)
Definition: cons.c:5457
SCIP_Bool probingobjchanged
Definition: struct_tree.h:232
unsigned int reopttype
Definition: struct_tree.h:156
SCIP_RETCODE SCIPlpStartProbing(SCIP_LP *lp)
Definition: lp.c:15537
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:1306
SCIP_Bool SCIPnodesSharePath(SCIP_NODE *node1, SCIP_NODE *node2)
Definition: tree.c:8040
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:7991
int repropsubtreecount
Definition: struct_tree.h:220
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:129
static SCIP_RETCODE forkReleaseLPIState(SCIP_FORK *fork, BMS_BLKMEM *blkmem, SCIP_LP *lp)
Definition: tree.c:172
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:2698
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_Bool SCIPboundchgIsRedundant(SCIP_BOUNDCHG *boundchg)
Definition: var.c:16599
SCIP_RETCODE SCIPdomchgMakeStatic(SCIP_DOMCHG **domchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:1084
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:983
SCIP_Longint lpcount
Definition: struct_stat.h:171
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:5901
void SCIPnodeGetNDomchg(SCIP_NODE *node, int *nbranchings, int *nconsprop, int *nprop)
Definition: tree.c:7445
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:9231
int siblingssize
Definition: struct_tree.h:211
SCIP_Bool SCIPtreeInRepropagation(SCIP_TREE *tree)
Definition: tree.c:8273
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:4236
#define SCIPdebugCheckInference(blkmem, set, node, var, newbound, boundtype)
Definition: debug.h:253
SCIP_Bool SCIPsetIsRelEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6661
SCIP_RETCODE SCIPvarRelease(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:2765
SCIP_RETCODE SCIPlpShrinkCols(SCIP_LP *lp, SCIP_SET *set, int newncols)
Definition: lp.c:9414
SCIP_COL ** SCIPlpGetCols(SCIP_LP *lp)
Definition: lp.c:16734
SCIP_LPISTATE * probinglpistate
Definition: struct_tree.h:199
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:3876
SCIP_NODE ** path
Definition: struct_tree.h:177
int repropdepth
Definition: struct_tree.h:219
SCIP_NODE * focuslpstatefork
Definition: struct_tree.h:185
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:7986
void SCIPlpMarkSize(SCIP_LP *lp)
Definition: lp.c:9571
SCIP_RETCODE SCIPnodePrintAncestorBranchings(SCIP_NODE *node, FILE *file)
Definition: tree.c:7939
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16662
SCIP_DOMCHGDYN domchgdyn
Definition: struct_var.h:155
SCIP_NODE * SCIPtreeGetBestSibling(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7082
void SCIPnodeGetAncestorBranchingsPart(SCIP_NODE *node, SCIP_NODE *parent, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:7731
SCIP_Bool SCIPnodeIsPropagatedAgain(SCIP_NODE *node)
Definition: tree.c:8105
SCIP_Real SCIPsetFeasCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6352
struct SCIP_LPiState SCIP_LPISTATE
Definition: type_lpi.h:97
static void treeCheckPath(SCIP_TREE *tree)
Definition: tree.c:3269
SCIP_DOMCHG * SCIPnodeGetDomchg(SCIP_NODE *node)
Definition: tree.c:7435
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:9290
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:3341
enum SCIP_ReoptType SCIP_REOPTTYPE
Definition: type_reopt.h:58
SCIP_Bool isrelax
Definition: struct_lp.h:355
SCIP_RETCODE SCIPvarSetRelaxSol(SCIP_VAR *var, SCIP_SET *set, SCIP_RELAXATION *relaxation, SCIP_Real solval, SCIP_Bool updateobj)
Definition: var.c:13268
int appliedeffectiverootdepth
Definition: struct_tree.h:216
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:3927
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:17650
SCIP_Bool SCIPsetIsRelGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6727
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:203
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:217
SCIP_SIBLING sibling
Definition: struct_tree.h:138
SCIP_NODEPQ * leaves
Definition: struct_tree.h:176
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:350
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6262
int SCIPlpGetNRows(SCIP_LP *lp)
Definition: lp.c:16764
SCIP_CONSSETCHG * SCIPnodeGetConssetchg(SCIP_NODE *node)
Definition: tree.c:8115
int SCIPnodeselCompare(SCIP_NODESEL *nodesel, SCIP_SET *set, SCIP_NODE *node1, SCIP_NODE *node2)
Definition: nodesel.c:984
SCIP_RETCODE SCIPconsDisable(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:6748
SCIP_Bool resolvelperror
Definition: struct_lp.h:364
SCIP_Bool probinglpwasprimchecked
Definition: struct_tree.h:235
SCIP_COL ** cols
Definition: struct_tree.h:115
internal methods for relaxators
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5798
SCIP_CONS * infercons
Definition: struct_tree.h:166
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:251
unsigned int nboundchgs
Definition: struct_var.h:141
SCIP_Real SCIPlpGetObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:12628
SCIP_LPI * lpi
Definition: struct_lp.h:282
SCIP_Longint ncreatednodesrun
Definition: struct_stat.h:80
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6218
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:252
SCIP_BOUNDTYPE boundtype
Definition: struct_tree.h:165
SCIP_RETCODE SCIProwRelease(SCIP_ROW **row, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp)
Definition: lp.c:5227
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:7243
SCIP_LPINORMS * lpinorms
Definition: struct_tree.h:47
void SCIPvarAdjustBd(SCIP_VAR *var, SCIP_SET *set, SCIP_BOUNDTYPE boundtype, SCIP_Real *bd)
Definition: var.c:6186
void SCIPtreeClearDiveBoundChanges(SCIP_TREE *tree)
Definition: tree.c:6241
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:446
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:2391
int SCIPnodeGetNDualBndchgs(SCIP_NODE *node)
Definition: tree.c:7497
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
SCIP_BOUNDTYPE * SCIPvarGetImplTypes(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17586
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:9552
SCIP_Bool lpwasdualfeas
Definition: struct_tree.h:57
static SCIP_RETCODE treeUpdatePathLPSize(SCIP_TREE *tree, int startdepth)
Definition: tree.c:2590
int SCIPtreeGetEffectiveRootDepth(SCIP_TREE *tree)
Definition: tree.c:8339
#define SCIP_Bool
Definition: def.h:61
void SCIPlpRecomputeLocalAndGlobalPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:12711
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:2998
void SCIPvarCapture(SCIP_VAR *var)
Definition: var.c:2753
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:5926
#define BMSallocBlockMemoryArray(mem, ptr, num)
Definition: memory.h:435
int arraypos
Definition: struct_tree.h:70
char * name
Definition: struct_cons.h:43
SCIP_Bool lpwasprimchecked
Definition: struct_tree.h:56
int SCIPsetCalcPathGrowSize(SCIP_SET *set, int num)
Definition: set.c:5344
SCIP_Bool focuslpconstructed
Definition: struct_tree.h:224
unsigned int depth
Definition: struct_tree.h:149
SCIP_NODE ** children
Definition: struct_tree.h:188
#define MAXREPROPMARK
Definition: tree.c:52
SCIP_VAR ** origobjvars
Definition: struct_tree.h:52
SCIP_Bool SCIPvarIsInLP(SCIP_VAR *var)
Definition: var.c:17001
SCIP_Longint nearlybacktracks
Definition: struct_stat.h:83
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:6340
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:4880
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:16796
int SCIPvarGetBranchPriority(SCIP_VAR *var)
Definition: var.c:17448
SCIP_Real lastlowerbound
Definition: struct_stat.h:135
#define ARRAYGROWTH
Definition: tree.c:6185
SCIP_RETCODE SCIPnodepqRemove(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
Definition: nodesel.c:511
SCIP_Bool divingobjchg
Definition: struct_lp.h:362
void SCIPtreeGetDiveBoundChangeData(SCIP_TREE *tree, SCIP_VAR ***variables, SCIP_BRANCHDIR **directions, SCIP_Real **values, int *ndivebdchgs, SCIP_Bool preferred)
Definition: tree.c:6218
unsigned int lpwasdualchecked
Definition: struct_tree.h:126
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:3669
int SCIPvarGetNImpls(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17554
#define BMSfreeBlockMemoryArray(mem, ptr, num)
Definition: memory.h:448
SCIP_Bool SCIPlpDivingObjChanged(SCIP_LP *lp)
Definition: lp.c:16999
SCIP_Longint nrepropcutoffs
Definition: struct_stat.h:89
int probingsumchgdobjs
Definition: struct_tree.h:221
#define MAX(x, y)
Definition: tclique_def.h:75
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:550
SCIP_VAR * SCIPboundchgGetVar(SCIP_BOUNDCHG *boundchg)
Definition: var.c:16569
SCIP_Bool lpwasprimfeas
Definition: struct_tree.h:55
methods for debugging
SCIP_Bool * SCIPcliqueGetValues(SCIP_CLIQUE *clique)
Definition: implics.c:3365
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_BOUNDCHG * SCIPdomchgGetBoundchg(SCIP_DOMCHG *domchg, int pos)
Definition: var.c:16617
SCIP_ROW ** addedrows
Definition: struct_tree.h:89
#define SCIPsetDebugMsg
Definition: set.h:1913
#define SCIP_EVENTTYPE_NODEINFEASIBLE
Definition: type_event.h:79
SCIP_Bool SCIPsetIsRelLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6683
const char * SCIPnodeselGetName(SCIP_NODESEL *nodesel)
Definition: nodesel.c:1001
SCIP_NODE * SCIPnodepqFirst(const SCIP_NODEPQ *nodepq)
Definition: nodesel.c:532
int * pathnlpcols
Definition: struct_tree.h:195
SCIP_Bool SCIPprobAllColsInLP(SCIP_PROB *prob, SCIP_SET *set, SCIP_LP *lp)
Definition: prob.c:2262
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17124
SCIP_RETCODE SCIPconshdlrsResetPropagationStatus(SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_CONSHDLR **conshdlrs, int nconshdlrs)
Definition: cons.c:7770
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:610
SCIP_Bool probinglpwasrelax
Definition: struct_tree.h:229
SCIP_Bool SCIPtreeHasCurrentNodeLP(SCIP_TREE *tree)
Definition: tree.c:8317
SCIP_RETCODE SCIPvisualUpdateChild(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:328
SCIP_RETCODE SCIPnodeCaptureLPIState(SCIP_NODE *node, int nuses)
Definition: tree.c:235
void SCIPlpSetSizeMark(SCIP_LP *lp, int nrows, int ncols)
Definition: lp.c:9583
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:7860
SCIP_NODESEL * SCIPtreeGetNodesel(SCIP_TREE *tree)
Definition: tree.c:5009
SCIP_Real SCIPvarGetRelaxSol(SCIP_VAR *var, SCIP_SET *set)
Definition: var.c:13329
SCIP_Bool cutoffdelayed
Definition: struct_tree.h:225
SCIP_Real * SCIPvarGetImplBounds(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17600
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6196
SCIP_Bool probdiverelaxincludeslp
Definition: struct_tree.h:239
SCIP_RETCODE SCIPlpGetNorms(SCIP_LP *lp, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
Definition: lp.c:9897
#define SCIP_MAXTREEDEPTH
Definition: def.h:286
SCIP_RETCODE SCIPnodeReleaseLPIState(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_LP *lp)
Definition: tree.c:263
const char * SCIPpropGetName(SCIP_PROP *prop)
Definition: prop.c:887
SCIP_RETCODE SCIPvarGetProbvarBound(SCIP_VAR **var, SCIP_Real *bound, SCIP_BOUNDTYPE *boundtype)
Definition: var.c:11879
SCIP_CONSSETCHG * conssetchg
Definition: struct_tree.h:147
#define SCIP_REAL_MAX
Definition: def.h:150
int ndivebdchanges[2]
Definition: struct_tree.h:206
SCIP_NODE * probingroot
Definition: struct_tree.h:187
SCIP_RETCODE SCIPtreeFree(SCIP_TREE **tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: tree.c:4772
SCIP_Real SCIPnodeGetEstimate(SCIP_NODE *node)
Definition: tree.c:7370
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:12841
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:151
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:3588
SCIP_VAR ** SCIPvarGetImplVars(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17571
SCIP_Real SCIPsetFeasFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6341
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:7153
int SCIPtreeGetNSiblings(SCIP_TREE *tree)
Definition: tree.c:8135
int SCIPnodeGetNAddedConss(SCIP_NODE *node)
Definition: tree.c:1668
SCIP_Bool SCIPtreeProbingObjChanged(SCIP_TREE *tree)
Definition: tree.c:8361
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:5815
static void treeNextRepropsubtreecount(SCIP_TREE *tree)
Definition: tree.c:1262
SCIP_NODE * parent
Definition: struct_tree.h:146
SCIP_Real SCIPnodepqGetLowerbound(SCIP_NODEPQ *nodepq, SCIP_SET *set)
Definition: nodesel.c:569
SCIP_LPISTATE * lpistate
Definition: struct_tree.h:46
SCIP_RETCODE SCIPlpSetCutoffbound(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob, SCIP_Real cutoffbound)
Definition: lp.c:9965
SCIP_NODE * SCIPtreeGetRootNode(SCIP_TREE *tree)
Definition: tree.c:8350
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:5544
int SCIPdomchgGetNBoundchgs(SCIP_DOMCHG *domchg)
Definition: var.c:16609
unsigned int SCIPnodeGetReoptID(SCIP_NODE *node)
Definition: tree.c:7411
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:5293
SCIP_RETCODE SCIPtreeMarkProbingNodeHasLP(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_LP *lp)
Definition: tree.c:6565
SCIP_NODE * SCIPtreeGetCurrentNode(SCIP_TREE *tree)
Definition: tree.c:8283
SCIP_Bool flushed
Definition: struct_lp.h:347
unsigned int updatedisable
Definition: struct_cons.h:91
int nrows
Definition: struct_lp.h:315
SCIP_NODE * focuslpfork
Definition: struct_tree.h:184
public methods for message output
SCIP_Real lowerbound
Definition: struct_tree.h:133
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5852
SCIP_Longint nboundchgs
Definition: struct_stat.h:104
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16781
SCIP_LPISTATE * lpistate
Definition: struct_tree.h:117
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
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:4966
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
Definition: tree.c:7330
static SCIP_RETCODE nodeCreate(SCIP_NODE **node, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: tree.c:953
#define SCIP_Real
Definition: def.h:149
void SCIPvisualCutoffNode(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node, SCIP_Bool infeasible)
Definition: visual.c:520
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:398
SCIP_VAR ** divebdchgvars[2]
Definition: struct_tree.h:192
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:1222
SCIP_RETCODE SCIPtreeStoreRelaxSol(SCIP_TREE *tree, SCIP_SET *set, SCIP_RELAXATION *relaxation, SCIP_PROB *transprob)
Definition: tree.c:6934
SCIP_Real referencebound
Definition: struct_stat.h:138
SCIP_Bool SCIPsetIsFeasPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6295
SCIP_RETCODE SCIPtreeLoadProbingLPState(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: tree.c:6484
SCIP_Longint nrepropboundchgs
Definition: struct_stat.h:88
int effectiverootdepth
Definition: struct_tree.h:215
SCIP_RETCODE SCIPvarGetProbvarHole(SCIP_VAR **var, SCIP_Real *left, SCIP_Real *right)
Definition: var.c:11972
#define BMSallocMemory(ptr)
Definition: memory.h:101
#define SCIP_INVALID
Definition: def.h:169
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:109
internal methods for constraints and constraint handlers
SCIP_NODE * SCIPtreeGetPrioChild(SCIP_TREE *tree)
Definition: tree.c:7003
SCIP_Bool SCIPlpIsRelax(SCIP_LP *lp)
Definition: lp.c:16939
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_Bool SCIPnodeIsActive(SCIP_NODE *node)
Definition: tree.c:8095
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
#define SCIP_Longint
Definition: def.h:134
SCIP_Longint nactivatednodes
Definition: struct_stat.h:81
SCIP_Longint nreprops
Definition: struct_stat.h:87
SCIP_COL ** addedcols
Definition: struct_tree.h:88
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6240
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:2339
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16827
void SCIPnodeSetReopttype(SCIP_NODE *node, SCIP_REOPTTYPE reopttype)
Definition: tree.c:7390
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:4165
SCIP_RETCODE SCIPconssetchgMakeGlobal(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_REOPT *reopt)
Definition: cons.c:5630
SCIP_CLOCK * nodeactivationtime
Definition: struct_stat.h:157
SCIP_Real SCIPsetEpsilon(SCIP_SET *set)
Definition: set.c:5658
SCIP_Bool dualfeasible
Definition: struct_lp.h:351
SCIP_RETCODE SCIPconssetchgAddDisabledCons(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:5339
SCIP_Bool probinglpwasprimfeas
Definition: struct_tree.h:234
int nchildren
Definition: struct_tree.h:210
#define nnodes
Definition: gastrans.c:65
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17342
SCIP_Real SCIPtreeGetLowerbound(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7153
int SCIPcliqueGetNVars(SCIP_CLIQUE *clique)
Definition: implics.c:3343
void SCIPgmlWriteOpening(FILE *file, SCIP_Bool directed)
Definition: misc.c:671
void SCIPvarAdjustUb(SCIP_VAR *var, SCIP_SET *set, SCIP_Real *ub)
Definition: var.c:6169
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:433
int plungedepth
Definition: struct_stat.h:219
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:5047
SCIP_RETCODE SCIPtreeRestoreRelaxSol(SCIP_TREE *tree, SCIP_SET *set, SCIP_RELAXATION *relaxation, SCIP_PROB *transprob)
Definition: tree.c:6971
unsigned int lpwasprimfeas
Definition: struct_tree.h:123
SCIP_Bool SCIPeventqueueIsDelayed(SCIP_EVENTQUEUE *eventqueue)
Definition: event.c:2440
SCIP_RETCODE SCIPprobDelVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Bool *deleted)
Definition: prob.c:993
common defines and data types used in all packages of SCIP
SCIP_Longint nnodes
Definition: struct_stat.h:71
SCIP_Real SCIPlpGetModifiedProvedPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_VAR *var, SCIP_Real oldbound, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype)
Definition: lp.c:12881
void SCIPvisualMarkedRepropagateNode(SCIP_VISUAL *visual, SCIP_STAT *stat, SCIP_NODE *node)
Definition: visual.c:617
SCIP_PENDINGBDCHG * pendingbdchgs
Definition: struct_tree.h:202
SCIP_Bool probingnodehaslp
Definition: struct_tree.h:223
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:419
int SCIPtreeGetNLeaves(SCIP_TREE *tree)
Definition: tree.c:8145
SCIP_RETCODE SCIPvarGetProbvarSum(SCIP_VAR **var, SCIP_SET *set, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12057
static void treeRemoveChild(SCIP_TREE *tree, SCIP_NODE *child)
Definition: tree.c:753
SCIP_NODE * root
Definition: struct_tree.h:175
SCIP_RETCODE SCIPconshdlrsStorePropagationStatus(SCIP_SET *set, SCIP_CONSHDLR **conshdlrs, int nconshdlrs)
Definition: cons.c:7730
SCIP_COL ** SCIPlpGetNewcols(SCIP_LP *lp)
Definition: lp.c:16774
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:2405
SCIP_CHILD child
Definition: struct_tree.h:139
unsigned int nchildren
Definition: struct_tree.h:122
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:361
int SCIPtreeGetNNodes(SCIP_TREE *tree)
Definition: tree.c:8155
#define SCIPABORT()
Definition: def.h:322
SCIP_Bool SCIPsetIsRelGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6749
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:3770
SCIP_LPSOLSTAT lpsolstat
Definition: struct_lp.h:334
SCIP_Longint nprobholechgs
Definition: struct_stat.h:107
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:16853
void SCIPchildChgNodeselPrio(SCIP_TREE *tree, SCIP_NODE *child, SCIP_Real priority)
Definition: tree.c:2373
SCIP_PROP * inferprop
Definition: struct_tree.h:167
SCIP_ROW ** addedrows
Definition: struct_tree.h:99
int ncols
Definition: struct_lp.h:309
union SCIP_Node::@10 data
unsigned int lpwasprimfeas
Definition: struct_tree.h:106
void SCIPnodeGetConsProps(SCIP_NODE *node, SCIP_VAR **vars, SCIP_Real *varbounds, SCIP_BOUNDTYPE *varboundtypes, int *nconspropvars, int conspropvarssize)
Definition: tree.c:7772
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:105
SCIP_RETCODE SCIPtreeCreateProbingNode(SCIP_TREE *tree, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp)
Definition: tree.c:6405
void SCIPlpUnmarkDivingObjChanged(SCIP_LP *lp)
Definition: lp.c:17020
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
Definition: memory.h:439
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:1345
static SCIP_RETCODE focusnodeToJunction(BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_LP *lp)
Definition: tree.c:3839
void SCIPtreeMarkProbingObjChanged(SCIP_TREE *tree)
Definition: tree.c:8372
SCIP_Bool SCIPrelaxationIsLpIncludedForSol(SCIP_RELAXATION *relaxation)
Definition: relax.c:659
SCIP callable library.
SCIP_Bool SCIPsetIsFeasNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6306
SCIP_Bool probinglpwasdualfeas
Definition: struct_tree.h:236
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:16949
SCIP_NODE * SCIPtreeGetPrioSibling(SCIP_TREE *tree)
Definition: tree.c:7029
SCIP_NODE * focusnode
Definition: struct_tree.h:180
SCIP_Bool focusnodehaslp
Definition: struct_tree.h:222