Scippy

SCIP

Solving Constraint Integer Programs

scip_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-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file scip_tree.c
17  * @brief public methods for the branch-and-bound tree
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Robert Lion Gottwald
22  * @author Stefan Heinz
23  * @author Gregor Hendel
24  * @author Thorsten Koch
25  * @author Alexander Martin
26  * @author Marc Pfetsch
27  * @author Michael Winkler
28  * @author Kati Wolter
29  *
30  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <ctype.h>
36 #include <stdarg.h>
37 #include <assert.h>
38 #include <string.h>
39 #if defined(_WIN32) || defined(_WIN64)
40 #else
41 #include <strings.h> /*lint --e{766}*/
42 #endif
43 
44 
45 #include "lpi/lpi.h"
46 #include "nlpi/exprinterpret.h"
47 #include "nlpi/nlpi.h"
48 #include "scip/benders.h"
49 #include "scip/benderscut.h"
50 #include "scip/branch.h"
51 #include "scip/branch_nodereopt.h"
52 #include "scip/clock.h"
53 #include "scip/compr.h"
54 #include "scip/concsolver.h"
55 #include "scip/concurrent.h"
56 #include "scip/conflict.h"
57 #include "scip/conflictstore.h"
58 #include "scip/cons.h"
59 #include "scip/cons_linear.h"
60 #include "scip/cutpool.h"
61 #include "scip/cuts.h"
62 #include "scip/debug.h"
63 #include "scip/def.h"
64 #include "scip/dialog.h"
65 #include "scip/dialog_default.h"
66 #include "scip/disp.h"
67 #include "scip/event.h"
68 #include "scip/heur.h"
69 #include "scip/heur_ofins.h"
70 #include "scip/heur_reoptsols.h"
72 #include "scip/heuristics.h"
73 #include "scip/history.h"
74 #include "scip/implics.h"
75 #include "scip/interrupt.h"
76 #include "scip/lp.h"
77 #include "scip/mem.h"
78 #include "scip/message_default.h"
79 #include "scip/misc.h"
80 #include "scip/nlp.h"
81 #include "scip/nodesel.h"
82 #include "scip/paramset.h"
83 #include "scip/presol.h"
84 #include "scip/presolve.h"
85 #include "scip/pricer.h"
86 #include "scip/pricestore.h"
87 #include "scip/primal.h"
88 #include "scip/prob.h"
89 #include "scip/prop.h"
90 #include "scip/reader.h"
91 #include "scip/relax.h"
92 #include "scip/reopt.h"
93 #include "scip/retcode.h"
94 #include "scip/scipbuildflags.h"
95 #include "scip/scipcoreplugins.h"
96 #include "scip/scipgithash.h"
97 #include "scip/sepa.h"
98 #include "scip/sepastore.h"
99 #include "scip/set.h"
100 #include "scip/sol.h"
101 #include "scip/solve.h"
102 #include "scip/stat.h"
103 #include "scip/syncstore.h"
104 #include "scip/table.h"
105 #include "scip/tree.h"
106 #include "scip/var.h"
107 #include "scip/visual.h"
108 #include "xml/xml.h"
109 
110 #include "scip/scip_mem.h"
111 #include "scip/scip_tree.h"
112 
113 #include "scip/pub_message.h"
114 #include "scip/pub_tree.h"
115 #include "scip/pub_var.h"
116 
117 
118 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
119  * this structure except the interface methods in scip.c.
120  * In optimized mode, the structure is included in scip.h, because some of the methods
121  * are implemented as defines for performance reasons (e.g. the numerical comparisons)
122  */
123 #ifndef NDEBUG
124 #include "scip/struct_scip.h"
125 #endif
126 
127 /** gets focus node in the tree
128  *
129  * if we are in probing/diving mode this method returns the node in the tree where the probing/diving mode was started.
130  *
131  * @return the current node of the search tree
132  *
133  * @pre This method can be called if @p scip is in one of the following stages:
134  * - \ref SCIP_STAGE_INITPRESOLVE
135  * - \ref SCIP_STAGE_PRESOLVING
136  * - \ref SCIP_STAGE_EXITPRESOLVE
137  * - \ref SCIP_STAGE_SOLVING
138  */
140  SCIP* scip /**< SCIP data structure */
141  )
142 {
143  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetFocusNode", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
144 
145  return SCIPtreeGetFocusNode(scip->tree);
146 }
147 
148 /** gets current node in the tree
149  *
150  * @return the current node of the search tree
151  *
152  * @pre This method can be called if @p scip is in one of the following stages:
153  * - \ref SCIP_STAGE_INITPRESOLVE
154  * - \ref SCIP_STAGE_PRESOLVING
155  * - \ref SCIP_STAGE_EXITPRESOLVE
156  * - \ref SCIP_STAGE_SOLVING
157  */
159  SCIP* scip /**< SCIP data structure */
160  )
161 {
162  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetCurrentNode", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
163 
164  return SCIPtreeGetCurrentNode(scip->tree);
165 }
166 
167 /** gets the root node of the tree
168  *
169  * @return the root node of the search tree
170  *
171  * @pre This method can be called if @p scip is in one of the following stages:
172  * - \ref SCIP_STAGE_INITPRESOLVE
173  * - \ref SCIP_STAGE_PRESOLVING
174  * - \ref SCIP_STAGE_EXITPRESOLVE
175  * - \ref SCIP_STAGE_SOLVING
176  */
178  SCIP* scip /**< SCIP data structure */
179  )
180 {
181  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRootNode", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
182 
183  return SCIPtreeGetRootNode(scip->tree);
184 }
185 
186 /** gets the effective root depth, i.e., the depth of the deepest node which is part of all paths from the root node
187  * to the unprocessed nodes.
188  *
189  * @return effective root depth
190  *
191  * @pre This method can be called if @p scip is in one of the following stages:
192  * - \ref SCIP_STAGE_SOLVING
193  */
195  SCIP* scip /**< SCIP data structure */
196  )
197 {
198  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetEffectiveRootDepth", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
199 
200  return SCIPtreeGetEffectiveRootDepth(scip->tree);
201 }
202 
203 /** returns whether the current node is already solved and only propagated again
204  *
205  * @return TRUE is returned if \SCIP performance repropagation, otherwise FALSE.
206  *
207  * @pre This method can be called if @p scip is in one of the following stages:
208  * - \ref SCIP_STAGE_INITPRESOLVE
209  * - \ref SCIP_STAGE_PRESOLVING
210  * - \ref SCIP_STAGE_EXITPRESOLVE
211  * - \ref SCIP_STAGE_SOLVING
212  */
214  SCIP* scip /**< SCIP data structure */
215  )
216 {
217  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPinRepropagation", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
218 
219  return SCIPtreeInRepropagation(scip->tree);
220 }
221 
222 /** gets children of focus node along with the number of children
223  *
224  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
225  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
226  *
227  * @pre This method can be called if @p scip is in one of the following stages:
228  * - \ref SCIP_STAGE_SOLVING
229  * - \ref SCIP_STAGE_SOLVED
230  */
232  SCIP* scip, /**< SCIP data structure */
233  SCIP_NODE*** children, /**< pointer to store children array, or NULL if not needed */
234  int* nchildren /**< pointer to store number of children, or NULL if not needed */
235  )
236 {
237  SCIP_CALL( SCIPcheckStage(scip, "SCIPgetChildren", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
238 
239  if( children != NULL )
240  *children = scip->tree->children;
241  if( nchildren != NULL )
242  *nchildren = scip->tree->nchildren;
243 
244  return SCIP_OKAY;
245 }
246 
247 /** gets number of children of focus node
248  *
249  * @return number of children of the focus node
250  *
251  * @pre This method can be called if @p scip is in one of the following stages:
252  * - \ref SCIP_STAGE_SOLVING
253  * - \ref SCIP_STAGE_SOLVED
254  */
256  SCIP* scip /**< SCIP data structure */
257  )
258 {
259  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNChildren", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
260 
261  return scip->tree->nchildren;
262 }
263 
264 /** gets siblings of focus node along with the number of siblings
265  *
266  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
267  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
268  *
269  * @pre This method can be called if @p scip is in one of the following stages:
270  * - \ref SCIP_STAGE_SOLVING
271  * - \ref SCIP_STAGE_SOLVED
272  */
274  SCIP* scip, /**< SCIP data structure */
275  SCIP_NODE*** siblings, /**< pointer to store siblings array, or NULL if not needed */
276  int* nsiblings /**< pointer to store number of siblings, or NULL if not needed */
277  )
278 {
279  SCIP_CALL( SCIPcheckStage(scip, "SCIPgetSiblings", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
280 
281  if( siblings != NULL )
282  *siblings = scip->tree->siblings;
283  if( nsiblings != NULL )
284  *nsiblings = scip->tree->nsiblings;
285 
286  return SCIP_OKAY;
287 }
288 
289 /** gets number of siblings of focus node
290  *
291  * @return the number of siblings of focus node
292  *
293  * @pre This method can be called if @p scip is in one of the following stages:
294  * - \ref SCIP_STAGE_SOLVING
295  * - \ref SCIP_STAGE_SOLVED
296  */
298  SCIP* scip /**< SCIP data structure */
299  )
300 {
301  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNSiblings", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
302 
303  return scip->tree->nsiblings;
304 }
305 
306 /** gets leaves of the tree along with the number of leaves
307  *
308  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
309  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
310  *
311  * @pre This method can be called if @p scip is in one of the following stages:
312  * - \ref SCIP_STAGE_SOLVING
313  * - \ref SCIP_STAGE_SOLVED
314  */
316  SCIP* scip, /**< SCIP data structure */
317  SCIP_NODE*** leaves, /**< pointer to store leaves array, or NULL if not needed */
318  int* nleaves /**< pointer to store number of leaves, or NULL if not needed */
319  )
320 {
321  SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLeaves", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
322 
323  if( leaves != NULL )
324  *leaves = SCIPnodepqNodes(scip->tree->leaves);
325  if( nleaves != NULL )
326  *nleaves = SCIPnodepqLen(scip->tree->leaves);
327 
328  return SCIP_OKAY;
329 }
330 
331 /** gets number of leaves in the tree
332  *
333  * @return the number of leaves in the tree
334  *
335  * @pre This method can be called if @p scip is in one of the following stages:
336  * - \ref SCIP_STAGE_SOLVING
337  * - \ref SCIP_STAGE_SOLVED
338  */
340  SCIP* scip /**< SCIP data structure */
341  )
342 {
344 
345  return SCIPnodepqLen(scip->tree->leaves);
346 }
347 
348 /** gets the best child of the focus node w.r.t. the node selection priority assigned by the branching rule
349  *
350  * @return the best child of the focus node w.r.t. the node selection priority assigned by the branching rule
351  *
352  * @pre This method can be called if @p scip is in one of the following stages:
353  * - \ref SCIP_STAGE_SOLVING
354  */
356  SCIP* scip /**< SCIP data structure */
357  )
358 {
359  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetPrioChild", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
360 
361  return SCIPtreeGetPrioChild(scip->tree);
362 }
363 
364 /** gets the best sibling of the focus node w.r.t. the node selection priority assigned by the branching rule
365  *
366  * @return the best sibling of the focus node w.r.t. the node selection priority assigned by the branching rule
367  *
368  * @pre This method can be called if @p scip is in one of the following stages:
369  * - \ref SCIP_STAGE_SOLVING
370  */
372  SCIP* scip /**< SCIP data structure */
373  )
374 {
375  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetPrioSibling", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
376 
377  return SCIPtreeGetPrioSibling(scip->tree);
378 }
379 
380 /** gets the best child of the focus node w.r.t. the node selection strategy
381  *
382  * @return the best child of the focus node w.r.t. the node selection strategy
383  *
384  * @pre This method can be called if @p scip is in one of the following stages:
385  * - \ref SCIP_STAGE_SOLVING
386  */
388  SCIP* scip /**< SCIP data structure */
389  )
390 {
391  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetBestChild", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
392 
393  return SCIPtreeGetBestChild(scip->tree, scip->set);
394 }
395 
396 /** gets the best sibling of the focus node w.r.t. the node selection strategy
397  *
398  * @return the best sibling of the focus node w.r.t. the node selection strategy
399  *
400  * @pre This method can be called if @p scip is in one of the following stages:
401  * - \ref SCIP_STAGE_SOLVING
402  */
404  SCIP* scip /**< SCIP data structure */
405  )
406 {
407  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetBestSibling", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
408 
409  return SCIPtreeGetBestSibling(scip->tree, scip->set);
410 }
411 
412 /** gets the best leaf from the node queue w.r.t. the node selection strategy
413  *
414  * @return the best leaf from the node queue w.r.t. the node selection strategy
415  *
416  * @pre This method can be called if @p scip is in one of the following stages:
417  * - \ref SCIP_STAGE_SOLVING
418  */
420  SCIP* scip /**< SCIP data structure */
421  )
422 {
424 
425  return SCIPtreeGetBestLeaf(scip->tree);
426 }
427 
428 /** gets the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy
429  *
430  * @return the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy
431  *
432  * @pre This method can be called if @p scip is in one of the following stages:
433  * - \ref SCIP_STAGE_SOLVING
434  */
436  SCIP* scip /**< SCIP data structure */
437  )
438 {
440 
441  return SCIPtreeGetBestNode(scip->tree, scip->set);
442 }
443 
444 /** gets the node with smallest lower bound from the tree (child, sibling, or leaf)
445  *
446  * @return the node with smallest lower bound from the tree (child, sibling, or leaf)
447  *
448  * @pre This method can be called if @p scip is in one of the following stages:
449  * - \ref SCIP_STAGE_SOLVING
450  */
452  SCIP* scip /**< SCIP data structure */
453  )
454 {
455  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetBestboundNode", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
456 
457  return SCIPtreeGetLowerboundNode(scip->tree, scip->set);
458 }
459 
460 /** access to all data of open nodes (leaves, children, and siblings)
461  *
462  * @pre This method can be called if @p scip is in one of the following stages:
463  * - \ref SCIP_STAGE_SOLVING
464  */
466  SCIP* scip, /**< SCIP data structure */
467  SCIP_NODE*** leaves, /**< pointer to store the leaves, or NULL if not needed */
468  SCIP_NODE*** children, /**< pointer to store the children, or NULL if not needed */
469  SCIP_NODE*** siblings, /**< pointer to store the siblings, or NULL if not needed */
470  int* nleaves, /**< pointer to store the number of leaves, or NULL */
471  int* nchildren, /**< pointer to store the number of children, or NULL */
472  int* nsiblings /**< pointer to store the number of siblings, or NULL */
473  )
474 {
475  SCIP_CALL( SCIPcheckStage(scip, "SCIPgetOpenNodesData", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
476 
477  if( leaves != NULL )
478  *leaves = SCIPnodepqNodes(scip->tree->leaves);
479  if( children != NULL )
480  *children = scip->tree->children;
481  if( siblings != NULL )
482  *siblings = scip->tree->siblings;
483  if( nleaves != NULL )
484  *nleaves = SCIPnodepqLen(scip->tree->leaves);
485  if( nchildren != NULL )
486  *nchildren = SCIPtreeGetNChildren(scip->tree);
487  if( nsiblings != NULL )
488  *nsiblings = SCIPtreeGetNSiblings(scip->tree);
489 
490  return SCIP_OKAY;
491 }
492 
493 /** cuts off node and whole sub tree from branch and bound tree
494  *
495  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
496  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
497  *
498  * @pre This method can be called if @p scip is in one of the following stages:
499  * - \ref SCIP_STAGE_SOLVING
500  */
502  SCIP* scip, /**< SCIP data structure */
503  SCIP_NODE* node /**< node that should be cut off */
504  )
505 {
506  SCIP_CALL( SCIPcheckStage(scip, "SCIPcutoffNode", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
507 
508  SCIP_CALL( SCIPnodeCutoff(node, scip->set, scip->stat, scip->tree, scip->transprob, scip->origprob, scip->reopt,
509  scip->lp, scip->mem->probmem) );
510 
511  return SCIP_OKAY;
512 }
513 
514 /** marks the given node to be propagated again the next time a node of its subtree is processed
515  *
516  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
517  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
518  *
519  * @pre This method can be called if @p scip is in one of the following stages:
520  * - \ref SCIP_STAGE_SOLVING
521  */
523  SCIP* scip, /**< SCIP data structure */
524  SCIP_NODE* node /**< node that should be propagated again */
525  )
526 {
527  SCIP_CALL( SCIPcheckStage(scip, "SCIPrepropagateNode", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
528 
529  SCIPnodePropagateAgain(node, scip->set, scip->stat, scip->tree);
530 
531  return SCIP_OKAY;
532 }
533 
534 /** returns depth of first node in active path that is marked being cutoff
535  *
536  * @return depth of first node in active path that is marked being cutoff
537  *
538  * @pre This method can be called if @p scip is in one of the following stages:
539  * - \ref SCIP_STAGE_SOLVING
540  */
542  SCIP* scip /**< SCIP data structure */
543  )
544 {
545  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetCutoffdepth", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
546 
547  return scip->tree->cutoffdepth;
548 }
549 
550 /** returns depth of first node in active path that has to be propagated again
551  *
552  * @return depth of first node in active path that has to be propagated again
553  *
554  * @pre This method can be called if @p scip is in one of the following stages:
555  * - \ref SCIP_STAGE_SOLVING
556  */
558  SCIP* scip /**< SCIP data structure */
559  )
560 {
561  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRepropdepth", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
562 
563  return scip->tree->repropdepth;
564 }
565 
566 /** prints all branching decisions on variables from the root to the given node
567  *
568  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
569  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
570  *
571  * @pre This method can be called if @p scip is in one of the following stages:
572  * - \ref SCIP_STAGE_SOLVING
573  */
575  SCIP* scip, /**< SCIP data structure */
576  SCIP_NODE* node, /**< node data */
577  FILE* file /**< output file (or NULL for standard output) */
578  )
579 {
580  SCIP_VAR** branchvars; /* array of variables on which the branchings has been performed in all ancestors */
581  SCIP_Real* branchbounds; /* array of bounds which the branchings in all ancestors set */
582  SCIP_BOUNDTYPE* boundtypes; /* array of boundtypes which the branchings in all ancestors set */
583  int* nodeswitches; /* marks, where in the arrays the branching decisions of the next node on the path start
584  * branchings performed at the parent of node always start at position 0. For single variable branching,
585  * nodeswitches[i] = i holds */
586  int nbranchvars; /* number of variables on which branchings have been performed in all ancestors
587  * if this is larger than the array size, arrays should be reallocated and method should be called again */
588  int branchvarssize; /* available slots in arrays */
589  int nnodes; /* number of nodes in the nodeswitch array */
590  int nodeswitchsize; /* available slots in node switch array */
591 
592  branchvarssize = SCIPnodeGetDepth(node);
593  nodeswitchsize = branchvarssize;
594 
595  /* memory allocation */
596  SCIP_CALL( SCIPallocBufferArray(scip, &branchvars, branchvarssize) );
597  SCIP_CALL( SCIPallocBufferArray(scip, &branchbounds, branchvarssize) );
598  SCIP_CALL( SCIPallocBufferArray(scip, &boundtypes, branchvarssize) );
599  SCIP_CALL( SCIPallocBufferArray(scip, &nodeswitches, nodeswitchsize) );
600 
601  SCIPnodeGetAncestorBranchingPath(node, branchvars, branchbounds, boundtypes, &nbranchvars, branchvarssize, nodeswitches, &nnodes, nodeswitchsize );
602 
603  /* if the arrays were to small, we have to reallocate them and recall SCIPnodeGetAncestorBranchingPath */
604  if( nbranchvars > branchvarssize || nnodes > nodeswitchsize )
605  {
606  branchvarssize = nbranchvars;
607  nodeswitchsize = nnodes;
608 
609  /* memory reallocation */
610  SCIP_CALL( SCIPreallocBufferArray(scip, &branchvars, branchvarssize) );
611  SCIP_CALL( SCIPreallocBufferArray(scip, &branchbounds, branchvarssize) );
612  SCIP_CALL( SCIPreallocBufferArray(scip, &boundtypes, branchvarssize) );
613  SCIP_CALL( SCIPreallocBufferArray(scip, &nodeswitches, nodeswitchsize) );
614 
615  SCIPnodeGetAncestorBranchingPath(node, branchvars, branchbounds, boundtypes, &nbranchvars, branchvarssize, nodeswitches, &nnodes, nodeswitchsize);
616  assert(nbranchvars == branchvarssize);
617  }
618 
619  /* we only want to create output, if branchings were performed */
620  if( nbranchvars >= 1 )
621  {
622  int i;
623  int j;
624 
625  /* print all nodes, starting from the root, which is last in the arrays */
626  for( j = nnodes-1; j >= 0; --j)
627  {
628  int end;
629  if(j == nnodes-1)
630  end = nbranchvars;
631  else
632  end = nodeswitches[j+1];
633 
634  for( i = nodeswitches[j]; i < end; ++i )
635  {
636  if( i > nodeswitches[j] )
637  SCIPmessageFPrintInfo(scip->messagehdlr, file, " AND ");
638  SCIPmessageFPrintInfo(scip->messagehdlr, file, "<%s> %s %.1f",SCIPvarGetName(branchvars[i]), boundtypes[i] == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", branchbounds[i]);
639  }
640  SCIPmessageFPrintInfo(scip->messagehdlr, file, "\n");
641  if( j > 0 )
642  {
643  if( nodeswitches[j]-nodeswitches[j-1] != 1 )
644  SCIPmessageFPrintInfo(scip->messagehdlr, file, " |\n |\n");
645  else if( boundtypes[i-1] == SCIP_BOUNDTYPE_LOWER )
646  SCIPmessageFPrintInfo(scip->messagehdlr, file, "\\ \n \\\n");
647  else
648  SCIPmessageFPrintInfo(scip->messagehdlr, file, " /\n/ \n");
649  }
650  }
651  }
652 
653  /* free all local memory */
654  SCIPfreeBufferArray(scip, &nodeswitches);
655  SCIPfreeBufferArray(scip, &boundtypes);
656  SCIPfreeBufferArray(scip, &branchbounds);
657  SCIPfreeBufferArray(scip, &branchvars);
658 
659  return SCIP_OKAY;
660 }
661 
662 /** sets whether the LP should be solved at the focus node
663  *
664  * @note In order to have an effect, this method needs to be called after a node is focused but before the LP is
665  * solved.
666  *
667  * @pre This method can be called if @p scip is in one of the following stages:
668  * - \ref SCIP_STAGE_SOLVING
669  */
671  SCIP* scip, /**< SCIP data structure */
672  SCIP_Bool solvelp /**< should the LP be solved? */
673  )
674 {
675  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPsetFocusnodeLP", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
676 
677  SCIPtreeSetFocusNodeLP(scip->tree, solvelp);
678 }
679 
680 /** gets number of nodes left in the tree (children + siblings + leaves)
681  *
682  * @return the number of nodes left in the tree (children + siblings + leaves)
683  *
684  * @pre This method can be called if SCIP is in one of the following stages:
685  * - \ref SCIP_STAGE_PRESOLVED
686  * - \ref SCIP_STAGE_SOLVING
687  * - \ref SCIP_STAGE_SOLVED
688  */
690  SCIP* scip /**< SCIP data structure */
691  )
692 {
693  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNNodesLeft", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
694 
695  return SCIPtreeGetNNodes(scip->tree);
696 }
697 
698 /** gets depth of current node, or -1 if no current node exists; in probing, the current node is the last probing node,
699  * such that the depth includes the probing path
700  *
701  * @return the depth of current node, or -1 if no current node exists; in probing, the current node is the last probing node,
702  * such that the depth includes the probing path
703  *
704  * @pre This method can be called if SCIP is in one of the following stages:
705  * - \ref SCIP_STAGE_TRANSFORMED
706  * - \ref SCIP_STAGE_INITPRESOLVE
707  * - \ref SCIP_STAGE_PRESOLVING
708  * - \ref SCIP_STAGE_EXITPRESOLVE
709  * - \ref SCIP_STAGE_PRESOLVED
710  * - \ref SCIP_STAGE_INITSOLVE
711  * - \ref SCIP_STAGE_SOLVING
712  * - \ref SCIP_STAGE_SOLVED
713  * - \ref SCIP_STAGE_EXITSOLVE
714  */
716  SCIP* scip /**< SCIP data structure */
717  )
718 {
719  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetDepth", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
720 
721  return SCIPtreeGetCurrentDepth(scip->tree);
722 }
723 
724 /** gets depth of the focus node, or -1 if no focus node exists; the focus node is the currently processed node in the
725  * branching tree, excluding the nodes of the probing path
726  *
727  * @return the depth of the focus node, or -1 if no focus node exists; the focus node is the currently processed node in the
728  * branching tree, excluding the nodes of the probing path
729  *
730  * @pre This method can be called if SCIP is in one of the following stages:
731  * - \ref SCIP_STAGE_TRANSFORMED
732  * - \ref SCIP_STAGE_INITPRESOLVE
733  * - \ref SCIP_STAGE_PRESOLVING
734  * - \ref SCIP_STAGE_EXITPRESOLVE
735  * - \ref SCIP_STAGE_PRESOLVED
736  * - \ref SCIP_STAGE_INITSOLVE
737  * - \ref SCIP_STAGE_SOLVING
738  * - \ref SCIP_STAGE_SOLVED
739  * - \ref SCIP_STAGE_EXITSOLVE
740  */
742  SCIP* scip /**< SCIP data structure */
743  )
744 {
745  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetFocusDepth", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
746 
747  return SCIPtreeGetFocusDepth(scip->tree);
748 }
749 
750 /** gets current plunging depth (successive times, a child was selected as next node)
751  *
752  * @return the current plunging depth (successive times, a child was selected as next node)
753  *
754  * @pre This method can be called if SCIP is in one of the following stages:
755  * - \ref SCIP_STAGE_PRESOLVED
756  * - \ref SCIP_STAGE_SOLVING
757  */
759  SCIP* scip /**< SCIP data structure */
760  )
761 {
762  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetPlungeDepth", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
763 
764  return scip->stat->plungedepth;
765 }
internal methods for separators
SCIP_STAT * stat
Definition: struct_scip.h:69
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
int SCIPgetFocusDepth(SCIP *scip)
Definition: scip_tree.c:741
SCIP_NODE ** SCIPnodepqNodes(const SCIP_NODEPQ *nodepq)
Definition: nodesel.c:548
SCIP_Bool SCIPinRepropagation(SCIP *scip)
Definition: scip_tree.c:213
#define NULL
Definition: def.h:246
internal methods for managing events
default message handler
int SCIPgetPlungeDepth(SCIP *scip)
Definition: scip_tree.c:758
trivialnegation primal heuristic
internal methods for storing primal CIP solutions
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip_tree.c:158
methods to interpret (evaluate) an expression tree "fast"
public methods for branch and bound tree
internal methods for branch and bound tree
void SCIPtreeSetFocusNodeLP(SCIP_TREE *tree, SCIP_Bool solvelp)
Definition: tree.c:8259
public methods for memory management
SCIP_NODE * SCIPtreeGetLowerboundNode(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7198
methods for implications, variable bounds, and cliques
SCIP_RETCODE SCIPgetLeaves(SCIP *scip, SCIP_NODE ***leaves, int *nleaves)
Definition: scip_tree.c:315
internal methods for clocks and timing issues
int SCIPgetNSiblings(SCIP *scip)
Definition: scip_tree.c:297
internal methods for NLPI solver interfaces
int SCIPgetNLeaves(SCIP *scip)
Definition: scip_tree.c:339
interface methods for specific LP solvers
SCIP_NODE * SCIPtreeGetBestNode(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7126
SCIP_RETCODE SCIPgetOpenNodesData(SCIP *scip, SCIP_NODE ***leaves, SCIP_NODE ***children, SCIP_NODE ***siblings, int *nleaves, int *nchildren, int *nsiblings)
Definition: scip_tree.c:465
internal methods for displaying statistics tables
SCIP_NODE * SCIPtreeGetBestChild(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7062
int SCIPnodepqLen(const SCIP_NODEPQ *nodepq)
Definition: nodesel.c:558
#define FALSE
Definition: def.h:72
methods for the aggregation rows
SCIP_NODE * SCIPgetBestSibling(SCIP *scip)
Definition: scip_tree.c:403
internal methods for Benders&#39; decomposition
SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
Definition: scip_tree.c:501
#define TRUE
Definition: def.h:71
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
methods commonly used by primal heuristics
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8307
internal methods for branching rules and branching candidate storage
datastructures for concurrent solvers
SCIP_NODE * SCIPtreeGetFocusNode(SCIP_TREE *tree)
Definition: tree.c:8215
int SCIPgetNNodesLeft(SCIP *scip)
Definition: scip_tree.c:689
public methods for problem variables
internal methods for handling parameter settings
SCIP_PROB * transprob
Definition: struct_scip.h:87
SCIP_NODE ** siblings
Definition: struct_tree.h:191
int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7357
methods for creating output for visualization tools (VBC, BAK)
nodereopt branching rule
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:142
SCIP_NODE * SCIPgetRootNode(SCIP *scip)
Definition: scip_tree.c:177
internal methods for LP management
SCIP_PROB * origprob
Definition: struct_scip.h:70
SCIP_RETCODE SCIPgetSiblings(SCIP *scip, SCIP_NODE ***siblings, int *nsiblings)
Definition: scip_tree.c:273
internal methods for branching and inference history
SCIP_RETCODE SCIPrepropagateNode(SCIP *scip, SCIP_NODE *node)
Definition: scip_tree.c:522
internal methods for collecting primal CIP solutions and primal informations
internal methods for propagators
int SCIPtreeGetFocusDepth(SCIP_TREE *tree)
Definition: tree.c:8232
public methods for the branch-and-bound tree
int SCIPtreeGetNChildren(SCIP_TREE *tree)
Definition: tree.c:8132
SCIP_NODE * SCIPtreeGetBestLeaf(SCIP_TREE *tree)
Definition: tree.c:7116
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:1146
SCIP_MEM * mem
Definition: struct_scip.h:61
int nsiblings
Definition: struct_tree.h:214
int cutoffdepth
Definition: struct_tree.h:220
git hash methods
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:7998
internal methods for storing and manipulating the main problem
int SCIPgetCutoffdepth(SCIP *scip)
Definition: scip_tree.c:541
methods for block memory pools and memory buffers
SCIP_Bool SCIPtreeInRepropagation(SCIP_TREE *tree)
Definition: tree.c:8280
SCIP_RETCODE SCIPgetChildren(SCIP *scip, SCIP_NODE ***children, int *nchildren)
Definition: scip_tree.c:231
int repropdepth
Definition: struct_tree.h:221
register additional core functionality that is designed as plugins
SCIP_RETCODE SCIPcheckStage(SCIP *scip, const char *method, SCIP_Bool init, SCIP_Bool problem, SCIP_Bool transforming, SCIP_Bool transformed, SCIP_Bool initpresolve, SCIP_Bool presolving, SCIP_Bool exitpresolve, SCIP_Bool presolved, SCIP_Bool initsolve, SCIP_Bool solving, SCIP_Bool solved, SCIP_Bool exitsolve, SCIP_Bool freetrans, SCIP_Bool freescip)
Definition: debug.c:2010
internal methods for presolvers
int SCIPgetNChildren(SCIP *scip)
Definition: scip_tree.c:255
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16730
SCIP_REOPT * reopt
Definition: struct_scip.h:74
SCIP_NODE * SCIPtreeGetBestSibling(SCIP_TREE *tree, SCIP_SET *set)
Definition: tree.c:7089
internal methods for NLP management
internal miscellaneous methods
internal methods for node selectors and node priority queues
internal methods for variable pricers
int SCIPgetEffectiveRootDepth(SCIP *scip)
Definition: scip_tree.c:194
SCIP_NODEPQ * leaves
Definition: struct_tree.h:178
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:358
SCIP main data structure.
SCIP_NODE * SCIPgetBestboundNode(SCIP *scip)
Definition: scip_tree.c:451
internal methods for storing priced variables
internal methods for relaxators
internal methods for storing separated cuts
SCIP_NODE * SCIPgetBestNode(SCIP *scip)
Definition: scip_tree.c:435
methods commonly used for presolving
methods for catching the user CTRL-C interrupt
internal methods for problem variables
data structures and methods for collecting reoptimization information
the function declarations for the synchronization store
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:130
void SCIPnodePropagateAgain(SCIP_NODE *node, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: tree.c:1206
internal methods for user interface dialog
int SCIPtreeGetEffectiveRootDepth(SCIP_TREE *tree)
Definition: tree.c:8346
#define SCIP_Bool
Definition: def.h:69
SCIP_NODE ** children
Definition: struct_tree.h:190
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:715
internal methods for input file readers
methods for debugging
reoptsols primal heuristic
internal methods for storing cuts in a cut pool
Constraint handler for linear constraints in their most general form, .
SCIP_NODE * SCIPgetFocusNode(SCIP *scip)
Definition: scip_tree.c:139
helper functions for concurrent scip solvers
SCIP_NODE * SCIPgetPrioSibling(SCIP *scip)
Definition: scip_tree.c:371
internal methods for return codes for SCIP methods
SCIP_RETCODE SCIPprintNodeRootPath(SCIP *scip, SCIP_NODE *node, FILE *file)
Definition: scip_tree.c:574
int SCIPtreeGetNSiblings(SCIP_TREE *tree)
Definition: tree.c:8142
BMS_BLKMEM * probmem
Definition: struct_mem.h:40
internal methods for conflict analysis
SCIP_NODE * SCIPtreeGetRootNode(SCIP_TREE *tree)
Definition: tree.c:8357
internal methods for tree compressions
internal methods for main solving loop and node processing
SCIP_NODE * SCIPtreeGetCurrentNode(SCIP_TREE *tree)
Definition: tree.c:8290
SCIP_SET * set
Definition: struct_scip.h:62
int SCIPgetRepropdepth(SCIP *scip)
Definition: scip_tree.c:557
public methods for message output
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:608
SCIP_MESSAGEHDLR * messagehdlr
Definition: struct_scip.h:65
default user interface dialog
#define SCIP_Real
Definition: def.h:157
internal methods for problem statistics
internal methods for constraints and constraint handlers
SCIP_NODE * SCIPtreeGetPrioChild(SCIP_TREE *tree)
Definition: tree.c:7010
SCIP_NODE * SCIPgetPrioChild(SCIP *scip)
Definition: scip_tree.c:355
SCIP_NODE * SCIPgetBestChild(SCIP *scip)
Definition: scip_tree.c:387
SCIP_TREE * tree
Definition: struct_scip.h:84
declarations for XML parsing
build flags methods
int nchildren
Definition: struct_tree.h:212
#define nnodes
Definition: gastrans.c:65
int plungedepth
Definition: struct_stat.h:221
SCIP_NODE * SCIPgetBestLeaf(SCIP *scip)
Definition: scip_tree.c:419
common defines and data types used in all packages of SCIP
#define SCIP_CALL_ABORT(x)
Definition: def.h:337
internal methods for primal heuristics
SCIP_LP * lp
Definition: struct_scip.h:80
int SCIPtreeGetNNodes(SCIP_TREE *tree)
Definition: tree.c:8162
void SCIPsetFocusnodeLP(SCIP *scip, SCIP_Bool solvelp)
Definition: scip_tree.c:670
internal methods for Benders&#39; decomposition cuts
SCIP_NODE * SCIPtreeGetPrioSibling(SCIP_TREE *tree)
Definition: tree.c:7036
internal methods for displaying runtime statistics
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:134
OFINS - Objective Function Induced Neighborhood Search - a primal heuristic for reoptimization.