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