Scippy

SCIP

Solving Constraint Integer Programs

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