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