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