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-2017 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  * @ingroup INTERNALAPI
18  * @brief internal miscellaneous methods
19  * @author Tobias Achterberg
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __SCIP_MISC_H__
25 #define __SCIP_MISC_H__
26 
27 
28 #include "scip/def.h"
29 #include "blockmemshell/memory.h"
30 #include "scip/type_retcode.h"
31 #include "scip/type_set.h"
32 #include "scip/type_misc.h"
33 #include "scip/pub_misc.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Dynamic Arrays
41  */
42 
43 /** creates a dynamic array of real values */
44 extern
46  SCIP_REALARRAY** realarray, /**< pointer to store the real array */
47  BMS_BLKMEM* blkmem /**< block memory */
48  );
49 
50 /** creates a copy of a dynamic array of real values */
51 extern
53  SCIP_REALARRAY** realarray, /**< pointer to store the copied real array */
54  BMS_BLKMEM* blkmem, /**< block memory */
55  SCIP_REALARRAY* sourcerealarray /**< dynamic real array to copy */
56  );
57 
58 /** frees a dynamic array of real values */
59 extern
61  SCIP_REALARRAY** realarray /**< pointer to the real array */
62  );
63 
64 /** extends dynamic array to be able to store indices from minidx to maxidx */
65 extern
67  SCIP_REALARRAY* realarray, /**< dynamic real array */
68  int arraygrowinit, /**< initial size of array */
69  SCIP_Real arraygrowfac, /**< growing factor of array */
70  int minidx, /**< smallest index to allocate storage for */
71  int maxidx /**< largest index to allocate storage for */
72  );
73 
74 /** clears a dynamic real array */
75 extern
77  SCIP_REALARRAY* realarray /**< dynamic real array */
78  );
79 
80 /** gets value of entry in dynamic array */
81 extern
83  SCIP_REALARRAY* realarray, /**< dynamic real array */
84  int idx /**< array index to get value for */
85  );
86 
87 /** sets value of entry in dynamic array */
88 extern
90  SCIP_REALARRAY* realarray, /**< dynamic real array */
91  int arraygrowinit, /**< initial size of array */
92  SCIP_Real arraygrowfac, /**< growing factor of array */
93  int idx, /**< array index to set value for */
94  SCIP_Real val /**< value to set array index to */
95  );
96 
97 /** increases value of entry in dynamic array */
98 extern
100  SCIP_REALARRAY* realarray, /**< dynamic real array */
101  int arraygrowinit, /**< initial size of array */
102  SCIP_Real arraygrowfac, /**< growing factor of array */
103  int idx, /**< array index to increase value for */
104  SCIP_Real incval /**< value to increase array index */
105  );
106 
107 /** returns the minimal index of all stored non-zero elements */
108 extern
110  SCIP_REALARRAY* realarray /**< dynamic real array */
111  );
112 
113 /** returns the maximal index of all stored non-zero elements */
114 extern
116  SCIP_REALARRAY* realarray /**< dynamic real array */
117  );
118 
119 /** creates a dynamic array of int values */
120 extern
122  SCIP_INTARRAY** intarray, /**< pointer to store the int array */
123  BMS_BLKMEM* blkmem /**< block memory */
124  );
125 
126 /** creates a copy of a dynamic array of int values */
127 extern
129  SCIP_INTARRAY** intarray, /**< pointer to store the copied int array */
130  BMS_BLKMEM* blkmem, /**< block memory */
131  SCIP_INTARRAY* sourceintarray /**< dynamic int array to copy */
132  );
133 
134 /** frees a dynamic array of int values */
135 extern
137  SCIP_INTARRAY** intarray /**< pointer to the int array */
138  );
139 
140 /** extends dynamic array to be able to store indices from minidx to maxidx */
141 extern
143  SCIP_INTARRAY* intarray, /**< dynamic int array */
144  int arraygrowinit, /**< initial size of array */
145  SCIP_Real arraygrowfac, /**< growing factor of array */
146  int minidx, /**< smallest index to allocate storage for */
147  int maxidx /**< largest index to allocate storage for */
148  );
149 
150 /** clears a dynamic int array */
151 extern
153  SCIP_INTARRAY* intarray /**< dynamic int array */
154  );
155 
156 /** gets value of entry in dynamic array */
157 extern
159  SCIP_INTARRAY* intarray, /**< dynamic int array */
160  int idx /**< array index to get value for */
161  );
162 
163 /** sets value of entry in dynamic array */
164 extern
166  SCIP_INTARRAY* intarray, /**< dynamic int array */
167  int arraygrowinit, /**< initial size of array */
168  SCIP_Real arraygrowfac, /**< growing factor of array */
169  int idx, /**< array index to set value for */
170  int val /**< value to set array index to */
171  );
172 
173 /** increases value of entry in dynamic array */
174 extern
176  SCIP_INTARRAY* intarray, /**< dynamic int array */
177  int arraygrowinit, /**< initial size of array */
178  SCIP_Real arraygrowfac, /**< growing factor of array */
179  int idx, /**< array index to increase value for */
180  int incval /**< value to increase array index */
181  );
182 
183 /** returns the minimal index of all stored non-zero elements */
184 extern
186  SCIP_INTARRAY* intarray /**< dynamic int array */
187  );
188 
189 /** returns the maximal index of all stored non-zero elements */
190 extern
192  SCIP_INTARRAY* intarray /**< dynamic int array */
193  );
194 
195 /** creates a dynamic array of bool values */
196 extern
198  SCIP_BOOLARRAY** boolarray, /**< pointer to store the bool array */
199  BMS_BLKMEM* blkmem /**< block memory */
200  );
201 
202 /** creates a copy of a dynamic array of bool values */
203 extern
205  SCIP_BOOLARRAY** boolarray, /**< pointer to store the copied bool array */
206  BMS_BLKMEM* blkmem, /**< block memory */
207  SCIP_BOOLARRAY* sourceboolarray /**< dynamic bool array to copy */
208  );
209 
210 /** frees a dynamic array of bool values */
211 extern
213  SCIP_BOOLARRAY** boolarray /**< pointer to the bool array */
214  );
215 
216 /** extends dynamic array to be able to store indices from minidx to maxidx */
217 extern
219  SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */
220  int arraygrowinit, /**< initial size of array */
221  SCIP_Real arraygrowfac, /**< growing factor of array */
222  int minidx, /**< smallest index to allocate storage for */
223  int maxidx /**< largest index to allocate storage for */
224  );
225 
226 /** clears a dynamic bool array */
227 extern
229  SCIP_BOOLARRAY* boolarray /**< dynamic bool array */
230  );
231 
232 /** gets value of entry in dynamic array */
233 extern
235  SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */
236  int idx /**< array index to get value for */
237  );
238 
239 /** sets value of entry in dynamic array */
240 extern
242  SCIP_BOOLARRAY* boolarray, /**< dynamic bool array */
243  int arraygrowinit, /**< initial size of array */
244  SCIP_Real arraygrowfac, /**< growing factor of array */
245  int idx, /**< array index to set value for */
246  SCIP_Bool val /**< value to set array index to */
247  );
248 
249 /** returns the minimal index of all stored non-zero elements */
250 extern
252  SCIP_BOOLARRAY* boolarray /**< dynamic bool array */
253  );
254 
255 /** returns the maximal index of all stored non-zero elements */
256 extern
258  SCIP_BOOLARRAY* boolarray /**< dynamic bool array */
259  );
260 
261 /** creates a dynamic array of pointer values */
262 extern
264  SCIP_PTRARRAY** ptrarray, /**< pointer to store the ptr array */
265  BMS_BLKMEM* blkmem /**< block memory */
266  );
267 
268 /** creates a copy of a dynamic array of pointer values */
269 extern
271  SCIP_PTRARRAY** ptrarray, /**< pointer to store the copied ptr array */
272  BMS_BLKMEM* blkmem, /**< block memory */
273  SCIP_PTRARRAY* sourceptrarray /**< dynamic ptr array to copy */
274  );
275 
276 /** frees a dynamic array of pointer values */
277 extern
279  SCIP_PTRARRAY** ptrarray /**< pointer to the ptr array */
280  );
281 
282 /** extends dynamic array to be able to store indices from minidx to maxidx */
283 extern
285  SCIP_PTRARRAY* ptrarray, /**< dynamic ptr array */
286  int arraygrowinit, /**< initial size of array */
287  SCIP_Real arraygrowfac, /**< growing factor of array */
288  int minidx, /**< smallest index to allocate storage for */
289  int maxidx /**< largest index to allocate storage for */
290  );
291 
292 /** clears a dynamic pointer array */
293 extern
295  SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */
296  );
297 
298 /** gets value of entry in dynamic array */
299 extern
300 void* SCIPptrarrayGetVal(
301  SCIP_PTRARRAY* ptrarray, /**< dynamic ptr array */
302  int idx /**< array index to get value for */
303  );
304 
305 /** sets value of entry in dynamic array */
306 extern
308  SCIP_PTRARRAY* ptrarray, /**< dynamic ptr array */
309  int arraygrowinit, /**< initial size of array */
310  SCIP_Real arraygrowfac, /**< growing factor of array */
311  int idx, /**< array index to set value for */
312  void* val /**< value to set array index to */
313  );
314 
315 /** returns the minimal index of all stored non-zero elements */
316 extern
318  SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */
319  );
320 
321 /** returns the maximal index of all stored non-zero elements */
322 extern
324  SCIP_PTRARRAY* ptrarray /**< dynamic ptr array */
325  );
326 
327 /*
328  * Additional math functions
329  */
330 
331 /** negates a number
332  *
333  * negation of a number that can be used to avoid that a negation is optimized away by a compiler
334  */
335 extern
337  SCIP_Real x /**< value to negate */
338  );
339 
340 #ifdef __cplusplus
341 }
342 #endif
343 
344 #endif
SCIP_RETCODE SCIPrealarrayCreate(SCIP_REALARRAY **realarray, BMS_BLKMEM *blkmem)
Definition: misc.c:3183
void * SCIPptrarrayGetVal(SCIP_PTRARRAY *ptrarray, int idx)
Definition: misc.c:4519
SCIP_RETCODE SCIPptrarrayCopy(SCIP_PTRARRAY **ptrarray, BMS_BLKMEM *blkmem, SCIP_PTRARRAY *sourceptrarray)
Definition: misc.c:4296
SCIP_RETCODE SCIPrealarraySetVal(SCIP_REALARRAY *realarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Real val)
Definition: misc.c:3448
int SCIPintarrayGetMinIdx(SCIP_INTARRAY *intarray)
Definition: misc.c:3899
type definitions for miscellaneous datastructures
int SCIPboolarrayGetMaxIdx(SCIP_BOOLARRAY *boolarray)
Definition: misc.c:4265
int SCIPrealarrayGetMaxIdx(SCIP_REALARRAY *realarray)
Definition: misc.c:3545
int SCIPrealarrayGetMinIdx(SCIP_REALARRAY *realarray)
Definition: misc.c:3535
SCIP_RETCODE SCIPptrarrayExtend(SCIP_PTRARRAY *ptrarray, int arraygrowinit, SCIP_Real arraygrowfac, int minidx, int maxidx)
Definition: misc.c:4333
SCIP_RETCODE SCIPboolarrayCopy(SCIP_BOOLARRAY **boolarray, BMS_BLKMEM *blkmem, SCIP_BOOLARRAY *sourceboolarray)
Definition: misc.c:3940
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:3517
int SCIPptrarrayGetMinIdx(SCIP_PTRARRAY *ptrarray)
Definition: misc.c:4608
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:3887
SCIP_Real SCIPrealarrayGetVal(SCIP_REALARRAY *realarray, int idx)
Definition: misc.c:3427
SCIP_RETCODE SCIPintarrayFree(SCIP_INTARRAY **intarray)
Definition: misc.c:3598
SCIP_RETCODE SCIPintarrayCopy(SCIP_INTARRAY **intarray, BMS_BLKMEM *blkmem, SCIP_INTARRAY *sourceintarray)
Definition: misc.c:3575
SCIP_RETCODE SCIPintarraySetVal(SCIP_INTARRAY *intarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, int val)
Definition: misc.c:3819
SCIP_RETCODE SCIPrealarrayCopy(SCIP_REALARRAY **realarray, BMS_BLKMEM *blkmem, SCIP_REALARRAY *sourcerealarray)
Definition: misc.c:3203
SCIP_RETCODE SCIPboolarraySetVal(SCIP_BOOLARRAY *boolarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Bool val)
Definition: misc.c:4187
SCIP_Real SCIPnegateReal(SCIP_Real x)
Definition: misc.c:8958
SCIP_RETCODE SCIPboolarrayClear(SCIP_BOOLARRAY *boolarray)
Definition: misc.c:4135
SCIP_RETCODE SCIPboolarrayCreate(SCIP_BOOLARRAY **boolarray, BMS_BLKMEM *blkmem)
Definition: misc.c:3920
public data structures and miscellaneous methods
SCIP_RETCODE SCIPptrarrayFree(SCIP_PTRARRAY **ptrarray)
Definition: misc.c:4319
#define SCIP_Bool
Definition: def.h:61
SCIP_RETCODE SCIPintarrayExtend(SCIP_INTARRAY *intarray, int arraygrowinit, SCIP_Real arraygrowfac, int minidx, int maxidx)
Definition: misc.c:3612
int SCIPptrarrayGetMaxIdx(SCIP_PTRARRAY *ptrarray)
Definition: misc.c:4618
int SCIPintarrayGetMaxIdx(SCIP_INTARRAY *intarray)
Definition: misc.c:3909
SCIP_RETCODE SCIPrealarrayExtend(SCIP_REALARRAY *realarray, int arraygrowinit, SCIP_Real arraygrowfac, int minidx, int maxidx)
Definition: misc.c:3241
SCIP_RETCODE SCIPboolarrayFree(SCIP_BOOLARRAY **boolarray)
Definition: misc.c:3964
SCIP_RETCODE SCIPptrarrayClear(SCIP_PTRARRAY *ptrarray)
Definition: misc.c:4488
int SCIPboolarrayGetMinIdx(SCIP_BOOLARRAY *boolarray)
Definition: misc.c:4255
SCIP_RETCODE SCIPintarrayCreate(SCIP_INTARRAY **intarray, BMS_BLKMEM *blkmem)
Definition: misc.c:3555
SCIP_RETCODE SCIPrealarrayFree(SCIP_REALARRAY **realarray)
Definition: misc.c:3227
SCIP_RETCODE SCIPptrarraySetVal(SCIP_PTRARRAY *ptrarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, void *val)
Definition: misc.c:4540
#define SCIP_Real
Definition: def.h:135
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPrealarrayClear(SCIP_REALARRAY *realarray)
Definition: misc.c:3396
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:392
SCIP_RETCODE SCIPintarrayClear(SCIP_INTARRAY *intarray)
Definition: misc.c:3767
SCIP_RETCODE SCIPptrarrayCreate(SCIP_PTRARRAY **ptrarray, BMS_BLKMEM *blkmem)
Definition: misc.c:4276
SCIP_Bool SCIPboolarrayGetVal(SCIP_BOOLARRAY *boolarray, int idx)
Definition: misc.c:4166
SCIP_RETCODE SCIPboolarrayExtend(SCIP_BOOLARRAY *boolarray, int arraygrowinit, SCIP_Real arraygrowfac, int minidx, int maxidx)
Definition: misc.c:3978
int SCIPintarrayGetVal(SCIP_INTARRAY *intarray, int idx)
Definition: misc.c:3798
memory allocation routines