EasyLocalpp  3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Definitions.h
Go to the documentation of this file.
1 /*
2  * Definitions.h
3  *
4  * Created on: Jul 23, 2010
5  * Author: marco
6  */
7 
8 #ifndef DEFINITIONS_H_
9 #define DEFINITIONS_H_
10 
11 #include <cstdio>
12 #include <cmath>
13 #include <climits>
14 #include <cfloat>
15 #include <cassert>
16 #include <cstdlib>
17 #include <vector>
18 #include <set>
19 #include <map>
20 
21 /*
22  * Boolean values
23  */
24 #ifndef BOOL// used in bin reader
25 #define BOOL char
26 #endif
27 
28 #ifndef Bool
29 #define Bool uint8_t
30 #ifndef TRUE
31 #define TRUE 1
32 #define FALSE 0
33 #endif
34 #endif
35 
36 #define VERSION 500
37 #define SUBVERSION 0
38 #define COPYRIGHT "Marco"
39 
40 enum RetCode {
41  OKAY = 1,
47 };
48 typedef enum RetCode RETCODE;
49 
50 /*
51  * Long Integer values
52  */
53 
54 #ifndef __STDC_LIMIT_MACROS
55 #define __STDC_LIMIT_MACROS
56 #endif
57 #include <stdint.h>
58 /* http://en.wikipedia.org/wiki/Stdint.h */
59 
60 
61 #define ULongint uint_64_t //unsigned long long
62 #ifndef ULLONG_MAX
63 #define ULLONG_MAX UINT64_MAX //=18446744073709551615 //9223372036854775807ULL*2
64 #define ULLONG_MIN 0 //(-LLONG_MAX - 1LL)
65 #endif
66 
67 #ifndef LLONG_MAX
68 #define LLONG_MAX INT64_MAX //=9,223,372,036,854,775,807 //9223372036854775807LL
69 #define LLONG_MIN INT64_MIN //(-LLONG_MAX - 1LL)
70 #endif
71 
72 #define Longint int64_t //long long
73 #define LONGINT_MAX LLONG_MAX
74 #define LONGINT_MIN LLONG_MIN
75 #ifndef LONGINT_FORMAT
76 #if defined(_APPLE_) || defined(_unix_)
77 #define LONGINT_FORMAT "ld"
78 #elif defined(_WIN32) || defined(_WIN64)
79 #define LONGINT_FORMAT "I64d"
80 #else
81 #define LONGINT_FORMAT "ld"
82 #endif
83 #endif
84 
85 #define Int int32_t
86 #ifndef INT_MAX
87 #define INT_MAX INT32_MAX // 2,147,483,647
88 #define INT_MIN INT32_MIN // -2,147,483,647
89 #endif
90 
91 #define Shortint int16_t
92 #ifndef SINT_MAX
93 #define SINT_MAX INT16_MAX // 2,147,483,647
94 #define SINT_MIN INT16_MIN // -2,147,483,647
95 #endif
96 
97 
98 #define fvalue int32_t
99 #define FVALUE_MAX INT32_MAX
100 
101 #define Color int16_t // could be int16_t 32,767 // need -1 as no color sometimes
102 #define COLOR_MAX INT16_MAX
103 #define Vertex uint16_t // could be int16_t max 65,535
104 #define VERTEX_MAX UINT16_MAX
105 
106 
107 typedef std::vector<Color> ColorMap;
108 typedef std::set<Vertex> VertexSet;
109 
110 #ifndef HAVE_BASENAME
111 #define basename(s) (strrchr((s), '/') == NULL ? (s) : strrchr((s), '/') + 1)
112 #endif
113 
114 /*
115  * Floating point values
116  */
117 
118 #define Real double
119 #define REAL_MAX (Real)DBL_MAX
120 #define REAL_MIN -(Real)DBL_MAX
121 #define REAL_FORMAT "lf"
122 
123 #define DEFAULT_INFINITY 1e+20
124 #define DEFAULT_EPSILON 1e-09
125 #define DEFAULT_SUMEPSILON 1e-06
126 #define DEFAULT_FEASTOL 1e-06
127 #define DEFAULT_DUALFEASTOL 1e-09
128 #define DEFAULT_BARRIERCONVTOL 1e-10
129 #define DEFAULT_BOUNDSTREPS 0.05
130 #define DEFAULT_PSEUDOCOSTEPS 1e-01
131 #define DEFAULT_PSEUDOCOSTDELTA 1e-04
132 #define MAXEPSILON 1e-03
133 #define MINEPSILON 1e-20
134 #define INVALID 1e+99
135 #define UNKNOWN 1e+98
137 #define REALABS(x) (fabs(x))
138 #define EPSEQ(x,y,eps) (REALABS((x)-(y)) <= (eps))
139 #define EPSLT(x,y,eps) ((x)-(y) < -(eps))
140 #define EPSLE(x,y,eps) ((x)-(y) <= (eps))
141 #define EPSGT(x,y,eps) ((x)-(y) > (eps))
142 #define EPSGE(x,y,eps) ((x)-(y) >= -(eps))
143 #define EPSZ(x,eps) (REALABS(x) <= (eps))
144 #define EPSP(x,eps) ((x) > (eps))
145 #define EPSN(x,eps) ((x) < -(eps))
146 #define EPSFLOOR(x,eps) (floor((x)+(eps)))
147 #define EPSCEIL(x,eps) (ceil((x)-(eps)))
148 #define EPSFRAC(x,eps) ((x)-EPSFLOOR(x,eps))
149 #define EPSISINT(x,eps) (EPSFRAC(x,eps) <= (eps))
150 
151 #ifndef SQR
152 #define SQR(x) ((x)*(x))
153 #define SQRT(x) (sqrt(x))
154 #endif
155 
156 #ifndef ABS
157 #define ABS(x) ((x) >= 0 ? (x) : -(x))
158 #endif
159 
160 #ifndef MAX
161 #define MAX(x,y) ((x) >= (y) ? (x) : (y))
162 #define MIN(x,y) ((x) <= (y) ? (x) : (y))
163 #endif
164 
165 #ifndef MAX3
166 #define MAX3(x,y,z) ((x) >= (y) ? MAX(x,z) : MAX(y,z))
167 #define MIN3(x,y,z) ((x) <= (y) ? MIN(x,z) : MIN(y,z))
168 #endif
169 
170 /*
171  * Pointers
172  */
173 
174 #ifndef NULL
175 #define NULL ((void*)0)
176 #endif
177 
178 /*
179  * Strings
180  */
181 
182 #define MAXSTRLEN 1024
183 #if defined(_WIN32) || defined(_WIN64)
184 #define snprintf _snprintf
185 #define vsnprintf _vsnprintf
186 #define strcasecmp _stricmp
187 #define strncasecmp _strnicmp
188 #endif
189 
190 /*
191  * Memory settings
192  */
193 
194 #define HASHSIZE_NAMES 131101
195 #define HASHSIZE_CUTPOOLS 131101
196 #define HASHSIZE_CLIQUES 131101
197 #define HASHSIZE_PARAMS 4099
198 #define HASHSIZE_VBC 131101
200 /*#define BMS_NOBLOCKMEM*/
201 
202 /*
203  * Global debugging settings
204  */
205 
206 /*#define DEBUG*/
207 
208 /*
209  * Defines for handling return codes
210  */
211 
212 #define ABORT() assert(FALSE)
213 
214 #define CALL_ABORT_QUIET(x) do { if( (x) != OKAY ) ABORT(); } while( FALSE )
215 //#define CALL_QUIET(x) do { RETCODE _restat_; if( (_restat_ = (x)) != OKAY ) return _restat_; } while( FALSE )
216 #define CALL_QUIET(x)
217 #define ALLOC_ABORT_QUIET(x) do { if( NULL == (x) ) ABORT(); } while( FALSE )
218 #define ALLOC_QUIET(x) do { if( NULL == (x) ) return NOMEMORY; } while( FALSE )
219 
220 #define CALL_ABORT(x) do \
221  { \
222  RETCODE _restat_; \
223  if( (_restat_ = (x)) != OKAY ) \
224  { \
225  printf("Error <%d> in function call\n", _restat_); \
226  ABORT(); \
227  } \
228  } \
229  while( FALSE )
230 
231 #define ALLOC_ABORT(x) do \
232  { \
233  if( NULL == (x) ) \
234  { \
235  printf("No memory in function call\n", __FILE__, __LINE__); \
236  ABORT(); \
237  } \
238  } \
239  while( FALSE )
240 
241 #define CALL(x) do \
242  { \
243  RETCODE _restat_; \
244  if( (_restat_ = (x)) != OKAY ) \
245  { \
246  printf("Error <%d> in function call\n", _restat_); \
247  return _restat_; \
248  } \
249  } \
250  while( FALSE )
251 
252 #define ALLOC(x) do \
253  { \
254  if( NULL == (x) ) \
255  { \
256  printf("No memory in function call\n"); \
257  return NOMEMORY; \
258  } \
259  } \
260  while( FALSE )
261 
270 #define ASCII_FORMAT 1
271 #define GZIP_FORMAT 2
272 #define BIN_FORMAT 3
273 
274 
275 #define PARTIAL_REPR 1
276 #define COMPLETE_REPR 0
277 
278 // For tabu length policy
279 #define TL_ADAPTIVE 1
280 #define TL_INTERVAL 2
281 #define TL_FIXED 3
282 
283 // For inverse type
284 #define INV_OLD 1
285 #define INV_NEW 2
286 #define INV_NEWOLD 3
287 #define INV_VERTEX 4
288 #define VLSN 5
289 
290 // For solver
291 #define CONSTRUCTION_HEUR 100
292 #define RANDOM_RESTART 0
293 #define FIXED_K_COL 1
294 #define SEQUENCE_K_COL 2
295 #define HYBRID_EA 4
296 #define PENALTY_FUNCTION 6
297 #define HEA_RLF 12
298 #define X_RLF_SOLVER 5
299 #define PORUMBELS_EA 110
300 #define MALAGUTIS_EA 120
301 #define EX_DSATUR_SOLVER 130
302 
303 // For Runner
304 #define BASIC 0
305 #define TABUCOL 1
306 #define PARTIALCOL 2
307 #define TABU_HASH 11
308 #define TABU_REACTIVE 12
309 #define TABU_VLSN 26
310 #define SA_KEMPE 45
311 #define GLS 50
312 #define ILS 60
313 #define NOVELTY 70
314 #define MIN_CONFLICT 71
315 #define X_RLF_RUNNER 30
316 #define EX_DSATUR_RUNNER 130
317 
318 //For Construction Heuristics
319 //init
320 #define RANDOM 0
321 #define ROS 1
322 #define ROS_FIXED 2
323 #define RLF 3
324 #define RLF_FIXED 4
325 #define DSATUR 5
326 #define DSATUR_FIXED 6
327 #define FROM_INPUT_FILE 7
328 #define RLF_STATIC 9
329 #define RLF_REVERSE 11
330 
331 #define CONFLICT_EDGES
332 #endif /* DEFINITIONS_H_ */
std::set< Vertex > VertexSet
Definition: Definitions.h:108
RetCode
Definition: Definitions.h:40
enum RetCode RETCODE
Definition: Definitions.h:48
std::vector< Color > ColorMap
Definition: Definitions.h:107