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