Scippy

SCIP

Solving Constraint Integer Programs

portab.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-2022 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 visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file portab.h
17  * @brief Portable definitions
18  * @author Thorsten Koch
19  * @author Daniel Rehfeldt
20  *
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #ifndef PORTAB_H
26 #define PORTAB_H
27 
28 #include <limits.h>
29 #include <math.h>
30 #include <float.h>
31 
32 #define EPSILON 1e-06
33 
34 typedef unsigned char STP_Bool;
35 
36 
37 #ifndef TRUE
38 #define TRUE 1
39 #endif
40 #ifndef FALSE
41 #define FALSE 0
42 #endif
43 
44 #ifndef SUCCESS
45 #define SUCCESS 0
46 #endif
47 #ifndef FAILURE
48 #define FAILURE (-1)
49 #endif
50 
51 #ifndef Max
52 #define Max(a, b) (((a) >= (b)) ? (a) : (b))
53 #endif
54 #ifndef Min
55 #define Min(a, b) (((a) <= (b)) ? (a) : (b))
56 #endif
57 
58 #define EPS_ZERO (DBL_EPSILON * 1e4)
59 #define EPS_ZERO_HARD (DBL_EPSILON * 1e6)
60 
61 
62 #ifndef Fsgn
63 #define Fsgn(x) ((((x) > -EPS_ZERO) && ((x) < EPS_ZERO)) ? 0 : (((x) < 0.0) ? -1 : 1))
64 #endif /* fsgn */
65 
66 
67 #define RELDIFF(a, b) (((a)-(b))/ MAX(MAX(fabs(a), fabs(b)), 1.0))
68 #define EQ_FEAS(a, b) (fabs(RELDIFF(a, b)) <= EPS_ZERO)
69 #define LT_FEAS(a, b) (RELDIFF(a, b) < -EPS_ZERO)
70 #define LE_FEAS(a, b) (RELDIFF(a, b) < EPS_ZERO)
71 #define GT_FEAS(a, b) (RELDIFF(a, b) > EPS_ZERO)
72 #define GE_FEAS(a, b) (RELDIFF(a, b) > -EPS_ZERO)
73 #define EQ_FEAS_EPS(a, b, eps) (fabs(RELDIFF(a, b)) <= eps)
74 #define LT_FEAS_EPS(a, b, eps) (RELDIFF(a, b) < -eps)
75 #define LE_FEAS_EPS(a, b, eps) (RELDIFF(a, b) < eps)
76 #define GT_FEAS_EPS(a, b, eps) (RELDIFF(a, b) > eps)
77 #define GE_FEAS_EPS(a, b, eps) (RELDIFF(a, b) > -eps)
78 
79 #define EQ(a, b) (fabs((a) - (b)) <= EPS_ZERO)
80 #define NE(a, b) (fabs((a) - (b)) > EPS_ZERO)
81 #define LT(a, b) (((a) - (b)) < -EPS_ZERO)
82 #define LT_HARD(a, b) (((a) - (b)) < -EPS_ZERO_HARD)
83 #define LE(a, b) (((a) - (b)) < EPS_ZERO)
84 #define GT(a, b) (((a) - (b)) > EPS_ZERO)
85 #define GE(a, b) (((a) - (b)) > -EPS_ZERO)
86 #define GE_HARD(a, b) (((a) - (b)) > -EPS_ZERO_HARD)
87 
88 #if defined(MSDOS) || defined(WIN32)
89 #define DIRSEP "\\"
90 #else
91 #define DIRSEP "/"
92 #endif
93 
94 #endif /* PORTAB_H */
unsigned char STP_Bool
Definition: portab.h:34