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-2015 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  * @brief common defines and data types used in all packages of SCIP
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __SCIP_DEF_H__
24 #define __SCIP_DEF_H__
25 
26 
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <math.h>
30 #include <limits.h>
31 #include <float.h>
32 #include <assert.h>
33 
34 /*
35  * GNU COMPILER VERSION define
36  */
37 #ifdef __GNUC__
38 #ifndef GCC_VERSION
39 #define GCC_VERSION (__GNUC__ * 100 \
40  + __GNUC_MINOR__ * 10 \
41  + __GNUC_PATCHLEVEL__)
42 #endif
43 #endif
44 
45 /*
46  * Boolean values
47  */
48 
49 #ifndef SCIP_Bool
50 #define SCIP_Bool unsigned int /**< type used for boolean values */
51 #ifndef TRUE
52 #define TRUE 1 /**< boolean value TRUE */
53 #define FALSE 0 /**< boolean value FALSE */
54 #endif
55 #endif
56 
57 /*
58  * Define the marco EXTERN and some functions depending if the OS is Windows or not
59  */
60 #if defined(_WIN32) || defined(_WIN64)
61 
62 #define strcasecmp _stricmp
63 #define strncasecmp _strnicmp
64 #define getcwd _getcwd
65 
66 #ifndef EXTERN
67 #define EXTERN __declspec(dllexport)
68 #endif
69 
70 #else
71 #ifndef EXTERN
72 #define EXTERN extern
73 #endif
74 #endif
75 
76 
77 
78 #include "scip/type_retcode.h"
79 #include "scip/pub_message.h"
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 
86 #define SCIP_VERSION 320 /**< SCIP version number (multiplied by 100 to get integer number) */
87 #define SCIP_SUBVERSION 0 /**< SCIP sub version number */
88 #define SCIP_COPYRIGHT "Copyright (c) 2002-2015 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)"
89 
90 
91 /*
92  * CIP format variable characters
93  */
94 
95 #define SCIP_VARTYPE_BINARY_CHAR 'B'
96 #define SCIP_VARTYPE_INTEGER_CHAR 'I'
97 #define SCIP_VARTYPE_IMPLINT_CHAR 'M'
98 #define SCIP_VARTYPE_CONTINUOUS_CHAR 'C'
99 
100 /*
101  * Long Integer values
102  */
103 
104 #ifndef LLONG_MAX
105 #define LLONG_MAX 9223372036854775807LL
106 #define LLONG_MIN (-LLONG_MAX - 1LL)
107 #endif
108 
109 #define SCIP_Longint long long /**< type used for long integer values */
110 #define SCIP_LONGINT_MAX LLONG_MAX
111 #define SCIP_LONGINT_MIN LLONG_MIN
112 #ifndef SCIP_LONGINT_FORMAT
113 #if defined(_WIN32) || defined(_WIN64)
114 #define SCIP_LONGINT_FORMAT "I64d"
115 #else
116 #define SCIP_LONGINT_FORMAT "lld"
117 #endif
118 #endif
119 
120 /*
121  * Floating point values
122  */
123 
124 #define SCIP_Real double /**< type used for floating point values */
125 #define SCIP_REAL_MAX (SCIP_Real)DBL_MAX
126 #define SCIP_REAL_MIN -(SCIP_Real)DBL_MAX
127 #define SCIP_REAL_FORMAT "lf"
128 
129 #define SCIP_DEFAULT_INFINITY 1e+20 /**< default value considered to be infinity */
130 #define SCIP_DEFAULT_EPSILON 1e-09 /**< default upper bound for floating points to be considered zero */
131 #define SCIP_DEFAULT_SUMEPSILON 1e-06 /**< default upper bound for sums of floating points to be considered zero */
132 #define SCIP_DEFAULT_FEASTOL 1e-06 /**< default feasibility tolerance for constraints */
133 #define SCIP_DEFAULT_CHECKFEASTOLFAC 1.0 /**< default factor to change the feasibility tolerance when testing the best solution for feasibility (after solving process) */
134 #define SCIP_DEFAULT_LPFEASTOL 1e-06 /**< default primal feasibility tolerance of LP solver */
135 #define SCIP_DEFAULT_DUALFEASTOL 1e-07 /**< default feasibility tolerance for reduced costs */
136 #define SCIP_DEFAULT_BARRIERCONVTOL 1e-10 /**< default convergence tolerance used in barrier algorithm */
137 #define SCIP_DEFAULT_BOUNDSTREPS 0.05 /**< default minimal relative improve for strengthening bounds */
138 #define SCIP_DEFAULT_PSEUDOCOSTEPS 1e-01 /**< default minimal variable distance value to use for pseudo cost updates */
139 #define SCIP_DEFAULT_PSEUDOCOSTDELTA 1e-04 /**< default minimal objective distance value to use for pseudo cost updates */
140 #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 */
141 #define SCIP_DEFAULT_HUGEVAL 1e+15 /**< values larger than this are considered huge and should be handled separately (e.g., in activity computation) */
142 #define SCIP_MAXEPSILON 1e-03 /**< maximum value for any numerical epsilon */
143 #define SCIP_MINEPSILON 1e-20 /**< minimum value for any numerical epsilon */
144 #define SCIP_INVALID 1e+99 /**< floating point value is not valid */
145 #define SCIP_UNKNOWN 1e+98 /**< floating point value is not known (in primal solution) */
146 
147 
148 #define REALABS(x) (fabs(x))
149 #define EPSEQ(x,y,eps) (REALABS((x)-(y)) <= (eps))
150 #define EPSLT(x,y,eps) ((x)-(y) < -(eps))
151 #define EPSLE(x,y,eps) ((x)-(y) <= (eps))
152 #define EPSGT(x,y,eps) ((x)-(y) > (eps))
153 #define EPSGE(x,y,eps) ((x)-(y) >= -(eps))
154 #define EPSZ(x,eps) (REALABS(x) <= (eps))
155 #define EPSP(x,eps) ((x) > (eps))
156 #define EPSN(x,eps) ((x) < -(eps))
157 #define EPSFLOOR(x,eps) (floor((x)+(eps)))
158 #define EPSCEIL(x,eps) (ceil((x)-(eps)))
159 #define EPSROUND(x,eps) (ceil((x)-0.5+(eps)))
160 #define EPSFRAC(x,eps) ((x)-EPSFLOOR(x,eps))
161 #define EPSISINT(x,eps) (EPSFRAC(x,eps) <= (eps))
162 
163 
164 #ifndef SQR
165 #define SQR(x) ((x)*(x))
166 #define SQRT(x) (sqrt(x))
167 #endif
168 
169 #ifndef ABS
170 #define ABS(x) ((x) >= 0 ? (x) : -(x))
171 #endif
172 
173 #ifndef MAX
174 #define MAX(x,y) ((x) >= (y) ? (x) : (y)) /**< returns maximum of x and y */
175 #define MIN(x,y) ((x) <= (y) ? (x) : (y)) /**< returns minimum of x and y */
176 #endif
177 
178 #ifndef MAX3
179 #define MAX3(x,y,z) ((x) >= (y) ? MAX(x,z) : MAX(y,z)) /**< returns maximum of x, y, and z */
180 #define MIN3(x,y,z) ((x) <= (y) ? MIN(x,z) : MIN(y,z)) /**< returns minimum of x, y, and z */
181 #endif
182 
183 
184 
185 /*
186  * Pointers
187  */
188 
189 #ifndef NULL
190 #define NULL ((void*)0) /**< zero pointer */
191 #endif
192 
193 
194 /*
195  * Strings
196  */
197 
198 #define SCIP_MAXSTRLEN 1024 /**< maximum string length in SCIP */
199 
200 /*
201  * Memory settings
202  */
203 
204 /* we use SIZE_MAX / 2 to detect negative sizes which got a very large value when casting to size_t */
205 #define SCIP_MAXMEMSIZE (SIZE_MAX/2) /**< maximum size of allocated memory (array) */
206 
207 #define SCIP_HASHSIZE_PARAMS 4099 /**< size of hash table in parameter name tables */
208 #define SCIP_HASHSIZE_NAMES 131101 /**< size of hash table in name tables */
209 #define SCIP_HASHSIZE_CUTPOOLS 131101 /**< size of hash table in cut pools */
210 #define SCIP_HASHSIZE_CLIQUES 131101 /**< size of hash table in clique tables */
211 #define SCIP_HASHSIZE_NAMES_SMALL 8011 /**< size of hash table in name tables for small problems */
212 #define SCIP_HASHSIZE_CUTPOOLS_SMALL 8011 /**< size of hash table in cut pools for small problems */
213 #define SCIP_HASHSIZE_CLIQUES_SMALL 8011 /**< size of hash table in clique tables for small problems */
214 #define SCIP_HASHSIZE_VBC 131101 /**< size of hash map for node -> nodenum mapping used for VBC output */
215 
216 #define SCIP_DEFAULT_MEM_ARRAYGROWFAC 1.2 /**< memory growing factor for dynamically allocated arrays */
217 #define SCIP_DEFAULT_MEM_ARRAYGROWINIT 4 /**< initial size of dynamically allocated arrays */
218 
219 /*
220  * Global debugging settings
221  */
222 
223 /*#define DEBUG*/
224 
225 
226 /*
227  * Defines for handling SCIP return codes
228  */
229 
230 /** this macro is used to stop SCIP in debug mode such that errors can be debugged;
231  *
232  * @note In optimized mode this macro has no effect. That means, in case of an error it has to be ensured that code
233  * terminates with an error code or continues safely.
234  */
235 #define SCIPABORT() assert(FALSE)
236 
237 #define SCIP_CALL_ABORT_QUIET(x) do { if( (x) != SCIP_OKAY ) SCIPABORT(); } while( FALSE )
238 #define SCIP_CALL_QUIET(x) do { SCIP_RETCODE _restat_; if( (_restat_ = (x)) != SCIP_OKAY ) return _restat_; } while( FALSE )
239 #define SCIP_ALLOC_ABORT_QUIET(x) do { if( NULL == (x) ) SCIPABORT(); } while( FALSE )
240 #define SCIP_ALLOC_QUIET(x) do { if( NULL == (x) ) return SCIP_NOMEMORY; } while( FALSE )
241 
242 #define SCIP_CALL_ABORT(x) do \
243  { \
244  SCIP_RETCODE _restat_; \
245  if( (_restat_ = (x)) != SCIP_OKAY ) \
246  { \
247  SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
248  SCIPABORT(); \
249  } \
250  } \
251  while( FALSE )
252 
253 #define SCIP_ALLOC_ABORT(x) do \
254  { \
255  if( NULL == (x) ) \
256  { \
257  SCIPerrorMessage("No memory in function call\n", __FILE__, __LINE__); \
258  SCIPABORT(); \
259  } \
260  } \
261  while( FALSE )
262 
263 #define SCIP_CALL(x) do \
264  { \
265  SCIP_RETCODE _restat_; \
266  if( (_restat_ = (x)) != SCIP_OKAY ) \
267  { \
268  SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
269  return _restat_; \
270  } \
271  } \
272  while( FALSE )
273 
274 #define SCIP_ALLOC(x) do \
275  { \
276  if( NULL == (x) ) \
277  { \
278  SCIPerrorMessage("No memory in function call\n"); \
279  return SCIP_NOMEMORY; \
280  } \
281  } \
282  while( FALSE )
283 
284 #define SCIP_CALL_TERMINATE(retcode, x, TERM) do \
285  { \
286  if( ((retcode) = (x)) != SCIP_OKAY ) \
287  { \
288  SCIPerrorMessage("Error <%d> in function call\n", retcode); \
289  goto TERM; \
290  } \
291  } \
292  while( FALSE )
293 
294 #define SCIP_ALLOC_TERMINATE(retcode, x, TERM) do \
295  { \
296  if( NULL == (x) ) \
297  { \
298  SCIPerrorMessage("No memory in function call\n"); \
299  retcode = SCIP_NOMEMORY; \
300  goto TERM; \
301  } \
302  } \
303  while( FALSE )
304 
305 
306 /*
307  * Define to mark deprecated API functions
308  */
309 
310 #if defined(_WIN32) || defined(_WIN64)
311 # define SCIP_DEPRECATED __declspec(deprecated)
312 #elif defined(__GNUC__) && defined(__linux__)
313 # define SCIP_DEPRECATED __attribute__ ((deprecated))
314 #else
315 # define SCIP_DEPRECATED
316 #endif
317 
318 #ifdef __cplusplus
319 }
320 #endif
321 
322 #endif
type definitions for return codes for SCIP methods
public methods for message output