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