Generated on Sat Feb 7 2015 02:01:13 for Gecode by doxygen 1.8.9.1
options.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2004
8  *
9  * Last modified:
10  * $Date: 2013-07-08 14:22:40 +0200 (Mon, 08 Jul 2013) $ by $Author: schulte $
11  * $Revision: 13820 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  *
18  * Permission is hereby granted, free of charge, to any person obtaining
19  * a copy of this software and associated documentation files (the
20  * "Software"), to deal in the Software without restriction, including
21  * without limitation the rights to use, copy, modify, merge, publish,
22  * distribute, sublicense, and/or sell copies of the Software, and to
23  * permit persons to whom the Software is furnished to do so, subject to
24  * the following conditions:
25  *
26  * The above copyright notice and this permission notice shall be
27  * included in all copies or substantial portions of the Software.
28  *
29  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36  *
37  */
38 
39 #include <cstring>
40 
41 namespace Gecode {
42 
43  namespace Driver {
44 
45  /*
46  * String option
47  *
48  */
49  inline const char*
51  return cur;
52  }
53 
54  /*
55  * String option
56  *
57  */
58  inline
59  StringOption::StringOption(const char* o, const char* e, int v)
60  : BaseOption(o,e), cur(v), fst(NULL), lst(NULL) {}
61  inline void
63  cur = v;
64  }
65  inline int
66  StringOption::value(void) const {
67  return cur;
68  }
69 
70  /*
71  * Integer option
72  *
73  */
74  inline
75  IntOption::IntOption(const char* o, const char* e, int v)
76  : BaseOption(o,e), cur(v) {}
77  inline void
79  cur = v;
80  }
81  inline int
82  IntOption::value(void) const {
83  return cur;
84  }
85 
86  /*
87  * Unsigned integer option
88  *
89  */
90  inline
91  UnsignedIntOption::UnsignedIntOption(const char* o, const char* e,
92  unsigned int v)
93  : BaseOption(o,e), cur(v) {}
94  inline void
95  UnsignedIntOption::value(unsigned int v) {
96  cur = v;
97  }
98  inline unsigned int
100  return cur;
101  }
102 
103  /*
104  * Double option
105  *
106  */
107  inline
108  DoubleOption::DoubleOption(const char* o, const char* e,
109  double v)
110  : BaseOption(o,e), cur(v) {}
111  inline void
113  cur = v;
114  }
115  inline double
116  DoubleOption::value(void) const {
117  return cur;
118  }
119 
120  /*
121  * Bool option
122  *
123  */
124  inline
125  BoolOption::BoolOption(const char* o, const char* e, bool v)
126  : BaseOption(o,e), cur(v) {}
127  inline void
129  cur = v;
130  }
131  inline bool
132  BoolOption::value(void) const {
133  return cur;
134  }
135 
136 
137  }
138 
139  /*
140  * Options
141  *
142  */
143  inline const char*
144  BaseOptions::name(void) const {
145  return _name;
146  }
147 
148 
149 
150  /*
151  * Model options
152  *
153  */
154  inline void
156  _model.value(v);
157  }
158  inline void
159  Options::model(int v, const char* o, const char* h) {
160  _model.add(v,o,h);
161  }
162  inline int
163  Options::model(void) const {
164  return _model.value();
165  }
166 
167  inline void
169  _symmetry.value(v);
170  }
171  inline void
172  Options::symmetry(int v, const char* o, const char* h) {
173  _symmetry.add(v,o,h);
174  }
175  inline int
176  Options::symmetry(void) const {
177  return _symmetry.value();
178  }
179 
180  inline void
182  _propagation.value(v);
183  }
184  inline void
185  Options::propagation(int v, const char* o, const char* h) {
186  _propagation.add(v,o,h);
187  }
188  inline int
189  Options::propagation(void) const {
190  return _propagation.value();
191  }
192 
193  inline void
195  _icl.value(i);
196  }
197  inline IntConLevel
198  Options::icl(void) const {
199  return static_cast<IntConLevel>(_icl.value());
200  }
201 
202  inline void
204  _branching.value(v);
205  }
206  inline void
207  Options::branching(int v, const char* o, const char* h) {
208  _branching.add(v,o,h);
209  }
210  inline int
211  Options::branching(void) const {
212  return _branching.value();
213  }
214 
215  inline void
216  Options::decay(double d) {
217  _decay.value(d);
218  }
219  inline double
220  Options::decay(void) const {
221  return _decay.value();
222  }
223 
224 
225  /*
226  * Search options
227  *
228  */
229  inline void
231  _search.value(v);
232  }
233  inline void
234  Options::search(int v, const char* o, const char* h) {
235  _search.add(v,o,h);
236  }
237  inline int
238  Options::search(void) const {
239  return _search.value();
240  }
241 
242  inline void
243  Options::solutions(unsigned int n) {
244  _solutions.value(n);
245  }
246  inline unsigned int
247  Options::solutions(void) const {
248  return _solutions.value();
249  }
250 
251  inline void
252  Options::threads(double n) {
253  _threads.value(n);
254  }
255  inline double
256  Options::threads(void) const {
257  return _threads.value();
258  }
259 
260  inline void
261  Options::c_d(unsigned int d) {
262  _c_d.value(d);
263  }
264  inline unsigned int
265  Options::c_d(void) const {
266  return _c_d.value();
267  }
268 
269  inline void
270  Options::a_d(unsigned int d) {
271  _a_d.value(d);
272  }
273  inline unsigned int
274  Options::a_d(void) const {
275  return _a_d.value();
276  }
277 
278  inline void
279  Options::node(unsigned int n) {
280  _node.value(n);
281  }
282  inline unsigned int
283  Options::node(void) const {
284  return _node.value();
285  }
286 
287  inline void
288  Options::fail(unsigned int n) {
289  _fail.value(n);
290  }
291  inline unsigned int
292  Options::fail(void) const {
293  return _fail.value();
294  }
295 
296  inline void
297  Options::time(unsigned int t) {
298  _time.value(t);
299  }
300  inline unsigned int
301  Options::time(void) const {
302  return _time.value();
303  }
304 
305  inline void
307  _restart.value(rm);
308  }
309  inline RestartMode
310  Options::restart(void) const {
311  return static_cast<RestartMode>(_restart.value());
312  }
313 
314  inline void
316  _r_base.value(n);
317  }
318  inline double
319  Options::restart_base(void) const {
320  return _r_base.value();
321  }
322 
323  inline void
324  Options::restart_scale(unsigned int n) {
325  _r_scale.value(n);
326  }
327  inline unsigned int
329  return _r_scale.value();
330  }
331 
332  inline void
334  _nogoods.value(b);
335  }
336  inline bool
337  Options::nogoods(void) const {
338  return _nogoods.value();
339  }
340 
341  inline void
342  Options::nogoods_limit(unsigned int l) {
344  }
345  inline unsigned int
347  return _nogoods_limit.value();
348  }
349 
350 
351 
352  inline void
354  _interrupt.value(b);
355  }
356  inline bool
357  Options::interrupt(void) const {
358  return _interrupt.value();
359  }
360 
361 
362  /*
363  * Execution options
364  *
365  */
366  inline void
368  _mode.value(sm);
369  }
370  inline ScriptMode
371  Options::mode(void) const {
372  return static_cast<ScriptMode>(_mode.value());
373  }
374 
375  inline void
376  Options::samples(unsigned int s) {
377  _samples.value(s);
378  }
379  inline unsigned int
380  Options::samples(void) const {
381  return _samples.value();
382  }
383 
384  inline void
385  Options::iterations(unsigned int i) {
386  _iterations.value(i);
387  }
388  inline unsigned int
389  Options::iterations(void) const {
390  return _iterations.value();
391  }
392 
393  inline void
395  _print_last.value(p);
396  }
397  inline bool
398  Options::print_last(void) const {
399  return _print_last.value();
400  }
401 
402  inline void
403  Options::out_file(const char *f) {
404  _out_file.value(f);
405  }
406 
407  inline const char*
408  Options::out_file(void) const {
409  return _out_file.value();
410  }
411 
412  inline void
413  Options::log_file(const char* f) {
414  _log_file.value(f);
415  }
416 
417  inline const char*
418  Options::log_file(void) const {
419  return _log_file.value();
420  }
421 
422 #ifdef GECODE_HAS_GIST
424  Options::_I::_I(void) : _click(heap,1), n_click(0),
425  _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
426  _compare(heap,1), n_compare(0) {}
427 
428  forceinline void
429  Options::_I::click(Gist::Inspector* i) {
430  _click[static_cast<int>(n_click++)] = i;
431  }
432  forceinline void
433  Options::_I::solution(Gist::Inspector* i) {
434  _solution[static_cast<int>(n_solution++)] = i;
435  }
436  forceinline void
437  Options::_I::move(Gist::Inspector* i) {
438  _move[static_cast<int>(n_move++)] = i;
439  }
440  forceinline void
441  Options::_I::compare(Gist::Comparator* i) {
442  _compare[static_cast<int>(n_compare++)] = i;
443  }
444  forceinline Gist::Inspector*
445  Options::_I::click(unsigned int i) const {
446  return (i < n_click) ? _click[i] : NULL;
447  }
448  forceinline Gist::Inspector*
449  Options::_I::solution(unsigned int i) const {
450  return (i < n_solution) ? _solution[i] : NULL;
451  }
452  forceinline Gist::Inspector*
453  Options::_I::move(unsigned int i) const {
454  return (i < n_move) ? _move[i] : NULL;
455  }
456  forceinline Gist::Comparator*
457  Options::_I::compare(unsigned int i) const {
458  return (i < n_compare) ? _compare[i] : NULL;
459  }
460 #endif
461 
462  /*
463  * Options with additional size argument
464  *
465  */
466  inline void
467  SizeOptions::size(unsigned int s) {
468  _size = s;
469  }
470  inline unsigned int
471  SizeOptions::size(void) const {
472  return _size;
473  }
474 
475  /*
476  * Options with additional string argument
477  *
478  */
479  inline const char*
481  return _inst;
482  }
483 
484 }
485 
486 // STATISTICS: driver-any
Driver::UnsignedIntOption _c_d
Copy recomputation distance.
Definition: driver.hh:343
Driver::BoolOption _interrupt
Whether to catch SIGINT.
Definition: driver.hh:353
int cur
Current value.
Definition: driver.hh:184
void value(int v)
Set default value to v.
Definition: options.hpp:62
UnsignedIntOption(const char *o, const char *e, unsigned int v=0)
Initialize for option o and explanation e and default value v.
Definition: options.hpp:91
NodeType t
Type of node.
Definition: bool-expr.cpp:234
Driver::UnsignedIntOption _iterations
How many iterations per sample.
Definition: driver.hh:360
IntConLevel
Consistency levels for integer propagators.
Definition: int.hh:937
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
unsigned int nogoods_limit(void) const
Return depth limit for nogoods.
Definition: options.hpp:346
int value(void) const
Return current option value.
Definition: options.hpp:66
Driver::DoubleOption _decay
Decay option.
Definition: driver.hh:335
unsigned int cur
Current value.
Definition: driver.hh:231
int search(void) const
Return search value.
Definition: options.hpp:238
void value(double v)
Set default value to v.
Definition: options.hpp:112
ScriptMode
Different modes for executing scripts.
Definition: driver.hh:98
unsigned int fail(void) const
Return failure cutoff.
Definition: options.hpp:292
bool print_last(void) const
Return whether to print only last solution found.
Definition: options.hpp:398
Driver::DoubleOption _threads
How many threads to use.
Definition: driver.hh:342
Driver::UnsignedIntOption _nogoods_limit
Limit for no-good extraction.
Definition: driver.hh:352
Driver::StringOption _restart
Restart method option.
Definition: driver.hh:348
Driver::BoolOption _nogoods
Whether to use no-goods.
Definition: driver.hh:351
void add(int v, const char *o, const char *h=NULL)
Add option value for value v, string o, and help text h.
Definition: options.cpp:121
IntOption(const char *o, const char *e, int v=0)
Initialize for option o and explanation e and default value v.
Definition: options.hpp:75
int propagation(void) const
Return propagation value.
Definition: options.hpp:189
BoolOption(const char *o, const char *e, bool v=false)
Initialize for option o and explanation e and default value v.
Definition: options.hpp:125
Base class for options.
Definition: driver.hh:124
IntConLevel icl(void) const
Return integer consistency level.
Definition: options.hpp:198
Driver::DoubleOption _r_base
Restart base.
Definition: driver.hh:349
RestartMode
Different modes for restart-based search.
Definition: driver.hh:109
double decay(void) const
Return decay factor.
Definition: options.hpp:220
void value(unsigned int v)
Set default value to v.
Definition: options.hpp:95
int model(void) const
Return model value.
Definition: options.hpp:163
Heap heap
The single global heap.
Definition: heap.cpp:49
bool cur
Current value.
Definition: driver.hh:271
Gecode::IntSet d(v, 7)
Driver::StringOption _model
General model options.
Definition: driver.hh:330
unsigned int restart_scale(void) const
Return restart scale factor.
Definition: options.hpp:328
unsigned int _size
Size value.
Definition: driver.hh:569
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Driver::UnsignedIntOption _fail
Cutoff for number of failures.
Definition: driver.hh:346
Driver::UnsignedIntOption _samples
How many samples.
Definition: driver.hh:359
unsigned int iterations(void) const
Return number of iterations.
Definition: options.hpp:389
unsigned int node(void) const
Return node cutoff.
Definition: options.hpp:283
Driver::StringValueOption _log_file
Where to print statistics.
Definition: driver.hh:363
ScriptMode mode(void) const
Return mode.
Definition: options.hpp:371
double cur
Current value.
Definition: driver.hh:251
Driver::StringOption _propagation
Propagation options.
Definition: driver.hh:332
const char * instance(void) const
Return instance name.
Definition: options.hpp:480
const char * _name
Script name.
Definition: driver.hh:295
Driver::StringOption _search
Search options.
Definition: driver.hh:340
Driver::BoolOption _print_last
Print only last solution found.
Definition: driver.hh:361
int value(void) const
Return current option value.
Definition: options.hpp:82
double value(void) const
Return current option value.
Definition: options.hpp:116
Driver::StringOption _symmetry
General symmetry options.
Definition: driver.hh:331
Driver::UnsignedIntOption _a_d
Adaptive recomputation distance.
Definition: driver.hh:344
unsigned int c_d(void) const
Return copy recomputation distance.
Definition: options.hpp:265
Driver::UnsignedIntOption _time
Cutoff for time.
Definition: driver.hh:347
Driver::StringOption _mode
Script mode to run.
Definition: driver.hh:358
StringOption(const char *o, const char *e, int v=0)
Initialize for option o and explanation e and default value v.
Definition: options.hpp:59
double restart_base(void) const
Return restart base.
Definition: options.hpp:319
const char * out_file(void) const
Get file name for solutions.
Definition: options.hpp:408
int symmetry(void) const
Return symmetry value.
Definition: options.hpp:176
const int v[7]
Definition: distinct.cpp:207
DoubleOption(const char *o, const char *e, double v=0)
Initialize for option o and explanation e and default value v.
Definition: options.hpp:108
void value(const char *v)
Set default value to v.
Definition: options.cpp:96
bool nogoods(void) const
Return whether nogoods are used.
Definition: options.hpp:337
Driver::StringValueOption _out_file
Where to print solutions.
Definition: driver.hh:362
#define forceinline
Definition: config.hpp:132
const char * _inst
Instance string.
Definition: driver.hh:590
const char * value(void) const
Return current option value.
Definition: options.hpp:50
Driver::UnsignedIntOption _solutions
How many solutions.
Definition: driver.hh:341
Driver::StringOption _branching
Branching options.
Definition: driver.hh:334
void value(bool v)
Set default value to v.
Definition: options.hpp:128
const char * cur
Current value.
Definition: driver.hh:153
unsigned int size(void) const
Return size.
Definition: options.hpp:471
bool value(void) const
Return current option value.
Definition: options.hpp:132
int branching(void) const
Return branching value.
Definition: options.hpp:211
CompareStatus compare(I &i, J &j)
Check whether range iterator i is a subset of j, or whether they are disjoint.
Driver::StringOption _icl
Integer consistency level.
Definition: driver.hh:333
unsigned int value(void) const
Return current option value.
Definition: options.hpp:99
int cur
Current value.
Definition: driver.hh:211
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
bool interrupt(void) const
Return interrupt behavior.
Definition: options.hpp:357
double threads(void) const
Return number of parallel threads.
Definition: options.hpp:256
const char * log_file(void) const
Get file name for Gecode stats.
Definition: options.hpp:418
unsigned int a_d(void) const
Return adaptive recomputation distance.
Definition: options.hpp:274
const char * name(void) const
Return name of script.
Definition: options.hpp:144
unsigned int time(void) const
Return time cutoff.
Definition: options.hpp:301
unsigned int samples(void) const
Return number of samples.
Definition: options.hpp:380
Driver::UnsignedIntOption _r_scale
Restart scale factor.
Definition: driver.hh:350
Driver::UnsignedIntOption _node
Cutoff for number of nodes.
Definition: driver.hh:345
unsigned int solutions(void) const
Return number of solutions to search for.
Definition: options.hpp:247
RestartMode restart(void) const
Return restart mode.
Definition: options.hpp:310