Generated on for Gecode by doxygen 1.18.0
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.dev>
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.dev
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
37namespace 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(nullptr), lst(nullptr) {}
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 * Unsigned long long integer option
101 *
102 */
103 inline
105 (const char* o, const char* e, unsigned long long int v)
106 : BaseOption(o,e), cur(v) {}
107 inline void
108 UnsignedLongLongIntOption::value(unsigned long long int v) {
109 cur = v;
110 }
111 inline unsigned long long int
113 return cur;
114 }
115
116 /*
117 * Double option
118 *
119 */
120 inline
121 DoubleOption::DoubleOption(const char* o, const char* e,
122 double v)
123 : BaseOption(o,e), cur(v) {}
124 inline void
126 cur = v;
127 }
128 inline double
130 return cur;
131 }
132
133 /*
134 * Bool option
135 *
136 */
137 inline
138 BoolOption::BoolOption(const char* o, const char* e, bool v)
139 : BaseOption(o,e), cur(v) {}
140 inline void
142 cur = v;
143 }
144 inline bool
145 BoolOption::value(void) const {
146 return cur;
147 }
148
149 /*
150 * Integer propagation level option
151 *
152 */
153 inline void
155 cur = ipl;
156 }
157 inline IntPropLevel
158 IplOption::value(void) const {
159 return cur;
160 }
161
162
163 /*
164 * Trace flag option
165 *
166 */
167 inline void
169 cur = f;
170 }
171 inline int
172 TraceOption::value(void) const {
173 return cur;
174 }
175
176 /*
177 * Profiler option
178 *
179 */
180 inline
181 ProfilerOption::ProfilerOption(const char* o, const char* e, unsigned int p, int i)
182 : BaseOption(o,e), cur_port(p), cur_execution_id(i) {}
183 inline void ProfilerOption::port(unsigned int p) { cur_port = p; }
184 inline unsigned int ProfilerOption::port(void) const { return cur_port; }
186 inline int ProfilerOption::execution_id(void) const { return cur_execution_id; }
187
188 }
189
190 /*
191 * Options
192 *
193 */
194 inline const char*
195 BaseOptions::name(void) const {
196 return _name;
197 }
198
199
200
201 /*
202 * Model options
203 *
204 */
205 inline void
207 _model.value(v);
208 }
209 inline void
210 Options::model(int v, const char* o, const char* h) {
211 _model.add(v,o,h);
212 }
213 inline int
214 Options::model(void) const {
215 return _model.value();
216 }
217
218 inline void
220 _symmetry.value(v);
221 }
222 inline void
223 Options::symmetry(int v, const char* o, const char* h) {
224 _symmetry.add(v,o,h);
225 }
226 inline int
227 Options::symmetry(void) const {
228 return _symmetry.value();
229 }
230
231 inline void
235 inline void
236 Options::propagation(int v, const char* o, const char* h) {
237 _propagation.add(v,o,h);
238 }
239 inline int
241 return _propagation.value();
242 }
243
244 inline void
248 inline IntPropLevel
249 Options::ipl(void) const {
250 return _ipl.value();
251 }
252
253 inline void
255 _branching.value(v);
256 }
257 inline void
258 Options::branching(int v, const char* o, const char* h) {
259 _branching.add(v,o,h);
260 }
261 inline int
262 Options::branching(void) const {
263 return _branching.value();
264 }
265
266 inline void
267 Options::decay(double d) {
268 _decay.value(d);
269 }
270 inline double
271 Options::decay(void) const {
272 return _decay.value();
273 }
274
275 inline void
276 Options::seed(unsigned int s) {
277 _seed.value(s);
278 }
279 inline unsigned int
280 Options::seed(void) const {
281 return _seed.value();
282 }
283
284 inline void
285 Options::step(double s) {
286 _step.value(s);
287 }
288 inline double
289 Options::step(void) const {
290 return _step.value();
291 }
292
293
294 /*
295 * Search options
296 *
297 */
298 inline void
300 _search.value(v);
301 }
302 inline void
303 Options::search(int v, const char* o, const char* h) {
304 _search.add(v,o,h);
305 }
306 inline int
307 Options::search(void) const {
308 return _search.value();
309 }
310
311 inline void
312 Options::solutions(unsigned long long int n) {
313 _solutions.value(n);
314 }
315 inline unsigned long long int
316 Options::solutions(void) const {
317 return _solutions.value();
318 }
319
320 inline void
322 _threads.value(n);
323 }
324 inline double
325 Options::threads(void) const {
326 return _threads.value();
327 }
328
329#ifdef GECODE_HAS_EXPERIMENTAL
330 inline void
334 inline const Search::HeuristicGuidance*
335 Options::guidance(void) const {
336 return _guidance;
337 }
338#endif
339
340 inline void
341 Options::c_d(unsigned int d) {
342 _c_d.value(d);
343 }
344 inline unsigned int
345 Options::c_d(void) const {
346 return _c_d.value();
347 }
348
349 inline void
350 Options::a_d(unsigned int d) {
351 _a_d.value(d);
352 }
353 inline unsigned int
354 Options::a_d(void) const {
355 return _a_d.value();
356 }
357
358 inline void
359 Options::d_l(unsigned int d) {
360 _d_l.value(d);
361 }
362 inline unsigned int
363 Options::d_l(void) const {
364 return _d_l.value();
365 }
366
367 inline void
368 Options::node(unsigned long long int n) {
369 _node.value(n);
370 }
371 inline unsigned long long int
372 Options::node(void) const {
373 return _node.value();
374 }
375
376 inline void
377 Options::fail(unsigned long long int n) {
378 _fail.value(n);
379 }
380 inline unsigned long long int
381 Options::fail(void) const {
382 return _fail.value();
383 }
384
385 inline void
386 Options::time(double t) {
387 _time.value(t);
388 }
389 inline double
390 Options::time(void) const {
391 return _time.value();
392 }
393
394 inline void
395 Options::assets(unsigned int n) {
396 _assets.value(n);
397 }
398 inline unsigned int
399 Options::assets(void) const {
400 return _assets.value();
401 }
402
403 inline void
404 Options::slice(unsigned int n) {
405 _slice.value(n);
406 }
407 inline unsigned int
408 Options::slice(void) const {
409 return _slice.value();
410 }
411
412 inline void
416 inline RestartMode
417 Options::restart(void) const {
418 return static_cast<RestartMode>(_restart.value());
419 }
420
421 inline void
423 _r_base.value(n);
424 }
425 inline double
427 return _r_base.value();
428 }
429
430 inline void
431 Options::restart_scale(unsigned int n) {
432 _r_scale.value(n);
433 }
434 inline unsigned int
436 return _r_scale.value();
437 }
438
439 inline void
440 Options::restart_limit(unsigned long long int n) {
441 _r_limit.value(n);
442 }
443 inline unsigned long long int
445 return _r_limit.value();
446 }
447
448 inline void
450 _nogoods.value(b);
451 }
452 inline bool
453 Options::nogoods(void) const {
454 return _nogoods.value();
455 }
456
457 inline void
458 Options::nogoods_limit(unsigned int l) {
460 }
461 inline unsigned int
463 return _nogoods_limit.value();
464 }
465
466 inline void
467 Options::relax(double d) {
468 _relax.value(d);
469 }
470 inline double
471 Options::relax(void) const {
472 return _relax.value();
473 }
474
475
476
477 inline void
479 _interrupt.value(b);
480 }
481 inline bool
482 Options::interrupt(void) const {
483 return _interrupt.value();
484 }
485
486
487 /*
488 * Execution options
489 *
490 */
491 inline void
493 _mode.value(sm);
494 }
495 inline ScriptMode
496 Options::mode(void) const {
497 return static_cast<ScriptMode>(_mode.value());
498 }
499
500 inline void
501 Options::samples(unsigned int s) {
502 _samples.value(s);
503 }
504 inline unsigned int
505 Options::samples(void) const {
506 return _samples.value();
507 }
508
509 inline void
510 Options::iterations(unsigned int i) {
512 }
513 inline unsigned int
515 return _iterations.value();
516 }
517
518 inline void
521 }
522 inline bool
524 return _print_last.value();
525 }
526
527 inline void
528 Options::out_file(const char *f) {
529 _out_file.value(f);
530 }
531
532 inline const char*
533 Options::out_file(void) const {
534 return _out_file.value();
535 }
536
537 inline void
538 Options::log_file(const char* f) {
539 _log_file.value(f);
540 }
541
542 inline const char*
543 Options::log_file(void) const {
544 return _log_file.value();
545 }
546
547 inline void
549 _trace.value(f);
550 }
551
552 inline int
553 Options::trace(void) const {
554 return _trace.value();
555 }
556
557#ifdef GECODE_HAS_CPPROFILER
558
559 /*
560 * Profiler options
561 *
562 */
563 inline void
567 inline int
569 return _profiler.execution_id();
570 }
571 inline void
572 Options::profiler_port(unsigned int p) {
573 _profiler.port(p);
574 }
575 inline unsigned int
577 return _profiler.port();
578 }
579#endif
580
581#ifdef GECODE_HAS_GIST
582 forceinline
583 Options::I_::I_(void) : _click(heap,1), n_click(0),
584 _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
585 _compare(heap,1), n_compare(0) {}
586
587 forceinline void
589 _click[static_cast<int>(n_click++)] = i;
590 }
591 forceinline void
593 _solution[static_cast<int>(n_solution++)] = i;
594 }
595 forceinline void
597 _move[static_cast<int>(n_move++)] = i;
598 }
599 forceinline void
601 _compare[static_cast<int>(n_compare++)] = i;
602 }
603 forceinline Gist::Inspector*
604 Options::I_::click(unsigned int i) const {
605 return (i < n_click) ? _click[i] : nullptr;
606 }
607 forceinline Gist::Inspector*
608 Options::I_::solution(unsigned int i) const {
609 return (i < n_solution) ? _solution[i] : nullptr;
610 }
611 forceinline Gist::Inspector*
612 Options::I_::move(unsigned int i) const {
613 return (i < n_move) ? _move[i] : nullptr;
614 }
615 forceinline Gist::Comparator*
616 Options::I_::compare(unsigned int i) const {
617 return (i < n_compare) ? _compare[i] : nullptr;
618 }
619#endif
620
621 /*
622 * Options with additional size argument
623 *
624 */
625 inline void
626 SizeOptions::size(unsigned int s) {
627 _size = s;
628 }
629 inline unsigned int
630 SizeOptions::size(void) const {
631 return _size;
632 }
633
634 /*
635 * Options with additional string argument
636 *
637 */
638 inline const char*
640 return _inst;
641 }
642
643 inline const char*
645 return _spec;
646 }
647
648 inline const char*
650 return _spec_file.value();
651 }
652
653 inline const char*
655 return _param.value();
656 }
657}
658
659// STATISTICS: driver-any
const char * _name
Script name.
Definition driver.hh:395
const char * name(void) const
Return name of script.
Definition options.hpp:195
BaseOption(const char *o, const char *e)
Initialize for option o and explanation e.
bool cur
Current value.
Definition driver.hh:307
BoolOption(const char *o, const char *e, bool v=false)
Initialize for option o and explanation e and default value v.
Definition options.hpp:138
void value(bool v)
Set default value to v.
Definition options.hpp:141
bool value(void) const
Return current option value.
Definition options.hpp:145
double value(void) const
Return current option value.
Definition options.hpp:129
double cur
Current value.
Definition driver.hh:287
DoubleOption(const char *o, const char *e, double v=0)
Initialize for option o and explanation e and default value v.
Definition options.hpp:121
void value(double v)
Set default value to v.
Definition options.hpp:125
int cur
Current value.
Definition driver.hh:226
int value(void) const
Return current option value.
Definition options.hpp:78
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
IntPropLevel cur
Current value.
Definition driver.hh:327
IntPropLevel value(void) const
Return current option value.
Definition options.hpp:158
void value(IntPropLevel l)
Set default level to l.
Definition options.hpp:154
void port(unsigned int p)
Set default port to p.
Definition options.hpp:183
ProfilerOption(const char *o, const char *e, unsigned int p=0, int v=-1)
Initialize for option o and explanation e and default value v.
Definition options.hpp:181
void execution_id(int i)
Set default execution ID to i.
Definition options.hpp:185
int execution_id(void) const
Return current execution ID.
Definition options.hpp:186
int cur_execution_id
Current execution ID.
Definition driver.hh:368
unsigned int cur_port
Current port.
Definition driver.hh:367
unsigned int port(void) const
Return current port.
Definition options.hpp:184
int cur
Current value.
Definition driver.hh:199
int value(void) const
Return current option value.
Definition options.hpp:62
void add(int v, const char *o, const char *h=nullptr)
Add option value for value v, string o, and help text h.
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
void value(int v)
Set default value to v.
Definition options.hpp:58
Value * lst
Last option value.
Definition driver.hh:201
Value * fst
First option value.
Definition driver.hh:200
void value(const char *v)
Set default value to v.
const char * value(void) const
Return current option value.
Definition options.hpp:46
const char * cur
Current value.
Definition driver.hh:155
int cur
Current value.
Definition driver.hh:347
void value(int f)
Set default trace flags to f.
Definition options.hpp:168
int value(void) const
Return current option value.
Definition options.hpp:172
unsigned int value(void) const
Return current option value.
Definition options.hpp:95
void value(unsigned int v)
Set default value to v.
Definition options.hpp:91
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
unsigned int cur
Current value.
Definition driver.hh:246
void value(unsigned long long int v)
Set default value to v.
Definition options.hpp:108
unsigned long long int cur
Current value.
Definition driver.hh:266
UnsignedLongLongIntOption(const char *o, const char *e, unsigned long long int v=0)
Initialize for option o and explanation e and default value v.
Definition options.hpp:105
unsigned long long int value(void) const
Return current option value.
Definition options.hpp:112
Abstract base class for comparators.
Definition gist.hh:119
Abstract base class for inspectors.
Definition gist.hh:99
const char * _inst
Instance string.
Definition driver.hh:802
Driver::StringListOption _param
Parameters for the spec.
Definition driver.hh:805
const char * instance(void) const
Return instance name.
Definition options.hpp:639
const char * spec(void) const
Return the reader spec for instance files (may be null).
Definition options.hpp:644
const char * _spec
Reader spec for instance files.
Definition driver.hh:803
const char * param(void) const
Return the spec parameters (may be null).
Definition options.hpp:654
Driver::StringValueOption _spec_file
File with a reader spec.
Definition driver.hh:804
const char * spec_file(void) const
Return the file with a reader spec (may be null).
Definition options.hpp:649
I_(void)
Constructor.
Definition options.hpp:583
void compare(Gist::Comparator *i)
Add comparator.
Definition options.hpp:600
void click(Gist::Inspector *i)
Add inspector that reacts on node double clicks.
Definition options.hpp:588
void move(Gist::Inspector *i)
Add inspector that reacts on each move of the cursor.
Definition options.hpp:596
void solution(Gist::Inspector *i)
Add inspector that reacts on each new solution that is found.
Definition options.hpp:592
Driver::DoubleOption _relax
Probability to relax variable.
Definition driver.hh:463
unsigned long long int restart_limit(void) const
Return restart cutoff.
Definition options.hpp:444
bool nogoods(void) const
Return whether nogoods are used.
Definition options.hpp:453
Driver::StringValueOption _log_file
Where to print statistics.
Definition driver.hh:478
unsigned int profiler_port(void) const
Return profiler execution id.
Definition options.hpp:576
Driver::StringOption _model
General model options.
Definition driver.hh:430
bool print_last(void) const
Return whether to print only last solution found.
Definition options.hpp:523
int model(void) const
Return model value.
Definition options.hpp:214
unsigned int a_d(void) const
Return adaptive recomputation distance.
Definition options.hpp:354
double threads(void) const
Return number of parallel threads.
Definition options.hpp:325
int symmetry(void) const
Return symmetry value.
Definition options.hpp:227
Driver::StringOption _mode
Script mode to run.
Definition driver.hh:473
Driver::DoubleOption _decay
Decay option.
Definition driver.hh:435
Driver::UnsignedIntOption _nogoods_limit
Limit for no-good extraction.
Definition driver.hh:462
unsigned int iterations(void) const
Return number of iterations.
Definition options.hpp:514
Driver::BoolOption _nogoods
Whether to use no-goods.
Definition driver.hh:461
Driver::UnsignedIntOption _slice
Size of a portfolio slice.
Definition driver.hh:455
Driver::UnsignedLongLongIntOption _r_limit
Cutoff for number of restarts.
Definition driver.hh:460
Driver::TraceOption _trace
Trace flags for tracing.
Definition driver.hh:479
Driver::UnsignedLongLongIntOption _fail
Cutoff for number of failures.
Definition driver.hh:452
Driver::UnsignedIntOption _d_l
Discrepancy limit for LDS.
Definition driver.hh:448
const Search::HeuristicGuidance * guidance(void) const
Return guidance for heuristic search.
Definition options.hpp:335
Driver::UnsignedIntOption _assets
Number of assets in a portfolio.
Definition driver.hh:454
Driver::UnsignedLongLongIntOption _node
Cutoff for number of nodes.
Definition driver.hh:450
int propagation(void) const
Return propagation value.
Definition options.hpp:240
unsigned int seed(void) const
Return seed value.
Definition options.hpp:280
unsigned int assets(void) const
Return slice size in a portfolio.
Definition options.hpp:399
ScriptMode mode(void) const
Return mode.
Definition options.hpp:496
unsigned long long int solutions(void) const
Return number of solutions to search for.
Definition options.hpp:316
Driver::UnsignedIntOption _iterations
How many iterations per sample.
Definition driver.hh:475
Driver::StringOption _search
Search options.
Definition driver.hh:442
Driver::StringOption _propagation
Propagation options.
Definition driver.hh:432
Driver::IplOption _ipl
Integer propagation level.
Definition driver.hh:433
Driver::UnsignedLongLongIntOption _solutions
How many solutions.
Definition driver.hh:444
const char * log_file(void) const
Get file name for Gecode stats.
Definition options.hpp:543
Driver::BoolOption _print_last
Print only last solution found.
Definition driver.hh:476
Driver::UnsignedIntOption _c_d
Copy recomputation distance.
Definition driver.hh:446
unsigned int c_d(void) const
Return copy recomputation distance.
Definition options.hpp:345
const Search::HeuristicGuidance * _guidance
Guidance for heuristic search.
Definition driver.hh:467
Driver::ProfilerOption _profiler
Options for the CP Profiler.
Definition driver.hh:482
Driver::DoubleOption _threads
How many threads to use.
Definition driver.hh:445
Driver::StringOption _branching
Branching options.
Definition driver.hh:434
int search(void) const
Return search value.
Definition options.hpp:307
Driver::StringOption _restart
Restart method option.
Definition driver.hh:456
Driver::UnsignedIntOption _seed
Seed option.
Definition driver.hh:436
Driver::DoubleOption _step
Step option.
Definition driver.hh:437
Driver::UnsignedIntOption _r_scale
Restart scale factor.
Definition driver.hh:458
Driver::DoubleOption _time
Cutoff for time.
Definition driver.hh:453
unsigned long long int fail(void) const
Return failure cutoff.
Definition options.hpp:381
Driver::BoolOption _interrupt
Whether to catch SIGINT.
Definition driver.hh:464
unsigned long long int node(void) const
Return node cutoff.
Definition options.hpp:372
double time(void) const
Return time cutoff.
Definition options.hpp:390
Driver::UnsignedIntOption _a_d
Adaptive recomputation distance.
Definition driver.hh:447
double decay(void) const
Return decay factor.
Definition options.hpp:271
Driver::DoubleOption _r_base
Restart base.
Definition driver.hh:457
Driver::StringOption _symmetry
General symmetry options.
Definition driver.hh:431
double step(void) const
Return step value.
Definition options.hpp:289
Driver::StringValueOption _out_file
Where to print solutions.
Definition driver.hh:477
unsigned int samples(void) const
Return number of samples.
Definition options.hpp:505
int profiler_id(void) const
Return profiler execution id.
Definition options.hpp:568
unsigned int d_l(void) const
Return discrepancy limit for LDS.
Definition options.hpp:363
RestartMode restart(void) const
Return restart mode.
Definition options.hpp:417
Driver::UnsignedIntOption _samples
How many samples.
Definition driver.hh:474
int trace(void) const
Return trace flags.
Definition options.hpp:553
const char * out_file(void) const
Get file name for solutions.
Definition options.hpp:533
double relax(void) const
Return default relax probability.
Definition options.hpp:471
bool interrupt(void) const
Return interrupt behavior.
Definition options.hpp:482
unsigned int slice(void) const
Return slice size in a portfolio.
Definition options.hpp:408
int branching(void) const
Return branching value.
Definition options.hpp:262
unsigned int nogoods_limit(void) const
Return depth limit for nogoods.
Definition options.hpp:462
double restart_base(void) const
Return restart base.
Definition options.hpp:426
IntPropLevel ipl(void) const
Return integer propagation level.
Definition options.hpp:249
unsigned int restart_scale(void) const
Return restart scale factor.
Definition options.hpp:435
Guidance for heuristic search engines (experimental).
Definition search.hh:1259
unsigned int size(void) const
Return size.
Definition options.hpp:630
unsigned int _size
Size value.
Definition driver.hh:755
Heap heap
The single global heap.
ScriptMode
Different modes for executing scripts.
Definition driver.hh:97
RestartMode
Different modes for restart-based search.
Definition driver.hh:108
IntPropLevel
Propagation levels for integer propagators.
Definition int.hh:1274
Script commandline driver.
Gecode toplevel namespace