Scippy

SCIP

Solving Constraint Integer Programs

tree.h
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-2014 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 email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file tree.h
17  * @brief internal methods for branch and bound tree
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __SCIP_TREE_H__
25 #define __SCIP_TREE_H__
26 
27 
28 #include "scip/def.h"
29 #include "blockmemshell/memory.h"
30 #include "scip/type_set.h"
31 #include "scip/type_stat.h"
32 #include "scip/type_event.h"
33 #include "scip/type_lp.h"
34 #include "scip/type_var.h"
35 #include "scip/type_prob.h"
36 #include "scip/type_primal.h"
37 #include "scip/type_tree.h"
38 #include "scip/type_branch.h"
39 #include "scip/type_prop.h"
40 #include "scip/pub_tree.h"
41 
42 #ifndef NDEBUG
43 #include "scip/struct_tree.h"
44 #endif
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 
51 /*
52  * Node methods
53  */
54 
55 /** creates a child node of the focus node */
56 extern
58  SCIP_NODE** node, /**< pointer to node data structure */
59  BMS_BLKMEM* blkmem, /**< block memory */
60  SCIP_SET* set, /**< global SCIP settings */
61  SCIP_STAT* stat, /**< problem statistics */
62  SCIP_TREE* tree, /**< branch and bound tree */
63  SCIP_Real nodeselprio, /**< node selection priority of new node */
64  SCIP_Real estimate /**< estimate for (transformed) objective value of best feasible solution in subtree */
65  );
66 
67 /** frees node */
68 extern
70  SCIP_NODE** node, /**< node data */
71  BMS_BLKMEM* blkmem, /**< block memory buffer */
72  SCIP_SET* set, /**< global SCIP settings */
73  SCIP_STAT* stat, /**< problem statistics */
74  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
75  SCIP_TREE* tree, /**< branch and bound tree */
76  SCIP_LP* lp /**< current LP data */
77  );
78 
79 /** increases the reference counter of the LP state in the fork or subroot node */
80 extern
82  SCIP_NODE* node, /**< fork/subroot node */
83  int nuses /**< number to add to the usage counter */
84  );
85 
86 /** decreases the reference counter of the LP state in the fork or subroot node */
87 extern
89  SCIP_NODE* node, /**< fork/subroot node */
90  BMS_BLKMEM* blkmem, /**< block memory buffers */
91  SCIP_LP* lp /**< current LP data */
92  );
93 
94 /** installs a child, a sibling, or a leaf node as the new focus node */
95 extern
97  SCIP_NODE** node, /**< pointer to node to focus (or NULL to remove focus); the node
98  * is freed, if it was cut off due to a cut off subtree */
99  BMS_BLKMEM* blkmem, /**< block memory */
100  SCIP_SET* set, /**< global SCIP settings */
101  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
102  SCIP_STAT* stat, /**< problem statistics */
103  SCIP_PROB* transprob, /**< transformed problem */
104  SCIP_PROB* origprob, /**< original problem */
105  SCIP_PRIMAL* primal, /**< primal data */
106  SCIP_TREE* tree, /**< branch and bound tree */
107  SCIP_LP* lp, /**< current LP data */
108  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
109  SCIP_CONFLICT* conflict, /**< conflict analysis data */
110  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
111  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
112  SCIP_Bool* cutoff, /**< pointer to store whether the given node can be cut off */
113  SCIP_Bool exitsolve /**< are we in exitsolve stage, so we only need to loose the children */
114  );
115 
116 /** cuts off node and whole sub tree from branch and bound tree */
117 extern
118 void SCIPnodeCutoff(
119  SCIP_NODE* node, /**< node that should be cut off */
120  SCIP_SET* set, /**< global SCIP settings */
121  SCIP_STAT* stat, /**< problem statistics */
122  SCIP_TREE* tree /**< branch and bound tree */
123  );
124 
125 /** marks node, that propagation should be applied again the next time, a node of its subtree is focused */
126 extern
128  SCIP_NODE* node, /**< node that should be propagated again */
129  SCIP_SET* set, /**< global SCIP settings */
130  SCIP_STAT* stat, /**< problem statistics */
131  SCIP_TREE* tree /**< branch and bound tree */
132  );
133 
134 /** marks node, that it is completely propagated in the current repropagation subtree level */
135 extern
137  SCIP_NODE* node, /**< node that should be propagated again */
138  SCIP_TREE* tree /**< branch and bound tree */
139  );
140 
141 /** adds constraint locally to the node and captures it; activates constraint, if node is active;
142  * if a local constraint is added to the root node, it is automatically upgraded into a global constraint
143  */
144 extern
146  SCIP_NODE* node, /**< node to add constraint to */
147  BMS_BLKMEM* blkmem, /**< block memory */
148  SCIP_SET* set, /**< global SCIP settings */
149  SCIP_STAT* stat, /**< problem statistics */
150  SCIP_TREE* tree, /**< branch and bound tree */
151  SCIP_CONS* cons /**< constraint to add */
152  );
153 
154 /** locally deletes constraint at the given node by disabling its separation, enforcing, and propagation capabilities
155  * at the node; captures constraint; disables constraint, if node is active
156  */
157 extern
159  SCIP_NODE* node, /**< node to add constraint to */
160  BMS_BLKMEM* blkmem, /**< block memory */
161  SCIP_SET* set, /**< global SCIP settings */
162  SCIP_STAT* stat, /**< problem statistics */
163  SCIP_TREE* tree, /**< branch and bound tree */
164  SCIP_CONS* cons /**< constraint to locally delete */
165  );
166 
167 /** adds bound change with inference information to focus node, child of focus node, or probing node;
168  * if possible, adjusts bound to integral value;
169  * at most one of infercons and inferprop may be non-NULL
170  */
171 extern
173  SCIP_NODE* node, /**< node to add bound change to */
174  BMS_BLKMEM* blkmem, /**< block memory */
175  SCIP_SET* set, /**< global SCIP settings */
176  SCIP_STAT* stat, /**< problem statistics */
177  SCIP_PROB* transprob, /**< transformed problem after presolve */
178  SCIP_PROB* origprob, /**< original problem */
179  SCIP_TREE* tree, /**< branch and bound tree */
180  SCIP_LP* lp, /**< current LP data */
181  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
182  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
183  SCIP_VAR* var, /**< variable to change the bounds for */
184  SCIP_Real newbound, /**< new value for bound */
185  SCIP_BOUNDTYPE boundtype, /**< type of bound: lower or upper bound */
186  SCIP_CONS* infercons, /**< constraint that deduced the bound change, or NULL */
187  SCIP_PROP* inferprop, /**< propagator that deduced the bound change, or NULL */
188  int inferinfo, /**< user information for inference to help resolving the conflict */
189  SCIP_Bool probingchange /**< is the bound change a temporary setting due to probing? */
190  );
191 
192 /** adds bound change to focus node, or child of focus node, or probing node;
193  * if possible, adjusts bound to integral value
194  */
195 extern
197  SCIP_NODE* node, /**< node to add bound change to */
198  BMS_BLKMEM* blkmem, /**< block memory */
199  SCIP_SET* set, /**< global SCIP settings */
200  SCIP_STAT* stat, /**< problem statistics */
201  SCIP_PROB* transprob, /**< transformed problem after presolve */
202  SCIP_PROB* origprob, /**< original problem */
203  SCIP_TREE* tree, /**< branch and bound tree */
204  SCIP_LP* lp, /**< current LP data */
205  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
206  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
207  SCIP_VAR* var, /**< variable to change the bounds for */
208  SCIP_Real newbound, /**< new value for bound */
209  SCIP_BOUNDTYPE boundtype, /**< type of bound: lower or upper bound */
210  SCIP_Bool probingchange /**< is the bound change a temporary setting due to probing? */
211  );
212 
213 /** adds hole with inference information to focus node, child of focus node, or probing node;
214  * if possible, adjusts bound to integral value;
215  * at most one of infercons and inferprop may be non-NULL
216  */
218  SCIP_NODE* node, /**< node to add bound change to */
219  BMS_BLKMEM* blkmem, /**< block memory */
220  SCIP_SET* set, /**< global SCIP settings */
221  SCIP_STAT* stat, /**< problem statistics */
222  SCIP_TREE* tree, /**< branch and bound tree */
223  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
224  SCIP_VAR* var, /**< variable to change the bounds for */
225  SCIP_Real left, /**< left bound of open interval defining the hole (left,right) */
226  SCIP_Real right, /**< right bound of open interval defining the hole (left,right) */
227  SCIP_CONS* infercons, /**< constraint that deduced the bound change, or NULL */
228  SCIP_PROP* inferprop, /**< propagator that deduced the bound change, or NULL */
229  int inferinfo, /**< user information for inference to help resolving the conflict */
230  SCIP_Bool probingchange, /**< is the bound change a temporary setting due to probing? */
231  SCIP_Bool* added /**< pointer to store whether the hole was added, or NULL */
232  );
233 
234 /** adds hole change to focus node, or child of focus node */
235 extern
237  SCIP_NODE* node, /**< node to add bound change to */
238  BMS_BLKMEM* blkmem, /**< block memory */
239  SCIP_SET* set, /**< global SCIP settings */
240  SCIP_STAT* stat, /**< problem statistics */
241  SCIP_TREE* tree, /**< branch and bound tree */
242  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
243  SCIP_VAR* var, /**< variable to change the bounds for */
244  SCIP_Real left, /**< left bound of open interval defining the hole (left,right) */
245  SCIP_Real right, /**< right bound of open interval defining the hole (left,right) */
246  SCIP_Bool probingchange, /**< is the bound change a temporary setting due to probing? */
247  SCIP_Bool* added /**< pointer to store whether the hole was added, or NULL */
248  );
249 
250 /** if given value is larger than the node's lower bound, sets the node's lower bound to the new value */
251 extern
253  SCIP_NODE* node, /**< node to update lower bound for */
254  SCIP_STAT* stat, /**< problem statistics */
255  SCIP_SET* set, /**< global SCIP settings */
256  SCIP_TREE* tree, /**< branch and bound tree */
257  SCIP_PROB* transprob, /**< transformed problem data */
258  SCIP_PROB* origprob, /**< original problem */
259  SCIP_Real newbound /**< new lower bound for the node (if it's larger than the old one) */
260  );
261 
262 /** updates lower bound of node using lower bound of LP */
263 extern
265  SCIP_NODE* node, /**< node to set lower bound for */
266  SCIP_SET* set, /**< global SCIP settings */
267  SCIP_STAT* stat, /**< problem statistics */
268  SCIP_TREE* tree, /**< branch and bound tree */
269  SCIP_PROB* transprob, /**< transformed problem after presolve */
270  SCIP_PROB* origprob, /**< original problem */
271  SCIP_LP* lp /**< LP data */
272  );
273 
274 /** change the node selection priority of the given child */
275 extern
277  SCIP_TREE* tree, /**< branch and bound tree */
278  SCIP_NODE* child, /**< child to update the node selection priority */
279  SCIP_Real priority /**< node selection priority value */
280  );
281 
282 
283 /** sets the node's estimated bound to the new value */
284 extern
286  SCIP_NODE* node, /**< node to update lower bound for */
287  SCIP_SET* set, /**< global SCIP settings */
288  SCIP_Real newestimate /**< new estimated bound for the node */
289  );
290 
291 /** propagates implications of binary fixings at the given node triggered by the implication graph and the clique table */
292 extern
294  SCIP_NODE* node, /**< node to propagate implications on */
295  BMS_BLKMEM* blkmem, /**< block memory */
296  SCIP_SET* set, /**< global SCIP settings */
297  SCIP_STAT* stat, /**< problem statistics */
298  SCIP_PROB* transprob, /**< transformed problem after presolve */
299  SCIP_PROB* origprob, /**< original problem */
300  SCIP_TREE* tree, /**< branch and bound tree */
301  SCIP_LP* lp, /**< current LP data */
302  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
303  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
304  SCIP_Bool* cutoff /**< pointer to store whether the node can be cut off */
305  );
306 
307 
308 
309 
310 /*
311  * Tree methods
312  */
313 
314 /** creates an initialized tree data structure */
315 extern
317  SCIP_TREE** tree, /**< pointer to tree data structure */
318  SCIP_SET* set, /**< global SCIP settings */
319  SCIP_NODESEL* nodesel /**< node selector to use for sorting leaves in the priority queue */
320  );
321 
322 /** frees tree data structure */
323 extern
325  SCIP_TREE** tree, /**< pointer to tree data structure */
326  BMS_BLKMEM* blkmem, /**< block memory buffers */
327  SCIP_SET* set, /**< global SCIP settings */
328  SCIP_STAT* stat, /**< problem statistics */
329  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
330  SCIP_LP* lp /**< current LP data */
331  );
332 
333 /** clears and resets tree data structure and deletes all nodes */
334 extern
336  SCIP_TREE* tree, /**< tree data structure */
337  BMS_BLKMEM* blkmem, /**< block memory buffers */
338  SCIP_SET* set, /**< global SCIP settings */
339  SCIP_STAT* stat, /**< problem statistics */
340  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
341  SCIP_LP* lp /**< current LP data */
342  );
343 
344 /** creates the root node of the tree and puts it into the leaves queue */
345 extern
347  SCIP_TREE* tree, /**< tree data structure */
348  BMS_BLKMEM* blkmem, /**< block memory buffers */
349  SCIP_SET* set, /**< global SCIP settings */
350  SCIP_STAT* stat, /**< problem statistics */
351  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
352  SCIP_LP* lp /**< current LP data */
353  );
354 
355 /** creates a temporary presolving root node of the tree and installs it as focus node */
356 extern
358  SCIP_TREE* tree, /**< tree data structure */
359  BMS_BLKMEM* blkmem, /**< block memory buffers */
360  SCIP_SET* set, /**< global SCIP settings */
361  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
362  SCIP_STAT* stat, /**< problem statistics */
363  SCIP_PROB* transprob, /**< transformed problem */
364  SCIP_PROB* origprob, /**< original problem */
365  SCIP_PRIMAL* primal, /**< primal data */
366  SCIP_LP* lp, /**< current LP data */
367  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
368  SCIP_CONFLICT* conflict, /**< conflict analysis data */
369  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
370  SCIP_EVENTQUEUE* eventqueue /**< event queue */
371  );
372 
373 /** frees the temporary presolving root and resets tree data structure */
374 extern
376  SCIP_TREE* tree, /**< tree data structure */
377  BMS_BLKMEM* blkmem, /**< block memory buffers */
378  SCIP_SET* set, /**< global SCIP settings */
379  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
380  SCIP_STAT* stat, /**< problem statistics */
381  SCIP_PROB* transprob, /**< transformed problem */
382  SCIP_PROB* origprob, /**< original problem */
383  SCIP_PRIMAL* primal, /**< primal data */
384  SCIP_LP* lp, /**< current LP data */
385  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
386  SCIP_CONFLICT* conflict, /**< conflict analysis data */
387  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
388  SCIP_EVENTQUEUE* eventqueue /**< event queue */
389  );
390 
391 /** returns the node selector associated with the given node priority queue */
392 extern
394  SCIP_TREE* tree /**< branch and bound tree */
395  );
396 
397 /** sets the node selector used for sorting the nodes in the priority queue, and resorts the queue if necessary */
398 extern
400  SCIP_TREE* tree, /**< branch and bound tree */
401  SCIP_SET* set, /**< global SCIP settings */
402  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
403  SCIP_STAT* stat, /**< problem statistics */
404  SCIP_NODESEL* nodesel /**< node selector to use for sorting the nodes in the queue */
405  );
406 
407 /** cuts off nodes with lower bound not better than given upper bound */
408 extern
410  SCIP_TREE* tree, /**< branch and bound tree */
411  BMS_BLKMEM* blkmem, /**< block memory */
412  SCIP_SET* set, /**< global SCIP settings */
413  SCIP_STAT* stat, /**< dynamic problem statistics */
414  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
415  SCIP_LP* lp, /**< current LP data */
416  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
417  );
418 
419 /** constructs the LP relaxation of the focus node */
420 extern
422  SCIP_TREE* tree, /**< branch and bound tree */
423  BMS_BLKMEM* blkmem, /**< block memory */
424  SCIP_SET* set, /**< global SCIP settings */
425  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
426  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
427  SCIP_LP* lp, /**< current LP data */
428  SCIP_Bool* initroot /**< pointer to store whether the root LP relaxation has to be initialized */
429  );
430 
431 /** loads LP state for fork/subroot of the focus node */
432 extern
434  SCIP_TREE* tree, /**< branch and bound tree */
435  BMS_BLKMEM* blkmem, /**< block memory buffers */
436  SCIP_SET* set, /**< global SCIP settings */
437  SCIP_STAT* stat, /**< dynamic problem statistics */
438  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
439  SCIP_LP* lp /**< current LP data */
440  );
441 
442 /** calculates the node selection priority for moving the given variable's LP value to the given target value;
443  * this node selection priority can be given to the SCIPcreateChild() call
444  */
445 extern
447  SCIP_TREE* tree, /**< branch and bound tree */
448  SCIP_SET* set, /**< global SCIP settings */
449  SCIP_STAT* stat, /**< dynamic problem statistics */
450  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
451  SCIP_BRANCHDIR branchdir, /**< type of branching that was performed: upwards, downwards, or fixed
452  * fixed should only be used, when both bounds changed
453  */
454  SCIP_Real targetvalue /**< new value of the variable in the child node */
455  );
456 
457 /** calculates an estimate for the objective of the best feasible solution contained in the subtree after applying the given
458  * branching; this estimate can be given to the SCIPcreateChild() call
459  */
460 extern
462  SCIP_TREE* tree, /**< branch and bound tree */
463  SCIP_SET* set, /**< global SCIP settings */
464  SCIP_STAT* stat, /**< dynamic problem statistics */
465  SCIP_VAR* var, /**< variable, of which the branching factor should be applied, or NULL */
466  SCIP_Real targetvalue /**< new value of the variable in the child node */
467  );
468 
469 /** branches on a variable x
470  * if x is a continuous variable, then two child nodes will be created
471  * (x <= x', x >= x')
472  * but if the bounds of x are such that their relative difference is smaller than epsilon,
473  * the variable is fixed to val (if not SCIP_INVALID) or a well chosen alternative in the current node,
474  * i.e., no children are created
475  * if x is not a continuous variable, then:
476  * if solution value x' is fractional, two child nodes will be created
477  * (x <= floor(x'), x >= ceil(x')),
478  * if solution value is integral, the x' is equal to lower or upper bound of the branching
479  * variable and the bounds of x are finite, then two child nodes will be created
480  * (x <= x", x >= x"+1 with x" = floor((lb + ub)/2)),
481  * otherwise (up to) three child nodes will be created
482  * (x <= x'-1, x == x', x >= x'+1)
483  * if solution value is equal to one of the bounds and the other bound is infinite, only two child nodes
484  * will be created (the third one would be infeasible anyway)
485  */
486 extern
488  SCIP_TREE* tree, /**< branch and bound tree */
489  BMS_BLKMEM* blkmem, /**< block memory */
490  SCIP_SET* set, /**< global SCIP settings */
491  SCIP_STAT* stat, /**< problem statistics data */
492  SCIP_PROB* transprob, /**< transformed problem after presolve */
493  SCIP_PROB* origprob, /**< original problem */
494  SCIP_LP* lp, /**< current LP data */
495  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
496  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
497  SCIP_VAR* var, /**< variable to branch on */
498  SCIP_Real val, /**< value to branch on or SCIP_INVALID for branching on current LP/pseudo solution. A branching value is required for branching on continuous variables */
499  SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
500  SCIP_NODE** eqchild, /**< pointer to return the middle child with variable fixed, or NULL */
501  SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
502  );
503 
504 /** branches a variable x using the given domain hole; two child nodes will be created (x <= left, x >= right) */
505 extern
507  SCIP_TREE* tree, /**< branch and bound tree */
508  BMS_BLKMEM* blkmem, /**< block memory */
509  SCIP_SET* set, /**< global SCIP settings */
510  SCIP_STAT* stat, /**< problem statistics data */
511  SCIP_PROB* transprob, /**< transformed problem after presolve */
512  SCIP_PROB* origprob, /**< original problem */
513  SCIP_LP* lp, /**< current LP data */
514  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
515  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
516  SCIP_VAR* var, /**< variable to branch on */
517  SCIP_Real left, /**< left side of the domain hole */
518  SCIP_Real right, /**< right side of the domain hole */
519  SCIP_NODE** downchild, /**< pointer to return the left child with variable rounded down, or NULL */
520  SCIP_NODE** upchild /**< pointer to return the right child with variable rounded up, or NULL */
521  );
522 
523 /** n-ary branching on a variable x
524  * Branches on variable x such that up to n/2 children are created on each side of the usual branching value.
525  * The branching value is selected as in SCIPtreeBranchVar().
526  * If n is 2 or the variables local domain is too small for a branching into n pieces, SCIPtreeBranchVar() is called.
527  * The parameters minwidth and widthfactor determine the domain width of the branching variable in the child nodes.
528  * If n is odd, one child with domain width 'width' and having the branching value in the middle is created.
529  * Otherwise, two children with domain width 'width' and being left and right of the branching value are created.
530  * Next further nodes to the left and right are created, where width is multiplied by widthfactor with increasing distance from the first nodes.
531  * The initial width is calculated such that n/2 nodes are created to the left and to the right of the branching value.
532  * If this value is below minwidth, the initial width is set to minwidth, which may result in creating less than n nodes.
533  *
534  * Giving a large value for widthfactor results in creating children with small domain when close to the branching value
535  * and large domain when closer to the current variable bounds. That is, setting widthfactor to a very large value and n to 3
536  * results in a ternary branching where the branching variable is mostly fixed in the middle child.
537  * Setting widthfactor to 1.0 results in children where the branching variable always has the same domain width
538  * (except for one child if the branching value is not in the middle).
539  */
540 extern
542  SCIP_TREE* tree, /**< branch and bound tree */
543  BMS_BLKMEM* blkmem, /**< block memory */
544  SCIP_SET* set, /**< global SCIP settings */
545  SCIP_STAT* stat, /**< problem statistics data */
546  SCIP_PROB* transprob, /**< transformed problem after presolve */
547  SCIP_PROB* origprob, /**< original problem */
548  SCIP_LP* lp, /**< current LP data */
549  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
550  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
551  SCIP_VAR* var, /**< variable to branch on */
552  SCIP_Real val, /**< value to branch on or SCIP_INVALID for branching on current LP/pseudo solution.
553  * A branching value is required for branching on continuous variables */
554  int n, /**< attempted number of children to be created, must be >= 2 */
555  SCIP_Real minwidth, /**< minimal domain width in children */
556  SCIP_Real widthfactor, /**< multiplier for children domain width with increasing distance from val, must be >= 1.0 */
557  int* nchildren /**< buffer to store number of created children, or NULL */
558  );
559 
560 /** switches to probing mode and creates a probing root */
561 extern
563  SCIP_TREE* tree, /**< branch and bound tree */
564  BMS_BLKMEM* blkmem, /**< block memory */
565  SCIP_SET* set, /**< global SCIP settings */
566  SCIP_LP* lp, /**< current LP data */
567  SCIP_Bool strongbranching /**< is the probing mode used for strongbranching? */
568  );
569 
570 /** creates a new probing child node in the probing path */
571 extern
573  SCIP_TREE* tree, /**< branch and bound tree */
574  BMS_BLKMEM* blkmem, /**< block memory */
575  SCIP_SET* set, /**< global SCIP settings */
576  SCIP_LP* lp /**< current LP data */
577  );
578 
579 /** loads the LP state for the current probing node */
580 extern
582  SCIP_TREE* tree, /**< branch and bound tree */
583  BMS_BLKMEM* blkmem, /**< block memory buffers */
584  SCIP_SET* set, /**< global SCIP settings */
585  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
586  SCIP_LP* lp /**< current LP data */
587  );
588 
589 /** marks the probing node to have a solved LP relaxation */
590 extern
592  SCIP_TREE* tree, /**< branch and bound tree */
593  BMS_BLKMEM* blkmem, /**< block memory */
594  SCIP_LP* lp /**< current LP data */
595  );
596 
597 /** undoes all changes to the problem applied in probing up to the given probing depth;
598  * the changes of the probing node of the given probing depth are the last ones that remain active;
599  * changes that were applied before calling SCIPtreeCreateProbingNode() cannot be undone
600  */
601 extern
603  SCIP_TREE* tree, /**< branch and bound tree */
604  BMS_BLKMEM* blkmem, /**< block memory buffers */
605  SCIP_SET* set, /**< global SCIP settings */
606  SCIP_STAT* stat, /**< problem statistics */
607  SCIP_PROB* transprob, /**< transformed problem */
608  SCIP_PROB* origprob, /**< original problem */
609  SCIP_LP* lp, /**< current LP data */
610  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
611  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
612  SCIP_EVENTFILTER* eventfilter, /**< global event filter */
613  int probingdepth /**< probing depth of the node in the probing path that should be reactivated */
614  );
615 
616 /** switches back from probing to normal operation mode, frees all nodes on the probing path, restores bounds of all
617  * variables and restores active constraints arrays of focus node
618  */
619 extern
621  SCIP_TREE* tree, /**< branch and bound tree */
622  BMS_BLKMEM* blkmem, /**< block memory buffers */
623  SCIP_SET* set, /**< global SCIP settings */
624  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
625  SCIP_STAT* stat, /**< problem statistics */
626  SCIP_PROB* transprob, /**< transformed problem after presolve */
627  SCIP_PROB* origprob, /**< original problem */
628  SCIP_LP* lp, /**< current LP data */
629  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
630  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
631  SCIP_EVENTFILTER* eventfilter /**< global event filter */
632  );
633 
634 
635 /** gets number of children of the focus node */
636 extern
638  SCIP_TREE* tree /**< branch and bound tree */
639  );
640 
641 /** gets number of siblings of the focus node */
642 extern
644  SCIP_TREE* tree /**< branch and bound tree */
645  );
646 
647 /** gets number of leaves in the tree (excluding children and siblings of focus nodes) */
648 extern
650  SCIP_TREE* tree /**< branch and bound tree */
651  );
652 
653 /** gets number of open nodes in the tree (children + siblings + leaves) */
654 extern
656  SCIP_TREE* tree /**< branch and bound tree */
657  );
658 
659 /** returns whether the active path goes completely down to the focus node */
660 extern
662  SCIP_TREE* tree /**< branch and bound tree */
663  );
664 
665 /** returns whether the current node is a temporary probing node */
666 extern
668  SCIP_TREE* tree /**< branch and bound tree */
669  );
670 
671 /** returns the temporary probing root node, or NULL if the we are not in probing mode */
672 extern
674  SCIP_TREE* tree /**< branch and bound tree */
675  );
676 
677 /** returns the current probing depth, i.e. the number of probing sub nodes existing in the probing path */
678 extern
680  SCIP_TREE* tree /**< branch and bound tree */
681  );
682 
683 /** gets focus node of the tree */
684 extern
686  SCIP_TREE* tree /**< branch and bound tree */
687  );
688 
689 /** gets depth of focus node in the tree, or -1 if no focus node exists */
690 extern
692  SCIP_TREE* tree /**< branch and bound tree */
693  );
694 
695 /** returns, whether the LP was or is to be solved in the focus node */
696 extern
698  SCIP_TREE* tree /**< branch and bound tree */
699  );
700 
701 /** sets mark to solve or to ignore the LP while processing the focus node */
702 extern
704  SCIP_TREE* tree, /**< branch and bound tree */
705  SCIP_Bool solvelp /**< should the LP be solved in focus node? */
706  );
707 
708 /** returns whether the LP of the focus node is already constructed */
709 extern
711  SCIP_TREE* tree /**< branch and bound tree */
712  );
713 
714 /** returns whether the focus node is already solved and only propagated again */
715 extern
717  SCIP_TREE* tree /**< branch and bound tree */
718  );
719 
720 /** gets current node of the tree, i.e. the last node in the active path, or NULL if no current node exists */
721 extern
723  SCIP_TREE* tree /**< branch and bound tree */
724  );
725 
726 /** 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 */
727 extern
729  SCIP_TREE* tree /**< branch and bound tree */
730  );
731 
732 /** returns, whether the LP was or is to be solved in the current node */
733 extern
735  SCIP_TREE* tree /**< branch and bound tree */
736  );
737 
738 /** returns the depth of the effective root node (i.e. the first depth level of a node with at least two children) */
739 extern
741  SCIP_TREE* tree /**< branch and bound tree */
742  );
743 
744 /** gets the root node of the tree */
745 extern
747  SCIP_TREE* tree /**< branch and bound tree */
748  );
749 
750 #ifdef NDEBUG
751 
752 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
753  * speed up the algorithms.
754  */
755 
756 #define SCIPtreeGetNLeaves(tree) SCIPnodepqLen((tree)->leaves)
757 #define SCIPtreeGetNChildren(tree) ((tree)->nchildren)
758 #define SCIPtreeGetNSiblings(tree) ((tree)->nsiblings)
759 #define SCIPtreeGetNNodes(tree) \
760  (SCIPtreeGetNChildren(tree) + SCIPtreeGetNSiblings(tree) + SCIPtreeGetNLeaves(tree))
761 #define SCIPtreeIsPathComplete(tree) ((tree)->focusnode == NULL || (tree)->focusnode->depth < (tree)->pathlen)
762 #define SCIPtreeProbing(tree) ((tree)->probingroot != NULL)
763 #define SCIPtreeGetProbingRoot(tree) (tree)->probingroot
764 #define SCIPtreeGetProbingDepth(tree) (SCIPtreeGetCurrentDepth(tree) - SCIPnodeGetDepth((tree)->probingroot))
765 #define SCIPtreeGetFocusNode(tree) (tree)->focusnode
766 #define SCIPtreeGetFocusDepth(tree) ((tree)->focusnode != NULL ? (tree)->focusnode->depth : -1)
767 #define SCIPtreeHasFocusNodeLP(tree) (tree)->focusnodehaslp
768 #define SCIPtreeSetFocusNodeLP(tree,solvelp) ((tree)->focusnodehaslp = solvelp)
769 #define SCIPtreeIsFocusNodeLPConstructed(tree) (tree)->focuslpconstructed
770 #define SCIPtreeInRepropagation(tree) ((tree)->focusnode != NULL \
771  && SCIPnodeGetType((tree)->focusnode) == SCIP_NODETYPE_REFOCUSNODE)
772 #define SCIPtreeGetCurrentNode(tree) ((tree)->pathlen > 0 ? (tree)->path[(tree)->pathlen-1] : NULL)
773 #define SCIPtreeGetCurrentDepth(tree) ((tree)->pathlen-1)
774 #define SCIPtreeHasCurrentNodeLP(tree) (SCIPtreeProbing(tree) ? (tree)->probingnodehaslp : SCIPtreeHasFocusNodeLP(tree))
775 #define SCIPtreeGetEffectiveRootDepth(tree) ((tree)->effectiverootdepth)
776 #define SCIPtreeGetRootNode(tree) ((tree)->root)
777 
778 #endif
779 
780 
781 /** gets the best child of the focus node w.r.t. the node selection priority assigned by the branching rule */
782 extern
784  SCIP_TREE* tree /**< branch and bound tree */
785  );
786 
787 /** gets the best sibling of the focus node w.r.t. the node selection priority assigned by the branching rule */
788 extern
790  SCIP_TREE* tree /**< branch and bound tree */
791  );
792 
793 /** gets the best child of the focus node w.r.t. the node selection strategy */
794 extern
796  SCIP_TREE* tree, /**< branch and bound tree */
797  SCIP_SET* set /**< global SCIP settings */
798  );
799 
800 /** gets the best sibling of the focus node w.r.t. the node selection strategy */
801 extern
803  SCIP_TREE* tree, /**< branch and bound tree */
804  SCIP_SET* set /**< global SCIP settings */
805  );
806 
807 /** gets the best leaf from the node queue w.r.t. the node selection strategy */
808 extern
810  SCIP_TREE* tree /**< branch and bound tree */
811  );
812 
813 /** gets the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy */
814 extern
816  SCIP_TREE* tree, /**< branch and bound tree */
817  SCIP_SET* set /**< global SCIP settings */
818  );
819 
820 /** gets the minimal lower bound of all nodes in the tree */
821 extern
823  SCIP_TREE* tree, /**< branch and bound tree */
824  SCIP_SET* set /**< global SCIP settings */
825  );
826 
827 /** gets the node with minimal lower bound of all nodes in the tree (child, sibling, or leaf) */
828 extern
830  SCIP_TREE* tree, /**< branch and bound tree */
831  SCIP_SET* set /**< global SCIP settings */
832  );
833 
834 /** gets the average lower bound of all nodes in the tree */
835 extern
837  SCIP_TREE* tree, /**< branch and bound tree */
838  SCIP_Real cutoffbound /**< global cutoff bound */
839  );
840 
841 #ifdef __cplusplus
842 }
843 #endif
844 
845 #endif
846