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