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