Scippy

SCIP

Solving Constraint Integer Programs

misc.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-2016 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 misc.h
17  * @brief internal miscellaneous methods
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __SCIP_MISC_H__
24 #define __SCIP_MISC_H__
25 
26 
27 #include "scip/def.h"
28 #include "blockmemshell/memory.h"
29 #include "scip/type_retcode.h"
30 #include "scip/type_set.h"
31 #include "scip/type_misc.h"
32 #include "scip/pub_misc.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Dynamic Arrays
40  */
41 
42 /** creates a dynamic array of real values */
43 extern
45  SCIP_REALARRAY** realarray, /**< pointer to store the real array */
46  BMS_BLKMEM* blkmem /**< block memory */
47  );
48 
49 /** creates a copy of a dynamic array of real values */
50 extern
52  SCIP_REALARRAY** realarray, /**< pointer to store the copied real array */
53  BMS_BLKMEM* blkmem, /**< block memory */
54  SCIP_REALARRAY* sourcerealarray /**< dynamic real array to copy */
55  );
56 
57 /** frees a dynamic array of real values */
58 extern
60  SCIP_REALARRAY** realarray /**< pointer to the real array */
61  );
62 
63 /** extends dynamic array to be able to store indices from minidx to maxidx */
64 extern
66  SCIP_REALARRAY* realarray, /**< dynamic real array */
67  int arraygrowinit, /**< initial size of array */
68  SCIP_Real arraygrowfac, /**< growing factor of array */
69  int minidx, /**< smallest index to allocate storage for */
70  int maxidx /**< largest index to allocate storage for */
71  );
72 
73 /** clears a dynamic real array */
74 extern
76  SCIP_REALARRAY* realarray /**< dynamic real array */
77  );
78 
79 /** gets value of entry in dynamic array */
80 extern
82  SCIP_REALARRAY* realarray, /**< dynamic real array */
83  int idx /**< array index to get value for */
84  );
85 
86 /** sets value of entry in dynamic array */
87 extern
89  SCIP_REALARRAY* realarray, /**< dynamic real array */
90  int arraygrowinit, /**< initial size of array */
91  SCIP_Real arraygrowfac, /**< growing factor of array */
92  int idx, /**< array index to set value for */
93  SCIP_Real val /**< value to set array index to */
94  );
95 
96 /** increases value of entry in dynamic array */
97 extern
99  SCIP_REALARRAY* realarray, /**< dynamic real array */
100  int arraygrowinit, /**< initial size of array */
101  SCIP_Real arraygrowfac, /**< growing factor of array */
102  int idx, /**< array index to increase value for */
103  SCIP_Real incval /**< value to increase array index */
104  );
105 
106 /** returns the minimal index of all stored non-zero elements */
107 extern
109  SCIP_REALARRAY* realarray /**< dynamic real array */
110  );
111 
112 /** returns the maximal index of all stored non-zero elements */
113 extern
115  SCIP_REALARRAY* realarray /**< dynamic real array */
116  );
117 
118 /** creates a dynamic array of int values */
119 extern
121  SCIP_INTARRAY** intarray, /**< pointer to store the int array */
122  BMS_BLKMEM* blkmem /**< block memory */
123  );
124 
125 /** creates a copy of a dynamic array of int values */
126 extern
128  SCIP_INTARRAY** intarray, /**< pointer to store the copied int array */
129  BMS_BLKMEM* blkmem, /**< block memory */
130  SCIP_INTARRAY* sourceintarray /**< dynamic int array to copy */
131  );
132 
133 /** frees a dynamic array of int values */
134 extern
136  SCIP_INTARRAY** intarray /**< pointer to the int array */
137  );
138 
139 /** extends dynamic array to be able to store indices from minidx to maxidx */
140 extern
142  SCIP_INTARRAY* intarray, /**< dynamic int array */
143  int arraygrowinit, /**< initial size of array */
144  SCIP_Real arraygrowfac, /**< growing factor of array */
145  int minidx, /**< smallest index to allocate storage for */
146  int maxidx /**< largest index to allocate storage for */
147  );
148 
149 /** clears a dynamic int array */
150 extern
152  SCIP_INTARRAY* intarray /**< dynamic int array */
153  );
154 
155 /** gets value of entry in dynamic array */
156 extern
158  SCIP_INTARRAY* intarray, /**< dynamic int array */
159  int idx /**< array index to get value for */
160  );
161 
162 /** sets value of entry in dynamic array */
163 extern
165  SCIP_INTARRAY* intarray, /**< dynamic int array */
166  int arraygrowinit, /**< initial size of array */
167  SCIP_Real arraygrowfac, /**< growing factor of array */
168  int idx, /**< array index to set value for */
169  int val /**< value to set array index to */
170  );
171 
172 /** increases value of entry in dynamic array */
173 extern
175  SCIP_INTARRAY* intarray, /**< dynamic int array */
176  int arraygrowinit, /**< initial size of array */
177  SCIP_Real arraygrowfac, /**< growing factor of array */
178  int idx, /**< array index to increase value for */
179  int incval /**< value to increase array index */
180  );
181 
182 /** returns the minimal index of all stored non-zero elements */
183 extern
185  SCIP_INTARRAY* intarray /**< dynamic int array */
186  );
187 
188 /** returns the maximal index of all stored non-zero elements */
189 extern
191  SCIP_INTARRAY* intarray /**< dynamic int array */
192  );
193 
194 /** creates a dynamic array of bool values */
195 extern
197  SCIP_BOOLARRAY** boolarray, /**< pointer to store the bool array */
198  BMS_BLKMEM* blkmem /**< block memory */
199  );
200 
201 /** creates a copy of a dynamic array of bool values */
202 extern
204  SCIP_BOOLARRAY** boolarray, /**< pointer to store the copied bool array */
205  BMS_BLKMEM* blkmem, /**< block memory */
206  SCIP_BOOLARRAY* sourceboolarray /**< dynamic bool array to copy */
207  );
208 
209 /** frees a dynamic array of bool values */
210 extern
212  SCIP_BOOLARRAY** boolarray /**< pointer to the bool array */
213  );
214 
215 /** extends dynamic array to be able to store indices from minidx to maxidx */
216 extern
218  SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */
219  int arraygrowinit, /**< initial size of array */
220  SCIP_Real arraygrowfac, /**< growing factor of array */
221  int minidx, /**< smallest index to allocate storage for */
222  int maxidx /**< largest index to allocate storage for */
223  );
224 
225 /** clears a dynamic bool array */
226 extern
228  SCIP_BOOLARRAY* boolarray /**< dynamic bool array */
229  );
230 
231 /** gets value of entry in dynamic array */
232 extern
234  SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */
235  int idx /**< array index to get value for */
236  );
237 
238 /** sets value of entry in dynamic array */
239 extern
241  SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */
242  int arraygrowinit, /**< initial size of array */
243  SCIP_Real arraygrowfac, /**< growing factor of array */
244  int idx, /**< array index to set value for */
245  SCIP_Bool val /**< value to set array index to */
246  );
247 
248 /** returns the minimal index of all stored non-zero elements */
249 extern
251  SCIP_BOOLARRAY* boolarray /**< dynamic bool array */
252  );
253 
254 /** returns the maximal index of all stored non-zero elements */
255 extern
257  SCIP_BOOLARRAY* boolarray /**< dynamic bool array */
258  );
259 
260 /** creates a dynamic array of pointer values */
261 extern
263  SCIP_PTRARRAY** ptrarray, /**< pointer to store the ptr array */
264  BMS_BLKMEM* blkmem /**< block memory */
265  );
266 
267 /** creates a copy of a dynamic array of pointer values */
268 extern
270  SCIP_PTRARRAY** ptrarray, /**< pointer to store the copied ptr array */
271  BMS_BLKMEM* blkmem, /**< block memory */
272  SCIP_PTRARRAY* sourceptrarray /**< dynamic ptr array to copy */
273  );
274 
275 /** frees a dynamic array of pointer values */
276 extern
278  SCIP_PTRARRAY** ptrarray /**< pointer to the ptr array */
279  );
280 
281 /** extends dynamic array to be able to store indices from minidx to maxidx */
282 extern
284  SCIP_PTRARRAY* ptrarray, /**< dynamic ptr array */
285  int arraygrowinit, /**< initial size of array */
286  SCIP_Real arraygrowfac, /**< growing factor of array */
287  int minidx, /**< smallest index to allocate storage for */
288  int maxidx /**< largest index to allocate storage for */
289  );
290 
291 /** clears a dynamic pointer array */
292 extern
294  SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */
295  );
296 
297 /** gets value of entry in dynamic array */
298 extern
299 void* SCIPptrarrayGetVal(
300  SCIP_PTRARRAY* ptrarray, /**< dynamic ptr array */
301  int idx /**< array index to get value for */
302  );
303 
304 /** sets value of entry in dynamic array */
305 extern
307  SCIP_PTRARRAY* ptrarray, /**< dynamic ptr array */
308  int arraygrowinit, /**< initial size of array */
309  SCIP_Real arraygrowfac, /**< growing factor of array */
310  int idx, /**< array index to set value for */
311  void* val /**< value to set array index to */
312  );
313 
314 /** returns the minimal index of all stored non-zero elements */
315 extern
317  SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */
318  );
319 
320 /** returns the maximal index of all stored non-zero elements */
321 extern
323  SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */
324  );
325 
326 /*
327  * Additional math functions
328  */
329 
330 /** negates a number
331  *
332  * negation of a number that can be used to avoid that a negation is optimized away by a compiler
333  */
334 extern
336  SCIP_Real x /**< value to negate */
337  );
338 
339 #ifdef __cplusplus
340 }
341 #endif
342 
343 #endif
SCIP_RETCODE SCIPrealarrayCreate(SCIP_REALARRAY **realarray, BMS_BLKMEM *blkmem)
Definition: misc.c:2359
void * SCIPptrarrayGetVal(SCIP_PTRARRAY *ptrarray, int idx)
Definition: misc.c:3695
SCIP_RETCODE SCIPptrarrayCopy(SCIP_PTRARRAY **ptrarray, BMS_BLKMEM *blkmem, SCIP_PTRARRAY *sourceptrarray)
Definition: misc.c:3472
SCIP_RETCODE SCIPrealarraySetVal(SCIP_REALARRAY *realarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Real val)
Definition: misc.c:2624
int SCIPintarrayGetMinIdx(SCIP_INTARRAY *intarray)
Definition: misc.c:3075
type definitions for miscellaneous datastructures
int SCIPboolarrayGetMaxIdx(SCIP_BOOLARRAY *boolarray)
Definition: misc.c:3441
double arraygrowfac
Definition: memory.c:2424
int SCIPrealarrayGetMaxIdx(SCIP_REALARRAY *realarray)
Definition: misc.c:2721
int SCIPrealarrayGetMinIdx(SCIP_REALARRAY *realarray)
Definition: misc.c:2711
SCIP_RETCODE SCIPptrarrayExtend(SCIP_PTRARRAY *ptrarray, int arraygrowinit, SCIP_Real arraygrowfac, int minidx, int maxidx)
Definition: misc.c:3509
SCIP_RETCODE SCIPboolarrayCopy(SCIP_BOOLARRAY **boolarray, BMS_BLKMEM *blkmem, SCIP_BOOLARRAY *sourceboolarray)
Definition: misc.c:3116
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
type definitions for global SCIP settings
SCIP_RETCODE SCIPrealarrayIncVal(SCIP_REALARRAY *realarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Real incval)
Definition: misc.c:2693
int SCIPptrarrayGetMinIdx(SCIP_PTRARRAY *ptrarray)
Definition: misc.c:3784
type definitions for return codes for SCIP methods
SCIP_RETCODE SCIPintarrayIncVal(SCIP_INTARRAY *intarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, int incval)
Definition: misc.c:3063
SCIP_Real SCIPrealarrayGetVal(SCIP_REALARRAY *realarray, int idx)
Definition: misc.c:2603
SCIP_RETCODE SCIPintarrayFree(SCIP_INTARRAY **intarray)
Definition: misc.c:2774
SCIP_RETCODE SCIPintarrayCopy(SCIP_INTARRAY **intarray, BMS_BLKMEM *blkmem, SCIP_INTARRAY *sourceintarray)
Definition: misc.c:2751
SCIP_RETCODE SCIPintarraySetVal(SCIP_INTARRAY *intarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, int val)
Definition: misc.c:2995
SCIP_RETCODE SCIPrealarrayCopy(SCIP_REALARRAY **realarray, BMS_BLKMEM *blkmem, SCIP_REALARRAY *sourcerealarray)
Definition: misc.c:2379
SCIP_RETCODE SCIPboolarraySetVal(SCIP_BOOLARRAY *boolarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Bool val)
Definition: misc.c:3363
SCIP_Real SCIPnegateReal(SCIP_Real x)
Definition: misc.c:7817
SCIP_RETCODE SCIPboolarrayClear(SCIP_BOOLARRAY *boolarray)
Definition: misc.c:3311
SCIP_RETCODE SCIPboolarrayCreate(SCIP_BOOLARRAY **boolarray, BMS_BLKMEM *blkmem)
Definition: misc.c:3096
public data structures and miscellaneous methods
SCIP_RETCODE SCIPptrarrayFree(SCIP_PTRARRAY **ptrarray)
Definition: misc.c:3495
#define SCIP_Bool
Definition: def.h:53
SCIP_RETCODE SCIPintarrayExtend(SCIP_INTARRAY *intarray, int arraygrowinit, SCIP_Real arraygrowfac, int minidx, int maxidx)
Definition: misc.c:2788
int SCIPptrarrayGetMaxIdx(SCIP_PTRARRAY *ptrarray)
Definition: misc.c:3794
int SCIPintarrayGetMaxIdx(SCIP_INTARRAY *intarray)
Definition: misc.c:3085
SCIP_RETCODE SCIPrealarrayExtend(SCIP_REALARRAY *realarray, int arraygrowinit, SCIP_Real arraygrowfac, int minidx, int maxidx)
Definition: misc.c:2417
SCIP_RETCODE SCIPboolarrayFree(SCIP_BOOLARRAY **boolarray)
Definition: misc.c:3140
unsigned int arraygrowinit
Definition: memory.c:2425
SCIP_RETCODE SCIPptrarrayClear(SCIP_PTRARRAY *ptrarray)
Definition: misc.c:3664
int SCIPboolarrayGetMinIdx(SCIP_BOOLARRAY *boolarray)
Definition: misc.c:3431
SCIP_RETCODE SCIPintarrayCreate(SCIP_INTARRAY **intarray, BMS_BLKMEM *blkmem)
Definition: misc.c:2731
SCIP_RETCODE SCIPrealarrayFree(SCIP_REALARRAY **realarray)
Definition: misc.c:2403
SCIP_RETCODE SCIPptrarraySetVal(SCIP_PTRARRAY *ptrarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, void *val)
Definition: misc.c:3716
#define SCIP_Real
Definition: def.h:127
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPrealarrayClear(SCIP_REALARRAY *realarray)
Definition: misc.c:2572
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:392
SCIP_RETCODE SCIPintarrayClear(SCIP_INTARRAY *intarray)
Definition: misc.c:2943
SCIP_RETCODE SCIPptrarrayCreate(SCIP_PTRARRAY **ptrarray, BMS_BLKMEM *blkmem)
Definition: misc.c:3452
SCIP_Bool SCIPboolarrayGetVal(SCIP_BOOLARRAY *boolarray, int idx)
Definition: misc.c:3342
SCIP_RETCODE SCIPboolarrayExtend(SCIP_BOOLARRAY *boolarray, int arraygrowinit, SCIP_Real arraygrowfac, int minidx, int maxidx)
Definition: misc.c:3154
int SCIPintarrayGetVal(SCIP_INTARRAY *intarray, int idx)
Definition: misc.c:2974
memory allocation routines