Scippy

SCIP

Solving Constraint Integer Programs

pub_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-2025 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 pub_tree.h
26 * @ingroup PUBLICCOREAPI
27 * @brief public methods for branch and bound tree
28 * @author Tobias Achterberg
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#ifndef __SCIP_PUB_TREE_H__
34#define __SCIP_PUB_TREE_H__
35
36#include "scip/def.h"
37#include "scip/type_cons.h"
38#include "scip/type_lp.h"
39#include "scip/type_misc.h"
40#include "scip/type_rational.h"
41#include "scip/type_reopt.h"
42#include "scip/type_retcode.h"
43#include "scip/type_tree.h"
44#include "scip/type_var.h"
45
46#ifdef NDEBUG
47#include "scip/struct_tree.h"
48#endif
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54/*
55 * Node methods
56 */
57
58/**@addtogroup PublicNodeMethods
59 *
60 * @{
61 */
62
63/** node comparator for best lower bound */
64SCIP_EXPORT
65SCIP_DECL_SORTPTRCOMP(SCIPnodeCompLowerbound);
66
67/** returns the set of variable branchings that were performed in the parent node to create this node */
68SCIP_EXPORT
70 SCIP_NODE* node, /**< node data */
71 SCIP_VAR** branchvars, /**< array of variables on which the branching has been performed in the parent node */
72 SCIP_Real* branchbounds, /**< array of bounds which the branching in the parent node set */
73 SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branching in the parent node set */
74 int* nbranchvars, /**< number of variables on which branching has been performed in the parent node
75 * if this is larger than the array size, arrays should be reallocated and method should be called again */
76 int branchvarssize /**< available slots in arrays */
77 );
78
79/** returns the set of variable branchings that were performed in all ancestor nodes (nodes on the path to the root) to create this node */
80SCIP_EXPORT
82 SCIP_NODE* node, /**< node data */
83 SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
84 SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
85 SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
86 int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
87 * if this is larger than the array size, arrays should be reallocated and method should be called again */
88 int branchvarssize /**< available slots in arrays */
89 );
90
91/** returns the set of variable branchings that were performed between the given @p node and the given @p parent node. */
92SCIP_EXPORT
94 SCIP_NODE* node, /**< node data */
95 SCIP_NODE* parent, /**< node data */
96 SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
97 SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
98 SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
99 int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
100 * if this is larger than the array size, arrays should be reallocated and method should be called again */
101 int branchvarssize /**< available slots in arrays */
102 );
103
104/** outputs the path into given file stream in GML format */
105SCIP_EXPORT
107 SCIP_NODE* node, /**< node data */
108 FILE* file /**< file to output the path */
109 );
110
111/** returns the set of variable branchings that were performed in all ancestor nodes (nodes on the path to the root) to create this node
112 * sorted by the nodes, starting from the current node going up to the root
113 */
114SCIP_EXPORT
116 SCIP_NODE* node, /**< node data */
117 SCIP_VAR** branchvars, /**< array of variables on which the branchings has been performed in all ancestors */
118 SCIP_Real* branchbounds, /**< array of bounds which the branchings in all ancestors set */
119 SCIP_BOUNDTYPE* boundtypes, /**< array of boundtypes which the branchings in all ancestors set */
120 int* nbranchvars, /**< number of variables on which branchings have been performed in all ancestors
121 * if this is larger than the array size, arrays should be reallocated and method
122 * should be called again */
123 int branchvarssize, /**< available slots in arrays */
124 int* nodeswitches, /**< marks, where in the arrays the branching decisions of the next node on the path
125 * start; branchings performed at the parent of node always start at position 0.
126 * For single variable branching, nodeswitches[i] = i holds */
127 int* nnodes, /**< number of nodes in the nodeswitch array */
128 int nodeswitchsize /**< available slots in node switch array */
129 );
130
131
132/** checks for two nodes whether they share the same root path, i.e., whether one is an ancestor of the other */
133SCIP_EXPORT
135 SCIP_NODE* node1, /**< node data */
136 SCIP_NODE* node2 /**< node data */
137 );
138
139/** finds the common ancestor node of two given nodes */
140SCIP_EXPORT
142 SCIP_NODE* node1, /**< node data */
143 SCIP_NODE* node2 /**< node data */
144 );
145
146
147/** gets the type of the node */
148SCIP_EXPORT
150 SCIP_NODE* node /**< node */
151 );
152
153/** gets successively assigned number of the node */
154SCIP_EXPORT
156 SCIP_NODE* node /**< node */
157 );
158
159/** gets the depth of the node */
160SCIP_EXPORT
162 SCIP_NODE* node /**< node */
163 );
164
165/** gets the lower bound of the node */
166SCIP_EXPORT
168 SCIP_NODE* node /**< node */
169 );
170
171/** gets the rational lower bound of the node */
172SCIP_EXPORT
174 SCIP_NODE* node /**< node */
175 );
176
177/** gets the estimated value of the best feasible solution in subtree of the node */
178SCIP_EXPORT
180 SCIP_NODE* node /**< node */
181 );
182
183
184/** gets the reoptimization type of a node */
185SCIP_EXPORT
187 SCIP_NODE* node /**< node */
188 );
189
190/** gets the unique id to identify the node during reoptimization; id is 0 if the node is the root or not part of the
191 * reoptimization tree
192 */
193SCIP_EXPORT
194unsigned int SCIPnodeGetReoptID(
195 SCIP_NODE* node /**< node */
196 );
197
198/** sets the reoptimization type of the node */
199SCIP_EXPORT
201 SCIP_NODE* node, /**< node */
202 SCIP_REOPTTYPE reopttype /**< reoptimization type */
203 );
204
205/** sets a unique id to identify the node during reoptimization */
206SCIP_EXPORT
208 SCIP_NODE* node, /**< node */
209 unsigned int id /**< unique id */
210 );
211
212/** counts the number of bound changes due to branching, constraint propagation, and propagation */
213SCIP_EXPORT
215 SCIP_NODE* node, /**< node */
216 int* nbranchings, /**< pointer to store number of branchings (or NULL if not needed) */
217 int* nconsprop, /**< pointer to store number of constraint propagations (or NULL if not needed) */
218 int* nprop /**< pointer to store number of propagations (or NULL if not needed) */
219 );
220
221/** gets the domain change information of the node, i.e., the information about the differences in the
222 * variables domains to the parent node
223 */
224SCIP_EXPORT
226 SCIP_NODE* node /**< node */
227 );
228
229/** gets the parent node of a node in the branch-and-bound tree, if any */
230SCIP_EXPORT
232 SCIP_NODE* node /**< node */
233 );
234
235/** returns all constraints added to a given node */
236SCIP_EXPORT
238 SCIP_NODE* node, /**< node */
239 SCIP_CONS** addedconss, /**< array to store the constraints */
240 int* naddedconss, /**< number of added constraints */
241 int addedconsssize /**< size of the constraint array */
242 );
243
244/** returns the number of added constraints to the given node */
245SCIP_EXPORT
247 SCIP_NODE* node
248 );
249
250/** returns whether node is in the path to the current node */
251SCIP_EXPORT
253 SCIP_NODE* node /**< node */
254 );
255
256/** returns whether the node is marked to be propagated again */
257SCIP_EXPORT
259 SCIP_NODE* node /**< node data */
260 );
261
262/* returns the set of changed constraints for a particular node */
263SCIP_EXPORT
265 SCIP_NODE* node /**< node data */
266 );
267
268
269#ifdef NDEBUG
270
271/* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
272 * speed up the algorithms.
273 */
274
275#define SCIPnodeGetType(node) ((SCIP_NODETYPE)(node)->nodetype)
276#define SCIPnodeGetNumber(node) ((node)->number)
277#define SCIPnodeGetDepth(node) ((int) (node)->depth)
278#define SCIPnodeGetLowerbound(node) ((node)->lowerbound)
279#define SCIPnodeGetEstimate(node) ((node)->estimate)
280#define SCIPnodeGetDomchg(node) ((node)->domchg)
281#define SCIPnodeGetParent(node) ((node)->parent)
282#define SCIPnodeIsActive(node) ((node)->active)
283#define SCIPnodeIsPropagatedAgain(node) ((node)->reprop)
284#define SCIPnodeGetConssetchg(node) ((node)->conssetchg)
285
286#endif
287
288/** @} */
289
290#ifdef __cplusplus
291}
292#endif
293
294#endif
common defines and data types used in all packages of SCIP
#define SCIP_Longint
Definition: def.h:141
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:156
#define nnodes
Definition: gastrans.c:74
void SCIPnodeGetAncestorBranchings(SCIP_NODE *node, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:8856
void SCIPnodeSetReopttype(SCIP_NODE *node, SCIP_REOPTTYPE reopttype)
Definition: tree.c:8543
void SCIPnodeSetReoptID(SCIP_NODE *node, unsigned int id)
Definition: tree.c:8574
void SCIPnodeGetAncestorBranchingsPart(SCIP_NODE *node, SCIP_NODE *parent, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:8893
void SCIPnodeGetParentBranchings(SCIP_NODE *node, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
Definition: tree.c:8792
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
Definition: tree.c:8473
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
Definition: tree.c:8503
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:9170
void SCIPnodeGetNDomchg(SCIP_NODE *node, int *nbranchings, int *nconsprop, int *nprop)
Definition: tree.c:8598
SCIP_NODE * SCIPnodesGetCommonAncestor(SCIP_NODE *node1, SCIP_NODE *node2)
Definition: tree.c:9243
SCIP_Bool SCIPnodeIsActive(SCIP_NODE *node)
Definition: tree.c:9274
SCIP_DOMCHG * SCIPnodeGetDomchg(SCIP_NODE *node)
Definition: tree.c:8588
SCIP_RATIONAL * SCIPnodeGetLowerboundExact(SCIP_NODE *node)
Definition: tree.c:8513
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:8483
SCIP_NODE * SCIPnodeGetParent(SCIP_NODE *node)
Definition: tree.c:8782
SCIP_Bool SCIPnodesSharePath(SCIP_NODE *node1, SCIP_NODE *node2)
Definition: tree.c:9219
int SCIPnodeGetNAddedConss(SCIP_NODE *node)
Definition: tree.c:1799
SCIP_Real SCIPnodeGetEstimate(SCIP_NODE *node)
Definition: tree.c:8523
void SCIPnodeGetAddedConss(SCIP_NODE *node, SCIP_CONS **addedconss, int *naddedconss, int addedconsssize)
Definition: tree.c:1769
int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:8493
SCIP_REOPTTYPE SCIPnodeGetReopttype(SCIP_NODE *node)
Definition: tree.c:8533
unsigned int SCIPnodeGetReoptID(SCIP_NODE *node)
Definition: tree.c:8564
SCIP_Bool SCIPnodeIsPropagatedAgain(SCIP_NODE *node)
Definition: tree.c:9284
SCIP_RETCODE SCIPnodePrintAncestorBranchings(SCIP_NODE *node, FILE *file)
Definition: tree.c:9118
SCIP_DECL_SORTPTRCOMP(SCIPnodeCompLowerbound)
Definition: tree.c:157
SCIP_CONSSETCHG * SCIPnodeGetConssetchg(SCIP_NODE *node)
Definition: tree.c:9294
data structures for branch and bound tree
type definitions for constraints and constraint handlers
type definitions for LP management
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:60
type definitions for miscellaneous datastructures
type definitions for rational numbers
type definitions for collecting reoptimization information
enum SCIP_ReoptType SCIP_REOPTTYPE
Definition: type_reopt.h:67
type definitions for return codes for SCIP methods
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
type definitions for branch and bound tree
enum SCIP_NodeType SCIP_NODETYPE
Definition: type_tree.h:53
type definitions for problem variables