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