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