Generated on Tue Jan 19 2021 06:15:49 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  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  *
14  * Permission is hereby granted, free of charge, to any person obtaining
15  * a copy of this software and associated documentation files (the
16  * "Software"), to deal in the Software without restriction, including
17  * without limitation the rights to use, copy, modify, merge, publish,
18  * distribute, sublicense, and/or sell copies of the Software, and to
19  * permit persons to whom the Software is furnished to do so, subject to
20  * the following conditions:
21  *
22  * The above copyright notice and this permission notice shall be
23  * included in all copies or substantial portions of the Software.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32  *
33  */
34 
35 #include <cstring>
36 
37 namespace Gecode {
38 
39  namespace Driver {
40 
41  /*
42  * String option
43  *
44  */
45  inline const char*
47  return cur;
48  }
49 
50  /*
51  * String option
52  *
53  */
54  inline
55  StringOption::StringOption(const char* o, const char* e, int v)
56  : BaseOption(o,e), cur(v), fst(NULL), lst(NULL) {}
57  inline void
59  cur = v;
60  }
61  inline int
62  StringOption::value(void) const {
63  return cur;
64  }
65 
66  /*
67  * Integer option
68  *
69  */
70  inline
71  IntOption::IntOption(const char* o, const char* e, int v)
72  : BaseOption(o,e), cur(v) {}
73  inline void
75  cur = v;
76  }
77  inline int
78  IntOption::value(void) const {
79  return cur;
80  }
81 
82  /*
83  * Unsigned integer option
84  *
85  */
86  inline
87  UnsignedIntOption::UnsignedIntOption(const char* o, const char* e,
88  unsigned int v)
89  : BaseOption(o,e), cur(v) {}
90  inline void
91  UnsignedIntOption::value(unsigned int v) {
92  cur = v;
93  }
94  inline unsigned int
96  return cur;
97  }
98 
99  /*
100  * Double option
101  *
102  */
103  inline
104  DoubleOption::DoubleOption(const char* o, const char* e,
105  double v)
106  : BaseOption(o,e), cur(v) {}
107  inline void
109  cur = v;
110  }
111  inline double
112  DoubleOption::value(void) const {
113  return cur;
114  }
115 
116  /*
117  * Bool option
118  *
119  */
120  inline
121  BoolOption::BoolOption(const char* o, const char* e, bool v)
122  : BaseOption(o,e), cur(v) {}
123  inline void
125  cur = v;
126  }
127  inline bool
128  BoolOption::value(void) const {
129  return cur;
130  }
131 
132  /*
133  * Integer propagation level option
134  *
135  */
136  inline void
138  cur = ipl;
139  }
140  inline IntPropLevel
141  IplOption::value(void) const {
142  return cur;
143  }
144 
145 
146  /*
147  * Trace flag option
148  *
149  */
150  inline void
152  cur = f;
153  }
154  inline int
155  TraceOption::value(void) const {
156  return cur;
157  }
158 
159  }
160 
161  /*
162  * Options
163  *
164  */
165  inline const char*
166  BaseOptions::name(void) const {
167  return _name;
168  }
169 
170 
171 
172  /*
173  * Model options
174  *
175  */
176  inline void
178  _model.value(v);
179  }
180  inline void
181  Options::model(int v, const char* o, const char* h) {
182  _model.add(v,o,h);
183  }
184  inline int
185  Options::model(void) const {
186  return _model.value();
187  }
188 
189  inline void
191  _symmetry.value(v);
192  }
193  inline void
194  Options::symmetry(int v, const char* o, const char* h) {
195  _symmetry.add(v,o,h);
196  }
197  inline int
198  Options::symmetry(void) const {
199  return _symmetry.value();
200  }
201 
202  inline void
204  _propagation.value(v);
205  }
206  inline void
207  Options::propagation(int v, const char* o, const char* h) {
208  _propagation.add(v,o,h);
209  }
210  inline int
211  Options::propagation(void) const {
212  return _propagation.value();
213  }
214 
215  inline void
217  _ipl.value(i);
218  }
219  inline IntPropLevel
220  Options::ipl(void) const {
221  return _ipl.value();
222  }
223 
224  inline void
226  _branching.value(v);
227  }
228  inline void
229  Options::branching(int v, const char* o, const char* h) {
230  _branching.add(v,o,h);
231  }
232  inline int
233  Options::branching(void) const {
234  return _branching.value();
235  }
236 
237  inline void
238  Options::decay(double d) {
239  _decay.value(d);
240  }
241  inline double
242  Options::decay(void) const {
243  return _decay.value();
244  }
245 
246  inline void
247  Options::seed(unsigned int s) {
248  _seed.value(s);
249  }
250  inline unsigned int
251  Options::seed(void) const {
252  return _seed.value();
253  }
254 
255  inline void
256  Options::step(double s) {
257  _step.value(s);
258  }
259  inline double
260  Options::step(void) const {
261  return _step.value();
262  }
263 
264 
265  /*
266  * Search options
267  *
268  */
269  inline void
271  _search.value(v);
272  }
273  inline void
274  Options::search(int v, const char* o, const char* h) {
275  _search.add(v,o,h);
276  }
277  inline int
278  Options::search(void) const {
279  return _search.value();
280  }
281 
282  inline void
283  Options::solutions(unsigned int n) {
284  _solutions.value(n);
285  }
286  inline unsigned int
287  Options::solutions(void) const {
288  return _solutions.value();
289  }
290 
291  inline void
292  Options::threads(double n) {
293  _threads.value(n);
294  }
295  inline double
296  Options::threads(void) const {
297  return _threads.value();
298  }
299 
300  inline void
301  Options::c_d(unsigned int d) {
302  _c_d.value(d);
303  }
304  inline unsigned int
305  Options::c_d(void) const {
306  return _c_d.value();
307  }
308 
309  inline void
310  Options::a_d(unsigned int d) {
311  _a_d.value(d);
312  }
313  inline unsigned int
314  Options::a_d(void) const {
315  return _a_d.value();
316  }
317 
318  inline void
319  Options::d_l(unsigned int d) {
320  _d_l.value(d);
321  }
322  inline unsigned int
323  Options::d_l(void) const {
324  return _d_l.value();
325  }
326 
327  inline void
328  Options::node(unsigned int n) {
329  _node.value(n);
330  }
331  inline unsigned int
332  Options::node(void) const {
333  return _node.value();
334  }
335 
336  inline void
337  Options::fail(unsigned int n) {
338  _fail.value(n);
339  }
340  inline unsigned int
341  Options::fail(void) const {
342  return _fail.value();
343  }
344 
345  inline void
346  Options::time(unsigned int t) {
347  _time.value(t);
348  }
349  inline unsigned int
350  Options::time(void) const {
351  return _time.value();
352  }
353 
354  inline void
355  Options::assets(unsigned int n) {
356  _assets.value(n);
357  }
358  inline unsigned int
359  Options::assets(void) const {
360  return _assets.value();
361  }
362 
363  inline void
364  Options::slice(unsigned int n) {
365  _slice.value(n);
366  }
367  inline unsigned int
368  Options::slice(void) const {
369  return _slice.value();
370  }
371 
372  inline void
374  _restart.value(rm);
375  }
376  inline RestartMode
377  Options::restart(void) const {
378  return static_cast<RestartMode>(_restart.value());
379  }
380 
381  inline void
383  _r_base.value(n);
384  }
385  inline double
386  Options::restart_base(void) const {
387  return _r_base.value();
388  }
389 
390  inline void
391  Options::restart_scale(unsigned int n) {
392  _r_scale.value(n);
393  }
394  inline unsigned int
396  return _r_scale.value();
397  }
398 
399  inline void
401  _nogoods.value(b);
402  }
403  inline bool
404  Options::nogoods(void) const {
405  return _nogoods.value();
406  }
407 
408  inline void
409  Options::nogoods_limit(unsigned int l) {
410  _nogoods_limit.value(l);
411  }
412  inline unsigned int
414  return _nogoods_limit.value();
415  }
416 
417  inline void
418  Options::relax(double d) {
419  _relax.value(d);
420  }
421  inline double
422  Options::relax(void) const {
423  return _relax.value();
424  }
425 
426 
427 
428  inline void
430  _interrupt.value(b);
431  }
432  inline bool
433  Options::interrupt(void) const {
434  return _interrupt.value();
435  }
436 
437 
438  /*
439  * Execution options
440  *
441  */
442  inline void
444  _mode.value(sm);
445  }
446  inline ScriptMode
447  Options::mode(void) const {
448  return static_cast<ScriptMode>(_mode.value());
449  }
450 
451  inline void
452  Options::samples(unsigned int s) {
453  _samples.value(s);
454  }
455  inline unsigned int
456  Options::samples(void) const {
457  return _samples.value();
458  }
459 
460  inline void
461  Options::iterations(unsigned int i) {
462  _iterations.value(i);
463  }
464  inline unsigned int
465  Options::iterations(void) const {
466  return _iterations.value();
467  }
468 
469  inline void
471  _print_last.value(p);
472  }
473  inline bool
474  Options::print_last(void) const {
475  return _print_last.value();
476  }
477 
478  inline void
479  Options::out_file(const char *f) {
480  _out_file.value(f);
481  }
482 
483  inline const char*
484  Options::out_file(void) const {
485  return _out_file.value();
486  }
487 
488  inline void
489  Options::log_file(const char* f) {
490  _log_file.value(f);
491  }
492 
493  inline const char*
494  Options::log_file(void) const {
495  return _log_file.value();
496  }
497 
498  inline void
500  _trace.value(f);
501  }
502 
503  inline int
504  Options::trace(void) const {
505  return _trace.value();
506  }
507 
508 #ifdef GECODE_HAS_CPPROFILER
509 
510  /*
511  * Profiler options
512  *
513  */
514  inline void
516  _profiler_id.value(i);
517  }
518  inline int
519  Options::profiler_id(void) const {
520  return _profiler_id.value();
521  }
522  inline void
523  Options::profiler_port(unsigned int p) {
524  _profiler_port.value(p);
525  }
526  inline unsigned int
528  return _profiler_port.value();
529  }
530  inline void
532  _profiler_info.value(b);
533  }
534  inline bool
536  return _profiler_info.value();
537  }
538 
539 #endif
540 
541 #ifdef GECODE_HAS_GIST
543  Options::_I::_I(void) : _click(heap,1), n_click(0),
544  _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
545  _compare(heap,1), n_compare(0) {}
546 
547  forceinline void
549  _click[static_cast<int>(n_click++)] = i;
550  }
551  forceinline void
553  _solution[static_cast<int>(n_solution++)] = i;
554  }
555  forceinline void
557  _move[static_cast<int>(n_move++)] = i;
558  }
559  forceinline void
561  _compare[static_cast<int>(n_compare++)] = i;
562  }
564  Options::_I::click(unsigned int i) const {
565  return (i < n_click) ? _click[i] : NULL;
566  }
568  Options::_I::solution(unsigned int i) const {
569  return (i < n_solution) ? _solution[i] : NULL;
570  }
572  Options::_I::move(unsigned int i) const {
573  return (i < n_move) ? _move[i] : NULL;
574  }
576  Options::_I::compare(unsigned int i) const {
577  return (i < n_compare) ? _compare[i] : NULL;
578  }
579 #endif
580 
581  /*
582  * Options with additional size argument
583  *
584  */
585  inline void
586  SizeOptions::size(unsigned int s) {
587  _size = s;
588  }
589  inline unsigned int
590  SizeOptions::size(void) const {
591  return _size;
592  }
593 
594  /*
595  * Options with additional string argument
596  *
597  */
598  inline const char*
600  return _inst;
601  }
602 
603 }
604 
605 // STATISTICS: driver-any
int cur
Current value.
Definition: driver.hh:184
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:87
NodeType t
Type of node.
Definition: bool-expr.cpp:230
int search(void) const
Return search value.
Definition: options.hpp:278
NNF * l
Left subtree.
Definition: bool-expr.cpp:240
unsigned int d_l(void) const
Return discrepancy limit for LDS.
Definition: options.hpp:323
unsigned int cur
Current value.
Definition: driver.hh:231
double relax(void) const
Return default relax probability.
Definition: options.hpp:422
int model(void) const
Return model value.
Definition: options.hpp:185
ScriptMode
Different modes for executing scripts.
Definition: driver.hh:94
RestartMode restart(void) const
Return restart mode.
Definition: options.hpp:377
int value(void) const
Return current option value.
Definition: options.hpp:155
bool nogoods(void) const
Return whether nogoods are used.
Definition: options.hpp:404
IntPropLevel ipl(void) const
Return integer propagation level.
Definition: options.hpp:220
Abstract base class for comparators.
Definition: gist.hh:119
double restart_base(void) const
Return restart base.
Definition: options.hpp:386
unsigned int node(void) const
Return node cutoff.
Definition: options.hpp:332
unsigned int restart_scale(void) const
Return restart scale factor.
Definition: options.hpp:395
ScriptMode mode(void) const
Return mode.
Definition: options.hpp:447
IntOption(const char *o, const char *e, int v=0)
Initialize for option o and explanation e and default value v.
Definition: options.hpp:71
const char * log_file(void) const
Get file name for Gecode stats.
Definition: options.hpp:494
unsigned int fail(void) const
Return failure cutoff.
Definition: options.hpp:341
BoolOption(const char *o, const char *e, bool v=false)
Initialize for option o and explanation e and default value v.
Definition: options.hpp:121
bool interrupt(void) const
Return interrupt behavior.
Definition: options.hpp:433
Base class for options.
Definition: driver.hh:121
const char * instance(void) const
Return instance name.
Definition: options.hpp:599
double decay(void) const
Return decay factor.
Definition: options.hpp:242
int trace(void) const
Return trace flags.
Definition: options.hpp:504
#define forceinline
Definition: config.hpp:185
RestartMode
Different modes for restart-based search.
Definition: driver.hh:106
bool value(void) const
Return current option value.
Definition: options.hpp:128
Abstract base class for inspectors.
Definition: gist.hh:99
double value(void) const
Return current option value.
Definition: options.hpp:112
bool cur
Current value.
Definition: driver.hh:271
Gecode::IntSet d(v, 7)
unsigned int time(void) const
Return time cutoff.
Definition: options.hpp:350
unsigned int iterations(void) const
Return number of iterations.
Definition: options.hpp:465
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
const char * out_file(void) const
Get file name for solutions.
Definition: options.hpp:484
unsigned int value(void) const
Return current option value.
Definition: options.hpp:95
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Gecode::IntArgs i({1, 2, 3, 4})
void solution(Gist::Inspector *i)
Add inspector that reacts on each new solution that is found.
Definition: options.hpp:552
double step(void) const
Return step value.
Definition: options.hpp:260
int propagation(void) const
Return propagation value.
Definition: options.hpp:211
int value(void) const
Return current option value.
Definition: options.hpp:62
double threads(void) const
Return number of parallel threads.
Definition: options.hpp:296
double cur
Current value.
Definition: driver.hh:251
unsigned int profiler_port(void) const
Return profiler execution id.
Definition: options.hpp:527
struct Gecode::@593::NNF::@62::@63 b
For binary nodes (and, or, eqv)
unsigned int seed(void) const
Return seed value.
Definition: options.hpp:251
void click(Gist::Inspector *i)
Add inspector that reacts on node double clicks.
Definition: options.hpp:548
unsigned int slice(void) const
Return slice size in a portfolio.
Definition: options.hpp:368
const char * name(void) const
Return name of script.
Definition: options.hpp:166
bool print_last(void) const
Return whether to print only last solution found.
Definition: options.hpp:474
unsigned int solutions(void) const
Return number of solutions to search for.
Definition: options.hpp:287
bool profiler_info(void) const
Return whether solution info should be sent to profiler.
Definition: options.hpp:535
_I(void)
Constructor.
Definition: options.hpp:543
void compare(Gist::Comparator *i)
Add comparator.
Definition: options.hpp:560
int value(void) const
Return current option value.
Definition: options.hpp:78
StringOption(const char *o, const char *e, int v=0)
Initialize for option o and explanation e and default value v.
Definition: options.hpp:55
unsigned int c_d(void) const
Return copy recomputation distance.
Definition: options.hpp:305
int symmetry(void) const
Return symmetry value.
Definition: options.hpp:198
unsigned int samples(void) const
Return number of samples.
Definition: options.hpp:456
const char * value(void) const
Return current option value.
Definition: options.hpp:46
const int v[7]
Definition: distinct.cpp:259
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:974
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:104
unsigned int nogoods_limit(void) const
Return depth limit for nogoods.
Definition: options.hpp:413
Heap heap
The single global heap.
Definition: heap.cpp:44
unsigned int a_d(void) const
Return adaptive recomputation distance.
Definition: options.hpp:314
const char * cur
Current value.
Definition: driver.hh:153
int cur
Current value.
Definition: driver.hh:211
int profiler_id(void) const
Return profiler execution id.
Definition: options.hpp:519
Gecode toplevel namespace
unsigned int assets(void) const
Return slice size in a portfolio.
Definition: options.hpp:359
void move(Gist::Inspector *i)
Add inspector that reacts on each move of the cursor.
Definition: options.hpp:556
unsigned int size(void) const
Return size.
Definition: options.hpp:590
int branching(void) const
Return branching value.
Definition: options.hpp:233
IntPropLevel value(void) const
Return current option value.
Definition: options.hpp:141