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