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