Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
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$ by $Author$
11  * $Revision$
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  * Integer propagation level option
138  *
139  */
140  inline void
142  cur = ipl;
143  }
144  inline IntPropLevel
145  IplOption::value(void) const {
146  return cur;
147  }
148 
149 
150  /*
151  * Trace flag option
152  *
153  */
154  inline void
156  cur = f;
157  }
158  inline int
159  TraceOption::value(void) const {
160  return cur;
161  }
162 
163  }
164 
165  /*
166  * Options
167  *
168  */
169  inline const char*
170  BaseOptions::name(void) const {
171  return _name;
172  }
173 
174 
175 
176  /*
177  * Model options
178  *
179  */
180  inline void
182  _model.value(v);
183  }
184  inline void
185  Options::model(int v, const char* o, const char* h) {
186  _model.add(v,o,h);
187  }
188  inline int
189  Options::model(void) const {
190  return _model.value();
191  }
192 
193  inline void
195  _symmetry.value(v);
196  }
197  inline void
198  Options::symmetry(int v, const char* o, const char* h) {
199  _symmetry.add(v,o,h);
200  }
201  inline int
202  Options::symmetry(void) const {
203  return _symmetry.value();
204  }
205 
206  inline void
208  _propagation.value(v);
209  }
210  inline void
211  Options::propagation(int v, const char* o, const char* h) {
212  _propagation.add(v,o,h);
213  }
214  inline int
215  Options::propagation(void) const {
216  return _propagation.value();
217  }
218 
219  inline void
221  _ipl.value(i);
222  }
223  inline IntPropLevel
224  Options::ipl(void) const {
225  return _ipl.value();
226  }
227 
228  inline void
230  _branching.value(v);
231  }
232  inline void
233  Options::branching(int v, const char* o, const char* h) {
234  _branching.add(v,o,h);
235  }
236  inline int
237  Options::branching(void) const {
238  return _branching.value();
239  }
240 
241  inline void
242  Options::decay(double d) {
243  _decay.value(d);
244  }
245  inline double
246  Options::decay(void) const {
247  return _decay.value();
248  }
249 
250  inline void
251  Options::seed(unsigned int s) {
252  _seed.value(s);
253  }
254  inline unsigned int
255  Options::seed(void) const {
256  return _seed.value();
257  }
258 
259  inline void
260  Options::step(double s) {
261  _step.value(s);
262  }
263  inline double
264  Options::step(void) const {
265  return _step.value();
266  }
267 
268 
269  /*
270  * Search options
271  *
272  */
273  inline void
275  _search.value(v);
276  }
277  inline void
278  Options::search(int v, const char* o, const char* h) {
279  _search.add(v,o,h);
280  }
281  inline int
282  Options::search(void) const {
283  return _search.value();
284  }
285 
286  inline void
287  Options::solutions(unsigned int n) {
288  _solutions.value(n);
289  }
290  inline unsigned int
291  Options::solutions(void) const {
292  return _solutions.value();
293  }
294 
295  inline void
296  Options::threads(double n) {
297  _threads.value(n);
298  }
299  inline double
300  Options::threads(void) const {
301  return _threads.value();
302  }
303 
304  inline void
305  Options::c_d(unsigned int d) {
306  _c_d.value(d);
307  }
308  inline unsigned int
309  Options::c_d(void) const {
310  return _c_d.value();
311  }
312 
313  inline void
314  Options::a_d(unsigned int d) {
315  _a_d.value(d);
316  }
317  inline unsigned int
318  Options::a_d(void) const {
319  return _a_d.value();
320  }
321 
322  inline void
323  Options::d_l(unsigned int d) {
324  _d_l.value(d);
325  }
326  inline unsigned int
327  Options::d_l(void) const {
328  return _d_l.value();
329  }
330 
331  inline void
332  Options::node(unsigned int n) {
333  _node.value(n);
334  }
335  inline unsigned int
336  Options::node(void) const {
337  return _node.value();
338  }
339 
340  inline void
341  Options::fail(unsigned int n) {
342  _fail.value(n);
343  }
344  inline unsigned int
345  Options::fail(void) const {
346  return _fail.value();
347  }
348 
349  inline void
350  Options::time(unsigned int t) {
351  _time.value(t);
352  }
353  inline unsigned int
354  Options::time(void) const {
355  return _time.value();
356  }
357 
358  inline void
359  Options::assets(unsigned int n) {
360  _assets.value(n);
361  }
362  inline unsigned int
363  Options::assets(void) const {
364  return _assets.value();
365  }
366 
367  inline void
368  Options::slice(unsigned int n) {
369  _slice.value(n);
370  }
371  inline unsigned int
372  Options::slice(void) const {
373  return _slice.value();
374  }
375 
376  inline void
378  _restart.value(rm);
379  }
380  inline RestartMode
381  Options::restart(void) const {
382  return static_cast<RestartMode>(_restart.value());
383  }
384 
385  inline void
387  _r_base.value(n);
388  }
389  inline double
390  Options::restart_base(void) const {
391  return _r_base.value();
392  }
393 
394  inline void
395  Options::restart_scale(unsigned int n) {
396  _r_scale.value(n);
397  }
398  inline unsigned int
400  return _r_scale.value();
401  }
402 
403  inline void
405  _nogoods.value(b);
406  }
407  inline bool
408  Options::nogoods(void) const {
409  return _nogoods.value();
410  }
411 
412  inline void
413  Options::nogoods_limit(unsigned int l) {
414  _nogoods_limit.value(l);
415  }
416  inline unsigned int
418  return _nogoods_limit.value();
419  }
420 
421  inline void
422  Options::relax(double d) {
423  _relax.value(d);
424  }
425  inline double
426  Options::relax(void) const {
427  return _relax.value();
428  }
429 
430 
431 
432  inline void
434  _interrupt.value(b);
435  }
436  inline bool
437  Options::interrupt(void) const {
438  return _interrupt.value();
439  }
440 
441 
442  /*
443  * Execution options
444  *
445  */
446  inline void
448  _mode.value(sm);
449  }
450  inline ScriptMode
451  Options::mode(void) const {
452  return static_cast<ScriptMode>(_mode.value());
453  }
454 
455  inline void
456  Options::samples(unsigned int s) {
457  _samples.value(s);
458  }
459  inline unsigned int
460  Options::samples(void) const {
461  return _samples.value();
462  }
463 
464  inline void
465  Options::iterations(unsigned int i) {
466  _iterations.value(i);
467  }
468  inline unsigned int
469  Options::iterations(void) const {
470  return _iterations.value();
471  }
472 
473  inline void
475  _print_last.value(p);
476  }
477  inline bool
478  Options::print_last(void) const {
479  return _print_last.value();
480  }
481 
482  inline void
483  Options::out_file(const char *f) {
484  _out_file.value(f);
485  }
486 
487  inline const char*
488  Options::out_file(void) const {
489  return _out_file.value();
490  }
491 
492  inline void
493  Options::log_file(const char* f) {
494  _log_file.value(f);
495  }
496 
497  inline const char*
498  Options::log_file(void) const {
499  return _log_file.value();
500  }
501 
502  inline void
504  _trace.value(f);
505  }
506 
507  inline int
508  Options::trace(void) const {
509  return _trace.value();
510  }
511 
512 #ifdef GECODE_HAS_CPPROFILER
513 
514  /*
515  * Profiler options
516  *
517  */
518  inline void
520  _profiler_id.value(i);
521  }
522  inline int
523  Options::profiler_id(void) const {
524  return _profiler_id.value();
525  }
526  inline void
527  Options::profiler_port(unsigned int p) {
528  _profiler_port.value(p);
529  }
530  inline unsigned int
532  return _profiler_port.value();
533  }
534  inline void
536  _profiler_info.value(b);
537  }
538  inline bool
540  return _profiler_info.value();
541  }
542 
543 #endif
544 
545 #ifdef GECODE_HAS_GIST
547  Options::_I::_I(void) : _click(heap,1), n_click(0),
548  _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
549  _compare(heap,1), n_compare(0) {}
550 
551  forceinline void
553  _click[static_cast<int>(n_click++)] = i;
554  }
555  forceinline void
557  _solution[static_cast<int>(n_solution++)] = i;
558  }
559  forceinline void
561  _move[static_cast<int>(n_move++)] = i;
562  }
563  forceinline void
565  _compare[static_cast<int>(n_compare++)] = i;
566  }
568  Options::_I::click(unsigned int i) const {
569  return (i < n_click) ? _click[i] : NULL;
570  }
572  Options::_I::solution(unsigned int i) const {
573  return (i < n_solution) ? _solution[i] : NULL;
574  }
576  Options::_I::move(unsigned int i) const {
577  return (i < n_move) ? _move[i] : NULL;
578  }
580  Options::_I::compare(unsigned int i) const {
581  return (i < n_compare) ? _compare[i] : NULL;
582  }
583 #endif
584 
585  /*
586  * Options with additional size argument
587  *
588  */
589  inline void
590  SizeOptions::size(unsigned int s) {
591  _size = s;
592  }
593  inline unsigned int
594  SizeOptions::size(void) const {
595  return _size;
596  }
597 
598  /*
599  * Options with additional string argument
600  *
601  */
602  inline const char*
604  return _inst;
605  }
606 
607 }
608 
609 // STATISTICS: driver-any
int cur
Current value.
Definition: driver.hh:188
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
int search(void) const
Return search value.
Definition: options.hpp:282
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
unsigned int d_l(void) const
Return discrepancy limit for LDS.
Definition: options.hpp:327
unsigned int cur
Current value.
Definition: driver.hh:235
double relax(void) const
Return default relax probability.
Definition: options.hpp:426
int model(void) const
Return model value.
Definition: options.hpp:189
ScriptMode
Different modes for executing scripts.
Definition: driver.hh:98
RestartMode restart(void) const
Return restart mode.
Definition: options.hpp:381
int value(void) const
Return current option value.
Definition: options.hpp:159
bool nogoods(void) const
Return whether nogoods are used.
Definition: options.hpp:408
IntPropLevel ipl(void) const
Return integer propagation level.
Definition: options.hpp:224
Abstract base class for comparators.
Definition: gist.hh:123
double restart_base(void) const
Return restart base.
Definition: options.hpp:390
unsigned int node(void) const
Return node cutoff.
Definition: options.hpp:336
unsigned int restart_scale(void) const
Return restart scale factor.
Definition: options.hpp:399
ScriptMode mode(void) const
Return mode.
Definition: options.hpp:451
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
const char * log_file(void) const
Get file name for Gecode stats.
Definition: options.hpp:498
unsigned int fail(void) const
Return failure cutoff.
Definition: options.hpp:345
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
bool interrupt(void) const
Return interrupt behavior.
Definition: options.hpp:437
Base class for options.
Definition: driver.hh:125
const char * instance(void) const
Return instance name.
Definition: options.hpp:603
double decay(void) const
Return decay factor.
Definition: options.hpp:246
int trace(void) const
Return trace flags.
Definition: options.hpp:508
#define forceinline
Definition: config.hpp:182
RestartMode
Different modes for restart-based search.
Definition: driver.hh:110
bool value(void) const
Return current option value.
Definition: options.hpp:132
Abstract base class for inspectors.
Definition: gist.hh:103
double value(void) const
Return current option value.
Definition: options.hpp:116
bool cur
Current value.
Definition: driver.hh:275
Gecode::IntSet d(v, 7)
unsigned int time(void) const
Return time cutoff.
Definition: options.hpp:354
unsigned int iterations(void) const
Return number of iterations.
Definition: options.hpp:469
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
const char * out_file(void) const
Get file name for solutions.
Definition: options.hpp:488
Gecode::IntArgs i(4, 1, 2, 3, 4)
unsigned int value(void) const
Return current option value.
Definition: options.hpp:99
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
void solution(Gist::Inspector *i)
Add inspector that reacts on each new solution that is found.
Definition: options.hpp:556
double step(void) const
Return step value.
Definition: options.hpp:264
int propagation(void) const
Return propagation value.
Definition: options.hpp:215
int value(void) const
Return current option value.
Definition: options.hpp:66
double threads(void) const
Return number of parallel threads.
Definition: options.hpp:300
double cur
Current value.
Definition: driver.hh:255
unsigned int profiler_port(void) const
Return profiler execution id.
Definition: options.hpp:531
unsigned int seed(void) const
Return seed value.
Definition: options.hpp:255
void click(Gist::Inspector *i)
Add inspector that reacts on node double clicks.
Definition: options.hpp:552
unsigned int slice(void) const
Return slice size in a portfolio.
Definition: options.hpp:372
const char * name(void) const
Return name of script.
Definition: options.hpp:170
bool print_last(void) const
Return whether to print only last solution found.
Definition: options.hpp:478
unsigned int solutions(void) const
Return number of solutions to search for.
Definition: options.hpp:291
bool profiler_info(void) const
Return whether solution info should be sent to profiler.
Definition: options.hpp:539
_I(void)
Constructor.
Definition: options.hpp:547
void compare(Gist::Comparator *i)
Add comparator.
Definition: options.hpp:564
int value(void) const
Return current option value.
Definition: options.hpp:82
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
unsigned int c_d(void) const
Return copy recomputation distance.
Definition: options.hpp:309
int symmetry(void) const
Return symmetry value.
Definition: options.hpp:202
unsigned int samples(void) const
Return number of samples.
Definition: options.hpp:460
const char * value(void) const
Return current option value.
Definition: options.hpp:50
const int v[7]
Definition: distinct.cpp:263
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:953
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
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
unsigned int nogoods_limit(void) const
Return depth limit for nogoods.
Definition: options.hpp:417
Heap heap
The single global heap.
Definition: heap.cpp:48
unsigned int a_d(void) const
Return adaptive recomputation distance.
Definition: options.hpp:318
const char * cur
Current value.
Definition: driver.hh:157
int cur
Current value.
Definition: driver.hh:215
int profiler_id(void) const
Return profiler execution id.
Definition: options.hpp:523
Gecode toplevel namespace
unsigned int assets(void) const
Return slice size in a portfolio.
Definition: options.hpp:363
void move(Gist::Inspector *i)
Add inspector that reacts on each move of the cursor.
Definition: options.hpp:560
unsigned int size(void) const
Return size.
Definition: options.hpp:594
int branching(void) const
Return branching value.
Definition: options.hpp:237
IntPropLevel value(void) const
Return current option value.
Definition: options.hpp:145