Scippy

SCIP

Solving Constraint Integer Programs

def.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 def.h
17  * @ingroup INTERNALAPI
18  * @brief common defines and data types used in all packages of SCIP
19  * @author Tobias Achterberg
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __SCIP_DEF_H__
25 #define __SCIP_DEF_H__
26 
27 #ifdef __cplusplus
28 #define __STDC_LIMIT_MACROS
29 #define __STDC_CONSTANT_MACROS
30 #endif
31 
32 #include <stdio.h>
33 #include <stdint.h>
34 #include <math.h>
35 #include <limits.h>
36 #include <float.h>
37 #include <assert.h>
38 
39 /*
40  * include build configuration flags
41  */
42 #ifndef NO_CONFIG_HEADER
43 #include "scip/config.h"
44 #endif
45 
46 /*
47  * GNU COMPILER VERSION define
48  */
49 #ifdef __GNUC__
50 #ifndef GCC_VERSION
51 #define GCC_VERSION (__GNUC__ * 100 \
52  + __GNUC_MINOR__ * 10 \
53  + __GNUC_PATCHLEVEL__)
54 #endif
55 #endif
56 
57 /*
58  * define whether compiler allows variadic macros
59  */
60 #if defined(_MSC_VER) || ( __STDC_VERSION__ >= 199901L )
61 #define SCIP_HAVE_VARIADIC_MACROS 1
62 #endif
63 
64 /*
65  * Boolean values
66  */
67 
68 #ifndef SCIP_Bool
69 #define SCIP_Bool unsigned int /**< type used for Boolean values */
70 #ifndef TRUE
71 #define TRUE 1 /**< Boolean value TRUE */
72 #define FALSE 0 /**< Boolean value FALSE */
73 #endif
74 #endif
75 
76 #ifndef SCIP_Shortbool
77 #define SCIP_Shortbool uint8_t /**< type used for Boolean values with less space */
78 #endif
79 
80 /*
81  * Define the marco EXTERN and some functions depending if the OS is Windows or not
82  */
83 #if defined(_WIN32) || defined(_WIN64)
84 
85 #define strcasecmp _stricmp
86 #define strncasecmp _strnicmp
87 #define getcwd _getcwd
88 
89 #ifndef EXTERN
90 #define EXTERN __declspec(dllexport)
91 #endif
92 
93 #else
94 #ifndef EXTERN
95 #define EXTERN extern
96 #endif
97 #endif
98 
99 /* define INLINE */
100 #ifndef INLINE
101 #if defined(_WIN32) || defined(_WIN64) || defined(__STDC__)
102 #define INLINE __inline
103 #else
104 #define INLINE inline
105 #endif
106 #endif
107 
108 
109 
110 #include "scip/type_retcode.h"
111 #include "scip/type_message.h"
112 
113 #ifdef __cplusplus
114 extern "C" {
115 #endif
116 
117 
118 #define SCIP_VERSION 601 /**< SCIP version number (multiplied by 100 to get integer number) */
119 #define SCIP_SUBVERSION 0 /**< SCIP sub version number */
120 #define SCIP_APIVERSION 34 /**< SCIP API version number */
121 #define SCIP_COPYRIGHT "Copyright (C) 2002-2019 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)"
122 
123 
124 /*
125  * CIP format variable characters
126  */
127 
128 #define SCIP_VARTYPE_BINARY_CHAR 'B'
129 #define SCIP_VARTYPE_INTEGER_CHAR 'I'
130 #define SCIP_VARTYPE_IMPLINT_CHAR 'M'
131 #define SCIP_VARTYPE_CONTINUOUS_CHAR 'C'
132 
133 /*
134  * Long Integer values
135  */
136 
137 #ifndef LLONG_MAX
138 #define LLONG_MAX 9223372036854775807LL
139 #define LLONG_MIN (-LLONG_MAX - 1LL)
140 #endif
141 
142 #define SCIP_Longint long long /**< type used for long integer values */
143 #define SCIP_LONGINT_MAX LLONG_MAX
144 #define SCIP_LONGINT_MIN LLONG_MIN
145 #ifndef SCIP_LONGINT_FORMAT
146 #if defined(_WIN32) || defined(_WIN64)
147 #define SCIP_LONGINT_FORMAT "I64d"
148 #else
149 #define SCIP_LONGINT_FORMAT "lld"
150 #endif
151 #endif
152 
153 /*
154  * Floating point values
155  */
156 
157 #define SCIP_Real double /**< type used for floating point values */
158 #define SCIP_REAL_MAX (SCIP_Real)DBL_MAX
159 #define SCIP_REAL_MIN -(SCIP_Real)DBL_MAX
160 #define SCIP_REAL_FORMAT "lf"
161 
162 #define SCIP_DEFAULT_INFINITY 1e+20 /**< default value considered to be infinity */
163 #define SCIP_DEFAULT_EPSILON 1e-09 /**< default upper bound for floating points to be considered zero */
164 #define SCIP_DEFAULT_SUMEPSILON 1e-06 /**< default upper bound for sums of floating points to be considered zero */
165 #define SCIP_DEFAULT_FEASTOL 1e-06 /**< default feasibility tolerance for constraints */
166 #define SCIP_DEFAULT_CHECKFEASTOLFAC 1.0 /**< default factor to change the feasibility tolerance when testing the best solution for feasibility (after solving process) */
167 #define SCIP_DEFAULT_LPFEASTOL 1e-06 /**< default primal feasibility tolerance of LP solver */
168 #define SCIP_DEFAULT_DUALFEASTOL 1e-07 /**< default feasibility tolerance for reduced costs */
169 #define SCIP_DEFAULT_BARRIERCONVTOL 1e-10 /**< default convergence tolerance used in barrier algorithm */
170 #define SCIP_DEFAULT_BOUNDSTREPS 0.05 /**< default minimal relative improve for strengthening bounds */
171 #define SCIP_DEFAULT_PSEUDOCOSTEPS 1e-01 /**< default minimal variable distance value to use for pseudo cost updates */
172 #define SCIP_DEFAULT_PSEUDOCOSTDELTA 1e-04 /**< default minimal objective distance value to use for pseudo cost updates */
173 #define SCIP_DEFAULT_RECOMPFAC 1e+07 /**< default minimal decrease factor that causes the recomputation of a value (e.g., pseudo objective) instead of an update */
174 #define SCIP_DEFAULT_HUGEVAL 1e+15 /**< values larger than this are considered huge and should be handled separately (e.g., in activity computation) */
175 #define SCIP_MAXEPSILON 1e-03 /**< maximum value for any numerical epsilon */
176 #define SCIP_MINEPSILON 1e-20 /**< minimum value for any numerical epsilon */
177 #define SCIP_INVALID (double)1e+99 /**< floating point value is not valid */
178 #define SCIP_UNKNOWN (double)1e+98 /**< floating point value is not known (in primal solution) */
179 
180 
181 #define REALABS(x) (fabs(x))
182 #define EPSEQ(x,y,eps) (REALABS((x)-(y)) <= (eps))
183 #define EPSLT(x,y,eps) ((x)-(y) < -(eps))
184 #define EPSLE(x,y,eps) ((x)-(y) <= (eps))
185 #define EPSGT(x,y,eps) ((x)-(y) > (eps))
186 #define EPSGE(x,y,eps) ((x)-(y) >= -(eps))
187 #define EPSZ(x,eps) (REALABS(x) <= (eps))
188 #define EPSP(x,eps) ((x) > (eps))
189 #define EPSN(x,eps) ((x) < -(eps))
190 #define EPSFLOOR(x,eps) (floor((x)+(eps)))
191 #define EPSCEIL(x,eps) (ceil((x)-(eps)))
192 #define EPSROUND(x,eps) (ceil((x)-0.5+(eps)))
193 #define EPSFRAC(x,eps) ((x)-EPSFLOOR(x,eps))
194 #define EPSISINT(x,eps) (EPSFRAC(x,eps) <= (eps))
195 
196 
197 #ifndef SQR
198 #define SQR(x) ((x)*(x))
199 #define SQRT(x) (sqrt(x))
200 #endif
201 
202 #ifndef LOG2
203 #if defined(_MSC_VER) && (_MSC_VER < 1800)
204 #define LOG2(x) (log(x) / log(2.0))
205 #else
206 #define LOG2(x) log2(x)
207 #endif
208 #endif
209 
210 #ifndef ABS
211 #define ABS(x) ((x) >= 0 ? (x) : -(x))
212 #endif
213 
214 #ifndef MAX
215 #define MAX(x,y) ((x) >= (y) ? (x) : (y)) /**< returns maximum of x and y */
216 #define MIN(x,y) ((x) <= (y) ? (x) : (y)) /**< returns minimum of x and y */
217 #endif
218 
219 #ifndef MAX3
220 #define MAX3(x,y,z) ((x) >= (y) ? MAX(x,z) : MAX(y,z)) /**< returns maximum of x, y, and z */
221 #define MIN3(x,y,z) ((x) <= (y) ? MIN(x,z) : MIN(y,z)) /**< returns minimum of x, y, and z */
222 #endif
223 
224 /* platform-dependent specification of the log1p, which is numerically more stable around x = 0.0 */
225 #ifndef LOG1P
226 #if defined(_WIN32) || defined(_WIN64)
227 #define LOG1P(x) (log(1.0+x))
228 #else
229 #define LOG1P(x) (log1p(x))
230 #endif
231 #endif
232 
233 #ifndef COPYSIGN
234 #if defined(_MSC_VER) && (_MSC_VER < 1800)
235 #define COPYSIGN _copysign
236 #else
237 #define COPYSIGN copysign
238 #endif
239 #endif
240 
241 /*
242  * Pointers
243  */
244 
245 #ifndef NULL
246 #define NULL ((void*)0) /**< zero pointer */
247 #endif
248 
249 #ifndef RESTRICT
250 #if defined(_MSC_VER)
251 #define RESTRICT __restrict
252 #else
253 #ifdef __cplusplus
254 #define RESTRICT __restrict__
255 #elif __STDC_VERSION__ >= 199901L
256 #define RESTRICT restrict
257 #else
258 #define RESTRICT
259 #endif
260 #endif
261 #endif
262 
263 /*
264  * Strings
265  */
266 
267 #define SCIP_MAXSTRLEN 1024 /**< maximum string length in SCIP */
268 
269 /*
270  * Memory settings
271  */
272 
273 /* we use SIZE_MAX / 2 to detect negative sizes which got a very large value when casting to size_t */
274 #define SCIP_MAXMEMSIZE (SIZE_MAX/2) /**< maximum size of allocated memory (array) */
275 
276 #define SCIP_HASHSIZE_PARAMS 2048 /**< size of hash table in parameter name tables */
277 #define SCIP_HASHSIZE_NAMES 500 /**< size of hash table in name tables */
278 #define SCIP_HASHSIZE_CUTPOOLS 500 /**< size of hash table in cut pools */
279 #define SCIP_HASHSIZE_CLIQUES 500 /**< size of hash table in clique tables */
280 #define SCIP_HASHSIZE_NAMES_SMALL 100 /**< size of hash table in name tables for small problems */
281 #define SCIP_HASHSIZE_CUTPOOLS_SMALL 100 /**< size of hash table in cut pools for small problems */
282 #define SCIP_HASHSIZE_CLIQUES_SMALL 100 /**< size of hash table in clique tables for small problems */
283 #define SCIP_HASHSIZE_VBC 500 /**< size of hash map for node -> nodenum mapping used for VBC output */
284 
285 #define SCIP_DEFAULT_MEM_ARRAYGROWFAC 1.2 /**< memory growing factor for dynamically allocated arrays */
286 #define SCIP_DEFAULT_MEM_ARRAYGROWINIT 4 /**< initial size of dynamically allocated arrays */
287 
288 #define SCIP_MEM_NOLIMIT (SCIP_Longint)SCIP_LONGINT_MAX/1048576.0/**< initial size of dynamically allocated arrays */
289 
290 /*
291  * Tree settings
292  */
293 
294 #define SCIP_MAXTREEDEPTH 65534 /**< maximal allowed depth of the branch-and-bound tree */
295 
296 /*
297  * Probing scoring settings
298  */
299 
300 #define SCIP_PROBINGSCORE_PENALTYRATIO 2 /**< ratio for penalizing too small fractionalities in diving heuristics.
301  * if the fractional part of a variable is smaller than a given threshold
302  * the corresponding score gets penalized. due to numerical troubles
303  * we will flip a coin whenever SCIPisEQ(scip, fractionality, threshold)
304  * evaluates to true. this parameter defines the chance that this results
305  * in penalizing the score, i.e., there is 1:2 chance for penalizing.
306  */
307 
308 /*
309  * Global debugging settings
310  */
311 
312 /*#define DEBUG*/
313 
314 
315 /*
316  * Defines for handling SCIP return codes
317  */
318 
319 /** this macro is used to stop SCIP in debug mode such that errors can be debugged;
320  *
321  * @note In optimized mode this macro has no effect. That means, in case of an error it has to be ensured that code
322  * terminates with an error code or continues safely.
323  */
324 #define SCIPABORT() assert(FALSE) /*lint --e{527} */
325 
326 #define SCIP_CALL_ABORT_QUIET(x) do { if( (x) != SCIP_OKAY ) SCIPABORT(); } while( FALSE )
327 #define SCIP_CALL_QUIET(x) do { SCIP_RETCODE _restat_; if( (_restat_ = (x)) != SCIP_OKAY ) return _restat_; } while( FALSE )
328 #define SCIP_ALLOC_ABORT_QUIET(x) do { if( NULL == (x) ) SCIPABORT(); } while( FALSE )
329 #define SCIP_ALLOC_QUIET(x) do { if( NULL == (x) ) return SCIP_NOMEMORY; } while( FALSE )
331 #define SCIP_CALL_ABORT(x) do \
332  { \
333  SCIP_RETCODE _restat_; /*lint -e{506,774}*/ \
334  if( (_restat_ = (x)) != SCIP_OKAY ) \
335  { \
336  SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
337  SCIPABORT(); \
338  } \
339  } \
340  while( FALSE )
341 
342 #define SCIP_ALLOC_ABORT(x) do \
343  { \
344  if( NULL == (x) ) \
345  { \
346  SCIPerrorMessage("No memory in function call\n", __FILE__, __LINE__); \
347  SCIPABORT(); \
348  } \
349  } \
350  while( FALSE )
351 
352 #define SCIP_CALL(x) do \
353  { \
354  SCIP_RETCODE _restat_; /*lint -e{506,774}*/ \
355  if( (_restat_ = (x)) != SCIP_OKAY ) \
356  { \
357  SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
358  return _restat_; \
359  } \
360  } \
361  while( FALSE )
362 
363 #define SCIP_ALLOC(x) do \
364  { \
365  if( NULL == (x) ) \
366  { \
367  SCIPerrorMessage("No memory in function call\n"); \
368  return SCIP_NOMEMORY; \
369  } \
370  } \
371  while( FALSE )
372 
373 #define SCIP_CALL_TERMINATE(retcode, x, TERM) do \
374  { \
375  if( ((retcode) = (x)) != SCIP_OKAY ) \
376  { \
377  SCIPerrorMessage("Error <%d> in function call\n", retcode); \
378  goto TERM; \
379  } \
380  } \
381  while( FALSE )
382 
383 #define SCIP_ALLOC_TERMINATE(retcode, x, TERM) do \
384  { \
385  if( NULL == (x) ) \
386  { \
387  SCIPerrorMessage("No memory in function call\n"); \
388  retcode = SCIP_NOMEMORY; \
389  goto TERM; \
390  } \
391  } \
392  while( FALSE )
393 
394 #define SCIP_CALL_FINALLY(x, y) do \
395  { \
396  SCIP_RETCODE _restat_; \
397  if( (_restat_ = (x)) != SCIP_OKAY ) \
398  { \
399  SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
400  (y); \
401  return _restat_; \
402  } \
403  } \
404  while( FALSE )
405 
406 #define SCIP_UNUSED(x) ((void) (x))
407 
408 /*
409  * Define to mark deprecated API functions
410  */
411 
412 #if defined(_MSC_VER)
413 # define SCIP_DEPRECATED __declspec(deprecated)
414 #elif defined(__GNUC__)
415 # define SCIP_DEPRECATED __attribute__ ((deprecated))
416 #else
417 # define SCIP_DEPRECATED
418 #endif
419 
420 #ifdef __cplusplus
421 }
422 #endif
424 #endif
type definitions for return codes for SCIP methods
type definitions for message output methods