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