Generated on Sat Feb 9 2019 13:59:26 for Gecode by doxygen 1.8.5
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: 2015-03-17 16:09:10 +0100 (Tue, 17 Mar 2015) $ by $Author: schulte $
11  * $Revision: 14446 $
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  inline void
225  Options::seed(unsigned int s) {
226  _seed.value(s);
227  }
228  inline unsigned int
229  Options::seed(void) const {
230  return _seed.value();
231  }
232 
233  inline void
234  Options::step(double s) {
235  _step.value(s);
236  }
237  inline double
238  Options::step(void) const {
239  return _step.value();
240  }
241 
242 
243  /*
244  * Search options
245  *
246  */
247  inline void
249  _search.value(v);
250  }
251  inline void
252  Options::search(int v, const char* o, const char* h) {
253  _search.add(v,o,h);
254  }
255  inline int
256  Options::search(void) const {
257  return _search.value();
258  }
259 
260  inline void
261  Options::solutions(unsigned int n) {
262  _solutions.value(n);
263  }
264  inline unsigned int
265  Options::solutions(void) const {
266  return _solutions.value();
267  }
268 
269  inline void
270  Options::threads(double n) {
271  _threads.value(n);
272  }
273  inline double
274  Options::threads(void) const {
275  return _threads.value();
276  }
277 
278  inline void
279  Options::c_d(unsigned int d) {
280  _c_d.value(d);
281  }
282  inline unsigned int
283  Options::c_d(void) const {
284  return _c_d.value();
285  }
286 
287  inline void
288  Options::a_d(unsigned int d) {
289  _a_d.value(d);
290  }
291  inline unsigned int
292  Options::a_d(void) const {
293  return _a_d.value();
294  }
295 
296  inline void
297  Options::node(unsigned int n) {
298  _node.value(n);
299  }
300  inline unsigned int
301  Options::node(void) const {
302  return _node.value();
303  }
304 
305  inline void
306  Options::fail(unsigned int n) {
307  _fail.value(n);
308  }
309  inline unsigned int
310  Options::fail(void) const {
311  return _fail.value();
312  }
313 
314  inline void
315  Options::time(unsigned int t) {
316  _time.value(t);
317  }
318  inline unsigned int
319  Options::time(void) const {
320  return _time.value();
321  }
322 
323  inline void
325  _restart.value(rm);
326  }
327  inline RestartMode
328  Options::restart(void) const {
329  return static_cast<RestartMode>(_restart.value());
330  }
331 
332  inline void
334  _r_base.value(n);
335  }
336  inline double
337  Options::restart_base(void) const {
338  return _r_base.value();
339  }
340 
341  inline void
342  Options::restart_scale(unsigned int n) {
343  _r_scale.value(n);
344  }
345  inline unsigned int
347  return _r_scale.value();
348  }
349 
350  inline void
352  _nogoods.value(b);
353  }
354  inline bool
355  Options::nogoods(void) const {
356  return _nogoods.value();
357  }
358 
359  inline void
360  Options::nogoods_limit(unsigned int l) {
362  }
363  inline unsigned int
365  return _nogoods_limit.value();
366  }
367 
368 
369 
370  inline void
372  _interrupt.value(b);
373  }
374  inline bool
375  Options::interrupt(void) const {
376  return _interrupt.value();
377  }
378 
379 
380  /*
381  * Execution options
382  *
383  */
384  inline void
386  _mode.value(sm);
387  }
388  inline ScriptMode
389  Options::mode(void) const {
390  return static_cast<ScriptMode>(_mode.value());
391  }
392 
393  inline void
394  Options::samples(unsigned int s) {
395  _samples.value(s);
396  }
397  inline unsigned int
398  Options::samples(void) const {
399  return _samples.value();
400  }
401 
402  inline void
403  Options::iterations(unsigned int i) {
404  _iterations.value(i);
405  }
406  inline unsigned int
407  Options::iterations(void) const {
408  return _iterations.value();
409  }
410 
411  inline void
413  _print_last.value(p);
414  }
415  inline bool
416  Options::print_last(void) const {
417  return _print_last.value();
418  }
419 
420  inline void
421  Options::out_file(const char *f) {
422  _out_file.value(f);
423  }
424 
425  inline const char*
426  Options::out_file(void) const {
427  return _out_file.value();
428  }
429 
430  inline void
431  Options::log_file(const char* f) {
432  _log_file.value(f);
433  }
434 
435  inline const char*
436  Options::log_file(void) const {
437  return _log_file.value();
438  }
439 
440 #ifdef GECODE_HAS_GIST
442  Options::_I::_I(void) : _click(heap,1), n_click(0),
443  _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
444  _compare(heap,1), n_compare(0) {}
445 
446  forceinline void
447  Options::_I::click(Gist::Inspector* i) {
448  _click[static_cast<int>(n_click++)] = i;
449  }
450  forceinline void
451  Options::_I::solution(Gist::Inspector* i) {
452  _solution[static_cast<int>(n_solution++)] = i;
453  }
454  forceinline void
455  Options::_I::move(Gist::Inspector* i) {
456  _move[static_cast<int>(n_move++)] = i;
457  }
458  forceinline void
459  Options::_I::compare(Gist::Comparator* i) {
460  _compare[static_cast<int>(n_compare++)] = i;
461  }
462  forceinline Gist::Inspector*
463  Options::_I::click(unsigned int i) const {
464  return (i < n_click) ? _click[i] : NULL;
465  }
466  forceinline Gist::Inspector*
467  Options::_I::solution(unsigned int i) const {
468  return (i < n_solution) ? _solution[i] : NULL;
469  }
470  forceinline Gist::Inspector*
471  Options::_I::move(unsigned int i) const {
472  return (i < n_move) ? _move[i] : NULL;
473  }
474  forceinline Gist::Comparator*
475  Options::_I::compare(unsigned int i) const {
476  return (i < n_compare) ? _compare[i] : NULL;
477  }
478 #endif
479 
480  /*
481  * Options with additional size argument
482  *
483  */
484  inline void
485  SizeOptions::size(unsigned int s) {
486  _size = s;
487  }
488  inline unsigned int
489  SizeOptions::size(void) const {
490  return _size;
491  }
492 
493  /*
494  * Options with additional string argument
495  *
496  */
497  inline const char*
499  return _inst;
500  }
501 
502 }
503 
504 // STATISTICS: driver-any
Driver::UnsignedIntOption _c_d
Copy recomputation distance.
Definition: driver.hh:345
Driver::BoolOption _interrupt
Whether to catch SIGINT.
Definition: driver.hh:355
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:362
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:364
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:256
Driver::DoubleOption _step
Step option.
Definition: driver.hh:337
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:310
bool print_last(void) const
Return whether to print only last solution found.
Definition: options.hpp:416
Driver::DoubleOption _threads
How many threads to use.
Definition: driver.hh:344
Driver::UnsignedIntOption _nogoods_limit
Limit for no-good extraction.
Definition: driver.hh:354
Driver::StringOption _restart
Restart method option.
Definition: driver.hh:350
Driver::BoolOption _nogoods
Whether to use no-goods.
Definition: driver.hh:353
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:351
double step(void) const
Return step value.
Definition: options.hpp:238
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:346
unsigned int _size
Size value.
Definition: driver.hh:581
unsigned int seed(void) const
Return seed value.
Definition: options.hpp:229
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:348
Driver::UnsignedIntOption _samples
How many samples.
Definition: driver.hh:361
unsigned int iterations(void) const
Return number of iterations.
Definition: options.hpp:407
unsigned int node(void) const
Return node cutoff.
Definition: options.hpp:301
Driver::StringValueOption _log_file
Where to print statistics.
Definition: driver.hh:365
ScriptMode mode(void) const
Return mode.
Definition: options.hpp:389
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:498
const char * _name
Script name.
Definition: driver.hh:295
Driver::StringOption _search
Search options.
Definition: driver.hh:342
Driver::BoolOption _print_last
Print only last solution found.
Definition: driver.hh:363
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:346
unsigned int c_d(void) const
Return copy recomputation distance.
Definition: options.hpp:283
Driver::UnsignedIntOption _time
Cutoff for time.
Definition: driver.hh:349
Driver::StringOption _mode
Script mode to run.
Definition: driver.hh:360
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:337
const char * out_file(void) const
Get file name for solutions.
Definition: options.hpp:426
int symmetry(void) const
Return symmetry value.
Definition: options.hpp:176
const int v[7]
Definition: distinct.cpp:207
struct Gecode::@519::NNF::@60::@61 b
For binary nodes (and, or, eqv)
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:355
Driver::StringValueOption _out_file
Where to print solutions.
Definition: driver.hh:364
#define forceinline
Definition: config.hpp:132
const char * _inst
Instance string.
Definition: driver.hh:602
const char * value(void) const
Return current option value.
Definition: options.hpp:50
Driver::UnsignedIntOption _solutions
How many solutions.
Definition: driver.hh:343
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:489
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
Driver::UnsignedIntOption _seed
Seed option.
Definition: driver.hh:336
bool interrupt(void) const
Return interrupt behavior.
Definition: options.hpp:375
double threads(void) const
Return number of parallel threads.
Definition: options.hpp:274
const char * log_file(void) const
Get file name for Gecode stats.
Definition: options.hpp:436
unsigned int a_d(void) const
Return adaptive recomputation distance.
Definition: options.hpp:292
const char * name(void) const
Return name of script.
Definition: options.hpp:144
unsigned int time(void) const
Return time cutoff.
Definition: options.hpp:319
unsigned int samples(void) const
Return number of samples.
Definition: options.hpp:398
Driver::UnsignedIntOption _r_scale
Restart scale factor.
Definition: driver.hh:352
Driver::UnsignedIntOption _node
Cutoff for number of nodes.
Definition: driver.hh:347
unsigned int solutions(void) const
Return number of solutions to search for.
Definition: options.hpp:265
RestartMode restart(void) const
Return restart mode.
Definition: options.hpp:328