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-2018 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(!SCIPtreeProbing(tree));
4277  assert(lp != NULL);
4278  assert(cutoff != NULL);
4279 
4280  SCIPsetDebugMsg(set, "focusing node #%" SCIP_LONGINT_FORMAT " of type %d in depth %d\n",
4281  *node != NULL ? SCIPnodeGetNumber(*node) : -1, *node != NULL ? (int)SCIPnodeGetType(*node) : 0,
4282  *node != NULL ? SCIPnodeGetDepth(*node) : -1);
4283 
4284  /* remember old cutoff depth in order to know, whether the children and siblings can be deleted */
4285  oldcutoffdepth = tree->cutoffdepth;
4286 
4287  /* find the common fork node, the new LP defining fork, and the new focus subroot,
4288  * thereby checking, if the new node can be cut off
4289  */
4290  treeFindSwitchForks(tree, *node, &fork, &lpfork, &lpstatefork, &subroot, cutoff);
4291  SCIPsetDebugMsg(set, "focus node: focusnodedepth=%d, forkdepth=%d, lpforkdepth=%d, lpstateforkdepth=%d, subrootdepth=%d, cutoff=%u\n",
4292  *node != NULL ? (*node)->depth : -1, fork != NULL ? fork->depth : -1, /*lint !e705 */
4293  lpfork != NULL ? lpfork->depth : -1, lpstatefork != NULL ? lpstatefork->depth : -1, /*lint !e705 */
4294  subroot != NULL ? subroot->depth : -1, *cutoff); /*lint !e705 */
4295 
4296  /* free the new node, if it is located in a cut off subtree */
4297  if( *cutoff )
4298  {
4299  assert(*node != NULL);
4300  assert(tree->cutoffdepth == oldcutoffdepth);
4301  if( SCIPnodeGetType(*node) == SCIP_NODETYPE_LEAF )
4302  {
4303  SCIP_CALL( SCIPnodepqRemove(tree->leaves, set, *node) );
4304  }
4305  SCIPvisualCutoffNode(stat->visual, set, stat, *node, FALSE);
4306 
4307  if( set->reopt_enable )
4308  {
4309  assert(reopt != NULL);
4310  /* check if the node should be stored for reoptimization */
4312  tree->root == (*node), tree->focusnode == (*node), (*node)->lowerbound, tree->effectiverootdepth) );
4313  }
4314 
4315  SCIP_CALL( SCIPnodeFree(node, blkmem, set, stat, eventqueue, tree, lp) );
4316 
4317  return SCIP_OKAY;
4318  }
4319 
4320  assert(tree->cutoffdepth == INT_MAX);
4321  assert(fork == NULL || fork->active);
4322  assert(lpstatefork == NULL || lpfork != NULL);
4323  assert(subroot == NULL || lpstatefork != NULL);
4324 
4325  /* remember the depth of the common fork node for LP updates */
4326  SCIPsetDebugMsg(set, "focus node: old correctlpdepth=%d\n", tree->correctlpdepth);
4327  if( subroot == tree->focussubroot && fork != NULL && lpfork != NULL )
4328  {
4329  /* we are in the same subtree with valid LP fork: the LP is correct at most upto the common fork depth */
4330  assert(subroot == NULL || subroot->active);
4331  tree->correctlpdepth = MIN(tree->correctlpdepth, (int)fork->depth);
4332  }
4333  else
4334  {
4335  /* we are in a different subtree, or no valid LP fork exists: the LP is completely incorrect */
4336  assert(subroot == NULL || !subroot->active
4337  || (tree->focussubroot != NULL && (int)(tree->focussubroot->depth) > subroot->depth));
4338  tree->correctlpdepth = -1;
4339  }
4340 
4341  /* if the LP state fork changed, the lpcount information for the new LP state fork is unknown */
4342  if( lpstatefork != tree->focuslpstatefork )
4343  tree->focuslpstateforklpcount = -1;
4344 
4345  /* in exitsolve we only need to take care of open children
4346  *
4347  * @note because we might do a 'newstart' and converted cuts to constraints might have rendered the LP in the current
4348  * focusnode unsolved the latter code would have resolved the LP unnecessarily
4349  */
4350  if( exitsolve && tree->nchildren > 0 )
4351  {
4352  SCIPsetDebugMsg(set, " -> deleting the %d children (in exitsolve) of the old focus node\n", tree->nchildren);
4353  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, NULL, -SCIPsetInfinity(set)) );
4354  assert(tree->nchildren == 0);
4355  }
4356 
4357  /* if the old focus node was cut off, we can delete its children;
4358  * if the old focus node's parent was cut off, we can also delete the focus node's siblings
4359  */
4360  if( tree->focusnode != NULL && oldcutoffdepth <= (int)tree->focusnode->depth )
4361  {
4362  SCIPsetDebugMsg(set, "path to old focus node of depth %u was cut off at depth %d\n", tree->focusnode->depth, oldcutoffdepth);
4363 
4364  /* delete the focus node's children by converting them to leaves with a cutoffbound of -SCIPsetInfinity(set);
4365  * we cannot delete them directly, because in SCIPnodeFree(), the children array is changed, which is the
4366  * same array we would have to iterate over here;
4367  * the children don't have an LP fork, because the old focus node is not yet converted into a fork or subroot
4368  */
4369  SCIPsetDebugMsg(set, " -> deleting the %d children of the old focus node\n", tree->nchildren);
4370  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, NULL, -SCIPsetInfinity(set)) );
4371  assert(tree->nchildren == 0);
4372 
4373  if( oldcutoffdepth < (int)tree->focusnode->depth )
4374  {
4375  /* delete the focus node's siblings by converting them to leaves with a cutoffbound of -SCIPsetInfinity(set);
4376  * we cannot delete them directly, because in SCIPnodeFree(), the siblings array is changed, which is the
4377  * same array we would have to iterate over here;
4378  * the siblings have the same LP state fork as the old focus node
4379  */
4380  SCIPsetDebugMsg(set, " -> deleting the %d siblings of the old focus node\n", tree->nsiblings);
4381  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4382  -SCIPsetInfinity(set)) );
4383  assert(tree->nsiblings == 0);
4384  }
4385  }
4386 
4387  /* convert the old focus node into a fork or subroot node, if it has children;
4388  * otherwise, convert it into a dead-end, which will be freed later in treeSwitchPath();
4389  * if the node was postponed, make it a leaf.
4390  */
4391  childrenlpstatefork = tree->focuslpstatefork;
4392 
4393  assert(!postponed || *node == NULL);
4394  assert(!postponed || tree->focusnode != NULL);
4395 
4396  if( postponed )
4397  {
4398  assert(tree->nchildren == 0);
4399  assert(*node == NULL);
4400 
4401  /* if the node is infeasible, convert it into a deadend; otherwise, put it into the LEAF queue */
4402  if( SCIPsetIsGE(set, tree->focusnode->lowerbound, primal->cutoffbound) )
4403  {
4404  /* in case the LP was not constructed (due to the parameter settings for example) we have the finally remember the
4405  * old size of the LP (if it was constructed in an earlier node) before we change the current node into a deadend
4406  */
4407  if( !tree->focuslpconstructed )
4408  SCIPlpMarkSize(lp);
4409 
4410  /* convert old focus node into deadend */
4411  SCIP_CALL( focusnodeToDeadend(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand,
4412  cliquetable) );
4413  }
4414  else
4415  {
4416  SCIP_CALL( focusnodeToLeaf(blkmem, set, stat, eventqueue, tree, reopt, lp, tree->focuslpstatefork,
4417  SCIPsetInfinity(set)) );
4418  }
4419  }
4420  else if( tree->nchildren > 0 )
4421  {
4422  SCIP_Bool selectedchild;
4423 
4424  assert(tree->focusnode != NULL);
4426  assert(oldcutoffdepth == INT_MAX);
4427 
4428  /* check whether the next focus node is a child of the old focus node */
4429  selectedchild = (*node != NULL && SCIPnodeGetType(*node) == SCIP_NODETYPE_CHILD);
4430 
4431  if( tree->focusnodehaslp && lp->isrelax )
4432  {
4433  assert(tree->focuslpconstructed);
4434 
4435 #ifdef WITHSUBROOTS /** @todo test whether subroots should be created, decide: old focus node becomes fork or subroot */
4436  if( tree->focusnode->depth > 0 && tree->focusnode->depth % 25 == 0 )
4437  {
4438  /* convert old focus node into a subroot node */
4439  SCIP_CALL( focusnodeToSubroot(blkmem, set, messagehdlr, stat, eventqueue, eventfilter, transprob, origprob, tree, lp, branchcand) );
4440  if( *node != NULL && SCIPnodeGetType(*node) == SCIP_NODETYPE_CHILD
4442  subroot = tree->focusnode;
4443  }
4444  else
4445 #endif
4446  {
4447  /* convert old focus node into a fork node */
4448  SCIP_CALL( focusnodeToFork(blkmem, set, messagehdlr, stat, eventqueue, eventfilter, transprob, origprob, tree,
4449  reopt, lp, branchcand, cliquetable) );
4450  }
4451 
4452  /* check, if the conversion into a subroot or fork was successful */
4455  {
4456  childrenlpstatefork = tree->focusnode;
4457 
4458  /* if a child of the old focus node was selected as new focus node, the old node becomes the new focus
4459  * LP fork and LP state fork
4460  */
4461  if( selectedchild )
4462  {
4463  lpfork = tree->focusnode;
4464  tree->correctlpdepth = tree->focusnode->depth;
4465  lpstatefork = tree->focusnode;
4466  tree->focuslpstateforklpcount = stat->lpcount;
4467  }
4468  }
4469 
4470  /* update the path's LP size */
4471  tree->pathnlpcols[tree->focusnode->depth] = SCIPlpGetNCols(lp);
4472  tree->pathnlprows[tree->focusnode->depth] = SCIPlpGetNRows(lp);
4473  }
4474  else if( tree->focuslpconstructed && (SCIPlpGetNNewcols(lp) > 0 || SCIPlpGetNNewrows(lp) > 0) )
4475  {
4476  /* convert old focus node into pseudofork */
4477  SCIP_CALL( focusnodeToPseudofork(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp,
4478  branchcand, cliquetable) );
4480 
4481  /* update the path's LP size */
4482  tree->pathnlpcols[tree->focusnode->depth] = SCIPlpGetNCols(lp);
4483  tree->pathnlprows[tree->focusnode->depth] = SCIPlpGetNRows(lp);
4484 
4485  /* if a child of the old focus node was selected as new focus node, the old node becomes the new focus LP fork */
4486  if( selectedchild )
4487  {
4488  lpfork = tree->focusnode;
4489  tree->correctlpdepth = tree->focusnode->depth;
4490  }
4491  }
4492  else
4493  {
4494  /* in case the LP was not constructed (due to the parameter settings for example) we have the finally remember the
4495  * old size of the LP (if it was constructed in an earlier node) before we change the current node into a junction
4496  */
4497  SCIPlpMarkSize(lp);
4498 
4499  /* convert old focus node into junction */
4500  SCIP_CALL( focusnodeToJunction(blkmem, set, eventqueue, tree, lp) );
4501  }
4502  }
4503  else if( tree->focusnode != NULL )
4504  {
4505  /* in case the LP was not constructed (due to the parameter settings for example) we have the finally remember the
4506  * old size of the LP (if it was constructed in an earlier node) before we change the current node into a deadend
4507  */
4508  if( !tree->focuslpconstructed )
4509  SCIPlpMarkSize(lp);
4510 
4511  /* convert old focus node into deadend */
4512  SCIP_CALL( focusnodeToDeadend(blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp, branchcand, cliquetable) );
4513  }
4514  assert(subroot == NULL || SCIPnodeGetType(subroot) == SCIP_NODETYPE_SUBROOT);
4515  assert(lpstatefork == NULL
4516  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_SUBROOT
4517  || SCIPnodeGetType(lpstatefork) == SCIP_NODETYPE_FORK);
4518  assert(childrenlpstatefork == NULL
4519  || SCIPnodeGetType(childrenlpstatefork) == SCIP_NODETYPE_SUBROOT
4520  || SCIPnodeGetType(childrenlpstatefork) == SCIP_NODETYPE_FORK);
4521  assert(lpfork == NULL
4523  || SCIPnodeGetType(lpfork) == SCIP_NODETYPE_FORK
4525  SCIPsetDebugMsg(set, "focus node: new correctlpdepth=%d\n", tree->correctlpdepth);
4526 
4527  /* set up the new lists of siblings and children */
4528  oldfocusnode = tree->focusnode;
4529  if( *node == NULL )
4530  {
4531  /* move siblings to the queue, make them LEAFs */
4532  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4533  primal->cutoffbound) );
4534 
4535  /* move children to the queue, make them LEAFs */
4536  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, childrenlpstatefork,
4537  primal->cutoffbound) );
4538  }
4539  else
4540  {
4541  SCIP_NODE* bestleaf;
4542 
4543  switch( SCIPnodeGetType(*node) )
4544  {
4545  case SCIP_NODETYPE_SIBLING:
4546  /* reset plunging depth, if the selected node is better than all leaves */
4547  bestleaf = SCIPtreeGetBestLeaf(tree);
4548  if( bestleaf == NULL || SCIPnodepqCompare(tree->leaves, set, *node, bestleaf) <= 0 )
4549  stat->plungedepth = 0;
4550 
4551  /* move children to the queue, make them LEAFs */
4552  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, childrenlpstatefork,
4553  primal->cutoffbound) );
4554 
4555  /* remove selected sibling from the siblings array */
4556  treeRemoveSibling(tree, *node);
4557 
4558  SCIPsetDebugMsg(set, "selected sibling node, lowerbound=%g, plungedepth=%d\n", (*node)->lowerbound, stat->plungedepth);
4559  break;
4560 
4561  case SCIP_NODETYPE_CHILD:
4562  /* reset plunging depth, if the selected node is better than all leaves; otherwise, increase plunging depth */
4563  bestleaf = SCIPtreeGetBestLeaf(tree);
4564  if( bestleaf == NULL || SCIPnodepqCompare(tree->leaves, set, *node, bestleaf) <= 0 )
4565  stat->plungedepth = 0;
4566  else
4567  stat->plungedepth++;
4568 
4569  /* move siblings to the queue, make them LEAFs */
4570  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4571  primal->cutoffbound) );
4572 
4573  /* remove selected child from the children array */
4574  treeRemoveChild(tree, *node);
4575 
4576  /* move remaining children to the siblings array, make them SIBLINGs */
4577  treeChildrenToSiblings(tree);
4578 
4579  SCIPsetDebugMsg(set, "selected child node, lowerbound=%g, plungedepth=%d\n", (*node)->lowerbound, stat->plungedepth);
4580  break;
4581 
4582  case SCIP_NODETYPE_LEAF:
4583  /* move siblings to the queue, make them LEAFs */
4584  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->siblings, &tree->nsiblings, tree->focuslpstatefork,
4585  primal->cutoffbound) );
4586 
4587  /* encounter an early backtrack if there is a child which does not exceed given reference bound */
4588  if( !SCIPsetIsInfinity(set, stat->referencebound) )
4589  {
4590  int c;
4591 
4592  /* loop over children and stop if we find a child with a lower bound below given reference bound */
4593  for( c = 0; c < tree->nchildren; ++c )
4594  {
4595  if( SCIPsetIsLT(set, SCIPnodeGetLowerbound(tree->children[c]), stat->referencebound) )
4596  {
4597  ++stat->nearlybacktracks;
4598  break;
4599  }
4600  }
4601  }
4602  /* move children to the queue, make them LEAFs */
4603  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, childrenlpstatefork,
4604  primal->cutoffbound) );
4605 
4606  /* remove node from the queue */
4607  SCIP_CALL( SCIPnodepqRemove(tree->leaves, set, *node) );
4608 
4609  stat->plungedepth = 0;
4610  if( SCIPnodeGetDepth(*node) > 0 )
4611  stat->nbacktracks++;
4612  SCIPsetDebugMsg(set, "selected leaf node, lowerbound=%g, plungedepth=%d\n", (*node)->lowerbound, stat->plungedepth);
4613  break;
4614 
4615  default:
4616  SCIPerrorMessage("selected node is neither sibling, child, nor leaf (nodetype=%d)\n", SCIPnodeGetType(*node));
4617  return SCIP_INVALIDDATA;
4618  } /*lint !e788*/
4619 
4620  /* convert node into the focus node */
4621  (*node)->nodetype = SCIP_NODETYPE_FOCUSNODE; /*lint !e641*/
4622  }
4623  assert(tree->nchildren == 0);
4624 
4625  /* set new focus node, LP fork, LP state fork, and subroot */
4626  assert(subroot == NULL || (lpstatefork != NULL && subroot->depth <= lpstatefork->depth));
4627  assert(lpstatefork == NULL || (lpfork != NULL && lpstatefork->depth <= lpfork->depth));
4628  assert(lpfork == NULL || (*node != NULL && lpfork->depth < (*node)->depth));
4629  tree->focusnode = *node;
4630  tree->focuslpfork = lpfork;
4631  tree->focuslpstatefork = lpstatefork;
4632  tree->focussubroot = subroot;
4633  tree->focuslpconstructed = FALSE;
4634  lp->resolvelperror = FALSE;
4635 
4636  /* track the path from the old focus node to the new node, and perform domain and constraint set changes */
4637  SCIP_CALL( treeSwitchPath(tree, reopt, blkmem, set, stat, transprob, origprob, primal, lp, branchcand, conflict,
4638  eventfilter, eventqueue, cliquetable, fork, *node, cutoff) );
4639  assert(tree->pathlen >= 0);
4640  assert(*node != NULL || tree->pathlen == 0);
4641  assert(*node == NULL || tree->pathlen-1 <= (int)(*node)->depth);
4642 
4643  /* if the old focus node is a dead end (has no children), delete it */
4644  if( oldfocusnode != NULL && SCIPnodeGetType(oldfocusnode) == SCIP_NODETYPE_DEADEND )
4645  {
4646  int appliedeffectiverootdepth;
4647 
4648  appliedeffectiverootdepth = tree->appliedeffectiverootdepth;
4649  assert(appliedeffectiverootdepth <= tree->effectiverootdepth);
4650 
4651  SCIP_CALL( SCIPnodeFree(&oldfocusnode, blkmem, set, stat, eventqueue, tree, lp) );
4652  assert(tree->effectiverootdepth < tree->pathlen || *node == NULL || *cutoff);
4653 
4654  if( tree->effectiverootdepth > appliedeffectiverootdepth && *node != NULL && !(*cutoff) )
4655  {
4656  int d;
4657 
4658  /* promote the constraint set and bound changes up to the new effective root to be global changes */
4659  SCIPsetDebugMsg(set, "effective root is now at depth %d: applying constraint set and bound changes to global problem\n",
4660  tree->effectiverootdepth);
4661 
4662  for( d = appliedeffectiverootdepth + 1; d <= tree->effectiverootdepth; ++d )
4663  {
4664  SCIP_Bool nodecutoff;
4665 
4666  SCIPsetDebugMsg(set, " -> applying constraint set changes of depth %d\n", d);
4667  SCIP_CALL( SCIPconssetchgMakeGlobal(&tree->path[d]->conssetchg, blkmem, set, stat, transprob, reopt) );
4668  SCIPsetDebugMsg(set, " -> applying bound changes of depth %d\n", d);
4669  SCIP_CALL( SCIPdomchgApplyGlobal(tree->path[d]->domchg, blkmem, set, stat, lp, branchcand, eventqueue, cliquetable,
4670  &nodecutoff) );
4671 
4672  if( nodecutoff )
4673  {
4674  SCIP_CALL( SCIPnodeCutoff(tree->path[d], set, stat, tree, transprob, origprob, reopt, lp, blkmem) );
4675  *cutoff = TRUE;
4676  }
4677  }
4678 
4680  }
4681  }
4682  assert(*cutoff || SCIPtreeIsPathComplete(tree));
4683 
4684  return SCIP_OKAY;
4685 }
4686 
4687 
4688 
4689 
4690 /*
4691  * Tree methods
4692  */
4693 
4694 /** creates an initialized tree data structure */
4696  SCIP_TREE** tree, /**< pointer to tree data structure */
4697  BMS_BLKMEM* blkmem, /**< block memory buffers */
4698  SCIP_SET* set, /**< global SCIP settings */
4699  SCIP_NODESEL* nodesel /**< node selector to use for sorting leaves in the priority queue */
4700  )
4701 {
4702  int p;
4703 
4704  assert(tree != NULL);
4705  assert(blkmem != NULL);
4706 
4707  SCIP_ALLOC( BMSallocMemory(tree) );
4708 
4709  (*tree)->root = NULL;
4710 
4711  SCIP_CALL( SCIPnodepqCreate(&(*tree)->leaves, set, nodesel) );
4712 
4713  /* allocate one slot for the prioritized and the unprioritized bound change */
4714  for( p = 0; p <= 1; ++p )
4715  {
4716  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*tree)->divebdchgdirs[p], 1) ); /*lint !e866*/
4717  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*tree)->divebdchgvars[p], 1) ); /*lint !e866*/
4718  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*tree)->divebdchgvals[p], 1) ); /*lint !e866*/
4719  (*tree)->ndivebdchanges[p] = 0;
4720  (*tree)->divebdchgsize[p] = 1;
4721  }
4722 
4723  (*tree)->path = NULL;
4724  (*tree)->focusnode = NULL;
4725  (*tree)->focuslpfork = NULL;
4726  (*tree)->focuslpstatefork = NULL;
4727  (*tree)->focussubroot = NULL;
4728  (*tree)->children = NULL;
4729  (*tree)->siblings = NULL;
4730  (*tree)->probingroot = NULL;
4731  (*tree)->childrenprio = NULL;
4732  (*tree)->siblingsprio = NULL;
4733  (*tree)->pathnlpcols = NULL;
4734  (*tree)->pathnlprows = NULL;
4735  (*tree)->probinglpistate = NULL;
4736  (*tree)->probinglpinorms = NULL;
4737  (*tree)->pendingbdchgs = NULL;
4738  (*tree)->probdiverelaxsol = NULL;
4739  (*tree)->pendingbdchgssize = 0;
4740  (*tree)->npendingbdchgs = 0;
4741  (*tree)->focuslpstateforklpcount = -1;
4742  (*tree)->childrensize = 0;
4743  (*tree)->nchildren = 0;
4744  (*tree)->siblingssize = 0;
4745  (*tree)->nsiblings = 0;
4746  (*tree)->pathlen = 0;
4747  (*tree)->pathsize = 0;
4748  (*tree)->effectiverootdepth = 0;
4749  (*tree)->appliedeffectiverootdepth = 0;
4750  (*tree)->correctlpdepth = -1;
4751  (*tree)->cutoffdepth = INT_MAX;
4752  (*tree)->repropdepth = INT_MAX;
4753  (*tree)->repropsubtreecount = 0;
4754  (*tree)->focusnodehaslp = FALSE;
4755  (*tree)->probingnodehaslp = FALSE;
4756  (*tree)->focuslpconstructed = FALSE;
4757  (*tree)->cutoffdelayed = FALSE;
4758  (*tree)->probinglpwasflushed = FALSE;
4759  (*tree)->probinglpwassolved = FALSE;
4760  (*tree)->probingloadlpistate = FALSE;
4761  (*tree)->probinglpwasrelax = FALSE;
4762  (*tree)->probingsolvedlp = FALSE;
4763  (*tree)->forcinglpmessage = FALSE;
4764  (*tree)->sbprobing = FALSE;
4765  (*tree)->probinglpwasprimfeas = TRUE;
4766  (*tree)->probinglpwasdualfeas = TRUE;
4767  (*tree)->probdiverelaxstored = FALSE;
4768  (*tree)->probdiverelaxincludeslp = FALSE;
4769 
4770  return SCIP_OKAY;
4771 }
4772 
4773 /** frees tree data structure */
4775  SCIP_TREE** tree, /**< pointer to tree data structure */
4776  BMS_BLKMEM* blkmem, /**< block memory buffers */
4777  SCIP_SET* set, /**< global SCIP settings */
4778  SCIP_STAT* stat, /**< problem statistics */
4779  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4780  SCIP_LP* lp /**< current LP data */
4781  )
4782 {
4783  int p;
4784 
4785  assert(tree != NULL);
4786  assert(*tree != NULL);
4787  assert((*tree)->nchildren == 0);
4788  assert((*tree)->nsiblings == 0);
4789  assert((*tree)->focusnode == NULL);
4790  assert(!SCIPtreeProbing(*tree));
4791 
4792  SCIPsetDebugMsg(set, "free tree\n");
4793 
4794  /* free node queue */
4795  SCIP_CALL( SCIPnodepqFree(&(*tree)->leaves, blkmem, set, stat, eventqueue, *tree, lp) );
4796 
4797  /* free diving bound change storage */
4798  for( p = 0; p <= 1; ++p )
4799  {
4800  BMSfreeBlockMemoryArray(blkmem, &(*tree)->divebdchgdirs[p], (*tree)->divebdchgsize[p]); /*lint !e866*/
4801  BMSfreeBlockMemoryArray(blkmem, &(*tree)->divebdchgvals[p], (*tree)->divebdchgsize[p]); /*lint !e866*/
4802  BMSfreeBlockMemoryArray(blkmem, &(*tree)->divebdchgvars[p], (*tree)->divebdchgsize[p]); /*lint !e866*/
4803  }
4804 
4805  /* free pointer arrays */
4806  BMSfreeMemoryArrayNull(&(*tree)->path);
4807  BMSfreeMemoryArrayNull(&(*tree)->children);
4808  BMSfreeMemoryArrayNull(&(*tree)->siblings);
4809  BMSfreeMemoryArrayNull(&(*tree)->childrenprio);
4810  BMSfreeMemoryArrayNull(&(*tree)->siblingsprio);
4811  BMSfreeMemoryArrayNull(&(*tree)->pathnlpcols);
4812  BMSfreeMemoryArrayNull(&(*tree)->pathnlprows);
4813  BMSfreeMemoryArrayNull(&(*tree)->probdiverelaxsol);
4814  BMSfreeMemoryArrayNull(&(*tree)->pendingbdchgs);
4815 
4816  BMSfreeMemory(tree);
4817 
4818  return SCIP_OKAY;
4819 }
4820 
4821 /** clears and resets tree data structure and deletes all nodes */
4823  SCIP_TREE* tree, /**< tree data structure */
4824  BMS_BLKMEM* blkmem, /**< block memory buffers */
4825  SCIP_SET* set, /**< global SCIP settings */
4826  SCIP_STAT* stat, /**< problem statistics */
4827  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4828  SCIP_LP* lp /**< current LP data */
4829  )
4830 {
4831  int v;
4832 
4833  assert(tree != NULL);
4834  assert(tree->nchildren == 0);
4835  assert(tree->nsiblings == 0);
4836  assert(tree->focusnode == NULL);
4837  assert(!SCIPtreeProbing(tree));
4838 
4839  SCIPsetDebugMsg(set, "clearing tree\n");
4840 
4841  /* clear node queue */
4842  SCIP_CALL( SCIPnodepqClear(tree->leaves, blkmem, set, stat, eventqueue, tree, lp) );
4843  assert(tree->root == NULL);
4844 
4845  /* we have to remove the captures of the variables within the pending bound change data structure */
4846  for( v = tree->npendingbdchgs-1; v >= 0; --v )
4847  {
4848  SCIP_VAR* var;
4849 
4850  var = tree->pendingbdchgs[v].var;
4851  assert(var != NULL);
4852 
4853  /* release the variable */
4854  SCIP_CALL( SCIPvarRelease(&var, blkmem, set, eventqueue, lp) );
4855  }
4856 
4857  /* mark working arrays to be empty and reset data */
4858  tree->focuslpstateforklpcount = -1;
4859  tree->nchildren = 0;
4860  tree->nsiblings = 0;
4861  tree->pathlen = 0;
4862  tree->effectiverootdepth = 0;
4863  tree->appliedeffectiverootdepth = 0;
4864  tree->correctlpdepth = -1;
4865  tree->cutoffdepth = INT_MAX;
4866  tree->repropdepth = INT_MAX;
4867  tree->repropsubtreecount = 0;
4868  tree->npendingbdchgs = 0;
4869  tree->focusnodehaslp = FALSE;
4870  tree->probingnodehaslp = FALSE;
4871  tree->cutoffdelayed = FALSE;
4872  tree->probinglpwasflushed = FALSE;
4873  tree->probinglpwassolved = FALSE;
4874  tree->probingloadlpistate = FALSE;
4875  tree->probinglpwasrelax = FALSE;
4876  tree->probingsolvedlp = FALSE;
4877 
4878  return SCIP_OKAY;
4879 }
4880 
4881 /** creates the root node of the tree and puts it into the leaves queue */
4883  SCIP_TREE* tree, /**< tree data structure */
4884  SCIP_REOPT* reopt, /**< reoptimization data structure */
4885  BMS_BLKMEM* blkmem, /**< block memory buffers */
4886  SCIP_SET* set, /**< global SCIP settings */
4887  SCIP_STAT* stat, /**< problem statistics */
4888  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4889  SCIP_LP* lp /**< current LP data */
4890  )
4891 {
4892  assert(tree != NULL);
4893  assert(tree->nchildren == 0);
4894  assert(tree->nsiblings == 0);
4895  assert(tree->root == NULL);
4896  assert(tree->focusnode == NULL);
4897  assert(!SCIPtreeProbing(tree));
4898 
4899  /* create root node */
4900  SCIP_CALL( SCIPnodeCreateChild(&tree->root, blkmem, set, stat, tree, 0.0, -SCIPsetInfinity(set)) );
4901  assert(tree->nchildren == 1);
4902 
4903 #ifndef NDEBUG
4904  /* check, if the sizes in the data structures match the maximal numbers defined here */
4905  tree->root->depth = SCIP_MAXTREEDEPTH + 1;
4907  assert(tree->root->depth - 1 == SCIP_MAXTREEDEPTH); /*lint !e650*/
4908  assert(tree->root->repropsubtreemark == MAXREPROPMARK);
4909  tree->root->depth++; /* this should produce an overflow and reset the value to 0 */
4910  tree->root->repropsubtreemark++; /* this should produce an overflow and reset the value to 0 */
4911  assert(tree->root->depth == 0);
4912  assert((SCIP_NODETYPE)tree->root->nodetype == SCIP_NODETYPE_CHILD);
4913  assert(!tree->root->active);
4914  assert(!tree->root->cutoff);
4915  assert(!tree->root->reprop);
4916  assert(tree->root->repropsubtreemark == 0);
4917 #endif
4918 
4919  /* move root to the queue, convert it to LEAF */
4920  SCIP_CALL( treeNodesToQueue(tree, reopt, blkmem, set, stat, eventqueue, lp, tree->children, &tree->nchildren, NULL,
4921  SCIPsetInfinity(set)) );
4922 
4923  return SCIP_OKAY;
4924 }
4925 
4926 /** creates a temporary presolving root node of the tree and installs it as focus node */
4928  SCIP_TREE* tree, /**< tree data structure */
4929  SCIP_REOPT* reopt, /**< reoptimization data structure */
4930  BMS_BLKMEM* blkmem, /**< block memory buffers */
4931  SCIP_SET* set, /**< global SCIP settings */
4932  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4933  SCIP_STAT* stat, /**< problem statistics */
4934  SCIP_PROB* transprob, /**< transformed problem */
4935  SCIP_PROB* origprob, /**< original problem */
4936  SCIP_PRIMAL* primal, /**< primal data */
4937  SCIP_LP* lp, /**< current LP data */
4938  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4939  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4940  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
4941  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4942  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4943  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
4944  )
4945 {
4946  SCIP_Bool cutoff;
4947 
4948  assert(tree != NULL);
4949  assert(tree->nchildren == 0);
4950  assert(tree->nsiblings == 0);
4951  assert(tree->root == NULL);
4952  assert(tree->focusnode == NULL);
4953  assert(!SCIPtreeProbing(tree));
4954 
4955  /* create temporary presolving root node */
4956  SCIP_CALL( SCIPtreeCreateRoot(tree, reopt, blkmem, set, stat, eventqueue, lp) );
4957  assert(tree->root != NULL);
4958 
4959  /* install the temporary root node as focus node */
4960  SCIP_CALL( SCIPnodeFocus(&tree->root, blkmem, set, messagehdlr, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4961  conflict, conflictstore, eventfilter, eventqueue, cliquetable, &cutoff, FALSE, FALSE) );
4962  assert(!cutoff);
4963 
4964  return SCIP_OKAY;
4965 }
4966 
4967 /** frees the temporary presolving root and resets tree data structure */
4969  SCIP_TREE* tree, /**< tree data structure */
4970  SCIP_REOPT* reopt, /**< reoptimization data structure */
4971  BMS_BLKMEM* blkmem, /**< block memory buffers */
4972  SCIP_SET* set, /**< global SCIP settings */
4973  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
4974  SCIP_STAT* stat, /**< problem statistics */
4975  SCIP_PROB* transprob, /**< transformed problem */
4976  SCIP_PROB* origprob, /**< original problem */
4977  SCIP_PRIMAL* primal, /**< primal data */
4978  SCIP_LP* lp, /**< current LP data */
4979  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
4980  SCIP_CONFLICT* conflict, /**< conflict analysis data */
4981  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
4982  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
4983  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
4984  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
4985  )
4986 {
4987  SCIP_NODE* node;
4988  SCIP_Bool cutoff;
4989 
4990  assert(tree != NULL);
4991  assert(tree->root != NULL);
4992  assert(tree->focusnode == tree->root);
4993  assert(tree->pathlen == 1);
4994 
4995  /* unfocus the temporary root node */
4996  node = NULL;
4997  SCIP_CALL( SCIPnodeFocus(&node, blkmem, set, messagehdlr, stat, transprob, origprob, primal, tree, reopt, lp, branchcand,
4998  conflict, conflictstore, eventfilter, eventqueue, cliquetable, &cutoff, FALSE, FALSE) );
4999  assert(!cutoff);
5000  assert(tree->root == NULL);
5001  assert(tree->focusnode == NULL);
5002  assert(tree->pathlen == 0);
5003 
5004  /* reset tree data structure */
5005  SCIP_CALL( SCIPtreeClear(tree, blkmem, set, stat, eventqueue, lp) );
5006 
5007  return SCIP_OKAY;
5008 }
5009 
5010 /** returns the node selector associated with the given node priority queue */
5012  SCIP_TREE* tree /**< branch and bound tree */
5013  )
5014 {
5015  assert(tree != NULL);
5016 
5017  return SCIPnodepqGetNodesel(tree->leaves);
5018 }
5019 
5020 /** sets the node selector used for sorting the nodes in the priority queue, and resorts the queue if necessary */
5022  SCIP_TREE* tree, /**< branch and bound tree */
5023  SCIP_SET* set, /**< global SCIP settings */
5024  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
5025  SCIP_STAT* stat, /**< problem statistics */
5026  SCIP_NODESEL* nodesel /**< node selector to use for sorting the nodes in the queue */
5027  )
5028 {
5029  assert(tree != NULL);
5030  assert(stat != NULL);
5031 
5032  if( SCIPnodepqGetNodesel(tree->leaves) != nodesel )
5033  {
5034  /* change the node selector used in the priority queue and resort the queue */
5035  SCIP_CALL( SCIPnodepqSetNodesel(&tree->leaves, set, nodesel) );
5036 
5037  /* issue message */
5038  if( stat->nnodes > 0 )
5039  {
5040  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
5041  "(node %" SCIP_LONGINT_FORMAT ") switching to node selector <%s>\n", stat->nnodes, SCIPnodeselGetName(nodesel));
5042  }
5043  }
5044 
5045  return SCIP_OKAY;
5046 }
5047 
5048 /** cuts off nodes with lower bound not better than given cutoff bound */
5050  SCIP_TREE* tree, /**< branch and bound tree */
5051  SCIP_REOPT* reopt, /**< reoptimization data structure */
5052  BMS_BLKMEM* blkmem, /**< block memory */
5053  SCIP_SET* set, /**< global SCIP settings */
5054  SCIP_STAT* stat, /**< dynamic problem statistics */
5055  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5056  SCIP_LP* lp, /**< current LP data */
5057  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
5058  )
5059 {
5060  SCIP_NODE* node;
5061  int i;
5062 
5063  assert(tree != NULL);
5064  assert(stat != NULL);
5065  assert(lp != NULL);
5066 
5067  /* if we are in diving mode, it is not allowed to cut off nodes, because this can lead to deleting LP rows which
5068  * would modify the currently unavailable (due to diving modifications) SCIP_LP
5069  * -> the cutoff must be delayed and executed after the diving ends
5070  */
5071  if( SCIPlpDiving(lp) )
5072  {
5073  tree->cutoffdelayed = TRUE;
5074  return SCIP_OKAY;
5075  }
5076 
5077  tree->cutoffdelayed = FALSE;
5078 
5079  /* cut off leaf nodes in the queue */
5080  SCIP_CALL( SCIPnodepqBound(tree->leaves, blkmem, set, stat, eventqueue, tree, reopt, lp, cutoffbound) );
5081 
5082  /* cut off siblings: we have to loop backwards, because a removal leads to moving the last node in empty slot */
5083  for( i = tree->nsiblings-1; i >= 0; --i )
5084  {
5085  node = tree->siblings[i];
5086  if( SCIPsetIsGE(set, node->lowerbound, cutoffbound) )
5087  {
5088  SCIPsetDebugMsg(set, "cut off sibling #%" SCIP_LONGINT_FORMAT " at depth %d with lowerbound=%g at position %d\n",
5089  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node), node->lowerbound, i);
5090 
5091  if( set->reopt_enable )
5092  {
5093  assert(reopt != NULL);
5094  /* check if the node should be stored for reoptimization */
5096  tree->root == node, tree->focusnode == node, node->lowerbound, tree->effectiverootdepth) );
5097  }
5098 
5099  SCIPvisualCutoffNode(stat->visual, set, stat, node, FALSE);
5100 
5101  SCIP_CALL( SCIPnodeFree(&node, blkmem, set, stat, eventqueue, tree, lp) );
5102  }
5103  }
5104 
5105  /* cut off children: we have to loop backwards, because a removal leads to moving the last node in empty slot */
5106  for( i = tree->nchildren-1; i >= 0; --i )
5107  {
5108  node = tree->children[i];
5109  if( SCIPsetIsGE(set, node->lowerbound, cutoffbound) )
5110  {
5111  SCIPsetDebugMsg(set, "cut off child #%" SCIP_LONGINT_FORMAT " at depth %d with lowerbound=%g at position %d\n",
5112  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node), node->lowerbound, i);
5113 
5114  if( set->reopt_enable )
5115  {
5116  assert(reopt != NULL);
5117  /* check if the node should be stored for reoptimization */
5119  tree->root == node, tree->focusnode == node, node->lowerbound, tree->effectiverootdepth) );
5120  }
5121 
5122  SCIPvisualCutoffNode(stat->visual, set, stat, node, FALSE);
5123 
5124  SCIP_CALL( SCIPnodeFree(&node, blkmem, set, stat, eventqueue, tree, lp) );
5125  }
5126  }
5127 
5128  return SCIP_OKAY;
5129 }
5130 
5131 /** calculates the node selection priority for moving the given variable's LP value to the given target value;
5132  * this node selection priority can be given to the SCIPcreateChild() call
5133  */
5135  SCIP_TREE* tree, /**< branch and bound tree */
5136  SCIP_SET* set, /**< global SCIP settings */
5137  SCIP_STAT* stat, /**< dynamic problem statistics */
5138  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
5139  SCIP_BRANCHDIR branchdir, /**< type of branching that was performed: upwards, downwards, or fixed
5140  * fixed should only be used, when both bounds changed
5141  */
5142  SCIP_Real targetvalue /**< new value of the variable in the child node */
5143  )
5144 {
5145  SCIP_Real prio;
5146  SCIP_Real varsol;
5147  SCIP_Real varrootsol;
5148  SCIP_Real downinfs;
5149  SCIP_Real upinfs;
5150  SCIP_Bool isroot;
5151  SCIP_Bool haslp;
5152 
5153  assert(set != NULL);
5154 
5155  /* extract necessary information */
5156  isroot = (SCIPtreeGetCurrentDepth(tree) == 0);
5157  haslp = SCIPtreeHasFocusNodeLP(tree);
5158  varsol = SCIPvarGetSol(var, haslp);
5159  varrootsol = SCIPvarGetRootSol(var);
5160  downinfs = SCIPvarGetAvgInferences(var, stat, SCIP_BRANCHDIR_DOWNWARDS);
5161  upinfs = SCIPvarGetAvgInferences(var, stat, SCIP_BRANCHDIR_UPWARDS);
5162 
5163  switch( branchdir )
5164  {
5166  switch( SCIPvarGetBranchDirection(var) )
5167  {
5169  prio = +1.0;
5170  break;
5172  prio = -1.0;
5173  break;
5174  case SCIP_BRANCHDIR_AUTO:
5175  switch( set->nodesel_childsel )
5176  {
5177  case 'd':
5178  prio = +1.0;
5179  break;
5180  case 'u':
5181  prio = -1.0;
5182  break;
5183  case 'p':
5184  prio = -SCIPvarGetPseudocost(var, stat, targetvalue - varsol);
5185  break;
5186  case 'i':
5187  prio = downinfs;
5188  break;
5189  case 'l':
5190  prio = targetvalue - varsol;
5191  break;
5192  case 'r':
5193  prio = varrootsol - varsol;
5194  break;
5195  case 'h':
5196  prio = downinfs + SCIPsetEpsilon(set);
5197  if( !isroot && haslp )
5198  prio *= (varrootsol - varsol + 1.0);
5199  break;
5200  default:
5201  SCIPerrorMessage("invalid child selection rule <%c>\n", set->nodesel_childsel);
5202  prio = 0.0;
5203  break;
5204  }
5205  break;
5206  default:
5207  SCIPerrorMessage("invalid preferred branching direction <%d> of variable <%s>\n",
5209  prio = 0.0;
5210  break;
5211  }
5212  break;
5214  /* the branch is directed upwards */
5215  switch( SCIPvarGetBranchDirection(var) )
5216  {
5218  prio = -1.0;
5219  break;
5221  prio = +1.0;
5222  break;
5223  case SCIP_BRANCHDIR_AUTO:
5224  switch( set->nodesel_childsel )
5225  {
5226  case 'd':
5227  prio = -1.0;
5228  break;
5229  case 'u':
5230  prio = +1.0;
5231  break;
5232  case 'p':
5233  prio = -SCIPvarGetPseudocost(var, stat, targetvalue - varsol);
5234  break;
5235  case 'i':
5236  prio = upinfs;
5237  break;
5238  case 'l':
5239  prio = varsol - targetvalue;
5240  break;
5241  case 'r':
5242  prio = varsol - varrootsol;
5243  break;
5244  case 'h':
5245  prio = upinfs + SCIPsetEpsilon(set);
5246  if( !isroot && haslp )
5247  prio *= (varsol - varrootsol + 1.0);
5248  break;
5249  default:
5250  SCIPerrorMessage("invalid child selection rule <%c>\n", set->nodesel_childsel);
5251  prio = 0.0;
5252  break;
5253  }
5254  /* since choosing the upwards direction is usually superior than the downwards direction (see results of
5255  * Achterberg's thesis (2007)), we break ties towards upwards branching
5256  */
5257  prio += SCIPsetEpsilon(set);
5258  break;
5259 
5260  default:
5261  SCIPerrorMessage("invalid preferred branching direction <%d> of variable <%s>\n",
5263  prio = 0.0;
5264  break;
5265  }
5266  break;
5267  case SCIP_BRANCHDIR_FIXED:
5268  prio = SCIPsetInfinity(set);
5269  break;
5270  case SCIP_BRANCHDIR_AUTO:
5271  default:
5272  SCIPerrorMessage("invalid branching direction <%d> of variable <%s>\n",
5274  prio = 0.0;
5275  break;
5276  }
5277 
5278  return prio;
5279 }
5280 
5281 /** calculates an estimate for the objective of the best feasible solution contained in the subtree after applying the given
5282  * branching; this estimate can be given to the SCIPcreateChild() call
5283  */
5285  SCIP_TREE* tree, /**< branch and bound tree */
5286  SCIP_SET* set, /**< global SCIP settings */
5287  SCIP_STAT* stat, /**< dynamic problem statistics */
5288  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
5289  SCIP_Real targetvalue /**< new value of the variable in the child node */
5290  )
5291 {
5292  SCIP_Real estimateinc;
5293  SCIP_Real estimate;
5294  SCIP_Real varsol;
5295 
5296  assert(tree != NULL);
5297  assert(var != NULL);
5298 
5299  estimate = SCIPnodeGetEstimate(tree->focusnode);
5300  varsol = SCIPvarGetSol(var, SCIPtreeHasFocusNodeLP(tree));
5301 
5302  /* compute increase above parent node's (i.e., focus node's) estimate value */
5304  estimateinc = SCIPvarGetPseudocost(var, stat, targetvalue - varsol);
5305  else
5306  {
5307  SCIP_Real pscdown;
5308  SCIP_Real pscup;
5309 
5310  /* calculate estimate based on pseudo costs:
5311  * estimate = lowerbound + sum(min{f_j * pscdown_j, (1-f_j) * pscup_j})
5312  * = parentestimate - min{f_b * pscdown_b, (1-f_b) * pscup_b} + (targetvalue-oldvalue)*{pscdown_b or pscup_b}
5313  */
5314  pscdown = SCIPvarGetPseudocost(var, stat, SCIPsetFeasFloor(set, varsol) - varsol);
5315  pscup = SCIPvarGetPseudocost(var, stat, SCIPsetFeasCeil(set, varsol) - varsol);
5316  estimateinc = SCIPvarGetPseudocost(var, stat, targetvalue - varsol) - MIN(pscdown, pscup);
5317  }
5318 
5319  /* due to rounding errors estimateinc might be slightly negative; in this case return the parent node's estimate */
5320  if( estimateinc > 0.0 )
5321  estimate += estimateinc;
5322 
5323  return estimate;
5324 }
5325 
5326 /** branches on a variable x
5327  * if x is a continuous variable, then two child nodes will be created
5328  * (x <= x', x >= x')
5329  * but if the bounds of x are such that their relative difference is smaller than epsilon,
5330  * the variable is fixed to val (if not SCIP_INVALID) or a well chosen alternative in the current node,
5331  * i.e., no children are created
5332  * if x is not a continuous variable, then:
5333  * if solution value x' is fractional, two child nodes will be created
5334  * (x <= floor(x'), x >= ceil(x')),
5335  * if solution value is integral, the x' is equal to lower or upper bound of the branching
5336  * variable and the bounds of x are finite, then two child nodes will be created
5337  * (x <= x", x >= x"+1 with x" = floor((lb + ub)/2)),
5338  * otherwise (up to) three child nodes will be created
5339  * (x <= x'-1, x == x', x >= x'+1)
5340  * if solution value is equal to one of the bounds and the other bound is infinite, only two child nodes
5341  * will be created (the third one would be infeasible anyway)
5342  */
5344  SCIP_TREE* tree, /**< branch and bound tree */
5345  SCIP_REOPT* reopt, /**< reoptimization data structure */
5346  BMS_BLKMEM* blkmem, /**< block memory */
5347  SCIP_SET* set, /**< global SCIP settings */
5348  SCIP_STAT* stat, /**< problem statistics data */
5349  SCIP_PROB* transprob, /**< transformed problem after presolve */
5350  SCIP_PROB* origprob, /**< original problem */
5351  SCIP_LP* lp, /**< current LP data */
5352  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5353  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5354  SCIP_VAR* var, /**< variable to branch on */
5355  SCIP_Real val, /**< value to branch on or SCIP_INVALID for branching on current LP/pseudo solution.
5356  * A branching value is required for branching on continuous variables */
5357  SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
5358  SCIP_NODE** eqchild, /**< pointer to return the middle child with variable fixed, or NULL */
5359  SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
5360  )
5361 {
5362  SCIP_NODE* node;
5363  SCIP_Real priority;
5364  SCIP_Real estimate;
5365 
5366  SCIP_Real downub;
5367  SCIP_Real fixval;
5368  SCIP_Real uplb;
5369  SCIP_Real lpval;
5370 
5371  SCIP_Bool validval;
5372 
5373  assert(tree != NULL);
5374  assert(set != NULL);
5375  assert(var != NULL);
5376 
5377  /* initialize children pointer */
5378  if( downchild != NULL )
5379  *downchild = NULL;
5380  if( eqchild != NULL )
5381  *eqchild = NULL;
5382  if( upchild != NULL )
5383  *upchild = NULL;
5384 
5385  /* store whether a valid value was given for branching */
5386  validval = (val != SCIP_INVALID); /*lint !e777 */
5387 
5388  /* get the corresponding active problem variable
5389  * if branching value is given, then transform it to the value of the active variable */
5390  if( validval )
5391  {
5392  SCIP_Real scalar;
5393  SCIP_Real constant;
5394 
5395  scalar = 1.0;
5396  constant = 0.0;
5397 
5398  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
5399 
5400  if( scalar == 0.0 )
5401  {
5402  SCIPerrorMessage("cannot branch on fixed variable <%s>\n", SCIPvarGetName(var));
5403  return SCIP_INVALIDDATA;
5404  }
5405 
5406  /* we should have givenvariable = scalar * activevariable + constant */
5407  val = (val - constant) / scalar;
5408  }
5409  else
5410  var = SCIPvarGetProbvar(var);
5411 
5413  {
5414  SCIPerrorMessage("cannot branch on fixed or multi-aggregated variable <%s>\n", SCIPvarGetName(var));
5415  SCIPABORT();
5416  return SCIP_INVALIDDATA; /*lint !e527*/
5417  }
5418 
5419  /* ensure, that branching on continuous variables will only be performed when a branching point is given. */
5420  if( SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS && !validval )
5421  {
5422  SCIPerrorMessage("Cannot branch on continuous variables without a given branching value.\n", SCIPvarGetName(var));
5423  SCIPABORT();
5424  return SCIP_INVALIDDATA; /*lint !e527*/
5425  }
5426 
5427  assert(SCIPvarIsActive(var));
5428  assert(SCIPvarGetProbindex(var) >= 0);
5432  assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
5433 
5434  /* update the information for the focus node before creating children */
5435  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, tree->focusnode) );
5436 
5437  /* get value of variable in current LP or pseudo solution */
5438  lpval = SCIPvarGetSol(var, tree->focusnodehaslp);
5439 
5440  /* if there was no explicit value given for branching, branch on current LP or pseudo solution value */
5441  if( !validval )
5442  {
5443  val = lpval;
5444 
5445  /* avoid branching on infinite values in pseudo solution */
5446  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5447  {
5448  val = SCIPvarGetWorstBoundLocal(var);
5449 
5450  /* if both bounds are infinite, choose zero as branching point */
5451  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5452  {
5453  assert(SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)));
5454  assert(SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)));
5455  val = 0.0;
5456  }
5457  }
5458  }
5459 
5460  assert(SCIPsetIsFeasGE(set, val, SCIPvarGetLbLocal(var)));
5461  assert(SCIPsetIsFeasLE(set, val, SCIPvarGetUbLocal(var)));
5462  /* see comment in SCIPbranchVarVal */
5463  assert(SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS ||
5464  SCIPrelDiff(SCIPvarGetUbLocal(var), SCIPvarGetLbLocal(var)) <= 2.02 * SCIPsetEpsilon(set) ||
5465  SCIPsetIsInfinity(set, -2.1*SCIPvarGetLbLocal(var)) || SCIPsetIsInfinity(set, 2.1*SCIPvarGetUbLocal(var)) ||
5466  (SCIPsetIsLT(set, 2.1*SCIPvarGetLbLocal(var), 2.1*val) && SCIPsetIsLT(set, 2.1*val, 2.1*SCIPvarGetUbLocal(var))) );
5467 
5468  downub = SCIP_INVALID;
5469  fixval = SCIP_INVALID;
5470  uplb = SCIP_INVALID;
5471 
5473  {
5474  if( SCIPsetIsRelEQ(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)) )
5475  {
5476  SCIPsetDebugMsg(set, "fixing continuous variable <%s> with value %g and bounds [%.15g, %.15g], priority %d (current lower bound: %g)\n",
5478 
5479  /* if val is at least epsilon away from both bounds, then we change both bounds to this value
5480  * otherwise, we fix the variable to its worst bound
5481  */
5482  if( SCIPsetIsGT(set, val, SCIPvarGetLbLocal(var)) && SCIPsetIsLT(set, val, SCIPvarGetUbLocal(var)) )
5483  {
5484  SCIP_CALL( SCIPnodeAddBoundchg(tree->focusnode, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
5485  branchcand, eventqueue, NULL, var, val, SCIP_BOUNDTYPE_LOWER, FALSE) );
5486  SCIP_CALL( SCIPnodeAddBoundchg(tree->focusnode, blkmem, set, stat, transprob, origprob, tree, reopt, lp,
5487  branchcand, eventqueue, NULL, var, val, SCIP_BOUNDTYPE_UPPER, FALSE) );
5488  }
5489  else if( SCIPvarGetObj(var) >= 0.0 )
5490  {
5491  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5492  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetUbLocal(var), SCIP_BOUNDTYPE_LOWER, FALSE) );
5493  }
5494  else
5495  {
5496  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5497  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetLbLocal(var), SCIP_BOUNDTYPE_UPPER, FALSE) );
5498  }
5499  }
5500  else if( SCIPrelDiff(SCIPvarGetUbLocal(var), SCIPvarGetLbLocal(var)) <= 2.02 * SCIPsetEpsilon(set) )
5501  {
5502  /* if the only way to branch is such that in both sides the relative domain width becomes smaller epsilon,
5503  * then fix the variable in both branches right away
5504  *
5505  * 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),
5506  * then fix the variable to the non-infinite value, as we cannot fix a variable to infinity
5507  */
5508  SCIPsetDebugMsg(set, "continuous branch on variable <%s> with bounds [%.15g, %.15g], priority %d (current lower bound: %g), node %p\n",
5510  if( SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)) )
5511  {
5512  assert(!SCIPsetIsInfinity(set, -SCIPvarGetUbLocal(var)));
5513  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5514  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetUbLocal(var), SCIP_BOUNDTYPE_LOWER, FALSE) );
5515  }
5516  else if( SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)) )
5517  {
5518  assert(!SCIPsetIsInfinity(set, SCIPvarGetLbLocal(var)));
5519  SCIP_CALL( SCIPnodeAddBoundchg(SCIPtreeGetCurrentNode(tree), blkmem, set, stat, transprob, origprob,
5520  tree, reopt, lp, branchcand, eventqueue, NULL, var, SCIPvarGetLbLocal(var), SCIP_BOUNDTYPE_UPPER, FALSE) );
5521  }
5522  else
5523  {
5524  downub = SCIPvarGetLbLocal(var);
5525  uplb = SCIPvarGetUbLocal(var);
5526  }
5527  }
5528  else
5529  {
5530  /* in the general case, there is enough space for two branches
5531  * a sophisticated user should have also chosen the branching value such that it is not very close to the bounds
5532  * so here we only ensure that it is at least epsilon away from both bounds
5533  */
5534  SCIPsetDebugMsg(set, "continuous branch on variable <%s> with value %g, priority %d (current lower bound: %g)\n",
5536  downub = MIN(val, SCIPvarGetUbLocal(var) - SCIPsetEpsilon(set)); /*lint !e666*/
5537  uplb = MAX(val, SCIPvarGetLbLocal(var) + SCIPsetEpsilon(set)); /*lint !e666*/
5538  }
5539  }
5540  else if( SCIPsetIsFeasIntegral(set, val) )
5541  {
5542  SCIP_Real lb;
5543  SCIP_Real ub;
5544 
5545  lb = SCIPvarGetLbLocal(var);
5546  ub = SCIPvarGetUbLocal(var);
5547 
5548  /* if there was no explicit value given for branching, the variable has a finite domain and the current LP/pseudo
5549  * solution is one of the bounds, we branch in the center of the domain */
5550  if( !validval && !SCIPsetIsInfinity(set, -lb) && !SCIPsetIsInfinity(set, ub)
5551  && (SCIPsetIsFeasEQ(set, val, lb) || SCIPsetIsFeasEQ(set, val, ub)) )
5552  {
5553  SCIP_Real center;
5554 
5555  /* create child nodes with x <= x", and x >= x"+1 with x" = floor((lb + ub)/2);
5556  * if x" is integral, make the interval smaller in the child in which the current solution x'
5557  * is still feasible
5558  */
5559  center = (ub + lb) / 2.0;
5560  if( val <= center )
5561  {
5562  downub = SCIPsetFeasFloor(set, center);
5563  uplb = downub + 1.0;
5564  }
5565  else
5566  {
5567  uplb = SCIPsetFeasCeil(set, center);
5568  downub = uplb - 1.0;
5569  }
5570  }
5571  else
5572  {
5573  /* create child nodes with x <= x'-1, x = x', and x >= x'+1 */
5574  assert(SCIPsetIsEQ(set, SCIPsetFeasCeil(set, val), SCIPsetFeasFloor(set, val)));
5575 
5576  fixval = SCIPsetFeasCeil(set, val); /* get rid of numerical issues */
5577 
5578  /* create child node with x <= x'-1, if this would be feasible */
5579  if( SCIPsetIsFeasGE(set, fixval-1.0, lb) )
5580  downub = fixval - 1.0;
5581 
5582  /* create child node with x >= x'+1, if this would be feasible */
5583  if( SCIPsetIsFeasLE(set, fixval+1.0, ub) )
5584  uplb = fixval + 1.0;
5585  }
5586  SCIPsetDebugMsg(set, "integral branch on variable <%s> with value %g, priority %d (current lower bound: %g)\n",
5588  }
5589  else
5590  {
5591  /* create child nodes with x <= floor(x'), and x >= ceil(x') */
5592  downub = SCIPsetFeasFloor(set, val);
5593  uplb = downub + 1.0;
5594  assert( SCIPsetIsRelEQ(set, SCIPsetCeil(set, val), uplb) );
5595  SCIPsetDebugMsg(set, "fractional branch on variable <%s> with value %g, root value %g, priority %d (current lower bound: %g)\n",
5597  }
5598 
5599  /* perform the branching;
5600  * set the node selection priority in a way, s.t. a node is preferred whose branching goes in the same direction
5601  * as the deviation from the variable's root solution
5602  */
5603  if( downub != SCIP_INVALID ) /*lint !e777*/
5604  {
5605  /* create child node x <= downub */
5606  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_DOWNWARDS, downub);
5607  /* if LP solution is cutoff in child, compute a new estimate
5608  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
5609  if( SCIPsetIsGT(set, lpval, downub) )
5610  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, downub);
5611  else
5612  estimate = SCIPnodeGetEstimate(tree->focusnode);
5613  SCIPsetDebugMsg(set, " -> creating child: <%s> <= %g (priority: %g, estimate: %g)\n",
5614  SCIPvarGetName(var), downub, priority, estimate);
5615  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5616  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5617  NULL, var, downub, SCIP_BOUNDTYPE_UPPER, FALSE) );
5618  /* output branching bound change to visualization file */
5619  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5620 
5621  if( downchild != NULL )
5622  *downchild = node;
5623  }
5624 
5625  if( fixval != SCIP_INVALID ) /*lint !e777*/
5626  {
5627  /* create child node with x = fixval */
5628  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_FIXED, fixval);
5629  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, fixval);
5630  SCIPsetDebugMsg(set, " -> creating child: <%s> == %g (priority: %g, estimate: %g)\n",
5631  SCIPvarGetName(var), fixval, priority, estimate);
5632  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5633  if( !SCIPsetIsFeasEQ(set, SCIPvarGetLbLocal(var), fixval) )
5634  {
5635  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5636  NULL, var, fixval, SCIP_BOUNDTYPE_LOWER, FALSE) );
5637  }
5638  if( !SCIPsetIsFeasEQ(set, SCIPvarGetUbLocal(var), fixval) )
5639  {
5640  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5641  NULL, var, fixval, SCIP_BOUNDTYPE_UPPER, FALSE) );
5642  }
5643  /* output branching bound change to visualization file */
5644  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5645 
5646  if( eqchild != NULL )
5647  *eqchild = node;
5648  }
5649 
5650  if( uplb != SCIP_INVALID ) /*lint !e777*/
5651  {
5652  /* create child node with x >= uplb */
5653  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_UPWARDS, uplb);
5654  if( SCIPsetIsLT(set, lpval, uplb) )
5655  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, uplb);
5656  else
5657  estimate = SCIPnodeGetEstimate(tree->focusnode);
5658  SCIPsetDebugMsg(set, " -> creating child: <%s> >= %g (priority: %g, estimate: %g)\n",
5659  SCIPvarGetName(var), uplb, priority, estimate);
5660  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5661  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5662  NULL, var, uplb, SCIP_BOUNDTYPE_LOWER, FALSE) );
5663  /* output branching bound change to visualization file */
5664  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5665 
5666  if( upchild != NULL )
5667  *upchild = node;
5668  }
5669 
5670 
5671  return SCIP_OKAY;
5672 }
5673 
5674 /** branches a variable x using the given domain hole; two child nodes will be created (x <= left, x >= right) */
5676  SCIP_TREE* tree, /**< branch and bound tree */
5677  SCIP_REOPT* reopt, /**< reoptimization data structure */
5678  BMS_BLKMEM* blkmem, /**< block memory */
5679  SCIP_SET* set, /**< global SCIP settings */
5680  SCIP_STAT* stat, /**< problem statistics data */
5681  SCIP_PROB* transprob, /**< transformed problem after presolve */
5682  SCIP_PROB* origprob, /**< original problem */
5683  SCIP_LP* lp, /**< current LP data */
5684  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5685  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5686  SCIP_VAR* var, /**< variable to branch on */
5687  SCIP_Real left, /**< left side of the domain hole */
5688  SCIP_Real right, /**< right side of the domain hole */
5689  SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
5690  SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
5691  )
5692 {
5693  SCIP_NODE* node;
5694  SCIP_Real priority;
5695  SCIP_Real estimate;
5696  SCIP_Real lpval;
5697 
5698  assert(tree != NULL);
5699  assert(set != NULL);
5700  assert(var != NULL);
5701  assert(SCIPsetIsLT(set, left, SCIPvarGetUbLocal(var)));
5702  assert(SCIPsetIsGE(set, left, SCIPvarGetLbLocal(var)));
5703  assert(SCIPsetIsGT(set, right, SCIPvarGetLbLocal(var)));
5704  assert(SCIPsetIsLE(set, right, SCIPvarGetUbLocal(var)));
5705  assert(SCIPsetIsLE(set, left, right));
5706 
5707  /* initialize children pointer */
5708  if( downchild != NULL )
5709  *downchild = NULL;
5710  if( upchild != NULL )
5711  *upchild = NULL;
5712 
5713  /* get the corresponding active problem variable */
5714  SCIP_CALL( SCIPvarGetProbvarHole(&var, &left, &right) );
5715 
5717  {
5718  SCIPerrorMessage("cannot branch on fixed or multi-aggregated variable <%s>\n", SCIPvarGetName(var));
5719  SCIPABORT();
5720  return SCIP_INVALIDDATA; /*lint !e527*/
5721  }
5722 
5723  assert(SCIPvarIsActive(var));
5724  assert(SCIPvarGetProbindex(var) >= 0);
5728  assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
5729 
5730  assert(SCIPsetIsFeasGE(set, left, SCIPvarGetLbLocal(var)));
5731  assert(SCIPsetIsFeasLE(set, right, SCIPvarGetUbLocal(var)));
5732 
5733  /* adjust left and right side of the domain hole if the variable is integral */
5734  if( SCIPvarIsIntegral(var) )
5735  {
5736  left = SCIPsetFeasFloor(set, left);
5737  right = SCIPsetFeasCeil(set, right);
5738  }
5739 
5740  assert(SCIPsetIsLT(set, left, SCIPvarGetUbLocal(var)));
5741  assert(SCIPsetIsGE(set, left, SCIPvarGetLbLocal(var)));
5742  assert(SCIPsetIsGT(set, right, SCIPvarGetLbLocal(var)));
5743  assert(SCIPsetIsLE(set, right, SCIPvarGetUbLocal(var)));
5744  assert(SCIPsetIsLE(set, left, right));
5745 
5746  /* get value of variable in current LP or pseudo solution */
5747  lpval = SCIPvarGetSol(var, tree->focusnodehaslp);
5748 
5749  /* perform the branching;
5750  * set the node selection priority in a way, s.t. a node is preferred whose branching goes in the same direction
5751  * as the deviation from the variable's root solution
5752  */
5753 
5754  /* create child node x <= left */
5755  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_DOWNWARDS, left);
5756 
5757  /* if LP solution is cutoff in child, compute a new estimate
5758  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node
5759  */
5760  if( SCIPsetIsGT(set, lpval, left) )
5761  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, left);
5762  else
5763  estimate = SCIPnodeGetEstimate(tree->focusnode);
5764 
5765  SCIPsetDebugMsg(set, " -> creating child: <%s> <= %g (priority: %g, estimate: %g)\n",
5766  SCIPvarGetName(var), left, priority, estimate);
5767 
5768  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5769  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue, NULL,
5770  var, left, SCIP_BOUNDTYPE_UPPER, FALSE) );
5771  /* output branching bound change to visualization file */
5772  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5773 
5774  if( downchild != NULL )
5775  *downchild = node;
5776 
5777  /* create child node with x >= right */
5778  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_UPWARDS, right);
5779 
5780  if( SCIPsetIsLT(set, lpval, right) )
5781  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, right);
5782  else
5783  estimate = SCIPnodeGetEstimate(tree->focusnode);
5784 
5785  SCIPsetDebugMsg(set, " -> creating child: <%s> >= %g (priority: %g, estimate: %g)\n",
5786  SCIPvarGetName(var), right, priority, estimate);
5787 
5788  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
5789  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
5790  NULL, var, right, SCIP_BOUNDTYPE_LOWER, FALSE) );
5791  /* output branching bound change to visualization file */
5792  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
5793 
5794  if( upchild != NULL )
5795  *upchild = node;
5796 
5797  return SCIP_OKAY;
5798 }
5799 
5800 /** n-ary branching on a variable x
5801  * Branches on variable x such that up to n/2 children are created on each side of the usual branching value.
5802  * The branching value is selected as in SCIPtreeBranchVar().
5803  * If n is 2 or the variables local domain is too small for a branching into n pieces, SCIPtreeBranchVar() is called.
5804  * The parameters minwidth and widthfactor determine the domain width of the branching variable in the child nodes.
5805  * If n is odd, one child with domain width 'width' and having the branching value in the middle is created.
5806  * Otherwise, two children with domain width 'width' and being left and right of the branching value are created.
5807  * Next further nodes to the left and right are created, where width is multiplied by widthfactor with increasing distance from the first nodes.
5808  * The initial width is calculated such that n/2 nodes are created to the left and to the right of the branching value.
5809  * If this value is below minwidth, the initial width is set to minwidth, which may result in creating less than n nodes.
5810  *
5811  * Giving a large value for widthfactor results in creating children with small domain when close to the branching value
5812  * and large domain when closer to the current variable bounds. That is, setting widthfactor to a very large value and n to 3
5813  * results in a ternary branching where the branching variable is mostly fixed in the middle child.
5814  * Setting widthfactor to 1.0 results in children where the branching variable always has the same domain width
5815  * (except for one child if the branching value is not in the middle).
5816  */
5818  SCIP_TREE* tree, /**< branch and bound tree */
5819  SCIP_REOPT* reopt, /**< reoptimization data structure */
5820  BMS_BLKMEM* blkmem, /**< block memory */
5821  SCIP_SET* set, /**< global SCIP settings */
5822  SCIP_STAT* stat, /**< problem statistics data */
5823  SCIP_PROB* transprob, /**< transformed problem after presolve */
5824  SCIP_PROB* origprob, /**< original problem */
5825  SCIP_LP* lp, /**< current LP data */
5826  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
5827  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
5828  SCIP_VAR* var, /**< variable to branch on */
5829  SCIP_Real val, /**< value to branch on or SCIP_INVALID for branching on current LP/pseudo solution.
5830  * A branching value is required for branching on continuous variables */
5831  int n, /**< attempted number of children to be created, must be >= 2 */
5832  SCIP_Real minwidth, /**< minimal domain width in children */
5833  SCIP_Real widthfactor, /**< multiplier for children domain width with increasing distance from val, must be >= 1.0 */
5834  int* nchildren /**< buffer to store number of created children, or NULL */
5835  )
5836 {
5837  SCIP_NODE* node;
5838  SCIP_Real priority;
5839  SCIP_Real estimate;
5840  SCIP_Real lpval;
5841  SCIP_Real width;
5842  SCIP_Bool validval;
5843  SCIP_Real left;
5844  SCIP_Real right;
5845  SCIP_Real bnd;
5846  int i;
5847 
5848  assert(tree != NULL);
5849  assert(set != NULL);
5850  assert(var != NULL);
5851  assert(n >= 2);
5852  assert(minwidth >= 0.0);
5853 
5854  /* if binary branching is requested or we have not enough space for n children, delegate to SCIPtreeBranchVar */
5855  if( n == 2 ||
5856  2.0 * minwidth >= SCIPvarGetUbLocal(var) - SCIPvarGetLbLocal(var) ||
5858  {
5859  SCIP_NODE* downchild;
5860  SCIP_NODE* fixchild;
5861  SCIP_NODE* upchild;
5862 
5863  SCIP_CALL( SCIPtreeBranchVar(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, var, val,
5864  &downchild, &fixchild, &upchild) );
5865 
5866  if( nchildren != NULL )
5867  *nchildren = (downchild != NULL ? 1 : 0) + (fixchild != NULL ? 1 : 0) + (upchild != NULL ? 1 : 0);
5868 
5869  return SCIP_OKAY;
5870  }
5871 
5872  /* store whether a valid value was given for branching */
5873  validval = (val != SCIP_INVALID); /*lint !e777 */
5874 
5875  /* get the corresponding active problem variable
5876  * if branching value is given, then transform it to the value of the active variable */
5877  if( validval )
5878  {
5879  SCIP_Real scalar;
5880  SCIP_Real constant;
5881 
5882  scalar = 1.0;
5883  constant = 0.0;
5884 
5885  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
5886 
5887  if( scalar == 0.0 )
5888  {
5889  SCIPerrorMessage("cannot branch on fixed variable <%s>\n", SCIPvarGetName(var));
5890  return SCIP_INVALIDDATA;
5891  }
5892 
5893  /* we should have givenvariable = scalar * activevariable + constant */
5894  val = (val - constant) / scalar;
5895  }
5896  else
5897  var = SCIPvarGetProbvar(var);
5898 
5900  {
5901  SCIPerrorMessage("cannot branch on fixed or multi-aggregated variable <%s>\n", SCIPvarGetName(var));
5902  SCIPABORT();
5903  return SCIP_INVALIDDATA; /*lint !e527*/
5904  }
5905 
5906  /* ensure, that branching on continuous variables will only be performed when a branching point is given. */
5907  if( SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS && !validval )
5908  {
5909  SCIPerrorMessage("Cannot branch on continuous variables without a given branching value.\n", SCIPvarGetName(var));
5910  SCIPABORT();
5911  return SCIP_INVALIDDATA; /*lint !e527*/
5912  }
5913 
5914  assert(SCIPvarIsActive(var));
5915  assert(SCIPvarGetProbindex(var) >= 0);
5919  assert(SCIPsetIsLT(set, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)));
5920 
5921  /* get value of variable in current LP or pseudo solution */
5922  lpval = SCIPvarGetSol(var, tree->focusnodehaslp);
5923 
5924  /* if there was no explicit value given for branching, branch on current LP or pseudo solution value */
5925  if( !validval )
5926  {
5927  val = lpval;
5928 
5929  /* avoid branching on infinite values in pseudo solution */
5930  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5931  {
5932  val = SCIPvarGetWorstBoundLocal(var);
5933 
5934  /* if both bounds are infinite, choose zero as branching point */
5935  if( SCIPsetIsInfinity(set, -val) || SCIPsetIsInfinity(set, val) )
5936  {
5937  assert(SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)));
5938  assert(SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)));
5939  val = 0.0;
5940  }
5941  }
5942  }
5943 
5944  assert(SCIPsetIsFeasGE(set, val, SCIPvarGetLbLocal(var)));
5945  assert(SCIPsetIsFeasLE(set, val, SCIPvarGetUbLocal(var)));
5946  assert(SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS ||
5948  (SCIPsetIsLT(set, 2.1*SCIPvarGetLbLocal(var), 2.1*val) && SCIPsetIsLT(set, 2.1*val, 2.1*SCIPvarGetUbLocal(var))) ); /* see comment in SCIPbranchVarVal */
5949 
5950  /* calculate minimal distance of val from bounds */
5951  width = SCIP_REAL_MAX;
5952  if( !SCIPsetIsInfinity(set, -SCIPvarGetLbLocal(var)) )
5953  {
5954  width = val - SCIPvarGetLbLocal(var);
5955  }
5956  if( !SCIPsetIsInfinity(set, SCIPvarGetUbLocal(var)) )
5957  {
5958  width = MIN(width, SCIPvarGetUbLocal(var) - val); /*lint !e666*/
5959  }
5960  /* calculate initial domain width of child nodes
5961  * 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
5962  */
5963  if( width == SCIP_REAL_MAX ) /*lint !e777*/
5964  {
5965  /* unbounded variable, let's create a child with a small domain */
5966  width = 1.0;
5967  }
5968  else if( widthfactor == 1.0 )
5969  {
5970  /* most domains get same size */
5971  width /= n/2; /*lint !e653*/ /* rounding is ok at this point */
5972  }
5973  else
5974  {
5975  /* width is increased by widthfactor for each child
5976  * if n is even, compute width such that we can create n/2 nodes with width
5977  * width, widthfactor*width, ..., widthfactor^(n/2)*width on each side, i.e.,
5978  * sum(width * widthfactor^(i-1), i = 1..n/2) = min(ub-val, val-lb)
5979  * <-> width * (widthfactor^(n/2) - 1) / (widthfactor - 1) = min(ub-val, val-lb)
5980  *
5981  * if n is odd, compute width such that we can create one middle node with width width
5982  * and n/2 nodes with width widthfactor*width, ..., widthfactor^(n/2)*width on each side, i.e.,
5983  * width/2 + sum(width * widthfactor^i, i = 1..n/2) = min(ub-val, val-lb)
5984  * <-> width * (1/2 + widthfactor * (widthfactor^(n/2) - 1) / (widthfactor - 1) = min(ub-val, val-lb)
5985  */
5986  assert(widthfactor > 1.0);
5987  if( n % 2 == 0 )
5988  width *= (widthfactor - 1.0) / (pow(widthfactor, (SCIP_Real)(n/2)) - 1.0); /*lint !e653*/
5989  else
5990  width /= 0.5 + widthfactor * (pow(widthfactor, (SCIP_Real)(n/2)) - 1.0) / (widthfactor - 1.0); /*lint !e653*/
5991  }
5993  minwidth = MAX(1.0, minwidth);
5994  if( width < minwidth )
5995  width = minwidth;
5996  assert(SCIPsetIsPositive(set, width));
5997 
5998  SCIPsetDebugMsg(set, "%d-ary branching on variable <%s> [%g, %g] around %g, initial width = %g\n",
5999  n, SCIPvarGetName(var), SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var), val, width);
6000 
6001  if( nchildren != NULL )
6002  *nchildren = 0;
6003 
6004  /* initialize upper bound on children left of val and children right of val
6005  * if we are supposed to create an odd number of children, then create a child that has val in the middle of its domain */
6006  if( n % 2 == 1 )
6007  {
6008  left = val - width/2.0;
6009  right = val + width/2.0;
6010  SCIPvarAdjustLb(var, set, &left);
6011  SCIPvarAdjustUb(var, set, &right);
6012 
6013  /* create child node left <= x <= right, if left <= right */
6014  if( left <= right )
6015  {
6016  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_FIXED, val); /* ????????????? how to compute priority for such a child? */
6017  /* if LP solution is cutoff in child, compute a new estimate
6018  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
6019  if( SCIPsetIsLT(set, lpval, left) )
6020  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, left);
6021  else if( SCIPsetIsGT(set, lpval, right) )
6022  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, right);
6023  else
6024  estimate = SCIPnodeGetEstimate(tree->focusnode);
6025 
6026  SCIPsetDebugMsg(set, " -> creating middle child: %g <= <%s> <= %g (priority: %g, estimate: %g, width: %g)\n",
6027  left, SCIPvarGetName(var), right, priority, estimate, right - left);
6028 
6029  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
6030  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand,
6031  eventqueue, NULL, var, left , SCIP_BOUNDTYPE_LOWER, FALSE) );
6032  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6033  NULL, var, right, SCIP_BOUNDTYPE_UPPER, FALSE) );
6034  /* output branching bound change to visualization file */
6035  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
6036 
6037  if( nchildren != NULL )
6038  ++*nchildren;
6039  }
6040  --n;
6041 
6043  {
6044  /* 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. */
6045  left -= 1.0;
6046  right += 1.0;
6047  }
6048 
6049  width *= widthfactor;
6050  }
6051  else
6052  {
6054  {
6055  left = SCIPsetFloor(set, val);
6056  right = SCIPsetCeil(set, val);
6057  if( right - left < 0.5 )
6058  left -= 1.0;
6059  }
6060  else if( SCIPsetIsZero(set, val) )
6061  {
6062  left = 0.0;
6063  right = 0.0;
6064  }
6065  else
6066  {
6067  left = val;
6068  right = val;
6069  }
6070  }
6071 
6072  assert(n % 2 == 0);
6073  n /= 2;
6074  for( i = 0; i < n; ++i )
6075  {
6076  /* create child node left - width <= x <= left, if left > lb(x) or x is discrete */
6078  {
6079  /* new lower bound should be variables lower bound, if we are in the last round or left - width is very close to lower bound
6080  * otherwise we take left - width
6081  */
6082  if( i == n-1 || SCIPsetIsRelEQ(set, SCIPvarGetLbLocal(var), left - width))
6083  {
6084  bnd = SCIPvarGetLbLocal(var);
6085  }
6086  else
6087  {
6088  bnd = left - width;
6089  SCIPvarAdjustLb(var, set, &bnd);
6090  bnd = MAX(SCIPvarGetLbLocal(var), bnd); /*lint !e666*/
6091  }
6092  assert(SCIPsetIsRelLT(set, bnd, left));
6093 
6094  /* the nodeselection priority of nodes is decreased as more as they are away from val */
6095  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_DOWNWARDS, bnd) / (i+1);
6096  /* if LP solution is cutoff in child, compute a new estimate
6097  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
6098  if( SCIPsetIsLT(set, lpval, bnd) )
6099  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, bnd);
6100  else if( SCIPsetIsGT(set, lpval, left) )
6101  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, left);
6102  else
6103  estimate = SCIPnodeGetEstimate(tree->focusnode);
6104 
6105  SCIPsetDebugMsg(set, " -> creating left child: %g <= <%s> <= %g (priority: %g, estimate: %g, width: %g)\n",
6106  bnd, SCIPvarGetName(var), left, priority, estimate, left - bnd);
6107 
6108  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
6109  if( SCIPsetIsGT(set, bnd, SCIPvarGetLbLocal(var)) )
6110  {
6111  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6112  NULL, var, bnd, SCIP_BOUNDTYPE_LOWER, FALSE) );
6113  }
6114  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6115  NULL, var, left, SCIP_BOUNDTYPE_UPPER, FALSE) );
6116  /* output branching bound change to visualization file */
6117  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
6118 
6119  if( nchildren != NULL )
6120  ++*nchildren;
6121 
6122  left = bnd;
6124  left -= 1.0;
6125  }
6126 
6127  /* create child node right <= x <= right + width, if right < ub(x) */
6128  if( SCIPsetIsRelGT(set, SCIPvarGetUbLocal(var), right) || SCIPvarGetType(var) != SCIP_VARTYPE_CONTINUOUS )
6129  {
6130  /* new upper bound should be variables upper bound, if we are in the last round or right + width is very close to upper bound
6131  * otherwise we take right + width
6132  */
6133  if( i == n-1 || SCIPsetIsRelEQ(set, SCIPvarGetUbLocal(var), right + width))
6134  {
6135  bnd = SCIPvarGetUbLocal(var);
6136  }
6137  else
6138  {
6139  bnd = right + width;
6140  SCIPvarAdjustUb(var, set, &bnd);
6141  bnd = MIN(SCIPvarGetUbLocal(var), bnd); /*lint !e666*/
6142  }
6143  assert(SCIPsetIsRelGT(set, bnd, right));
6144 
6145  /* the nodeselection priority of nodes is decreased as more as they are away from val */
6146  priority = SCIPtreeCalcNodeselPriority(tree, set, stat, var, SCIP_BRANCHDIR_UPWARDS, bnd) / (i+1);
6147  /* if LP solution is cutoff in child, compute a new estimate
6148  * otherwise we cannot expect a direct change in the best solution, so we keep the estimate of the parent node */
6149  if( SCIPsetIsLT(set, lpval, right) )
6150  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, right);
6151  else if( SCIPsetIsGT(set, lpval, bnd) )
6152  estimate = SCIPtreeCalcChildEstimate(tree, set, stat, var, bnd);
6153  else
6154  estimate = SCIPnodeGetEstimate(tree->focusnode);
6155 
6156  SCIPsetDebugMsg(set, " -> creating right child: %g <= <%s> <= %g (priority: %g, estimate: %g, width: %g)\n",
6157  right, SCIPvarGetName(var), bnd, priority, estimate, bnd - right);
6158 
6159  SCIP_CALL( SCIPnodeCreateChild(&node, blkmem, set, stat, tree, priority, estimate) );
6160  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6161  NULL, var, right, SCIP_BOUNDTYPE_LOWER, FALSE) );
6162  if( SCIPsetIsLT(set, bnd, SCIPvarGetUbLocal(var)) )
6163  {
6164  SCIP_CALL( SCIPnodeAddBoundchg(node, blkmem, set, stat, transprob, origprob, tree, reopt, lp, branchcand, eventqueue,
6165  NULL, var, bnd, SCIP_BOUNDTYPE_UPPER, FALSE) );
6166  }
6167  /* output branching bound change to visualization file */
6168  SCIP_CALL( SCIPvisualUpdateChild(stat->visual, set, stat, node) );
6169 
6170  if( nchildren != NULL )
6171  ++*nchildren;
6172 
6173  right = bnd;
6175  right += 1.0;
6176  }
6177 
6178  width *= widthfactor;
6179  }
6180 
6181  return SCIP_OKAY;
6182 }
6183 
6184 /** adds a diving bound change to the tree together with the information if this is a bound change
6185  * for the preferred direction or not
6186  */
6187 #define ARRAYGROWTH 5
6189  SCIP_TREE* tree, /**< branch and bound tree */
6190  BMS_BLKMEM* blkmem, /**< block memory buffers */
6191  SCIP_VAR* var, /**< variable to apply the bound change to */
6192  SCIP_BRANCHDIR dir, /**< direction of the bound change */
6193  SCIP_Real value, /**< value to adjust this variable bound to */
6194  SCIP_Bool preferred /**< is this a bound change for the preferred child? */
6195  )
6196 {
6197  int idx = preferred ? 0 : 1;
6198  int pos = tree->ndivebdchanges[idx];
6199 
6200  assert(pos < tree->divebdchgsize[idx]);
6201 
6202  if( pos == tree->divebdchgsize[idx] - 1 )
6203  {
6204  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tree->divebdchgdirs[idx], tree->divebdchgsize[idx], tree->divebdchgsize[idx] + ARRAYGROWTH) ); /*lint !e866*/
6205  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tree->divebdchgvars[idx], tree->divebdchgsize[idx], tree->divebdchgsize[idx] + ARRAYGROWTH) ); /*lint !e866*/
6206  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &tree->divebdchgvals[idx], tree->divebdchgsize[idx], tree->divebdchgsize[idx] + ARRAYGROWTH) ); /*lint !e866*/
6207  tree->divebdchgsize[idx] += ARRAYGROWTH;
6208  }
6209 
6210  tree->divebdchgvars[idx][pos] = var;
6211  tree->divebdchgdirs[idx][pos] = dir;
6212  tree->divebdchgvals[idx][pos] = value;
6213 
6214  ++tree->ndivebdchanges[idx];
6215 
6216  return SCIP_OKAY;
6217 }
6218 
6219 /** get the dive bound change data for the preferred or the alternative direction */
6221  SCIP_TREE* tree, /**< branch and bound tree */
6222  SCIP_VAR*** variables, /**< pointer to store variables for the specified direction */
6223  SCIP_BRANCHDIR** directions, /**< pointer to store the branching directions */
6224  SCIP_Real** values, /**< pointer to store bound change values */
6225  int* ndivebdchgs, /**< pointer to store the number of dive bound changes */
6226  SCIP_Bool preferred /**< should the dive bound changes for the preferred child be output? */
6227  )
6228 {
6229  int idx = preferred ? 0 : 1;
6230 
6231  assert(variables != NULL);
6232  assert(directions != NULL);
6233  assert(values != NULL);
6234  assert(ndivebdchgs != NULL);
6235 
6236  *variables = tree->divebdchgvars[idx];
6237  *directions = tree->divebdchgdirs[idx];
6238  *values = tree->divebdchgvals[idx];
6239  *ndivebdchgs = tree->ndivebdchanges[idx];
6240 }
6241 
6242 /** clear the tree bound change data structure */
6244  SCIP_TREE* tree /**< branch and bound tree */
6245  )
6246 {
6247  int p;
6248 
6249  for( p = 0; p < 2; ++p )
6250  tree->ndivebdchanges[p] = 0;
6251 }
6252 
6253 /** creates a probing child node of the current node, which must be the focus node, the current refocused node,
6254  * or another probing node; if the current node is the focus or a refocused node, the created probing node is
6255  * installed as probing root node
6256  */
6257 static
6259  SCIP_TREE* tree, /**< branch and bound tree */
6260  BMS_BLKMEM* blkmem, /**< block memory */
6261  SCIP_SET* set, /**< global SCIP settings */
6262  SCIP_LP* lp /**< current LP data */
6263  )
6264 {
6265  SCIP_NODE* currentnode;
6266  SCIP_NODE* node;
6267  SCIP_RETCODE retcode;
6268 
6269  assert(tree != NULL);
6270  assert(SCIPtreeIsPathComplete(tree));
6271  assert(tree->pathlen > 0);
6272  assert(blkmem != NULL);
6273  assert(set != NULL);
6274 
6275  /* get the current node */
6276  currentnode = SCIPtreeGetCurrentNode(tree);
6277  assert(SCIPnodeGetType(currentnode) == SCIP_NODETYPE_FOCUSNODE
6278  || SCIPnodeGetType(currentnode) == SCIP_NODETYPE_REFOCUSNODE
6279  || SCIPnodeGetType(currentnode) == SCIP_NODETYPE_PROBINGNODE);
6280  assert((SCIPnodeGetType(currentnode) == SCIP_NODETYPE_PROBINGNODE) == SCIPtreeProbing(tree));
6281 
6282  /* create the node data structure */
6283  SCIP_CALL( nodeCreate(&node, blkmem, set) );
6284  assert(node != NULL);
6285 
6286  /* mark node to be a probing node */
6287  node->nodetype = SCIP_NODETYPE_PROBINGNODE; /*lint !e641*/
6288 
6289  /* create the probingnode data */
6290  SCIP_CALL( probingnodeCreate(&node->data.probingnode, blkmem, lp) );
6291 
6292  /* make the current node the parent of the new probing node */
6293  retcode = nodeAssignParent(node, blkmem, set, tree, currentnode, 0.0);
6294 
6295  /* if we reached the maximal depth level we clean up the allocated memory and stop */
6296  if( retcode == SCIP_MAXDEPTHLEVEL )
6297  {
6298  SCIP_CALL( probingnodeFree(&(node->data.probingnode), blkmem, lp) );
6299  BMSfreeBlockMemory(blkmem, &node);
6300  }
6301  SCIP_CALL( retcode );
6302  assert(SCIPnodeGetDepth(node) == tree->pathlen);
6303 
6304  /* check, if the node is the probing root node */
6305  if( tree->probingroot == NULL )
6306  {
6307  tree->probingroot = node;
6308  SCIPsetDebugMsg(set, "created probing root node #%" SCIP_LONGINT_FORMAT " at depth %d\n",
6309  SCIPnodeGetNumber(node), SCIPnodeGetDepth(node));
6310  }
6311  else
6312  {
6314  assert(SCIPnodeGetDepth(tree->probingroot) < SCIPnodeGetDepth(node));
6315 
6316  SCIPsetDebugMsg(set, "created probing child node #%" SCIP_LONGINT_FORMAT " at depth %d, probing depth %d\n",
6318  }
6319 
6320  /* create the new active path */
6321  SCIP_CALL( treeEnsurePathMem(tree, set, tree->pathlen+1) );
6322  node->active = TRUE;
6323  tree->path[tree->pathlen] = node;
6324  tree->pathlen++;
6325 
6326  /* update the path LP size for the previous node and set the (initial) path LP size for the newly created node */
6327  SCIP_CALL( treeUpdatePathLPSize(tree, tree->pathlen-2) );
6328 
6329  /* mark the LP's size */
6330  SCIPlpMarkSize(lp);
6331  assert(tree->pathlen >= 2);
6332  assert(lp->firstnewrow == tree->pathnlprows[tree->pathlen-1]); /* marked LP size should be initial size of new node */
6333  assert(lp->firstnewcol == tree->pathnlpcols[tree->pathlen-1]);
6334 
6335  /* the current probing node does not yet have a solved LP */
6336  tree->probingnodehaslp = FALSE;
6337 
6338  return SCIP_OKAY;
6339 }
6340 
6341 /** switches to probing mode and creates a probing root */
6343  SCIP_TREE* tree, /**< branch and bound tree */
6344  BMS_BLKMEM* blkmem, /**< block memory */
6345  SCIP_SET* set, /**< global SCIP settings */
6346  SCIP_LP* lp, /**< current LP data */
6347  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6348  SCIP_PROB* transprob, /**< transformed problem after presolve */
6349  SCIP_Bool strongbranching /**< is the probing mode used for strongbranching? */
6350  )
6351 {
6352  assert(tree != NULL);
6353  assert(tree->probinglpistate == NULL);
6354  assert(tree->probinglpinorms == NULL);
6355  assert(!SCIPtreeProbing(tree));
6356  assert(lp != NULL);
6357 
6358  SCIPsetDebugMsg(set, "probing started in depth %d (LP flushed: %u, LP solved: %u, solstat: %d), probing root in depth %d\n",
6359  tree->pathlen-1, lp->flushed, lp->solved, SCIPlpGetSolstat(lp), tree->pathlen);
6360 
6361  /* store all marked constraints for propagation */
6362  SCIP_CALL( SCIPconshdlrsStorePropagationStatus(set, set->conshdlrs, set->nconshdlrs) );
6363 
6364  /* inform LP about probing mode */
6366 
6367  assert(!lp->divingobjchg);
6368 
6369  /* remember, whether the LP was flushed and solved */
6370  tree->probinglpwasflushed = lp->flushed;
6371  tree->probinglpwassolved = lp->solved;
6372  tree->probingloadlpistate = FALSE;
6373  tree->probinglpwasrelax = lp->isrelax;
6374  lp->isrelax = TRUE;
6375  tree->probingsolvedlp = FALSE;
6376  tree->probingobjchanged = FALSE;
6377  lp->divingobjchg = FALSE;
6378  tree->probingsumchgdobjs = 0;
6379  tree->sbprobing = strongbranching;
6380 
6381  /* remember the LP state in order to restore the LP solution quickly after probing */
6382  /**@todo could the lp state be worth storing if the LP is not flushed (and hence not solved)? */
6383  if( lp->flushed && lp->solved )
6384  {
6385  SCIP_CALL( SCIPlpGetState(lp, blkmem, &tree->probinglpistate) );
6386  SCIP_CALL( SCIPlpGetNorms(lp, blkmem, &tree->probinglpinorms) );
6389  tree->probinglpwasdualfeas = lp->dualfeasible;
6391  }
6392 
6393  /* remember the relaxation solution to reset it later */
6394  if( SCIPrelaxationIsSolValid(relaxation) )
6395  {
6396  SCIP_CALL( SCIPtreeStoreRelaxSol(tree, set, relaxation, transprob) );
6397  }
6398 
6399  /* create temporary probing root node */
6400  SCIP_CALL( treeCreateProbingNode(tree, blkmem, set, lp) );
6401  assert(SCIPtreeProbing(tree));
6402 
6403  return SCIP_OKAY;
6404 }
6405 
6406 /** creates a new probing child node in the probing path */
6408  SCIP_TREE* tree, /**< branch and bound tree */
6409  BMS_BLKMEM* blkmem, /**< block memory */
6410  SCIP_SET* set, /**< global SCIP settings */
6411  SCIP_LP* lp /**< current LP data */
6412  )
6413 {
6414  assert(SCIPtreeProbing(tree));
6415 
6416  SCIPsetDebugMsg(set, "new probing child in depth %d (probing depth: %d)\n", tree->pathlen, tree->pathlen-1 - SCIPnodeGetDepth(tree->probingroot));
6417 
6418  /* create temporary probing root node */
6419  SCIP_CALL( treeCreateProbingNode(tree, blkmem, set, lp) );
6420 
6421  return SCIP_OKAY;
6422 }
6423 
6424 /** sets the LP state for the current probing node
6425  *
6426  * @note state and norms are stored at the node and later released by SCIP; therefore, the pointers are set
6427  * to NULL by the method
6428  *
6429  * @note the pointers to state and norms must not be NULL; however, they may point to a NULL pointer if the
6430  * respective information should not be set
6431  */
6433  SCIP_TREE* tree, /**< branch and bound tree */
6434  BMS_BLKMEM* blkmem, /**< block memory */
6435  SCIP_LP* lp, /**< current LP data */
6436  SCIP_LPISTATE** lpistate, /**< pointer to LP state information (like basis information) */
6437  SCIP_LPINORMS** lpinorms, /**< pointer to LP pricing norms information */
6438  SCIP_Bool primalfeas, /**< primal feasibility when LP state information was stored */
6439  SCIP_Bool dualfeas /**< dual feasibility when LP state information was stored */
6440  )
6441 {
6442  SCIP_NODE* node;
6443 
6444  assert(tree != NULL);
6445  assert(SCIPtreeProbing(tree));
6446  assert(lpistate != NULL);
6447  assert(lpinorms != NULL);
6448 
6449  /* get the current probing node */
6450  node = SCIPtreeGetCurrentNode(tree);
6451 
6452  /* this check is necessary to avoid cppcheck warnings */
6453  if( node == NULL )
6454  return SCIP_INVALIDDATA;
6455 
6456  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6457  assert(node->data.probingnode != NULL);
6458 
6459  /* free already present LP state */
6460  if( node->data.probingnode->lpistate != NULL )
6461  {
6462  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &(node->data.probingnode->lpistate)) );
6463  }
6464 
6465  /* free already present LP pricing norms */
6466  if( node->data.probingnode->lpinorms != NULL )
6467  {
6468  SCIP_CALL( SCIPlpFreeNorms(lp, blkmem, &(node->data.probingnode->lpinorms)) );
6469  }
6470 
6471  node->data.probingnode->lpistate = *lpistate;
6472  node->data.probingnode->lpinorms = *lpinorms;
6473  node->data.probingnode->lpwasprimfeas = primalfeas;
6474  node->data.probingnode->lpwasdualfeas = dualfeas;
6475 
6476  /* set the pointers to NULL to avoid that they are still used and modified by the caller */
6477  *lpistate = NULL;
6478  *lpinorms = NULL;
6479 
6480  tree->probingloadlpistate = TRUE;
6481 
6482  return SCIP_OKAY;
6483 }
6484 
6485 /** loads the LP state for the current probing node */
6487  SCIP_TREE* tree, /**< branch and bound tree */
6488  BMS_BLKMEM* blkmem, /**< block memory buffers */
6489  SCIP_SET* set, /**< global SCIP settings */
6490  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6491  SCIP_LP* lp /**< current LP data */
6492  )
6493 {
6494  assert(tree != NULL);
6495  assert(SCIPtreeProbing(tree));
6496 
6497  /* loading the LP state is only necessary if we backtracked */
6498  if( tree->probingloadlpistate )
6499  {
6500  SCIP_NODE* node;
6501  SCIP_LPISTATE* lpistate;
6502  SCIP_LPINORMS* lpinorms;
6503  SCIP_Bool lpwasprimfeas = FALSE;
6504  SCIP_Bool lpwasprimchecked = FALSE;
6505  SCIP_Bool lpwasdualfeas = FALSE;
6506  SCIP_Bool lpwasdualchecked = FALSE;
6507 
6508  /* get the current probing node */
6509  node = SCIPtreeGetCurrentNode(tree);
6510  assert(node != NULL);
6511  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6512 
6513  /* search the last node where an LP state information was attached */
6514  lpistate = NULL;
6515  lpinorms = NULL;
6516  do
6517  {
6518  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6519  assert(node->data.probingnode != NULL);
6520  if( node->data.probingnode->lpistate != NULL )
6521  {
6522  lpistate = node->data.probingnode->lpistate;
6523  lpinorms = node->data.probingnode->lpinorms;
6524  lpwasprimfeas = node->data.probingnode->lpwasprimfeas;
6525  lpwasprimchecked = node->data.probingnode->lpwasprimchecked;
6526  lpwasdualfeas = node->data.probingnode->lpwasdualfeas;
6527  lpwasdualchecked = node->data.probingnode->lpwasdualchecked;
6528  break;
6529  }
6530  node = node->parent;
6531  assert(node != NULL); /* the root node cannot be a probing node! */
6532  }
6533  while( SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE );
6534 
6535  /* if there was no LP information stored in the probing nodes, use the one stored before probing started */
6536  if( lpistate == NULL )
6537  {
6538  lpistate = tree->probinglpistate;
6539  lpinorms = tree->probinglpinorms;
6540  lpwasprimfeas = tree->probinglpwasprimfeas;
6541  lpwasprimchecked = tree->probinglpwasprimchecked;
6542  lpwasdualfeas = tree->probinglpwasdualfeas;
6543  lpwasdualchecked = tree->probinglpwasdualchecked;
6544  }
6545 
6546  /* set the LP state */
6547  if( lpistate != NULL )
6548  {
6549  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, lpistate,
6550  lpwasprimfeas, lpwasprimchecked, lpwasdualfeas, lpwasdualchecked) );
6551  }
6552 
6553  /* set the LP pricing norms */
6554  if( lpinorms != NULL )
6555  {
6556  SCIP_CALL( SCIPlpSetNorms(lp, blkmem, lpinorms) );
6557  }
6558 
6559  /* now we don't need to load the LP state again until the next backtracking */
6560  tree->probingloadlpistate = FALSE;
6561  }
6562 
6563  return SCIP_OKAY;
6564 }
6565 
6566 /** marks the probing node to have a solved LP relaxation */
6568  SCIP_TREE* tree, /**< branch and bound tree */
6569  BMS_BLKMEM* blkmem, /**< block memory */
6570  SCIP_LP* lp /**< current LP data */
6571  )
6572 {
6573  SCIP_NODE* node;
6574 
6575  assert(tree != NULL);
6576  assert(SCIPtreeProbing(tree));
6577 
6578  /* mark the probing node to have an LP */
6579  tree->probingnodehaslp = TRUE;
6580 
6581  /* get current probing node */
6582  node = SCIPtreeGetCurrentNode(tree);
6583  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6584  assert(node != NULL && node->data.probingnode != NULL);
6585 
6586  /* update LP information in probingnode data */
6587  /* cppcheck-suppress nullPointer */
6588  SCIP_CALL( probingnodeUpdate(node->data.probingnode, blkmem, tree, lp) );
6589 
6590  return SCIP_OKAY;
6591 }
6592 
6593 /** undoes all changes to the problem applied in probing up to the given probing depth */
6594 static
6596  SCIP_TREE* tree, /**< branch and bound tree */
6597  SCIP_REOPT* reopt, /**< reoptimization data structure */
6598  BMS_BLKMEM* blkmem, /**< block memory buffers */
6599  SCIP_SET* set, /**< global SCIP settings */
6600  SCIP_STAT* stat, /**< problem statistics */
6601  SCIP_PROB* transprob, /**< transformed problem after presolve */
6602  SCIP_PROB* origprob, /**< original problem */
6603  SCIP_LP* lp, /**< current LP data */
6604  SCIP_PRIMAL* primal, /**< primal data structure */
6605  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6606  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6607  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
6608  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
6609  int probingdepth /**< probing depth of the node in the probing path that should be reactivated,
6610  * -1 to even deactivate the probing root, thus exiting probing mode */
6611  )
6612 {
6613  int newpathlen;
6614  int i;
6615 
6616  assert(tree != NULL);
6617  assert(SCIPtreeProbing(tree));
6618  assert(tree->probingroot != NULL);
6619  assert(tree->focusnode != NULL);
6623  assert(tree->probingroot->parent == tree->focusnode);
6624  assert(SCIPnodeGetDepth(tree->probingroot) == SCIPnodeGetDepth(tree->focusnode)+1);
6625  assert(tree->pathlen >= 2);
6626  assert(SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_PROBINGNODE);
6627  assert(-1 <= probingdepth && probingdepth <= SCIPtreeGetProbingDepth(tree));
6628 
6629  treeCheckPath(tree);
6630 
6631  newpathlen = SCIPnodeGetDepth(tree->probingroot) + probingdepth + 1;
6632  assert(newpathlen >= 1); /* at least root node of the tree remains active */
6633 
6634  /* check if we have to do any backtracking */
6635  if( newpathlen < tree->pathlen )
6636  {
6637  int ncols;
6638  int nrows;
6639 
6640  /* the correct LP size of the node to which we backtracked is stored as initial LP size for its child */
6641  assert(SCIPnodeGetType(tree->path[newpathlen]) == SCIP_NODETYPE_PROBINGNODE);
6642  ncols = tree->path[newpathlen]->data.probingnode->ninitialcols;
6643  nrows = tree->path[newpathlen]->data.probingnode->ninitialrows;
6644  assert(ncols >= tree->pathnlpcols[newpathlen-1] || !tree->focuslpconstructed);
6645  assert(nrows >= tree->pathnlprows[newpathlen-1] || !tree->focuslpconstructed);
6646 
6647  while( tree->pathlen > newpathlen )
6648  {
6649  SCIP_NODE* node;
6650 
6651  node = tree->path[tree->pathlen-1];
6652 
6653  assert(SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE);
6654  assert(tree->pathlen-1 == SCIPnodeGetDepth(node));
6655  assert(tree->pathlen-1 >= SCIPnodeGetDepth(tree->probingroot));
6656 
6657  if( node->data.probingnode->nchgdobjs > 0 )
6658  {
6659  /* @todo only do this if we don't backtrack to the root node - in that case, we can just restore the unchanged
6660  * objective values
6661  */
6662  for( i = node->data.probingnode->nchgdobjs - 1; i >= 0; --i )
6663  {
6664  assert(tree->probingobjchanged);
6665 
6666  SCIP_CALL( SCIPvarChgObj(node->data.probingnode->origobjvars[i], blkmem, set, transprob, primal, lp,
6667  eventqueue, node->data.probingnode->origobjvals[i]) );
6668  }
6669  tree->probingsumchgdobjs -= node->data.probingnode->nchgdobjs;
6670  assert(tree->probingsumchgdobjs >= 0);
6671 
6672  /* reset probingobjchanged flag and cutoff bound */
6673  if( tree->probingsumchgdobjs == 0 )
6674  {
6676  tree->probingobjchanged = FALSE;
6677 
6678  SCIP_CALL( SCIPlpSetCutoffbound(lp, set, transprob, primal->cutoffbound) );
6679  }
6680 
6681  /* recompute global and local pseudo objective values */
6682  SCIPlpRecomputeLocalAndGlobalPseudoObjval(lp, set, transprob);
6683  }
6684 
6685  /* undo bound changes by deactivating the probing node */
6686  SCIP_CALL( nodeDeactivate(node, blkmem, set, stat, tree, lp, branchcand, eventqueue) );
6687 
6688  /* free the probing node */
6689  SCIP_CALL( SCIPnodeFree(&tree->path[tree->pathlen-1], blkmem, set, stat, eventqueue, tree, lp) );
6690  tree->pathlen--;
6691  }
6692  assert(tree->pathlen == newpathlen);
6693 
6694  /* reset the path LP size to the initial size of the probing node */
6695  if( SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_PROBINGNODE )
6696  {
6697  tree->pathnlpcols[tree->pathlen-1] = tree->path[tree->pathlen-1]->data.probingnode->ninitialcols;
6698  tree->pathnlprows[tree->pathlen-1] = tree->path[tree->pathlen-1]->data.probingnode->ninitialrows;
6699  }
6700  else
6701  assert(SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_FOCUSNODE);
6702  treeCheckPath(tree);
6703 
6704  /* undo LP extensions */
6705  SCIP_CALL( SCIPlpShrinkCols(lp, set, ncols) );
6706  SCIP_CALL( SCIPlpShrinkRows(lp, blkmem, set, eventqueue, eventfilter, nrows) );
6707  tree->probingloadlpistate = TRUE; /* LP state must be reloaded if the next LP is solved */
6708 
6709  /* reset the LP's marked size to the initial size of the LP at the node stored in the path */
6710  assert(lp->nrows >= tree->pathnlprows[tree->pathlen-1] || !tree->focuslpconstructed);
6711  assert(lp->ncols >= tree->pathnlpcols[tree->pathlen-1] || !tree->focuslpconstructed);
6712  SCIPlpSetSizeMark(lp, tree->pathnlprows[tree->pathlen-1], tree->pathnlpcols[tree->pathlen-1]);
6713 
6714  /* if the highest cutoff or repropagation depth is inside the deleted part of the probing path,
6715  * reset them to infinity
6716  */
6717  if( tree->cutoffdepth >= tree->pathlen )
6718  {
6719  /* apply the pending bound changes */
6720  SCIP_CALL( treeApplyPendingBdchgs(tree, reopt, blkmem, set, stat, transprob, origprob, lp, branchcand, eventqueue, cliquetable) );
6721 
6722  /* applying the pending bound changes might have changed the cutoff depth; so the highest cutoff depth might
6723  * be outside of the deleted part of the probing path now
6724  */
6725  if( tree->cutoffdepth >= tree->pathlen )
6726  tree->cutoffdepth = INT_MAX;
6727  }
6728  if( tree->repropdepth >= tree->pathlen )
6729  tree->repropdepth = INT_MAX;
6730  }
6731 
6732  SCIPsetDebugMsg(set, "probing backtracked to depth %d (%d cols, %d rows)\n", tree->pathlen-1, SCIPlpGetNCols(lp), SCIPlpGetNRows(lp));
6733 
6734  return SCIP_OKAY;
6735 }
6736 
6737 /** undoes all changes to the problem applied in probing up to the given probing depth;
6738  * the changes of the probing node of the given probing depth are the last ones that remain active;
6739  * changes that were applied before calling SCIPtreeCreateProbingNode() cannot be undone
6740  */
6742  SCIP_TREE* tree, /**< branch and bound tree */
6743  SCIP_REOPT* reopt, /**< reoptimization data structure */
6744  BMS_BLKMEM* blkmem, /**< block memory buffers */
6745  SCIP_SET* set, /**< global SCIP settings */
6746  SCIP_STAT* stat, /**< problem statistics */
6747  SCIP_PROB* transprob, /**< transformed problem */
6748  SCIP_PROB* origprob, /**< original problem */
6749  SCIP_LP* lp, /**< current LP data */
6750  SCIP_PRIMAL* primal, /**< primal data structure */
6751  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6752  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6753  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
6754  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
6755  int probingdepth /**< probing depth of the node in the probing path that should be reactivated */
6756  )
6757 {
6758  assert(tree != NULL);
6759  assert(SCIPtreeProbing(tree));
6760  assert(0 <= probingdepth && probingdepth <= SCIPtreeGetProbingDepth(tree));
6761 
6762  /* undo the domain and constraint set changes and free the temporary probing nodes below the given probing depth */
6763  SCIP_CALL( treeBacktrackProbing(tree, reopt, blkmem, set, stat, transprob, origprob, lp, primal, branchcand,
6764  eventqueue, eventfilter, cliquetable, probingdepth) );
6765 
6766  assert(SCIPtreeProbing(tree));
6768 
6769  return SCIP_OKAY;
6770 }
6771 
6772 /** switches back from probing to normal operation mode, frees all nodes on the probing path, restores bounds of all
6773  * variables and restores active constraints arrays of focus node
6774  */
6776  SCIP_TREE* tree, /**< branch and bound tree */
6777  SCIP_REOPT* reopt, /**< reoptimization data structure */
6778  BMS_BLKMEM* blkmem, /**< block memory buffers */
6779  SCIP_SET* set, /**< global SCIP settings */
6780  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
6781  SCIP_STAT* stat, /**< problem statistics */
6782  SCIP_PROB* transprob, /**< transformed problem after presolve */
6783  SCIP_PROB* origprob, /**< original problem */
6784  SCIP_LP* lp, /**< current LP data */
6785  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6786  SCIP_PRIMAL* primal, /**< Primal LP data */
6787  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
6788  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
6789  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
6790  SCIP_CLIQUETABLE* cliquetable /**< clique table data structure */
6791  )
6792 {
6793  assert(tree != NULL);
6794  assert(SCIPtreeProbing(tree));
6795  assert(tree->probingroot != NULL);
6796  assert(tree->focusnode != NULL);
6800  assert(tree->probingroot->parent == tree->focusnode);
6801  assert(SCIPnodeGetDepth(tree->probingroot) == SCIPnodeGetDepth(tree->focusnode)+1);
6802  assert(tree->pathlen >= 2);
6803  assert(SCIPnodeGetType(tree->path[tree->pathlen-1]) == SCIP_NODETYPE_PROBINGNODE);
6804  assert(set != NULL);
6805 
6806  /* undo the domain and constraint set changes of the temporary probing nodes and free the probing nodes */
6807  SCIP_CALL( treeBacktrackProbing(tree, reopt, blkmem, set, stat, transprob, origprob, lp, primal, branchcand,
6808  eventqueue, eventfilter, cliquetable, -1) );
6809  assert(tree->probingsumchgdobjs == 0);
6810  assert(!tree->probingobjchanged);
6811  assert(!lp->divingobjchg);
6812  assert(lp->cutoffbound == primal->cutoffbound); /*lint !e777*/
6813  assert(SCIPtreeGetCurrentNode(tree) == tree->focusnode);
6814  assert(!SCIPtreeProbing(tree));
6815 
6816  /* if the LP was flushed before probing starts, flush it again */
6817  if( tree->probinglpwasflushed )
6818  {
6819  SCIP_CALL( SCIPlpFlush(lp, blkmem, set, eventqueue) );
6820 
6821  /* if the LP was solved before probing starts, solve it again to restore the LP solution */
6822  if( tree->probinglpwassolved )
6823  {
6824  SCIP_Bool lperror;
6825 
6826  /* reset the LP state before probing started */
6827  if( tree->probinglpistate == NULL )
6828  {
6829  assert(tree->probinglpinorms == NULL);
6831  lp->primalfeasible = (lp->nlpicols == 0 && lp->nlpirows == 0);
6832  lp->primalchecked = (lp->nlpicols == 0 && lp->nlpirows == 0);
6833  lp->dualfeasible = (lp->nlpicols == 0 && lp->nlpirows == 0);
6834  lp->dualchecked = (lp->nlpicols == 0 && lp->nlpirows == 0);
6835  lp->solisbasic = FALSE;
6836  }
6837  else
6838  {
6839  SCIP_CALL( SCIPlpSetState(lp, blkmem, set, eventqueue, tree->probinglpistate,
6841  tree->probinglpwasdualchecked) );
6842  SCIP_CALL( SCIPlpFreeState(lp, blkmem, &tree->probinglpistate) );
6843 
6844  if( tree->probinglpinorms != NULL )
6845  {
6846  SCIP_CALL( SCIPlpSetNorms(lp, blkmem, tree->probinglpinorms) );
6847  SCIP_CALL( SCIPlpFreeNorms(lp, blkmem, &tree->probinglpinorms) );
6848  tree->probinglpinorms = NULL;
6849  }
6850  }
6852 
6853  /* resolve LP to reset solution */
6854  SCIP_CALL( SCIPlpSolveAndEval(lp, set, messagehdlr, blkmem, stat, eventqueue, eventfilter, transprob, -1LL, FALSE, FALSE, FALSE, &lperror) );
6855  if( lperror )
6856  {
6857  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
6858  "(node %" SCIP_LONGINT_FORMAT ") unresolved numerical troubles while resolving LP %" SCIP_LONGINT_FORMAT " after probing\n",
6859  stat->nnodes, stat->nlps);
6860  lp->resolvelperror = TRUE;
6861  tree->focusnodehaslp = FALSE;
6862  }
6863  else if( SCIPlpGetSolstat(lp) != SCIP_LPSOLSTAT_OPTIMAL
6867  {
6868  SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_FULL,
6869  "LP was not resolved to a sufficient status after probing\n");
6870  lp->resolvelperror = TRUE;
6871  tree->focusnodehaslp = FALSE;
6872  }
6873  else if( tree->focuslpconstructed && SCIPlpIsRelax(lp) && SCIPprobAllColsInLP(transprob, set, lp))
6874  {
6875  SCIP_CALL( SCIPnodeUpdateLowerboundLP(tree->focusnode, set, stat, tree, transprob, origprob, lp) );
6876  }
6877  }
6878  }
6879  else
6880  lp->flushed = FALSE;
6881 
6882  assert(tree->probinglpistate == NULL);
6883 
6884  /* if no LP was solved during probing and the LP before probing was not solved, then it should not be solved now */
6885  assert(tree->probingsolvedlp || tree->probinglpwassolved || !lp->solved);
6886 
6887  /* if the LP was solved (and hence flushed) before probing, then lp->solved should be TRUE unless we occured an error
6888  * during resolving right above
6889  */
6890  assert(!tree->probinglpwassolved || lp->solved || lp->resolvelperror);
6891 
6892  /* if the LP was not solved before probing it should be marked unsolved now; this can occur if a probing LP was
6893  * solved in between
6894  */
6895  if( !tree->probinglpwassolved )
6896  {
6897  lp->solved = FALSE;
6899  }
6900 
6901  /* if the LP was solved during probing, but had been unsolved before probing started, we discard the LP state */
6902  if( set->lp_clearinitialprobinglp && tree->probingsolvedlp && !tree->probinglpwassolved )
6903  {
6904  SCIPsetDebugMsg(set, "clearing lp state at end of probing mode because LP was initially unsolved\n");
6906  }
6907 
6908  /* if a relaxation was stored before probing, restore it now */
6909  if( tree->probdiverelaxstored )
6910  {
6911  SCIP_CALL( SCIPtreeRestoreRelaxSol(tree, set, relaxation, transprob) );
6912  }
6913 
6914  assert(tree->probingobjchanged == SCIPlpDivingObjChanged(lp));
6915 
6916  /* reset flags */
6917  tree->probinglpwasflushed = FALSE;
6918  tree->probinglpwassolved = FALSE;
6919  tree->probingloadlpistate = FALSE;
6920  tree->probinglpwasrelax = FALSE;
6921  tree->probingsolvedlp = FALSE;
6922  tree->sbprobing = FALSE;
6923 
6924  /* inform LP about end of probing mode */
6925  SCIP_CALL( SCIPlpEndProbing(lp) );
6926 
6927  /* reset all marked constraints for propagation */
6928  SCIP_CALL( SCIPconshdlrsResetPropagationStatus(set, blkmem, set->conshdlrs, set->nconshdlrs) );
6929 
6930  SCIPsetDebugMsg(set, "probing ended in depth %d (LP flushed: %u, solstat: %d)\n", tree->pathlen-1, lp->flushed, SCIPlpGetSolstat(lp));
6931 
6932  return SCIP_OKAY;
6933 }
6934 
6935 /** stores relaxation solution before diving or probing */
6937  SCIP_TREE* tree, /**< branch and bound tree */
6938  SCIP_SET* set, /**< global SCIP settings */
6939  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6940  SCIP_PROB* transprob /**< transformed problem after presolve */
6941  )
6942 {
6943  SCIP_VAR** vars;
6944  int nvars;
6945  int v;
6946 
6947  assert(tree != NULL);
6948  assert(set != NULL);
6949  assert(relaxation != NULL);
6950  assert(transprob != NULL);
6951  assert(SCIPrelaxationIsSolValid(relaxation));
6952 
6953  nvars = transprob->nvars;
6954  vars = transprob->vars;
6955 
6956  /* check if memory still needs to be allocated */
6957  if( tree->probdiverelaxsol == NULL )
6958  {
6959  SCIP_ALLOC( BMSallocMemoryArray(&(tree->probdiverelaxsol), nvars) );
6960  }
6961 
6962  /* iterate over all variables to save the relaxation solution */
6963  for( v = 0; v < nvars; ++v )
6964  tree->probdiverelaxsol[v] = SCIPvarGetRelaxSol(vars[v], set);
6965 
6966  tree->probdiverelaxstored = TRUE;
6968 
6969  return SCIP_OKAY;
6970 }
6971 
6972 /** restores relaxation solution after diving or probing */
6974  SCIP_TREE* tree, /**< branch and bound tree */
6975  SCIP_SET* set, /**< global SCIP settings */
6976  SCIP_RELAXATION* relaxation, /**< global relaxation data */
6977  SCIP_PROB* transprob /**< transformed problem after presolve */
6978  )
6979 {
6980  SCIP_VAR** vars;
6981  int nvars;
6982  int v;
6983 
6984  assert(tree != NULL);
6985  assert(set != NULL);
6986  assert(tree->probdiverelaxstored);
6987  assert(tree->probdiverelaxsol != NULL);
6988 
6989  nvars = transprob->nvars;
6990  vars = transprob->vars;
6991 
6992  /* iterate over all variables to restore the relaxation solution */
6993  for( v = 0; v < nvars; ++v )
6994  {
6995  SCIP_CALL( SCIPvarSetRelaxSol(vars[v], set, relaxation, tree->probdiverelaxsol[v], TRUE) );
6996  }
6997 
6998  tree->probdiverelaxstored = FALSE;
7000 
7001  return SCIP_OKAY;
7002 }
7003 
7004 /** gets the best child of the focus node w.r.t. the node selection priority assigned by the branching rule */
7006  SCIP_TREE* tree /**< branch and bound tree */
7007  )
7008 {
7009  SCIP_NODE* bestnode;
7010  SCIP_Real bestprio;
7011  int i;
7012 
7013  assert(tree != NULL);
7014 
7015  bestnode = NULL;
7016  bestprio = SCIP_REAL_MIN;
7017  for( i = 0; i < tree->nchildren; ++i )
7018  {
7019  if( tree->childrenprio[i] > bestprio )
7020  {
7021  bestnode = tree->children[i];
7022  bestprio = tree->childrenprio[i];
7023  }
7024  }
7025  assert((tree->nchildren == 0) == (bestnode == NULL));
7026 
7027  return bestnode;
7028 }
7029 
7030 /** gets the best sibling of the focus node w.r.t. the node selection priority assigned by the branching rule */
7032  SCIP_TREE* tree /**< branch and bound tree */
7033  )
7034 {
7035  SCIP_NODE* bestnode;
7036  SCIP_Real bestprio;
7037  int i;
7038 
7039  assert(tree != NULL);
7040 
7041  bestnode = NULL;
7042  bestprio = SCIP_REAL_MIN;
7043  for( i = 0; i < tree->nsiblings; ++i )
7044  {
7045  if( tree->siblingsprio[i] > bestprio )
7046  {
7047  bestnode = tree->siblings[i];
7048  bestprio = tree->siblingsprio[i];
7049  }
7050  }
7051  assert((tree->nsiblings == 0) == (bestnode == NULL));
7052 
7053  return bestnode;
7054 }
7055 
7056 /** gets the best child of the focus node w.r.t. the node selection strategy */
7058  SCIP_TREE* tree, /**< branch and bound tree */
7059  SCIP_SET* set /**< global SCIP settings */
7060  )
7061 {
7062  SCIP_NODESEL* nodesel;
7063  SCIP_NODE* bestnode;
7064  int i;
7065 
7066  assert(tree != NULL);
7067 
7068  nodesel = SCIPnodepqGetNodesel(tree->leaves);
7069  assert(nodesel != NULL);
7070 
7071  bestnode = NULL;
7072  for( i = 0; i < tree->nchildren; ++i )
7073  {
7074  if( bestnode == NULL || SCIPnodeselCompare(nodesel, set, tree->children[i], bestnode) < 0 )
7075  {
7076  bestnode = tree->children[i];
7077  }
7078  }
7079 
7080  return bestnode;
7081 }
7082 
7083 /** gets the best sibling of the focus node w.r.t. the node selection strategy */
7085  SCIP_TREE* tree, /**< branch and bound tree */
7086  SCIP_SET* set /**< global SCIP settings */
7087  )
7088 {
7089  SCIP_NODESEL* nodesel;
7090  SCIP_NODE* bestnode;
7091  int i;
7092 
7093  assert(tree != NULL);
7094 
7095  nodesel = SCIPnodepqGetNodesel(tree->leaves);
7096  assert(nodesel != NULL);
7097 
7098  bestnode = NULL;
7099  for( i = 0; i < tree->nsiblings; ++i )
7100  {
7101  if( bestnode == NULL || SCIPnodeselCompare(nodesel, set, tree->siblings[i], bestnode) < 0 )
7102  {
7103  bestnode = tree->siblings[i];
7104  }
7105  }
7106 
7107  return bestnode;
7108 }
7109 
7110 /** gets the best leaf from the node queue w.r.t. the node selection strategy */
7112  SCIP_TREE* tree /**< branch and bound tree */
7113  )
7114 {
7115  assert(tree != NULL);
7116 
7117  return SCIPnodepqFirst(tree->leaves);
7118 }
7119 
7120 /** gets the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy */
7122  SCIP_TREE* tree, /**< branch and bound tree */
7123  SCIP_SET* set /**< global SCIP settings */
7124  )
7125 {
7126  SCIP_NODESEL* nodesel;
7127  SCIP_NODE* bestchild;
7128  SCIP_NODE* bestsibling;
7129  SCIP_NODE* bestleaf;
7130  SCIP_NODE* bestnode;
7131 
7132  assert(tree != NULL);
7133 
7134  nodesel = SCIPnodepqGetNodesel(tree->leaves);
7135  assert(nodesel != NULL);
7136 
7137  /* get the best child, sibling, and leaf */
7138  bestchild = SCIPtreeGetBestChild(tree, set);
7139  bestsibling = SCIPtreeGetBestSibling(tree, set);
7140  bestleaf = SCIPtreeGetBestLeaf(tree);
7141 
7142  /* return the best of the three */
7143  bestnode = bestchild;
7144  if( bestsibling != NULL && (bestnode == NULL || SCIPnodeselCompare(nodesel, set, bestsibling, bestnode) < 0) )
7145  bestnode = bestsibling;
7146  if( bestleaf != NULL && (bestnode == NULL || SCIPnodeselCompare(nodesel, set, bestleaf, bestnode) < 0) )
7147  bestnode = bestleaf;
7148 
7149  assert(SCIPtreeGetNLeaves(tree) == 0 || bestnode != NULL);
7150 
7151  return bestnode;
7152 }
7153 
7154 /** gets the minimal lower bound of all nodes in the tree */
7156  SCIP_TREE* tree, /**< branch and bound tree */
7157  SCIP_SET* set /**< global SCIP settings */
7158  )
7159 {
7160  SCIP_Real lowerbound;
7161  int i;
7162 
7163  assert(tree != NULL);
7164  assert(set != NULL);
7165 
7166  /* get the lower bound from the queue */
7167  lowerbound = SCIPnodepqGetLowerbound(tree->leaves, set);
7168 
7169  /* compare lower bound with children */
7170  for( i = 0; i < tree->nchildren; ++i )
7171  {
7172  assert(tree->children[i] != NULL);
7173  lowerbound = MIN(lowerbound, tree->children[i]->lowerbound);
7174  }
7175 
7176  /* compare lower bound with siblings */
7177  for( i = 0; i < tree->nsiblings; ++i )
7178  {
7179  assert(tree->siblings[i] != NULL);
7180  lowerbound = MIN(lowerbound, tree->siblings[i]->lowerbound);
7181  }
7182 
7183  /* compare lower bound with focus node */
7184  if( tree->focusnode != NULL )
7185  {
7186  lowerbound = MIN(lowerbound, tree->focusnode->lowerbound);
7187  }
7188 
7189  return lowerbound;
7190 }
7191 
7192 /** gets the node with minimal lower bound of all nodes in the tree (child, sibling, or leaf) */
7194  SCIP_TREE* tree, /**< branch and bound tree */
7195  SCIP_SET* set /**< global SCIP settings */
7196  )
7197 {
7198  SCIP_NODE* lowerboundnode;
7199  SCIP_Real lowerbound;
7200  SCIP_Real bestprio;
7201  int i;
7202 
7203  assert(tree != NULL);
7204  assert(set != NULL);
7205 
7206  /* get the lower bound from the queue */
7207  lowerboundnode = SCIPnodepqGetLowerboundNode(tree->leaves, set);
7208  lowerbound = lowerboundnode != NULL ? lowerboundnode->lowerbound : SCIPsetInfinity(set);
7209  bestprio = -SCIPsetInfinity(set);
7210 
7211  /* compare lower bound with children */
7212  for( i = 0; i < tree->nchildren; ++i )
7213  {
7214  assert(tree->children[i] != NULL);
7215  if( SCIPsetIsLE(set, tree->children[i]->lowerbound, lowerbound) )
7216  {
7217  if( SCIPsetIsLT(set, tree->children[i]->lowerbound, lowerbound) || tree->childrenprio[i] > bestprio )
7218  {
7219  lowerboundnode = tree->children[i];
7220  lowerbound = lowerboundnode->lowerbound;
7221  bestprio = tree->childrenprio[i];
7222  }
7223  }
7224  }
7225 
7226  /* compare lower bound with siblings */
7227  for( i = 0; i < tree->nsiblings; ++i )
7228  {
7229  assert(tree->siblings[i] != NULL);
7230  if( SCIPsetIsLE(set, tree->siblings[i]->lowerbound, lowerbound) )
7231  {
7232  if( SCIPsetIsLT(set, tree->siblings[i]->lowerbound, lowerbound) || tree->siblingsprio[i] > bestprio )
7233  {
7234  lowerboundnode = tree->siblings[i];
7235  lowerbound = lowerboundnode->lowerbound;
7236  bestprio = tree->siblingsprio[i];
7237  }
7238  }
7239  }
7240 
7241  return lowerboundnode;
7242 }
7243 
7244 /** gets the average lower bound of all nodes in the tree */
7246  SCIP_TREE* tree, /**< branch and bound tree */
7247  SCIP_Real cutoffbound /**< global cutoff bound */
7248  )
7249 {
7250  SCIP_Real lowerboundsum;
7251  int nnodes;
7252  int i;
7253 
7254  assert(tree != NULL);
7255 
7256  /* get sum of lower bounds from nodes in the queue */
7257  lowerboundsum = SCIPnodepqGetLowerboundSum(tree->leaves);
7258  nnodes = SCIPtreeGetNLeaves(tree);
7259 
7260  /* add lower bound of focus node */
7261  if( tree->focusnode != NULL && tree->focusnode->lowerbound < cutoffbound )
7262  {
7263  lowerboundsum += tree->focusnode->lowerbound;
7264  nnodes++;
7265  }
7266 
7267  /* add lower bounds of siblings */
7268  for( i = 0; i < tree->nsiblings; ++i )
7269  {
7270  assert(tree->siblings[i] != NULL);
7271  lowerboundsum += tree->siblings[i]->lowerbound;
7272  }
7273  nnodes += tree->nsiblings;
7274 
7275  /* add lower bounds of children */
7276  for( i = 0; i < tree->nchildren; ++i )
7277  {
7278  assert(tree->children[i] != NULL);
7279  lowerboundsum += tree->children[i]->lowerbound;
7280  }
7281  nnodes += tree->nchildren;
7282 
7283  return nnodes == 0 ? 0.0 : lowerboundsum/nnodes;
7284 }
7285 
7286 
7287 
7288 
7289 /*
7290  * simple functions implemented as defines
7291  */
7292 
7293 /* In debug mode, the following methods are implemented as function calls to ensure
7294  * type validity.
7295  * In optimized mode, the methods are implemented as defines to improve performance.
7296  * However, we want to have them in the library anyways, so we have to undef the defines.
7297  */
7298 
7299 #undef SCIPnodeGetType
7300 #undef SCIPnodeGetNumber
7301 #undef SCIPnodeGetDepth
7302 #undef SCIPnodeGetLowerbound
7303 #undef SCIPnodeGetEstimate
7304 #undef SCIPnodeGetDomchg
7305 #undef SCIPnodeGetParent
7306 #undef SCIPnodeGetConssetchg
7307 #undef SCIPnodeIsActive
7308 #undef SCIPnodeIsPropagatedAgain
7309 #undef SCIPtreeGetNLeaves
7310 #undef SCIPtreeGetNChildren
7311 #undef SCIPtreeGetNSiblings
7312 #undef SCIPtreeGetNNodes
7313 #undef SCIPtreeIsPathComplete
7314 #undef SCIPtreeProbing
7315 #undef SCIPtreeGetProbingRoot
7316 #undef SCIPtreeGetProbingDepth
7317 #undef SCIPtreeGetFocusNode
7318 #undef SCIPtreeGetFocusDepth
7319 #undef SCIPtreeHasFocusNodeLP
7320 #undef SCIPtreeSetFocusNodeLP
7321 #undef SCIPtreeIsFocusNodeLPConstructed
7322 #undef SCIPtreeInRepropagation
7323 #undef SCIPtreeGetCurrentNode
7324 #undef SCIPtreeGetCurrentDepth
7325 #undef SCIPtreeHasCurrentNodeLP
7326 #undef SCIPtreeGetEffectiveRootDepth
7327 #undef SCIPtreeGetRootNode
7328 #undef SCIPtreeProbingObjChanged
7329 #undef SCIPtreeMarkProbingObjChanged
7330 
7331 /** gets the type of the node */
7333  SCIP_NODE* node /**< node */
7334  )
7335 {
7336  assert(node != NULL);
7337 
7338  return (SCIP_NODETYPE)(node->nodetype);
7339 }
7340 
7341 /** gets successively assigned number of the node */
7343  SCIP_NODE* node /**< node */
7344  )
7345 {
7346  assert(node != NULL);
7347 
7348  return node->number;
7349 }
7350 
7351 /** gets the depth of the node */
7353  SCIP_NODE* node /**< node */
7354  )
7355 {
7356  assert(node != NULL);
7357 
7358  return (int) node->depth;
7359 }
7360 
7361 /** gets the lower bound of the node */
7363  SCIP_NODE* node /**< node */
7364  )
7365 {
7366  assert(node != NULL);
7367 
7368  return node->lowerbound;
7369 }
7370 
7371 /** gets the estimated value of the best feasible solution in subtree of the node */
7373  SCIP_NODE* node /**< node */
7374  )
7375 {
7376  assert(node != NULL);
7377 
7378  return node->estimate;
7379 }
7380 
7381 /** gets the reoptimization type of this node */
7383  SCIP_NODE* node /**< node */
7384  )
7385 {
7386  assert(node != NULL);
7387 
7388  return (SCIP_REOPTTYPE)node->reopttype;
7389 }
7390 
7391 /** sets the reoptimization type of this node */
7393  SCIP_NODE* node, /**< node */
7394  SCIP_REOPTTYPE reopttype /**< reoptimization type */
7395  )
7396 {
7397  assert(node != NULL);
7398  assert(reopttype == SCIP_REOPTTYPE_NONE
7399  || reopttype == SCIP_REOPTTYPE_TRANSIT
7400  || reopttype == SCIP_REOPTTYPE_INFSUBTREE
7401  || reopttype == SCIP_REOPTTYPE_STRBRANCHED
7402  || reopttype == SCIP_REOPTTYPE_LOGICORNODE
7403  || reopttype == SCIP_REOPTTYPE_LEAF
7404  || reopttype == SCIP_REOPTTYPE_PRUNED
7405  || reopttype == SCIP_REOPTTYPE_FEASIBLE);
7406 
7407  node->reopttype = (unsigned int) reopttype;
7408 }
7409 
7410 /** gets the unique id to identify the node during reoptimization; the id is 0 if the node is the root or not part of
7411  * the reoptimization tree
7412  */
7413 unsigned int SCIPnodeGetReoptID(
7414  SCIP_NODE* node /**< node */
7415  )
7416 {
7417  assert(node != NULL);
7418 
7419  return node->reoptid; /*lint !e732*/
7420 }
7421 
7422 /** set a unique id to identify the node during reoptimization */
7424  SCIP_NODE* node, /**< node */
7425  unsigned int id /**< unique id */
7426  )
7427 {
7428  assert(node != NULL);
7429  assert(id <= 536870911); /* id has only 29 bits and needs to be smaller than 2^29 */
7430 
7431  node->reoptid = id;
7432 }
7433 
7434 /** gets the domain change information of the node, i.e., the information about the differences in the
7435  * variables domains to the parent node
7436  */
7438  SCIP_NODE* node /**< node */
7439  )
7440 {
7441  assert(node != NULL);
7442 
7443  return node->domchg;
7444 }
7445 
7446 /** counts the number of bound changes due to branching, constraint propagation, and propagation */
7448  SCIP_NODE* node, /**< node */
7449  int* nbranchings, /**< pointer to store number of branchings (or NULL if not needed) */
7450  int* nconsprop, /**< pointer to store number of constraint propagations (or NULL if not needed) */
7451  int* nprop /**< pointer to store number of propagations (or NULL if not needed) */
7452  )
7453 { /*lint --e{641}*/
7454  SCIP_Bool count_branchings;
7455  SCIP_Bool count_consprop;
7456  SCIP_Bool count_prop;
7457  int i;
7458 
7459  assert(node != NULL);
7460 
7461  count_branchings = (nbranchings != NULL);
7462  count_consprop = (nconsprop != NULL);
7463  count_prop = (nprop != NULL);
7464 
7465  /* set counter to zero */
7466  if( count_branchings )
7467  *nbranchings = 0;
7468  if( count_consprop )
7469  *nconsprop = 0;
7470  if( count_prop )
7471  *nprop = 0;
7472 
7473  if( node->domchg != NULL )
7474  {
7475  for( i = 0; i < (int) node->domchg->domchgbound.nboundchgs; i++ )
7476  {
7477  if( count_branchings && node->domchg->domchgbound.boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING )
7478  (*nbranchings)++;
7479  else if( count_consprop && node->domchg->domchgbound.boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER )
7480  (*nconsprop)++;
7481  else if( count_prop && node->domchg->domchgbound.boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER )
7482  (*nprop)++;
7483  }
7484  }
7485 }
7486 
7487 /* return the number of bound changes based on dual information.
7488  *
7489  * currently, this methods works only for bound changes made by strong branching on binary variables. we need this
7490  * method to ensure optimality within reoptimization.
7491  *
7492  * since the bound changes made by strong branching are stored as SCIP_BOUNDCHGTYPE_CONSINFER or SCIP_BOUNDCHGTYPE_PROPINFER
7493  * with no constraint or propagator, resp., we are are interested in bound changes with these attributes.
7494  *
7495  * all bound changes of type SCIP_BOUNDCHGTYPE_BRANCHING are stored in the beginning of the bound change array, afterwards,
7496  * we can find the other two types. thus, we start the search at the end of the list and stop when reaching the first
7497  * bound change of type SCIP_BOUNDCHGTYPE_BRANCHING.
7498  */
7500  SCIP_NODE* node /**< node */
7501  )
7502 { /*lint --e{641}*/
7503  SCIP_BOUNDCHG* boundchgs;
7504  int i;
7505  int nboundchgs;
7506  int npseudobranchvars;
7507 
7508  assert(node != NULL);
7509 
7510  if( node->domchg == NULL )
7511  return 0;
7512 
7513  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7514  boundchgs = node->domchg->domchgbound.boundchgs;
7515 
7516  npseudobranchvars = 0;
7517 
7518  assert(boundchgs != NULL);
7519  assert(nboundchgs >= 0);
7520 
7521  /* count the number of pseudo-branching decisions; pseudo-branching decisions have to be in the ending of the bound change
7522  * array
7523  */
7524  for( i = nboundchgs-1; i >= 0; i--)
7525  {
7526  SCIP_Bool isint;
7527 
7528  isint = boundchgs[i].var->vartype == SCIP_VARTYPE_BINARY || boundchgs[i].var->vartype == SCIP_VARTYPE_INTEGER
7529  || boundchgs[i].var->vartype == SCIP_VARTYPE_IMPLINT;
7530 
7531  if( isint && ((boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER
7532  && boundchgs[i].data.inferencedata.reason.cons == NULL)
7533  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER
7534  && boundchgs[i].data.inferencedata.reason.prop == NULL)) )
7535  npseudobranchvars++;
7536  else if( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING )
7537  break;
7538  }
7539 
7540  return npseudobranchvars;
7541 }
7542 
7543 /** returns the set of variable branchings that were performed in the parent node to create this node */
7545  SCIP_NODE* node, /**< node data */
7546  SCIP_VAR** vars, /**< array of variables on which the bound change is based on dual information */
7547  SCIP_Real* bounds, /**< array of bounds which are based on dual information */
7548  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which are based on dual information */
7549  int* nvars, /**< number of variables on which the bound change is based on dual information
7550  * if this is larger than the array size, arrays should be reallocated and method
7551  * should be called again */
7552  int varssize /**< available slots in arrays */
7553  )
7554 { /*lint --e{641}*/
7555  SCIP_BOUNDCHG* boundchgs;
7556  int nboundchgs;
7557  int i;
7558 
7559  assert(node != NULL);
7560  assert(vars != NULL);
7561  assert(bounds != NULL);
7562  assert(boundtypes != NULL);
7563  assert(nvars != NULL);
7564  assert(varssize >= 0);
7565 
7566  (*nvars) = 0;
7567 
7568  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7569  return;
7570 
7571  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7572  boundchgs = node->domchg->domchgbound.boundchgs;
7573 
7574  assert(boundchgs != NULL);
7575  assert(nboundchgs >= 0);
7576 
7577  /* count the number of pseudo-branching decisions; pseudo-branching decisions have to be in the ending of the bound change
7578  * array
7579  */
7580  for( i = nboundchgs-1; i >= 0; i--)
7581  {
7582  if( boundchgs[i].var->vartype == SCIP_VARTYPE_BINARY || boundchgs[i].var->vartype == SCIP_VARTYPE_INTEGER
7583  || boundchgs[i].var->vartype == SCIP_VARTYPE_IMPLINT )
7584  {
7585  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER
7586  && boundchgs[i].data.inferencedata.reason.cons == NULL)
7587  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER
7588  && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7589  (*nvars)++;
7590  else if( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING )
7591  break;
7592  }
7593  }
7594 
7595  /* if the arrays have enough space store the branching decisions */
7596  if( varssize >= *nvars )
7597  {
7598  int j;
7599  j = 0;
7600  for( i = i+1; i < nboundchgs; i++)
7601  {
7602  assert( boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING );
7603  if( boundchgs[i].var->vartype == SCIP_VARTYPE_BINARY || boundchgs[i].var->vartype == SCIP_VARTYPE_INTEGER
7604  || boundchgs[i].var->vartype == SCIP_VARTYPE_IMPLINT )
7605  {
7606  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER
7607  && boundchgs[i].data.inferencedata.reason.cons == NULL)
7608  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER
7609  && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7610  {
7611  vars[j] = boundchgs[i].var;
7612  bounds[j] = boundchgs[i].newbound;
7613  boundtypes[j] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7614  j++;
7615  }
7616  }
7617  }
7618  }
7619 }
7620 
7621 /** gets the parent node of a node in the branch-and-bound tree, if any */
7623  SCIP_NODE* node /**< node */
7624  )
7625 {
7626  assert(node != NULL);
7627 
7628  return node->parent;
7629 }
7630 
7631 /** returns the set of variable branchings that were performed in the parent node to create this node */
7633  SCIP_NODE* node, /**< node data */
7634  SCIP_VAR** branchvars, /**< array of variables on which the branching has been performed in the parent node */
7635  SCIP_Real* branchbounds, /**< array of bounds which the branching in the parent node set */
7636  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branching in the parent node set */
7637  int* nbranchvars, /**< number of variables on which branching has been performed in the parent node
7638  * if this is larger than the array size, arrays should be reallocated and method
7639  * should be called again */
7640  int branchvarssize /**< available slots in arrays */
7641  )
7642 {
7643  SCIP_BOUNDCHG* boundchgs;
7644  int nboundchgs;
7645  int i;
7646 
7647  assert(node != NULL);
7648  assert(branchvars != NULL);
7649  assert(branchbounds != NULL);
7650  assert(boundtypes != NULL);
7651  assert(nbranchvars != NULL);
7652  assert(branchvarssize >= 0);
7653 
7654  (*nbranchvars) = 0;
7655 
7656  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7657  return;
7658 
7659  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7660  boundchgs = node->domchg->domchgbound.boundchgs;
7661 
7662  assert(boundchgs != NULL);
7663  assert(nboundchgs >= 0);
7664 
7665  /* count the number of branching decisions; branching decisions have to be in the beginning of the bound change
7666  * array
7667  */
7668  for( i = 0; i < nboundchgs; i++)
7669  {
7670  if( boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING ) /*lint !e641*/
7671  break;
7672 
7673  (*nbranchvars)++;
7674  }
7675 
7676 #ifndef NDEBUG
7677  /* check that the remaining bound change are no branching decisions */
7678  for( ; i < nboundchgs; i++)
7679  assert(boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING); /*lint !e641*/
7680 #endif
7681 
7682  /* if the arrays have enough space store the branching decisions */
7683  if( branchvarssize >= *nbranchvars )
7684  {
7685  for( i = 0; i < *nbranchvars; i++)
7686  {
7687  assert( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_BRANCHING ); /*lint !e641*/
7688  branchvars[i] = boundchgs[i].var;
7689  boundtypes[i] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7690  branchbounds[i] = boundchgs[i].newbound;
7691  }
7692  }
7693 }
7694 
7695 /** returns the set of variable branchings that were performed in all ancestor nodes (nodes on the path to the root) to create this node */
7697  SCIP_NODE* node, /**< node data */
7698  SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
7699  SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
7700  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
7701  int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
7702  * if this is larger than the array size, arrays should be reallocated and method
7703  * should be called again */
7704  int branchvarssize /**< available slots in arrays */
7705  )
7706 {
7707  assert(node != NULL);
7708  assert(branchvars != NULL);
7709  assert(branchbounds != NULL);
7710  assert(boundtypes != NULL);
7711  assert(nbranchvars != NULL);
7712  assert(branchvarssize >= 0);
7713 
7714  (*nbranchvars) = 0;
7715 
7716  while( SCIPnodeGetDepth(node) != 0 )
7717  {
7718  int nodenbranchvars;
7719  int start;
7720  int size;
7721 
7722  start = *nbranchvars < branchvarssize - 1 ? *nbranchvars : branchvarssize - 1;
7723  size = *nbranchvars > branchvarssize ? 0 : branchvarssize-(*nbranchvars);
7724 
7725  SCIPnodeGetParentBranchings(node, &branchvars[start], &branchbounds[start], &boundtypes[start], &nodenbranchvars, size);
7726  *nbranchvars += nodenbranchvars;
7727 
7728  node = node->parent;
7729  }
7730 }
7731 
7732 /** returns the set of variable branchings that were performed between the given @p node and the given @p parent node. */
7734  SCIP_NODE* node, /**< node data */
7735  SCIP_NODE* parent, /**< node data of the last ancestor node */
7736  SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
7737  SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
7738  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
7739  int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
7740  * if this is larger than the array size, arrays should be reallocated and method
7741  * should be called again */
7742  int branchvarssize /**< available slots in arrays */
7743  )
7744 {
7745  assert(node != NULL);
7746  assert(parent != NULL);
7747  assert(branchvars != NULL);
7748  assert(branchbounds != NULL);
7749  assert(boundtypes != NULL);
7750  assert(nbranchvars != NULL);
7751  assert(branchvarssize >= 0);
7752 
7753  (*nbranchvars) = 0;
7754 
7755  while( node != parent )
7756  {
7757  int nodenbranchvars;
7758  int start;
7759  int size;
7760 
7761  start = *nbranchvars < branchvarssize - 1 ? *nbranchvars : branchvarssize - 1;
7762  size = *nbranchvars > branchvarssize ? 0 : branchvarssize-(*nbranchvars);
7763 
7764  SCIPnodeGetParentBranchings(node, &branchvars[start], &branchbounds[start], &boundtypes[start], &nodenbranchvars, size);
7765  *nbranchvars += nodenbranchvars;
7766 
7767  node = node->parent;
7768  }
7769 }
7770 
7771 /** return all bound changes based on constraint propagation; stop saving the bound changes if we reach a branching
7772  * decision based on a dual information
7773  */
7775  SCIP_NODE* node, /**< node */
7776  SCIP_VAR** vars, /**< array of variables on which constraint propagation triggers a bound change */
7777  SCIP_Real* varbounds, /**< array of bounds set by constraint propagation */
7778  SCIP_BOUNDTYPE* varboundtypes, /**< array of boundtypes set by constraint propagation */
7779  int* nconspropvars, /**< number of variables on which constraint propagation triggers a bound change
7780  * if this is larger than the array size, arrays should be reallocated and method
7781  * should be called again */
7782  int conspropvarssize /**< available slots in arrays */
7783  )
7784 { /*lint --e{641}*/
7785  SCIP_BOUNDCHG* boundchgs;
7786  int nboundchgs;
7787  int first_dual;
7788  int nskip;
7789  int i;
7790 
7791  assert(node != NULL);
7792  assert(vars != NULL);
7793  assert(varbounds != NULL);
7794  assert(varboundtypes != NULL);
7795  assert(nconspropvars != NULL);
7796  assert(conspropvarssize >= 0);
7797 
7798  (*nconspropvars) = 0;
7799 
7800  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7801  return;
7802 
7803  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7804  boundchgs = node->domchg->domchgbound.boundchgs;
7805 
7806  assert(boundchgs != NULL);
7807  assert(nboundchgs >= 0);
7808 
7809  SCIPnodeGetNDomchg(node, &nskip, NULL, NULL);
7810  i = nskip;
7811 
7812  while( i < nboundchgs
7813  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons == NULL)
7814  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7815  i++;
7816 
7817  first_dual = i;
7818 
7819  /* count the number of bound changes because of constraint propagation and propagation */
7820  for(i = nskip; i < first_dual; i++)
7821  {
7822  assert(boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING);
7823 
7824  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL)
7825  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop != NULL) )
7826  {
7827  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7828  (*nconspropvars)++;
7829  }
7830  else if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons == NULL)
7831  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop == NULL))
7832  break;
7833  }
7834 
7835  /* if the arrays have enough space store the branching decisions */
7836  if( conspropvarssize >= *nconspropvars )
7837  {
7838  int pos;
7839 
7840  for(i = nskip, pos = 0; i < first_dual; i++)
7841  {
7842  if( boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL )
7843  {
7844  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7845  {
7846  vars[pos] = boundchgs[i].var;
7847  varboundtypes[pos] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7848  varbounds[pos] = boundchgs[i].newbound;
7849  pos++;
7850  }
7851  }
7852  }
7853  }
7854 
7855  return;
7856 }
7857 
7858 /** gets all bound changes applied after the first bound change based on dual information.
7859  *
7860  * @note: currently, we can only detect bound changes based in dual information if they arise from strong branching.
7861  */
7863  SCIP_NODE* node, /**< node */
7864  SCIP_VAR** vars, /**< array of variables on which the branching has been performed in the parent node */
7865  SCIP_Real* varbounds, /**< array of bounds which the branching in the parent node set */
7866  SCIP_BOUNDTYPE* varboundtypes, /**< array of boundtypes which the branching in the parent node set */
7867  int start, /**< first free slot in the arrays */
7868  int* nbranchvars, /**< number of variables on which branching has been performed in the parent node
7869  * if this is larger than the array size, arrays should be reallocated and method
7870  * should be called again */
7871  int branchvarssize /**< available slots in arrays */
7872  )
7873 { /*lint --e{641}*/
7874  SCIP_BOUNDCHG* boundchgs;
7875  int nboundchgs;
7876  int first_dual;
7877  int i;
7878 
7879  assert(node != NULL);
7880  assert(vars != NULL);
7881  assert(varbounds != NULL);
7882  assert(varboundtypes != NULL);
7883  assert(nbranchvars != NULL);
7884  assert(branchvarssize >= 0);
7885 
7886  (*nbranchvars) = 0;
7887 
7888  if( SCIPnodeGetDepth(node) == 0 || node->domchg == NULL )
7889  return;
7890 
7891  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7892  boundchgs = node->domchg->domchgbound.boundchgs;
7893 
7894  assert(boundchgs != NULL);
7895  assert(nboundchgs >= 0);
7896 
7897  /* find the first based on dual information */
7898  i = 0;
7899  while( i < nboundchgs
7900  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons == NULL)
7901  && !(boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop == NULL) )
7902  i++;
7903 
7904  first_dual = i;
7905 
7906  /* count the number of branching decisions; branching decisions have to be in the beginning of the bound change array */
7907  for( ; i < nboundchgs; i++)
7908  {
7909  assert(boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING);
7910 
7911  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL)
7912  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop != NULL) )
7913  {
7914  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7915  (*nbranchvars)++;
7916  }
7917  }
7918 
7919  /* if the arrays have enough space store the branching decisions */
7920  if( branchvarssize >= *nbranchvars )
7921  {
7922  int p;
7923  for(i = first_dual, p = start; i < nboundchgs; i++)
7924  {
7925  if( (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER && boundchgs[i].data.inferencedata.reason.cons != NULL)
7926  || (boundchgs[i].boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && boundchgs[i].data.inferencedata.reason.prop != NULL) )
7927  {
7928  if( boundchgs[i].var->vartype != SCIP_VARTYPE_CONTINUOUS )
7929  {
7930  vars[p] = boundchgs[i].var;
7931  varboundtypes[p] = (SCIP_BOUNDTYPE) boundchgs[i].boundtype;
7932  varbounds[p] = boundchgs[i].newbound;
7933  p++;
7934  }
7935  }
7936  }
7937  }
7938 }
7939 
7940 /** outputs the path into given file stream in GML format */
7942  SCIP_NODE* node, /**< node data */
7943  FILE* file /**< file to output the path */
7944  )
7945 {
7946  int nbranchings;
7947 
7948  nbranchings = 0;
7949 
7950  /* print opening in GML format */
7951  SCIPgmlWriteOpening(file, TRUE);
7952 
7953  while( SCIPnodeGetDepth(node) != 0 )
7954  {
7955  SCIP_BOUNDCHG* boundchgs;
7956  char label[SCIP_MAXSTRLEN];
7957  int nboundchgs;
7958  int i;
7959 
7960  nboundchgs = (int)node->domchg->domchgbound.nboundchgs;
7961  boundchgs = node->domchg->domchgbound.boundchgs;
7962 
7963  for( i = 0; i < nboundchgs; i++)
7964  {
7965  if( boundchgs[i].boundchgtype != SCIP_BOUNDCHGTYPE_BRANCHING ) /*lint !e641*/
7966  break;
7967 
7968  (void) SCIPsnprintf(label, SCIP_MAXSTRLEN, "%s %s %g", SCIPvarGetName(boundchgs[i].var),
7969  (SCIP_BOUNDTYPE) boundchgs[i].boundtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", boundchgs[i].newbound);
7970 
7971  SCIPgmlWriteNode(file, (unsigned int)nbranchings, label, "circle", NULL, NULL);
7972 
7973  if( nbranchings > 0 )
7974  {
7975  SCIPgmlWriteArc(file, (unsigned int)nbranchings, (unsigned int)(nbranchings-1), NULL, NULL);
7976  }
7977 
7978  nbranchings++;
7979  }
7980 
7981  node = node->parent;
7982  }
7983 
7984  /* print closing in GML format */
7985  SCIPgmlWriteClosing(file);
7986 
7987  return SCIP_OKAY;
7988 }
7989 
7990 /** returns the set of variable branchings that were performed in all ancestor nodes (nodes on the path to the root) to create this node
7991  * sorted by the nodes, starting from the current node going up to the root
7992  */
7994  SCIP_NODE* node, /**< node data */
7995  SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
7996  SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
7997  SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
7998  int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
7999  * if this is larger than the array size, arrays should be reallocated and method
8000  * should be called again */
8001  int branchvarssize, /**< available slots in arrays */
8002  int* nodeswitches, /**< marks, where in the arrays the branching decisions of the next node on the path
8003  * start branchings performed at the parent of node always start at position 0.
8004  * For single variable branching, nodeswitches[i] = i holds */
8005  int* nnodes, /**< number of nodes in the nodeswitch array */
8006  int nodeswitchsize /**< available slots in node switch array */
8007  )
8008 {
8009  assert(node != NULL);
8010  assert(branchvars != NULL);
8011  assert(branchbounds != NULL);
8012  assert(boundtypes != NULL);
8013  assert(nbranchvars != NULL);
8014  assert(branchvarssize >= 0);
8015 
8016  (*nbranchvars) = 0;
8017  (*nnodes) = 0;
8018 
8019  /* go up to the root, in the root no domains were changed due to branching */
8020  while( SCIPnodeGetDepth(node) != 0 )
8021  {
8022  int nodenbranchvars;
8023  int start;
8024  int size;
8025 
8026  /* calculate the start position for the current node and the maximum remaining slots in the arrays */
8027  start = *nbranchvars < branchvarssize - 1 ? *nbranchvars : branchvarssize - 1;
8028  size = *nbranchvars > branchvarssize ? 0 : branchvarssize-(*nbranchvars);
8029  if( *nnodes < nodeswitchsize )
8030  nodeswitches[*nnodes] = start;
8031 
8032  /* get branchings for a single node */
8033  SCIPnodeGetParentBranchings(node, &branchvars[start], &branchbounds[start], &boundtypes[start], &nodenbranchvars, size);
8034  *nbranchvars += nodenbranchvars;
8035  (*nnodes)++;
8036 
8037  node = node->parent;
8038  }
8039 }
8040 
8041 /** checks for two nodes whether they share the same root path, i.e., whether one is an ancestor of the other */
8043  SCIP_NODE* node1, /**< node data */
8044  SCIP_NODE* node2 /**< node data */
8045  )
8046 {
8047  assert(node1 != NULL);
8048  assert(node2 != NULL);
8049  assert(SCIPnodeGetDepth(node1) >= 0);
8050  assert(SCIPnodeGetDepth(node2) >= 0);
8051 
8052  /* if node2 is deeper than node1, follow the path until the level of node2 */
8053  while( SCIPnodeGetDepth(node1) < SCIPnodeGetDepth(node2) )
8054  node2 = node2->parent;
8055 
8056  /* if node1 is deeper than node2, follow the path until the level of node1 */
8057  while( SCIPnodeGetDepth(node2) < SCIPnodeGetDepth(node1) )
8058  node1 = node1->parent;
8059 
8060  assert(SCIPnodeGetDepth(node2) == SCIPnodeGetDepth(node1));
8061 
8062  return (node1 == node2);
8063 }
8064 
8065 /** finds the common ancestor node of two given nodes */
8067  SCIP_NODE* node1, /**< node data */
8068  SCIP_NODE* node2 /**< node data */
8069  )
8070 {
8071  assert(node1 != NULL);
8072  assert(node2 != NULL);
8073  assert(SCIPnodeGetDepth(node1) >= 0);
8074  assert(SCIPnodeGetDepth(node2) >= 0);
8075 
8076  /* if node2 is deeper than node1, follow the path until the level of node2 */
8077  while( SCIPnodeGetDepth(node1) < SCIPnodeGetDepth(node2) )
8078  node2 = node2->parent;
8079 
8080  /* if node1 is deeper than node2, follow the path until the level of node1 */
8081  while( SCIPnodeGetDepth(node2) < SCIPnodeGetDepth(node1) )
8082  node1 = node1->parent;
8083 
8084  /* move up level by level until you found a common ancestor */
8085  while( node1 != node2 )
8086  {
8087  node1 = node1->parent;
8088  node2 = node2->parent;
8089  assert(SCIPnodeGetDepth(node1) == SCIPnodeGetDepth(node2));
8090  }
8091  assert(SCIPnodeGetDepth(node1) >= 0);
8092 
8093  return node1;
8094 }
8095 
8096 /** returns whether node is in the path to the current node */
8098  SCIP_NODE* node /**< node */
8099  )
8100 {
8101  assert(node != NULL);
8102 
8103  return node->active;
8104 }
8105 
8106 /** returns whether the node is marked to be propagated again */
8108  SCIP_NODE* node /**< node data */
8109  )
8110 {
8111  assert(node != NULL);
8112 
8113  return node->reprop;
8114 }
8115 
8116 /* returns the set of changed constraints for a particular node */
8118  SCIP_NODE* node /**< node data */
8119  )
8120 {
8121  assert(node != NULL);
8122 
8123  return node->conssetchg;
8124 }
8125 
8126 /** gets number of children of the focus node */
8128  SCIP_TREE* tree /**< branch and bound tree */
8129  )
8130 {
8131  assert(tree != NULL);
8132 
8133  return tree->nchildren;
8134 }
8135 
8136 /** gets number of siblings of the focus node */
8138  SCIP_TREE* tree /**< branch and bound tree */
8139  )
8140 {
8141  assert(tree != NULL);
8142 
8143  return tree->nsiblings;
8144 }
8145 
8146 /** gets number of leaves in the tree (excluding children and siblings of focus nodes) */
8148  SCIP_TREE* tree /**< branch and bound tree */
8149  )
8150 {
8151  assert(tree != NULL);
8152 
8153  return SCIPnodepqLen(tree->leaves);
8154 }
8155 
8156 /** gets number of open nodes in the tree (children + siblings + leaves) */
8158  SCIP_TREE* tree /**< branch and bound tree */
8159  )
8160 {
8161  assert(tree != NULL);
8162 
8163  return tree->nchildren + tree->nsiblings + SCIPtreeGetNLeaves(tree);
8164 }
8165 
8166 /** returns whether the active path goes completely down to the focus node */
8168  SCIP_TREE* tree /**< branch and bound tree */
8169  )
8170 {
8171  assert(tree != NULL);
8172  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8173  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8174  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8175  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8176  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8177  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8178  || tree->path[tree->focusnode->depth] == tree->focusnode);
8179 
8180  return (tree->focusnode == NULL || (int)tree->focusnode->depth < tree->pathlen);
8181 }
8182 
8183 /** returns whether the current node is a temporary probing node */
8185  SCIP_TREE* tree /**< branch and bound tree */
8186  )
8187 {
8188  assert(tree != NULL);
8189  assert(tree->probingroot == NULL || (SCIP_NODETYPE)tree->probingroot->nodetype == SCIP_NODETYPE_PROBINGNODE);
8190  assert(tree->probingroot == NULL || tree->pathlen > SCIPnodeGetDepth(tree->probingroot));
8191  assert(tree->probingroot == NULL || tree->path[SCIPnodeGetDepth(tree->probingroot)] == tree->probingroot);
8192 
8193  return (tree->probingroot != NULL);
8194 }
8195 
8196 /** returns the temporary probing root node, or NULL if the we are not in probing mode */
8198  SCIP_TREE* tree /**< branch and bound tree */
8199  )
8200 {
8201  assert(tree != NULL);
8202  assert(tree->probingroot == NULL || (SCIP_NODETYPE)tree->probingroot->nodetype == SCIP_NODETYPE_PROBINGNODE);
8203  assert(tree->probingroot == NULL || tree->pathlen > SCIPnodeGetDepth(tree->probingroot));
8204  assert(tree->probingroot == NULL || tree->path[SCIPnodeGetDepth(tree->probingroot)] == tree->probingroot);
8205 
8206  return tree->probingroot;
8207 }
8208 
8209 /** gets focus node of the tree */
8211  SCIP_TREE* tree /**< branch and bound tree */
8212  )
8213 {
8214  assert(tree != NULL);
8215  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8216  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8217  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8218  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8219  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8220  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8221  || tree->path[tree->focusnode->depth] == tree->focusnode);
8222 
8223  return tree->focusnode;
8224 }
8225 
8226 /** gets depth of focus node in the tree */
8228  SCIP_TREE* tree /**< branch and bound tree */
8229  )
8230 {
8231  assert(tree != NULL);
8232  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8233  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8234  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8235  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8236  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8237  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8238  || tree->path[tree->focusnode->depth] == tree->focusnode);
8239 
8240  return tree->focusnode != NULL ? (int)tree->focusnode->depth : -1;
8241 }
8242 
8243 /** returns, whether the LP was or is to be solved in the focus node */
8245  SCIP_TREE* tree /**< branch and bound tree */
8246  )
8247 {
8248  assert(tree != NULL);
8249 
8250  return tree->focusnodehaslp;
8251 }
8252 
8253 /** sets mark to solve or to ignore the LP while processing the focus node */
8255  SCIP_TREE* tree, /**< branch and bound tree */
8256  SCIP_Bool solvelp /**< should the LP be solved in focus node? */
8257  )
8258 {
8259  assert(tree != NULL);
8260 
8261  tree->focusnodehaslp = solvelp;
8262 }
8263 
8264 /** returns whether the LP of the focus node is already constructed */
8266  SCIP_TREE* tree /**< branch and bound tree */
8267  )
8268 {
8269  assert(tree != NULL);
8270 
8271  return tree->focuslpconstructed;
8272 }
8273 
8274 /** returns whether the focus node is already solved and only propagated again */
8276  SCIP_TREE* tree /**< branch and bound tree */
8277  )
8278 {
8279  assert(tree != NULL);
8280 
8281  return (tree->focusnode != NULL && SCIPnodeGetType(tree->focusnode) == SCIP_NODETYPE_REFOCUSNODE);
8282 }
8283 
8284 /** gets current node of the tree, i.e. the last node in the active path, or NULL if no current node exists */
8286  SCIP_TREE* tree /**< branch and bound tree */
8287  )
8288 {
8289  assert(tree != NULL);
8290  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8291  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8292  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8293  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8294  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8295  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8296  || tree->path[tree->focusnode->depth] == tree->focusnode);
8297 
8298  return (tree->pathlen > 0 ? tree->path[tree->pathlen-1] : NULL);
8299 }
8300 
8301 /** 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 */
8303  SCIP_TREE* tree /**< branch and bound tree */
8304  )
8305 {
8306  assert(tree != NULL);
8307  assert(tree->focusnode != NULL || !SCIPtreeProbing(tree));
8308  assert(tree->pathlen == 0 || tree->focusnode != NULL);
8309  assert(tree->pathlen >= 2 || !SCIPtreeProbing(tree));
8310  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1] != NULL);
8311  assert(tree->pathlen == 0 || tree->path[tree->pathlen-1]->depth == tree->pathlen-1);
8312  assert(tree->focusnode == NULL || (int)tree->focusnode->depth >= tree->pathlen
8313  || tree->path[tree->focusnode->depth] == tree->focusnode);
8314 
8315  return tree->pathlen-1;
8316 }
8317 
8318 /** returns, whether the LP was or is to be solved in the current node */
8320  SCIP_TREE* tree /**< branch and bound tree */
8321  )
8322 {
8323  assert(tree != NULL);
8324  assert(SCIPtreeIsPathComplete(tree));
8325 
8326  return SCIPtreeProbing(tree) ? tree->probingnodehaslp : SCIPtreeHasFocusNodeLP(tree);
8327 }
8328 
8329 /** returns the current probing depth, i.e. the number of probing sub nodes existing in the probing path */
8331  SCIP_TREE* tree /**< branch and bound tree */
8332  )
8333 {
8334  assert(tree != NULL);
8335  assert(SCIPtreeProbing(tree));
8336 
8338 }
8339 
8340 /** returns the depth of the effective root node (i.e. the first depth level of a node with at least two children) */
8342  SCIP_TREE* tree /**< branch and bound tree */
8343  )
8344 {
8345  assert(tree != NULL);
8346  assert(tree->effectiverootdepth >= 0);
8347 
8348  return tree->effectiverootdepth;
8349 }
8350 
8351 /** gets the root node of the tree */
8353  SCIP_TREE* tree /**< branch and bound tree */
8354  )
8355 {
8356  assert(tree != NULL);
8357 
8358  return tree->root;
8359 }
8360 
8361 /** returns whether we are in probing and the objective value of at least one column was changed */
8362 
8364  SCIP_TREE* tree /**< branch and bound tree */
8365  )
8366 {
8367  assert(tree != NULL);
8368  assert(SCIPtreeProbing(tree) || !tree->probingobjchanged);
8369 
8370  return tree->probingobjchanged;
8371 }
8372 
8373 /** marks the current probing node to have a changed objective function */
8375  SCIP_TREE* tree /**< branch and bound tree */
8376  )
8377 {
8378  assert(tree != NULL);
8379  assert(SCIPtreeProbing(tree));
8380 
8381  tree->probingobjchanged = TRUE;
8382 }
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:4822
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:6188
int firstnewrow
Definition: struct_lp.h:317
SCIP_RETCODE SCIPlpGetProvedLowerbound(SCIP_LP *lp, SCIP_SET *set, SCIP_Real *bound)
Definition: lp.c:15716
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:4927
void SCIPnodeGetParentBranchings(SCIP_NODE *node, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:7632
void SCIPnodeGetDualBoundchgs(SCIP_NODE *node, SCIP_VAR **vars, SCIP_Real *bounds, SCIP_BOUNDTYPE *boundtypes, int *nvars, int varssize)
Definition: tree.c:7544
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:6775
#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:9944
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:6432
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:5343
int SCIPlpGetNNewrows(SCIP_LP *lp)
Definition: lp.c:16810
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:8244
static SCIP_RETCODE junctionInit(SCIP_JUNCTION *junction, SCIP_TREE *tree)
Definition: tree.c:407
SCIP_Bool SCIPlpDiving(SCIP_LP *lp)
Definition: lp.c:16992
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:9489
void SCIPlpSetIsRelax(SCIP_LP *lp, SCIP_Bool relax)
Definition: lp.c:16929
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:5284
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:5675
SCIP_Longint ndeactivatednodes
Definition: struct_stat.h:82
void SCIPtreeSetFocusNodeLP(SCIP_TREE *tree, SCIP_Bool solvelp)
Definition: tree.c:8254
SCIP_Bool primalfeasible
Definition: struct_lp.h:349
SCIP_NODE * SCIPnodesGetCommonAncestor(SCIP_NODE *node1, SCIP_NODE *node2)
Definition: tree.c:8066
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:7193
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:14907
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
Definition: tree.c:7362
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:5021
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:8330
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:4695
unsigned int repropsubtreemark
Definition: struct_tree.h:154
SCIP_NODE * SCIPnodeGetParent(SCIP_NODE *node)
Definition: tree.c:7622
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:7423
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:6741
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:7121
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:8197
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:7057
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:9883
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:9817
SCIP_Longint nbacktracks
Definition: struct_stat.h:85
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8302
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:8210
#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:6595
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:12048
SCIP_ROW ** SCIPlpGetRows(SCIP_LP *lp)
Definition: lp.c:16757
#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:15115
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:9924
unsigned int domchgtype
Definition: struct_var.h:142
SCIP_NODE ** siblings
Definition: struct_tree.h:189
int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7352
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:15555
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:12615
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:6258
#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:8167
SCIP_Longint number
Definition: struct_tree.h:132
SCIP_Bool SCIPtreeIsFocusNodeLPConstructed(SCIP_TREE *tree)
Definition: tree.c:8265
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:7696
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:16747
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:8227
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:7342
int SCIPtreeGetNChildren(SCIP_TREE *tree)
Definition: tree.c:8127
SCIP_NODE * SCIPtreeGetBestLeaf(SCIP_TREE *tree)
Definition: tree.c:7111
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:15076
SCIP_Real SCIPtreeCalcNodeselPriority(SCIP_TREE *tree, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var, SCIP_BRANCHDIR branchdir, SCIP_Real targetvalue)
Definition: tree.c:5134
SCIP_REOPTTYPE SCIPnodeGetReopttype(SCIP_NODE *node)
Definition: tree.c:7382
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:8184
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:9841
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:16788
#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:15540
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:8042
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:7993
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:7447
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:9234
int siblingssize
Definition: struct_tree.h:211
SCIP_Bool SCIPtreeInRepropagation(SCIP_TREE *tree)
Definition: tree.c:8275
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:9417
SCIP_COL ** SCIPlpGetCols(SCIP_LP *lp)
Definition: lp.c:16737
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:9574
SCIP_RETCODE SCIPnodePrintAncestorBranchings(SCIP_NODE *node, FILE *file)
Definition: tree.c:7941
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:7084
void SCIPnodeGetAncestorBranchingsPart(SCIP_NODE *node, SCIP_NODE *parent, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:7733
SCIP_Bool SCIPnodeIsPropagatedAgain(SCIP_NODE *node)
Definition: tree.c:8107
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:7437
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:9293
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:16767
SCIP_CONSSETCHG * SCIPnodeGetConssetchg(SCIP_NODE *node)
Definition: tree.c:8117
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:12631
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:7245
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:6243
#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:7499
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:9555
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:8341
#define SCIP_Bool
Definition: def.h:61
void SCIPlpRecomputeLocalAndGlobalPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:12714
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:5969
#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:6342
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:4882
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:16799
int SCIPvarGetBranchPriority(SCIP_VAR *var)
Definition: var.c:17448
SCIP_Real lastlowerbound
Definition: struct_stat.h:135
#define ARRAYGROWTH
Definition: tree.c:6187
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:6220
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:17002
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:8319
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:9586
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:7862
SCIP_NODESEL * SCIPtreeGetNodesel(SCIP_TREE *tree)
Definition: tree.c:5011
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:9900
#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:4774
SCIP_Real SCIPnodeGetEstimate(SCIP_NODE *node)
Definition: tree.c:7372
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:12844
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:8137
int SCIPnodeGetNAddedConss(SCIP_NODE *node)
Definition: tree.c:1668
SCIP_Bool SCIPtreeProbingObjChanged(SCIP_TREE *tree)
Definition: tree.c:8363
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:5817
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:9968
SCIP_NODE * SCIPtreeGetRootNode(SCIP_TREE *tree)
Definition: tree.c:8352
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:7413
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:6567
SCIP_NODE * SCIPtreeGetCurrentNode(SCIP_TREE *tree)
Definition: tree.c:8285
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:4968
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
Definition: tree.c:7332
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:6936
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:6486
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:7005
SCIP_Bool SCIPlpIsRelax(SCIP_LP *lp)
Definition: lp.c:16942
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:8097
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:7392
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:7155
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:5049
SCIP_RETCODE SCIPtreeRestoreRelaxSol(SCIP_TREE *tree, SCIP_SET *set, SCIP_RELAXATION *relaxation, SCIP_PROB *transprob)
Definition: tree.c:6973
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:12884
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:8147
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:16777
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:8157
#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:7774
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:6407
void SCIPlpUnmarkDivingObjChanged(SCIP_LP *lp)
Definition: lp.c:17023
#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:8374
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:7031
SCIP_NODE * focusnode
Definition: struct_tree.h:180
SCIP_Bool focusnodehaslp
Definition: struct_tree.h:222