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