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