Scippy

SCIP

Solving Constraint Integer Programs

scip_datastructures.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-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_datastructures.h
17  * @ingroup PUBLICCOREAPI
18  * @brief public methods for data structures
19  * @author Tobias Achterberg
20  * @author Timo Berthold
21  * @author Thorsten Koch
22  * @author Alexander Martin
23  * @author Marc Pfetsch
24  * @author Kati Wolter
25  * @author Gregor Hendel
26  * @author Robert Lion Gottwald
27  */
28 
29 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
30 
31 #ifndef __SCIP_SCIP_DATASTRUCTURES_H__
32 #define __SCIP_SCIP_DATASTRUCTURES_H__
33 
34 
35 #include "scip/def.h"
36 #include "scip/type_misc.h"
37 #include "scip/type_retcode.h"
38 #include "scip/type_scip.h"
39 
40 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
41  * this structure except the interface methods in scip.c.
42  * In optimized mode, the structure is included in scip.h, because some of the methods
43  * are implemented as defines for performance reasons (e.g. the numerical comparisons).
44  * Additionally, the internal "set.h" is included, such that the defines in set.h are
45  * available in optimized mode.
46  */
47 #ifdef NDEBUG
48 #include "scip/struct_scip.h"
49 #include "scip/struct_stat.h"
50 #include "scip/set.h"
51 #include "scip/tree.h"
52 #include "scip/misc.h"
53 #include "scip/var.h"
54 #include "scip/cons.h"
55 #include "scip/solve.h"
56 #include "scip/debug.h"
57 #endif
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 /**@addtogroup PublicDynamicArrayMethods
64  *
65  * @{
66  */
67 
68 /** creates a dynamic array of real values
69  *
70  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
71  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
72  */
73 extern
75  SCIP* scip, /**< SCIP data structure */
76  SCIP_REALARRAY** realarray /**< pointer to store the real array */
77  );
78 
79 /** frees a dynamic array of real values
80  *
81  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
82  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
83  */
84 extern
86  SCIP* scip, /**< SCIP data structure */
87  SCIP_REALARRAY** realarray /**< pointer to the real array */
88  );
89 
90 /** extends dynamic array to be able to store indices from minidx to maxidx
91  *
92  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
93  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
94  */
95 extern
97  SCIP* scip, /**< SCIP data structure */
98  SCIP_REALARRAY* realarray, /**< dynamic real array */
99  int minidx, /**< smallest index to allocate storage for */
100  int maxidx /**< largest index to allocate storage for */
101  );
102 
103 /** clears a dynamic real array
104  *
105  * @return clears a dynamic real array
106  */
107 extern
109  SCIP* scip, /**< SCIP data structure */
110  SCIP_REALARRAY* realarray /**< dynamic real array */
111  );
112 
113 /** gets value of entry in dynamic array */
114 extern
116  SCIP* scip, /**< SCIP data structure */
117  SCIP_REALARRAY* realarray, /**< dynamic real array */
118  int idx /**< array index to get value for */
119  );
120 
121 /** sets value of entry in dynamic array
122  *
123  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
124  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
125  */
126 extern
128  SCIP* scip, /**< SCIP data structure */
129  SCIP_REALARRAY* realarray, /**< dynamic real array */
130  int idx, /**< array index to set value for */
131  SCIP_Real val /**< value to set array index to */
132  );
133 
134 /** increases value of entry in dynamic array
135  *
136  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
137  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
138  */
139 extern
141  SCIP* scip, /**< SCIP data structure */
142  SCIP_REALARRAY* realarray, /**< dynamic real array */
143  int idx, /**< array index to increase value for */
144  SCIP_Real incval /**< value to increase array index */
145  );
146 
147 /** returns the minimal index of all stored non-zero elements
148  *
149  * @return the minimal index of all stored non-zero elements
150  */
151 extern
153  SCIP* scip, /**< SCIP data structure */
154  SCIP_REALARRAY* realarray /**< dynamic real array */
155  );
156 
157 /** returns the maximal index of all stored non-zero elements
158  *
159  * @return the maximal index of all stored non-zero elements
160  */
161 extern
163  SCIP* scip, /**< SCIP data structure */
164  SCIP_REALARRAY* realarray /**< dynamic real array */
165  );
166 
167 /** creates a dynamic array of int values
168  *
169  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
170  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
171  */
172 extern
174  SCIP* scip, /**< SCIP data structure */
175  SCIP_INTARRAY** intarray /**< pointer to store the int array */
176  );
177 
178 /** frees a dynamic array of int values
179  *
180  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
181  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
182  */
183 extern
185  SCIP* scip, /**< SCIP data structure */
186  SCIP_INTARRAY** intarray /**< pointer to the int array */
187  );
188 
189 /** extends dynamic array to be able to store indices from minidx to maxidx
190  *
191  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
192  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
193  */
194 extern
196  SCIP* scip, /**< SCIP data structure */
197  SCIP_INTARRAY* intarray, /**< dynamic int array */
198  int minidx, /**< smallest index to allocate storage for */
199  int maxidx /**< largest index to allocate storage for */
200  );
201 
202 /** clears a dynamic int array
203  *
204  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
205  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
206  */
207 extern
209  SCIP* scip, /**< SCIP data structure */
210  SCIP_INTARRAY* intarray /**< dynamic int array */
211  );
212 
213 /** gets value of entry in dynamic array
214  *
215  * @return value of entry in dynamic array
216  */
217 extern
219  SCIP* scip, /**< SCIP data structure */
220  SCIP_INTARRAY* intarray, /**< dynamic int array */
221  int idx /**< array index to get value for */
222  );
223 
224 /** sets value of entry in dynamic array
225  *
226  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
227  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
228  */
229 extern
231  SCIP* scip, /**< SCIP data structure */
232  SCIP_INTARRAY* intarray, /**< dynamic int array */
233  int idx, /**< array index to set value for */
234  int val /**< value to set array index to */
235  );
236 
237 /** increases value of entry in dynamic array
238  *
239  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
240  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
241  */
242 extern
244  SCIP* scip, /**< SCIP data structure */
245  SCIP_INTARRAY* intarray, /**< dynamic int array */
246  int idx, /**< array index to increase value for */
247  int incval /**< value to increase array index */
248  );
249 
250 /** returns the minimal index of all stored non-zero elements
251  *
252  * @return the minimal index of all stored non-zero elements
253  */
254 extern
256  SCIP* scip, /**< SCIP data structure */
257  SCIP_INTARRAY* intarray /**< dynamic int array */
258  );
259 
260 /** returns the maximal index of all stored non-zero elements
261  *
262  * @return the maximal index of all stored non-zero elements
263  */
264 extern
266  SCIP* scip, /**< SCIP data structure */
267  SCIP_INTARRAY* intarray /**< dynamic int array */
268  );
269 
270 /** creates a dynamic array of bool values
271  *
272  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
273  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
274  */
275 extern
277  SCIP* scip, /**< SCIP data structure */
278  SCIP_BOOLARRAY** boolarray /**< pointer to store the bool array */
279  );
280 
281 /** frees a dynamic array of bool values
282  *
283  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
284  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
285  */
286 extern
288  SCIP* scip, /**< SCIP data structure */
289  SCIP_BOOLARRAY** boolarray /**< pointer to the bool array */
290  );
291 
292 /** extends dynamic array to be able to store indices from minidx to maxidx
293  *
294  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
295  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
296  */
297 extern
299  SCIP* scip, /**< SCIP data structure */
300  SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */
301  int minidx, /**< smallest index to allocate storage for */
302  int maxidx /**< largest index to allocate storage for */
303  );
304 
305 /** clears a dynamic bool array
306  *
307  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
308  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
309  */
310 extern
312  SCIP* scip, /**< SCIP data structure */
313  SCIP_BOOLARRAY* boolarray /**< dynamic bool array */
314  );
315 
316 /** gets value of entry in dynamic array
317  *
318  * @return value of entry in dynamic array at position idx
319  */
320 extern
322  SCIP* scip, /**< SCIP data structure */
323  SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */
324  int idx /**< array index to get value for */
325  );
326 
327 /** sets value of entry in dynamic array
328  *
329  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
330  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
331  */
332 extern
334  SCIP* scip, /**< SCIP data structure */
335  SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */
336  int idx, /**< array index to set value for */
337  SCIP_Bool val /**< value to set array index to */
338  );
339 
340 /** returns the minimal index of all stored non-zero elements
341  *
342  * @return the minimal index of all stored non-zero elements
343  */
344 extern
346  SCIP* scip, /**< SCIP data structure */
347  SCIP_BOOLARRAY* boolarray /**< dynamic bool array */
348  );
349 
350 /** returns the maximal index of all stored non-zero elements
351  *
352  * @return the maximal index of all stored non-zero elements
353  */
354 extern
356  SCIP* scip, /**< SCIP data structure */
357  SCIP_BOOLARRAY* boolarray /**< dynamic bool array */
358  );
359 
360 /** creates a dynamic array of pointers
361  *
362  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
363  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
364  */
365 extern
367  SCIP* scip, /**< SCIP data structure */
368  SCIP_PTRARRAY** ptrarray /**< pointer to store the int array */
369  );
370 
371 /** frees a dynamic array of pointers
372  *
373  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
374  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
375  */
376 extern
378  SCIP* scip, /**< SCIP data structure */
379  SCIP_PTRARRAY** ptrarray /**< pointer to the int array */
380  );
381 
382 /** extends dynamic array to be able to store indices from minidx to maxidx
383  *
384  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
385  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
386  */
387 extern
389  SCIP* scip, /**< SCIP data structure */
390  SCIP_PTRARRAY* ptrarray, /**< dynamic int array */
391  int minidx, /**< smallest index to allocate storage for */
392  int maxidx /**< largest index to allocate storage for */
393  );
394 
395 /** clears a dynamic pointer array
396  *
397  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
398  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
399  */
400 extern
402  SCIP* scip, /**< SCIP data structure */
403  SCIP_PTRARRAY* ptrarray /**< dynamic int array */
404  );
405 
406 /** gets value of entry in dynamic array */
407 extern
408 void* SCIPgetPtrarrayVal(
409  SCIP* scip, /**< SCIP data structure */
410  SCIP_PTRARRAY* ptrarray, /**< dynamic int array */
411  int idx /**< array index to get value for */
412  );
413 
414 /** sets value of entry in dynamic array
415  *
416  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
417  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
418  */
419 extern
421  SCIP* scip, /**< SCIP data structure */
422  SCIP_PTRARRAY* ptrarray, /**< dynamic int array */
423  int idx, /**< array index to set value for */
424  void* val /**< value to set array index to */
425  );
426 
427 /** returns the minimal index of all stored non-zero elements
428  *
429  * @return the minimal index of all stored non-zero elements
430  */
431 extern
433  SCIP* scip, /**< SCIP data structure */
434  SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */
435  );
436 
437 /** returns the maximal index of all stored non-zero elements
438  *
439  * @return the maximal index of all stored non-zero elements
440  */
441 extern
443  SCIP* scip, /**< SCIP data structure */
444  SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */
445  );
446 
447 /**@} */
448 
449 /**@addtogroup DisjointSet
450  *
451  * @{
452  */
453 
454 /** creates a disjoint set (union find) structure \p djset for \p ncomponents many components (of size one) */
455 extern
457  SCIP* scip, /**< SCIP data structure */
458  SCIP_DISJOINTSET** djset, /**< disjoint set (union find) data structure */
459  int ncomponents /**< number of components */
460  );
461 
462 /** frees the disjoint set (union find) data structure */
463 extern
465  SCIP* scip, /**< SCIP data structure */
466  SCIP_DISJOINTSET** djset /**< pointer to disjoint set (union find) data structure */
467  );
468 
469 /* @} */
470 
471 /**@addtogroup DirectedGraph
472  *
473  * @{
474  */
475 
476 /** creates directed graph structure */
477 extern
479  SCIP* scip, /**< SCIP data structure */
480  SCIP_DIGRAPH** digraph, /**< pointer to store the created directed graph */
481  int nnodes /**< number of nodes */
482  );
483 
484 /**! [SnippetCodeStyleComment] */
485 
486 /** copies directed graph structure
487  *
488  * The copying procedure uses the memory of the passed SCIP instance. The user must ensure that the digraph lives
489  * as most as long as the SCIP instance.
490  *
491  * @note The data in nodedata is copied verbatim. This possibly has to be adapted by the user.
492  */
493 extern
495  SCIP* scip, /**< SCIP data structure */
496  SCIP_DIGRAPH** targetdigraph, /**< pointer to store the copied directed graph */
497  SCIP_DIGRAPH* sourcedigraph /**< source directed graph */
498  );
499 
500 /**! [SnippetCodeStyleComment] */
501 /**@} */
502 
503 #ifdef __cplusplus
504 }
505 #endif
506 
507 #endif
SCIP_RETCODE SCIPincIntarrayVal(SCIP *scip, SCIP_INTARRAY *intarray, int idx, int incval)
SCIP_RETCODE SCIPextendBoolarray(SCIP *scip, SCIP_BOOLARRAY *boolarray, int minidx, int maxidx)
internal methods for branch and bound tree
type definitions for miscellaneous datastructures
SCIP_RETCODE SCIPcreateBoolarray(SCIP *scip, SCIP_BOOLARRAY **boolarray)
int SCIPgetIntarrayMaxIdx(SCIP *scip, SCIP_INTARRAY *intarray)
SCIP_RETCODE SCIPcreateRealarray(SCIP *scip, SCIP_REALARRAY **realarray)
SCIP_RETCODE SCIPextendIntarray(SCIP *scip, SCIP_INTARRAY *intarray, int minidx, int maxidx)
SCIP_RETCODE SCIPincRealarrayVal(SCIP *scip, SCIP_REALARRAY *realarray, int idx, SCIP_Real incval)
SCIP_RETCODE SCIPextendRealarray(SCIP *scip, SCIP_REALARRAY *realarray, int minidx, int maxidx)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPcreateIntarray(SCIP *scip, SCIP_INTARRAY **intarray)
SCIP_RETCODE SCIPfreeIntarray(SCIP *scip, SCIP_INTARRAY **intarray)
type definitions for return codes for SCIP methods
int SCIPgetPtrarrayMaxIdx(SCIP *scip, SCIP_PTRARRAY *ptrarray)
int SCIPgetIntarrayMinIdx(SCIP *scip, SCIP_INTARRAY *intarray)
SCIP_RETCODE SCIPcreateDigraph(SCIP *scip, SCIP_DIGRAPH **digraph, int nnodes)
SCIP_RETCODE SCIPsetBoolarrayVal(SCIP *scip, SCIP_BOOLARRAY *boolarray, int idx, SCIP_Bool val)
SCIP_RETCODE SCIPclearRealarray(SCIP *scip, SCIP_REALARRAY *realarray)
SCIP_RETCODE SCIPclearPtrarray(SCIP *scip, SCIP_PTRARRAY *ptrarray)
void * SCIPgetPtrarrayVal(SCIP *scip, SCIP_PTRARRAY *ptrarray, int idx)
type definitions for SCIP&#39;s main datastructure
internal miscellaneous methods
SCIP_RETCODE SCIPclearBoolarray(SCIP *scip, SCIP_BOOLARRAY *boolarray)
SCIP_RETCODE SCIPfreeBoolarray(SCIP *scip, SCIP_BOOLARRAY **boolarray)
internal methods for global SCIP settings
SCIP main data structure.
int SCIPgetIntarrayVal(SCIP *scip, SCIP_INTARRAY *intarray, int idx)
SCIP_RETCODE SCIPfreeRealarray(SCIP *scip, SCIP_REALARRAY **realarray)
SCIP_RETCODE SCIPcreateDisjointset(SCIP *scip, SCIP_DISJOINTSET **djset, int ncomponents)
int SCIPgetRealarrayMaxIdx(SCIP *scip, SCIP_REALARRAY *realarray)
SCIP_RETCODE SCIPsetRealarrayVal(SCIP *scip, SCIP_REALARRAY *realarray, int idx, SCIP_Real val)
int SCIPgetBoolarrayMinIdx(SCIP *scip, SCIP_BOOLARRAY *boolarray)
internal methods for problem variables
#define SCIP_Bool
Definition: def.h:69
methods for debugging
SCIP_RETCODE SCIPsetIntarrayVal(SCIP *scip, SCIP_INTARRAY *intarray, int idx, int val)
datastructures for problem statistics
SCIP_RETCODE SCIPextendPtrarray(SCIP *scip, SCIP_PTRARRAY *ptrarray, int minidx, int maxidx)
int SCIPgetBoolarrayMaxIdx(SCIP *scip, SCIP_BOOLARRAY *boolarray)
SCIP_RETCODE SCIPcreatePtrarray(SCIP *scip, SCIP_PTRARRAY **ptrarray)
internal methods for main solving loop and node processing
SCIP_Real SCIPgetRealarrayVal(SCIP *scip, SCIP_REALARRAY *realarray, int idx)
int SCIPgetRealarrayMinIdx(SCIP *scip, SCIP_REALARRAY *realarray)
SCIP_RETCODE SCIPclearIntarray(SCIP *scip, SCIP_INTARRAY *intarray)
#define SCIP_Real
Definition: def.h:157
internal methods for constraints and constraint handlers
SCIP_Bool SCIPgetBoolarrayVal(SCIP *scip, SCIP_BOOLARRAY *boolarray, int idx)
#define nnodes
Definition: gastrans.c:65
int SCIPgetPtrarrayMinIdx(SCIP *scip, SCIP_PTRARRAY *ptrarray)
common defines and data types used in all packages of SCIP
void SCIPfreeDisjointset(SCIP *scip, SCIP_DISJOINTSET **djset)
SCIP_RETCODE SCIPcopyDigraph(SCIP *scip, SCIP_DIGRAPH **targetdigraph, SCIP_DIGRAPH *sourcedigraph)
SCIP_RETCODE SCIPsetPtrarrayVal(SCIP *scip, SCIP_PTRARRAY *ptrarray, int idx, void *val)
SCIP_RETCODE SCIPfreePtrarray(SCIP *scip, SCIP_PTRARRAY **ptrarray)