Scippy

SCIP

Solving Constraint Integer Programs

nodesel.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-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 nodesel.h
26  * @ingroup INTERNALAPI
27  * @brief internal methods for node selectors and node priority queues
28  * @author Tobias Achterberg
29  */
30 
31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32 
33 #ifndef __SCIP_NODESEL_H__
34 #define __SCIP_NODESEL_H__
35 
36 
37 #include "scip/def.h"
38 #include "blockmemshell/memory.h"
39 #include "scip/type_event.h"
40 #include "scip/type_retcode.h"
41 #include "scip/type_set.h"
42 #include "scip/type_stat.h"
43 #include "scip/type_lp.h"
44 #include "scip/type_tree.h"
45 #include "scip/type_reopt.h"
46 #include "scip/type_message.h"
47 #include "scip/pub_nodesel.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 /*
54  * node priority queue methods
55  */
56 
57 /** creates node priority queue */
59  SCIP_NODEPQ** nodepq, /**< pointer to a node priority queue */
60  SCIP_SET* set, /**< global SCIP settings */
61  SCIP_NODESEL* nodesel /**< node selector to use for sorting the nodes in the queue */
62  );
63 
64 /** frees node priority queue, but not the data nodes themselves */
66  SCIP_NODEPQ** nodepq /**< pointer to a node priority queue */
67  );
68 
69 /** frees node priority queue and all nodes in the queue */
71  SCIP_NODEPQ** nodepq, /**< pointer to a node priority queue */
72  BMS_BLKMEM* blkmem, /**< block memory buffers */
73  SCIP_SET* set, /**< global SCIP settings */
74  SCIP_STAT* stat, /**< problem statistics */
75  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
76  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
77  SCIP_TREE* tree, /**< branch and bound tree */
78  SCIP_LP* lp /**< current LP data */
79  );
80 
81 /** deletes all nodes in the node priority queue */
83  SCIP_NODEPQ* nodepq, /**< node priority queue */
84  BMS_BLKMEM* blkmem, /**< block memory buffers */
85  SCIP_SET* set, /**< global SCIP settings */
86  SCIP_STAT* stat, /**< problem statistics */
87  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
88  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
89  SCIP_TREE* tree, /**< branch and bound tree */
90  SCIP_LP* lp /**< current LP data */
91  );
92 
93 /** returns the node selector associated with the given node priority queue */
95  SCIP_NODEPQ* nodepq /**< node priority queue */
96  );
97 
98 /** sets the node selector used for sorting the nodes in the queue, and resorts the queue if necessary */
100  SCIP_NODEPQ** nodepq, /**< pointer to a node priority queue */
101  SCIP_SET* set, /**< global SCIP settings */
102  SCIP_NODESEL* nodesel /**< node selector to use for sorting the nodes in the queue */
103  );
104 
105 /** compares two nodes; returns -1/0/+1 if node1 better/equal/worse than node2 */
107  SCIP_NODEPQ* nodepq, /**< node priority queue */
108  SCIP_SET* set, /**< global SCIP settings */
109  SCIP_NODE* node1, /**< first node to compare */
110  SCIP_NODE* node2 /**< second node to compare */
111  );
112 
113 /** inserts node into node priority queue */
115  SCIP_NODEPQ* nodepq, /**< node priority queue */
116  SCIP_SET* set, /**< global SCIP settings */
117  SCIP_NODE* node /**< node to be inserted */
118  );
119 
120 /** removes node from the node priority queue */
122  SCIP_NODEPQ* nodepq, /**< node priority queue */
123  SCIP_SET* set, /**< global SCIP settings */
124  SCIP_NODE* node /**< node to remove */
125  );
126 
127 /** returns the best node of the queue without removing it */
129  const SCIP_NODEPQ* nodepq /**< node priority queue */
130  );
131 
132 /** returns the nodes array of the queue */
134  const SCIP_NODEPQ* nodepq /**< node priority queue */
135  );
136 
137 /** returns the number of nodes stored in the node priority queue */
138 int SCIPnodepqLen(
139  const SCIP_NODEPQ* nodepq /**< node priority queue */
140  );
141 
142 /** gets the minimal lower bound of all nodes in the queue */
144  SCIP_NODEPQ* nodepq, /**< node priority queue */
145  SCIP_SET* set /**< global SCIP settings */
146  );
147 
148 /** gets the node with minimal lower bound of all nodes in the queue */
150  SCIP_NODEPQ* nodepq, /**< node priority queue */
151  SCIP_SET* set /**< global SCIP settings */
152  );
153 
154 /** gets the sum of lower bounds of all nodes in the queue */
156  SCIP_NODEPQ* nodepq /**< node priority queue */
157  );
158 
159 /** free all nodes from the queue that are cut off by the given upper bound */
161  SCIP_NODEPQ* nodepq, /**< node priority queue */
162  BMS_BLKMEM* blkmem, /**< block memory buffer */
163  SCIP_SET* set, /**< global SCIP settings */
164  SCIP_STAT* stat, /**< dynamic problem statistics */
165  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
166  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
167  SCIP_TREE* tree, /**< branch and bound tree */
168  SCIP_REOPT* reopt, /**< reoptimization data structure */
169  SCIP_LP* lp, /**< current LP data */
170  SCIP_Real cutoffbound /**< cutoff bound: all nodes with lowerbound >= cutoffbound are cut off */
171  );
172 
173 
174 
175 
176 /*
177  * node selector methods
178  */
179 
180 /** copies the given node selector to a new scip */
182  SCIP_NODESEL* nodesel, /**< node selector */
183  SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
184  );
185 
186 /** creates a node selector */
188  SCIP_NODESEL** nodesel, /**< pointer to store node selector */
189  SCIP_SET* set, /**< global SCIP settings */
190  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
191  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
192  const char* name, /**< name of node selector */
193  const char* desc, /**< description of node selector */
194  int stdpriority, /**< priority of the node selector in standard mode */
195  int memsavepriority, /**< priority of the node selector in memory saving mode */
196  SCIP_DECL_NODESELCOPY ((*nodeselcopy)), /**< copy method of node selector or NULL if you don't want to copy your plugin into sub-SCIPs */
197  SCIP_DECL_NODESELFREE ((*nodeselfree)), /**< destructor of node selector */
198  SCIP_DECL_NODESELINIT ((*nodeselinit)), /**< initialize node selector */
199  SCIP_DECL_NODESELEXIT ((*nodeselexit)), /**< deinitialize node selector */
200  SCIP_DECL_NODESELINITSOL((*nodeselinitsol)),/**< solving process initialization method of node selector */
201  SCIP_DECL_NODESELEXITSOL((*nodeselexitsol)),/**< solving process deinitialization method of node selector */
202  SCIP_DECL_NODESELSELECT((*nodeselselect)),/**< node selection method */
203  SCIP_DECL_NODESELCOMP ((*nodeselcomp)), /**< node comparison method */
204  SCIP_NODESELDATA* nodeseldata /**< node selector data */
205  );
206 
207 /** frees memory of node selector */
209  SCIP_NODESEL** nodesel, /**< pointer to node selector data structure */
210  SCIP_SET* set /**< global SCIP settings */
211  );
212 
213 /** initializes node selector */
215  SCIP_NODESEL* nodesel, /**< node selector */
216  SCIP_SET* set /**< global SCIP settings */
217  );
218 
219 /** deinitializes node selector */
221  SCIP_NODESEL* nodesel, /**< node selector */
222  SCIP_SET* set /**< global SCIP settings */
223  );
224 
225 /** informs node selector that the branch and bound process is being started */
227  SCIP_NODESEL* nodesel, /**< node selector */
228  SCIP_SET* set /**< global SCIP settings */
229  );
230 
231 /** informs node selector that the branch and bound process data is being freed */
233  SCIP_NODESEL* nodesel, /**< node selector */
234  SCIP_SET* set /**< global SCIP settings */
235  );
236 
237 /** select next node to be processed */
239  SCIP_NODESEL* nodesel, /**< node selector */
240  SCIP_SET* set, /**< global SCIP settings */
241  SCIP_NODE** selnode /**< pointer to store node to be processed next */
242  );
243 
244 /** compares two nodes; returns -1/0/+1 if node1 better/equal/worse than node2 */
246  SCIP_NODESEL* nodesel, /**< node selector */
247  SCIP_SET* set, /**< global SCIP settings */
248  SCIP_NODE* node1, /**< first node to compare */
249  SCIP_NODE* node2 /**< second node to compare */
250  );
251 
252 /** sets priority of node selector in standard mode */
254  SCIP_NODESEL* nodesel, /**< node selector */
255  SCIP_SET* set, /**< global SCIP settings */
256  int priority /**< new priority of the node selector */
257  );
258 
259 /** sets priority of node selector in memory saving mode */
261  SCIP_NODESEL* nodesel, /**< node selector */
262  SCIP_SET* set, /**< global SCIP settings */
263  int priority /**< new priority of the node selector */
264  );
265 
266 /** sets copy method of node selector */
267 void SCIPnodeselSetCopy(
268  SCIP_NODESEL* nodesel, /**< node selector */
269  SCIP_DECL_NODESELCOPY ((*nodeselcopy)) /**< copy method of node selector or NULL if you don't want to copy your plugin into sub-SCIPs */
270  );
271 
272 /** sets destructor method of node selector */
273 void SCIPnodeselSetFree(
274  SCIP_NODESEL* nodesel, /**< node selector */
275  SCIP_DECL_NODESELFREE ((*nodeselfree)) /**< destructor of node selector */
276  );
277 
278 /** sets initialization method of node selector */
279 void SCIPnodeselSetInit(
280  SCIP_NODESEL* nodesel, /**< node selector */
281  SCIP_DECL_NODESELINIT ((*nodeselinit)) /**< initialize node selector */
282  );
283 
284 /** sets deinitialization method of node selector */
285 void SCIPnodeselSetExit(
286  SCIP_NODESEL* nodesel, /**< node selector */
287  SCIP_DECL_NODESELEXIT ((*nodeselexit)) /**< deinitialize node selector */
288  );
289 
290 /** sets solving process initialization method of node selector */
292  SCIP_NODESEL* nodesel, /**< node selector */
293  SCIP_DECL_NODESELINITSOL ((*nodeselinitsol))/**< solving process initialization method of node selector */
294  );
295 
296 /** sets solving process deinitialization method of node selector */
298  SCIP_NODESEL* nodesel, /**< node selector */
299  SCIP_DECL_NODESELEXITSOL ((*nodeselexitsol))/**< solving process deinitialization method of node selector */
300  );
301 
302 /** enables or disables all clocks of \p nodesel, depending on the value of the flag */
304  SCIP_NODESEL* nodesel, /**< the node selector for which all clocks should be enabled or disabled */
305  SCIP_Bool enable /**< should the clocks of the node selector be enabled? */
306  );
307 
308 #ifdef __cplusplus
309 }
310 #endif
311 
312 #endif
void SCIPnodeselSetInit(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELINIT((*nodeselinit)))
Definition: nodesel.c:1165
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
#define SCIP_DECL_NODESELCOMP(x)
Definition: type_nodesel.h:140
void SCIPnodeselEnableOrDisableClocks(SCIP_NODESEL *nodesel, SCIP_Bool enable)
Definition: nodesel.c:1219
int SCIPnodepqCompare(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node1, SCIP_NODE *node2)
Definition: nodesel.c:264
int SCIPnodepqLen(const SCIP_NODEPQ *nodepq)
Definition: nodesel.c:571
#define SCIP_DECL_NODESELINITSOL(x)
Definition: type_nodesel.h:97
SCIP_Real SCIPnodepqGetLowerboundSum(SCIP_NODEPQ *nodepq)
Definition: nodesel.c:629
SCIP_NODESEL * SCIPnodepqGetNodesel(SCIP_NODEPQ *nodepq)
Definition: nodesel.c:206
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
type definitions for global SCIP settings
SCIP_RETCODE SCIPnodeselExitsol(SCIP_NODESEL *nodesel, SCIP_SET *set)
Definition: nodesel.c:988
SCIP_NODE * SCIPnodepqGetLowerboundNode(SCIP_NODEPQ *nodepq, SCIP_SET *set)
Definition: nodesel.c:605
type definitions for return codes for SCIP methods
type definitions for collecting reoptimization information
#define SCIP_DECL_NODESELEXITSOL(x)
Definition: type_nodesel.h:108
type definitions for problem statistics
SCIP_RETCODE SCIPnodeselCopyInclude(SCIP_NODESEL *nodesel, SCIP_SET *set)
Definition: nodesel.c:749
#define SCIP_DECL_NODESELINIT(x)
Definition: type_nodesel.h:78
SCIP_RETCODE SCIPnodeselExit(SCIP_NODESEL *nodesel, SCIP_SET *set)
Definition: nodesel.c:934
type definitions for LP management
SCIP_RETCODE SCIPnodeselSelect(SCIP_NODESEL *nodesel, SCIP_SET *set, SCIP_NODE **selnode)
Definition: nodesel.c:1012
struct SCIP_NodeselData SCIP_NODESELDATA
Definition: type_nodesel.h:52
SCIP_RETCODE SCIPnodeselFree(SCIP_NODESEL **nodesel, SCIP_SET *set)
Definition: nodesel.c:869
SCIP_RETCODE SCIPnodepqInsert(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
Definition: nodesel.c:280
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 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 SCIPnodeselInitsol(SCIP_NODESEL *nodesel, SCIP_SET *set)
Definition: nodesel.c:964
SCIP_RETCODE SCIPnodeselInit(SCIP_NODESEL *nodesel, SCIP_SET *set)
Definition: nodesel.c:898
SCIP_RETCODE SCIPnodepqSetNodesel(SCIP_NODEPQ **nodepq, SCIP_SET *set, SCIP_NODESEL *nodesel)
Definition: nodesel.c:216
#define SCIP_DECL_NODESELFREE(x)
Definition: type_nodesel.h:70
SCIP_RETCODE SCIPnodepqRemove(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
Definition: nodesel.c:524
type definitions for managing events
public methods for node selectors
void SCIPnodeselSetExit(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELEXIT((*nodeselexit)))
Definition: nodesel.c:1176
#define SCIP_Bool
Definition: def.h:91
#define SCIP_DECL_NODESELEXIT(x)
Definition: type_nodesel.h:86
int SCIPnodeselCompare(SCIP_NODESEL *nodesel, SCIP_SET *set, SCIP_NODE *node1, SCIP_NODE *node2)
Definition: nodesel.c:1035
type definitions for branch and bound tree
void SCIPnodeselSetInitsol(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELINITSOL((*nodeselinitsol)))
Definition: nodesel.c:1187
void SCIPnodeselSetMemsavePriority(SCIP_NODESEL *nodesel, SCIP_SET *set, int priority)
Definition: nodesel.c:1106
void SCIPnodeselSetExitsol(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELEXITSOL((*nodeselexitsol)))
Definition: nodesel.c:1198
SCIP_RETCODE SCIPnodeselCreate(SCIP_NODESEL **nodesel, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int stdpriority, int memsavepriority, SCIP_DECL_NODESELCOPY((*nodeselcopy)), SCIP_DECL_NODESELFREE((*nodeselfree)), SCIP_DECL_NODESELINIT((*nodeselinit)), SCIP_DECL_NODESELEXIT((*nodeselexit)), SCIP_DECL_NODESELINITSOL((*nodeselinitsol)), SCIP_DECL_NODESELEXITSOL((*nodeselexitsol)), SCIP_DECL_NODESELSELECT((*nodeselselect)), SCIP_DECL_NODESELCOMP((*nodeselcomp)), SCIP_NODESELDATA *nodeseldata)
Definition: nodesel.c:835
SCIP_RETCODE SCIPnodepqCreate(SCIP_NODEPQ **nodepq, SCIP_SET *set, SCIP_NODESEL *nodesel)
Definition: nodesel.c:105
#define SCIP_Real
Definition: def.h:173
void SCIPnodeselSetFree(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELFREE((*nodeselfree)))
Definition: nodesel.c:1154
#define SCIP_DECL_NODESELCOPY(x)
Definition: type_nodesel.h:61
SCIP_NODE * SCIPnodepqFirst(const SCIP_NODEPQ *nodepq)
Definition: nodesel.c:545
SCIP_Real SCIPnodepqGetLowerbound(SCIP_NODEPQ *nodepq, SCIP_SET *set)
Definition: nodesel.c:582
type definitions for message output methods
SCIP_NODE ** SCIPnodepqNodes(const SCIP_NODEPQ *nodepq)
Definition: nodesel.c:561
void SCIPnodeselSetCopy(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELCOPY((*nodeselcopy)))
Definition: nodesel.c:1143
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:437
void SCIPnodeselSetStdPriority(SCIP_NODESEL *nodesel, SCIP_SET *set, int priority)
Definition: nodesel.c:1082
#define SCIP_DECL_NODESELSELECT(x)
Definition: type_nodesel.h:123
void SCIPnodepqDestroy(SCIP_NODEPQ **nodepq)
Definition: nodesel.c:127
memory allocation routines