SCIP Doxygen Documentation
 
Loading...
Searching...
No Matches
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-2023 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file def.h
26 * @ingroup INTERNALAPI
27 * @brief common defines and data types used in all packages of SCIP
28 * @author Tobias Achterberg
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#ifndef __SCIP_DEF_H__
34#define __SCIP_DEF_H__
35
36#ifdef __cplusplus
37#define __STDC_LIMIT_MACROS
38#define __STDC_CONSTANT_MACROS
39#endif
40
41#include <stdio.h>
42#include <stdint.h>
43#include <math.h>
44#include <limits.h>
45#include <float.h>
46#include <assert.h>
47
48/*
49 * include build configuration flags
50 */
51#ifndef NO_CONFIG_HEADER
52#include "scip/config.h"
53#include "scip/scip_export.h"
54#endif
55
56/*
57 * GNU COMPILER VERSION define
58 */
59#ifdef __GNUC__
60#ifndef GCC_VERSION
61#define GCC_VERSION (__GNUC__ * 100 \
62 + __GNUC_MINOR__ * 10 \
63 + __GNUC_PATCHLEVEL__)
64#endif
65#endif
66
67/*
68 * define whether compiler allows variadic macros
69 * __STDC_VERSION__ only exists for C code
70 * added the extra check using the GCC_VERSION to enable variadic macros also with C++ code with GCC atleast
71 *
72 */
73#if defined(_MSC_VER) || ( __STDC_VERSION__ >= 199901L ) || ( GCC_VERSION >= 480 )
74#define SCIP_HAVE_VARIADIC_MACROS 1
75#endif
76
77/** get the first parameter and all-but-the-first arguments from variadic arguments
78 *
79 * normally, SCIP_VARARGS_FIRST_ should be sufficient
80 * the SCIP_VARARGS_FIRST_/SCIP_VARARGS_FIRST kludge is to work around a bug in MSVC (https://stackoverflow.com/questions/4750688/how-to-single-out-the-first-parameter-sent-to-a-macro-taking-only-a-variadic-par)
81 */
82#define SCIP_VARARGS_FIRST_(firstarg, ...) firstarg
83#define SCIP_VARARGS_FIRST(args) SCIP_VARARGS_FIRST_ args
84
85/** get all but the first parameter from variadic arguments */
86#define SCIP_VARARGS_REST(firstarg, ...) __VA_ARGS__
87
88/*
89 * Boolean values
90 */
91
92#ifndef SCIP_Bool
93#define SCIP_Bool unsigned int /**< type used for Boolean values */
94#ifndef TRUE
95#define TRUE 1 /**< Boolean value TRUE */
96#define FALSE 0 /**< Boolean value FALSE */
97#endif
98#endif
99
100#ifndef SCIP_Shortbool
101#define SCIP_Shortbool uint8_t /**< type used for Boolean values with less space */
102#endif
103
104/*
105 * Add some macros for differing functions on Windows
106 */
107#if defined(_WIN32) || defined(_WIN64)
108
109#define strcasecmp _stricmp
110#define strncasecmp _strnicmp
111#define getcwd _getcwd
112#endif
113
114/*
115 * Define the marco SCIP_EXPORT if it is not included from the generated header
116 */
117#ifndef SCIP_EXPORT
118#if defined(_WIN32) || defined(_WIN64)
119#define SCIP_EXPORT __declspec(dllexport)
120#elif defined(__GNUC__) && __GNUC__ >= 4
121#define SCIP_EXPORT __attribute__((__visibility__("default")))
122#else
123#define SCIP_EXPORT
124#endif
125#endif
126
127/* define INLINE */
128#ifndef INLINE
129#if defined(_WIN32) || defined(__STDC__)
130#define INLINE __inline
131#else
132#define INLINE inline
133#endif
134#endif
135
136
137
138#include "scip/type_retcode.h"
139#include "scip/type_message.h"
140#include "scip/pub_message.h"
141
142#ifdef __cplusplus
143extern "C" {
144#endif
145
146
147#define SCIP_VERSION 810 /**< SCIP version number (multiplied by 100 to get integer number) */
148#define SCIP_SUBVERSION 0 /**< SCIP sub version number */
149#define SCIP_APIVERSION 104 /**< SCIP API version number */
150#define SCIP_COPYRIGHT "Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB)"
151
152
153/*
154 * CIP format variable characters
155 */
156
157#define SCIP_VARTYPE_BINARY_CHAR 'B'
158#define SCIP_VARTYPE_INTEGER_CHAR 'I'
159#define SCIP_VARTYPE_IMPLINT_CHAR 'M'
160#define SCIP_VARTYPE_CONTINUOUS_CHAR 'C'
161
162/*
163 * Long Integer values
164 */
165
166#ifndef LLONG_MAX
167#define LLONG_MAX 9223372036854775807LL
168#define LLONG_MIN (-LLONG_MAX - 1LL)
169#endif
170
171#define SCIP_Longint long long /**< type used for long integer values */
172#define SCIP_LONGINT_MAX LLONG_MAX
173#define SCIP_LONGINT_MIN LLONG_MIN
174#ifndef SCIP_LONGINT_FORMAT
175#if defined(_WIN32) || defined(_WIN64)
176#define SCIP_LONGINT_FORMAT "I64d"
177#else
178#define SCIP_LONGINT_FORMAT "lld"
179#endif
180#endif
181
182/*
183 * Floating point values
184 */
185
186#define SCIP_Real double /**< type used for floating point values */
187#define SCIP_REAL_MAX (SCIP_Real)DBL_MAX
188#define SCIP_REAL_MIN -(SCIP_Real)DBL_MAX
189#define SCIP_REAL_FORMAT "lf"
190
191#define SCIP_DEFAULT_INFINITY 1e+20 /**< default value considered to be infinity */
192#define SCIP_DEFAULT_EPSILON 1e-09 /**< default upper bound for floating points to be considered zero */
193#define SCIP_DEFAULT_SUMEPSILON 1e-06 /**< default upper bound for sums of floating points to be considered zero */
194#define SCIP_DEFAULT_FEASTOL 1e-06 /**< default feasibility tolerance for constraints */
195#define SCIP_DEFAULT_CHECKFEASTOLFAC 1.0 /**< default factor to change the feasibility tolerance when testing the best solution for feasibility (after solving process) */
196#define SCIP_DEFAULT_LPFEASTOLFACTOR 1.0 /**< default factor w.r.t. primal feasibility tolerance that determines default (and maximal) primal feasibility tolerance of LP solver */
197#define SCIP_DEFAULT_DUALFEASTOL 1e-07 /**< default feasibility tolerance for reduced costs */
198#define SCIP_DEFAULT_BARRIERCONVTOL 1e-10 /**< default convergence tolerance used in barrier algorithm */
199#define SCIP_DEFAULT_BOUNDSTREPS 0.05 /**< default minimal relative improve for strengthening bounds */
200#define SCIP_DEFAULT_PSEUDOCOSTEPS 1e-01 /**< default minimal variable distance value to use for pseudo cost updates */
201#define SCIP_DEFAULT_PSEUDOCOSTDELTA 1e-04 /**< default minimal objective distance value to use for pseudo cost updates */
202#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 */
203#define SCIP_DEFAULT_HUGEVAL 1e+15 /**< values larger than this are considered huge and should be handled separately (e.g., in activity computation) */
204#define SCIP_MAXEPSILON 1e-03 /**< maximum value for any numerical epsilon */
205#define SCIP_MINEPSILON 1e-20 /**< minimum value for any numerical epsilon */
206#define SCIP_INVALID (double)1e+99 /**< floating point value is not valid */
207#define SCIP_UNKNOWN (double)1e+98 /**< floating point value is not known (in primal solution) */
208#define SCIP_INTERVAL_INFINITY (double)1e+300 /**< infinity value for interval computations */
209
210#define REALABS(x) (fabs(x))
211#define EPSEQ(x,y,eps) (REALABS((x)-(y)) <= (eps))
212#define EPSLT(x,y,eps) ((x)-(y) < -(eps))
213#define EPSLE(x,y,eps) ((x)-(y) <= (eps))
214#define EPSGT(x,y,eps) ((x)-(y) > (eps))
215#define EPSGE(x,y,eps) ((x)-(y) >= -(eps))
216#define EPSZ(x,eps) (REALABS(x) <= (eps))
217#define EPSP(x,eps) ((x) > (eps))
218#define EPSN(x,eps) ((x) < -(eps))
219#define EPSFLOOR(x,eps) (floor((x)+(eps)))
220#define EPSCEIL(x,eps) (ceil((x)-(eps)))
221#define EPSROUND(x,eps) (ceil((x)-0.5+(eps)))
222#define EPSFRAC(x,eps) ((x)-EPSFLOOR(x,eps))
223#define EPSISINT(x,eps) (EPSFRAC(x,eps) <= (eps))
224
225
226#ifndef SQR
227#define SQR(x) ((x)*(x))
228#define SQRT(x) (sqrt(x))
229#endif
230
231/* platform-dependent specification of the log1p, which is numerically more stable around x = 0.0 */
232#ifndef LOG1P
233#if defined(_WIN32) || defined(_WIN64)
234#define LOG1P(x) (log(1.0+x))
235#else
236#define LOG1P(x) (log1p(x))
237#endif
238#endif
239
240#ifndef LOG2
241#if defined(_MSC_VER) && (_MSC_VER < 1800)
242#define LOG2(x) (log(x) / log(2.0))
243#else
244#define LOG2(x) log2(x)
245#endif
246#endif
247
248#ifndef ABS
249#define ABS(x) ((x) >= 0 ? (x) : -(x))
250#endif
251
252#ifndef MAX
253#define MAX(x, y) ((x) >= (y) ? (x) : (y)) /**< returns maximum of x and y */
254#endif
255
256#ifndef MIN
257#define MIN(x, y) ((x) <= (y) ? (x) : (y)) /**< returns minimum of x and y */
258#endif
259
260#ifndef MAX3
261#define MAX3(x, y, z) ((x) >= (y) ? MAX(x, z) : MAX(y, z)) /**< returns maximum of x, y, and z */
262#endif
263
264#ifndef MIN3
265#define MIN3(x, y, z) ((x) <= (y) ? MIN(x, z) : MIN(y, z)) /**< returns minimum of x, y, and z */
266#endif
267
268#ifndef COPYSIGN
269#if defined(_MSC_VER) && (_MSC_VER < 1800)
270#define COPYSIGN _copysign
271#else
272#define COPYSIGN copysign
273#endif
274#endif
275
276/*
277 * Pointers
278 */
279
280#ifndef NULL
281#define NULL ((void*)0) /**< zero pointer */
282#endif
283
284#ifndef RESTRICT
285#if defined(_MSC_VER)
286#define RESTRICT __restrict
287#else
288#ifdef __cplusplus
289#define RESTRICT __restrict__
290#elif __STDC_VERSION__ >= 199901L
291#define RESTRICT restrict
292#else
293#define RESTRICT
294#endif
295#endif
296#endif
297
298/*
299 * Strings
300 */
301
302#define SCIP_MAXSTRLEN 1024 /**< maximum string length in SCIP */
303#define SCIP_SPACECONTROL " tnvfr" /**< control specifier for escaped spaces */
304
305/*
306 * Memory settings
307 */
308
309/* we use SIZE_MAX / 2 to detect negative sizes which got a very large value when casting to size_t */
310#define SCIP_MAXMEMSIZE (SIZE_MAX/2) /**< maximum size of allocated memory (array) */
311
312#define SCIP_HASHSIZE_PARAMS 2048 /**< size of hash table in parameter name tables */
313#define SCIP_HASHSIZE_NAMES 500 /**< size of hash table in name tables */
314#define SCIP_HASHSIZE_CUTPOOLS 500 /**< size of hash table in cut pools */
315#define SCIP_HASHSIZE_CLIQUES 500 /**< size of hash table in clique tables */
316#define SCIP_HASHSIZE_NAMES_SMALL 100 /**< size of hash table in name tables for small problems */
317#define SCIP_HASHSIZE_CUTPOOLS_SMALL 100 /**< size of hash table in cut pools for small problems */
318#define SCIP_HASHSIZE_CLIQUES_SMALL 100 /**< size of hash table in clique tables for small problems */
319#define SCIP_HASHSIZE_VBC 500 /**< size of hash map for node -> nodenum mapping used for VBC output */
320
321#define SCIP_DEFAULT_MEM_ARRAYGROWFAC 1.2 /**< memory growing factor for dynamically allocated arrays */
322#define SCIP_DEFAULT_MEM_ARRAYGROWINIT 4 /**< initial size of dynamically allocated arrays */
323
324#define SCIP_MEM_NOLIMIT (SCIP_Longint)(SCIP_LONGINT_MAX >> 20)/**< initial size of dynamically allocated arrays */
325
326/*
327 * Tree settings
328 */
329
330#define SCIP_MAXTREEDEPTH 65534 /**< maximal allowed depth of the branch-and-bound tree */
331
332/*
333 * Probing scoring settings
334 */
335
336#define SCIP_PROBINGSCORE_PENALTYRATIO 2 /**< ratio for penalizing too small fractionalities in diving heuristics.
337 * if the fractional part of a variable is smaller than a given threshold
338 * the corresponding score gets penalized. due to numerical troubles
339 * we will flip a coin whenever SCIPisEQ(scip, fractionality, threshold)
340 * evaluates to true. this parameter defines the chance that this results
341 * in penalizing the score, i.e., there is 1:2 chance for penalizing.
342 */
343
344/*
345 * Global debugging settings
346 */
347
348/*#define DEBUG*/
349
350
351/*
352 * Defines for handling SCIP return codes
353 */
354
355/** this macro is used to stop SCIP in debug mode such that errors can be debugged;
356 *
357 * @note In optimized mode this macro has no effect. That means, in case of an error it has to be ensured that code
358 * terminates with an error code or continues safely.
359 */
360#define SCIPABORT() assert(FALSE) /*lint --e{527} */
361
362#define SCIP_CALL_ABORT_QUIET(x) do { if( (x) != SCIP_OKAY ) SCIPABORT(); } while( FALSE )
363#define SCIP_CALL_QUIET(x) do { SCIP_RETCODE _restat_; if( (_restat_ = (x)) != SCIP_OKAY ) return _restat_; } while( FALSE )
364#define SCIP_ALLOC_ABORT_QUIET(x) do { if( NULL == (x) ) SCIPABORT(); } while( FALSE )
365#define SCIP_ALLOC_QUIET(x) do { if( NULL == (x) ) return SCIP_NOMEMORY; } while( FALSE )
366
367#define SCIP_CALL_ABORT(x) do \
368 { \
369 SCIP_RETCODE _restat_; /*lint -e{506,774}*/ \
370 if( (_restat_ = (x)) != SCIP_OKAY ) \
371 { \
372 SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
373 SCIPABORT(); \
374 } \
375 } \
376 while( FALSE )
377
378#define SCIP_ALLOC_ABORT(x) do \
379 { \
380 if( NULL == (x) ) \
381 { \
382 SCIPerrorMessage("No memory in function call\n"); \
383 SCIPABORT(); \
384 } \
385 } \
386 while( FALSE )
387
388#define SCIP_CALL(x) do \
389 { \
390 SCIP_RETCODE _restat_; /*lint -e{506,774}*/ \
391 if( (_restat_ = (x)) != SCIP_OKAY ) \
392 { \
393 SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
394 return _restat_; \
395 } \
396 } \
397 while( FALSE )
398
399#define SCIP_ALLOC(x) do \
400 { \
401 if( NULL == (x) ) \
402 { \
403 SCIPerrorMessage("No memory in function call\n"); \
404 return SCIP_NOMEMORY; \
405 } \
406 } \
407 while( FALSE )
408
409#define SCIP_CALL_TERMINATE(retcode, x, TERM) do \
410 { \
411 if( ((retcode) = (x)) != SCIP_OKAY ) \
412 { \
413 SCIPerrorMessage("Error <%d> in function call\n", retcode); \
414 goto TERM; \
415 } \
416 } \
417 while( FALSE )
418
419#define SCIP_ALLOC_TERMINATE(retcode, x, TERM) do \
420 { \
421 if( NULL == (x) ) \
422 { \
423 SCIPerrorMessage("No memory in function call\n"); \
424 retcode = SCIP_NOMEMORY; \
425 goto TERM; \
426 } \
427 } \
428 while( FALSE )
429
430#define SCIP_CALL_FINALLY(x, y) do \
431 { \
432 SCIP_RETCODE _restat_; \
433 if( (_restat_ = (x)) != SCIP_OKAY ) \
434 { \
435 SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
436 (y); \
437 return _restat_; \
438 } \
439 } \
440 while( FALSE )
441
442#define SCIP_UNUSED(x) ((void) (x))
443
444/*
445 * Define to mark deprecated API functions
446 */
447
448#ifndef SCIP_DEPRECATED
449#if defined(_MSC_VER)
450# define SCIP_DEPRECATED __declspec(deprecated)
451#elif defined(__GNUC__)
452# define SCIP_DEPRECATED __attribute__ ((deprecated))
453#else
454# define SCIP_DEPRECATED
455#endif
456#endif
457
458#ifdef __cplusplus
459}
460#endif
461
462#endif
public methods for message output
type definitions for message output methods
type definitions for return codes for SCIP methods