Generated on for Gecode by doxygen 1.17.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
233 _propagation.value(v);
234 }
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
246 _ipl.value(i);
247 }
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 inline void
330 Options::c_d(unsigned int d) {
331 _c_d.value(d);
332 }
333 inline unsigned int
334 Options::c_d(void) const {
335 return _c_d.value();
336 }
337
338 inline void
339 Options::a_d(unsigned int d) {
340 _a_d.value(d);
341 }
342 inline unsigned int
343 Options::a_d(void) const {
344 return _a_d.value();
345 }
346
347 inline void
348 Options::d_l(unsigned int d) {
349 _d_l.value(d);
350 }
351 inline unsigned int
352 Options::d_l(void) const {
353 return _d_l.value();
354 }
355
356 inline void
357 Options::node(unsigned long long int n) {
358 _node.value(n);
359 }
360 inline unsigned long long int
361 Options::node(void) const {
362 return _node.value();
363 }
364
365 inline void
366 Options::fail(unsigned long long int n) {
367 _fail.value(n);
368 }
369 inline unsigned long long int
370 Options::fail(void) const {
371 return _fail.value();
372 }
373
374 inline void
375 Options::time(double t) {
376 _time.value(t);
377 }
378 inline double
379 Options::time(void) const {
380 return _time.value();
381 }
382
383 inline void
384 Options::assets(unsigned int n) {
385 _assets.value(n);
386 }
387 inline unsigned int
388 Options::assets(void) const {
389 return _assets.value();
390 }
391
392 inline void
393 Options::slice(unsigned int n) {
394 _slice.value(n);
395 }
396 inline unsigned int
397 Options::slice(void) const {
398 return _slice.value();
399 }
400
401 inline void
403 _restart.value(rm);
404 }
405 inline RestartMode
406 Options::restart(void) const {
407 return static_cast<RestartMode>(_restart.value());
408 }
409
410 inline void
412 _r_base.value(n);
413 }
414 inline double
416 return _r_base.value();
417 }
418
419 inline void
420 Options::restart_scale(unsigned int n) {
421 _r_scale.value(n);
422 }
423 inline unsigned int
425 return _r_scale.value();
426 }
427
428 inline void
429 Options::restart_limit(unsigned long long int n) {
430 _r_limit.value(n);
431 }
432 inline unsigned long long int
434 return _r_limit.value();
435 }
436
437 inline void
439 _nogoods.value(b);
440 }
441 inline bool
442 Options::nogoods(void) const {
443 return _nogoods.value();
444 }
445
446 inline void
447 Options::nogoods_limit(unsigned int l) {
448 _nogoods_limit.value(l);
449 }
450 inline unsigned int
452 return _nogoods_limit.value();
453 }
454
455 inline void
456 Options::relax(double d) {
457 _relax.value(d);
458 }
459 inline double
460 Options::relax(void) const {
461 return _relax.value();
462 }
463
464
465
466 inline void
468 _interrupt.value(b);
469 }
470 inline bool
471 Options::interrupt(void) const {
472 return _interrupt.value();
473 }
474
475
476 /*
477 * Execution options
478 *
479 */
480 inline void
482 _mode.value(sm);
483 }
484 inline ScriptMode
485 Options::mode(void) const {
486 return static_cast<ScriptMode>(_mode.value());
487 }
488
489 inline void
490 Options::samples(unsigned int s) {
491 _samples.value(s);
492 }
493 inline unsigned int
494 Options::samples(void) const {
495 return _samples.value();
496 }
497
498 inline void
499 Options::iterations(unsigned int i) {
500 _iterations.value(i);
501 }
502 inline unsigned int
504 return _iterations.value();
505 }
506
507 inline void
509 _print_last.value(p);
510 }
511 inline bool
513 return _print_last.value();
514 }
515
516 inline void
517 Options::out_file(const char *f) {
518 _out_file.value(f);
519 }
520
521 inline const char*
522 Options::out_file(void) const {
523 return _out_file.value();
524 }
525
526 inline void
527 Options::log_file(const char* f) {
528 _log_file.value(f);
529 }
530
531 inline const char*
532 Options::log_file(void) const {
533 return _log_file.value();
534 }
535
536 inline void
538 _trace.value(f);
539 }
540
541 inline int
542 Options::trace(void) const {
543 return _trace.value();
544 }
545
546#ifdef GECODE_HAS_CPPROFILER
547
548 /*
549 * Profiler options
550 *
551 */
552 inline void
554 _profiler.execution_id(i);
555 }
556 inline int
558 return _profiler.execution_id();
559 }
560 inline void
561 Options::profiler_port(unsigned int p) {
562 _profiler.port(p);
563 }
564 inline unsigned int
566 return _profiler.port();
567 }
568#endif
569
570#ifdef GECODE_HAS_GIST
571 forceinline
572 Options::I_::I_(void) : _click(heap,1), n_click(0),
573 _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
574 _compare(heap,1), n_compare(0) {}
575
576 forceinline void
578 _click[static_cast<int>(n_click++)] = i;
579 }
580 forceinline void
582 _solution[static_cast<int>(n_solution++)] = i;
583 }
584 forceinline void
586 _move[static_cast<int>(n_move++)] = i;
587 }
588 forceinline void
590 _compare[static_cast<int>(n_compare++)] = i;
591 }
592 forceinline Gist::Inspector*
593 Options::I_::click(unsigned int i) const {
594 return (i < n_click) ? _click[i] : nullptr;
595 }
596 forceinline Gist::Inspector*
597 Options::I_::solution(unsigned int i) const {
598 return (i < n_solution) ? _solution[i] : nullptr;
599 }
600 forceinline Gist::Inspector*
601 Options::I_::move(unsigned int i) const {
602 return (i < n_move) ? _move[i] : nullptr;
603 }
604 forceinline Gist::Comparator*
605 Options::I_::compare(unsigned int i) const {
606 return (i < n_compare) ? _compare[i] : nullptr;
607 }
608#endif
609
610 /*
611 * Options with additional size argument
612 *
613 */
614 inline void
615 SizeOptions::size(unsigned int s) {
616 _size = s;
617 }
618 inline unsigned int
619 SizeOptions::size(void) const {
620 return _size;
621 }
622
623 /*
624 * Options with additional string argument
625 *
626 */
627 inline const char*
629 return _inst;
630 }
631
632}
633
634// STATISTICS: driver-any
const char * _name
Script name.
Definition driver.hh:379
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:291
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
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:271
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
int cur
Current value.
Definition driver.hh:210
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:311
IntPropLevel value(void) const
Return current option value.
Definition options.hpp:158
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
int execution_id(void) const
Return current execution ID.
Definition options.hpp:186
int cur_execution_id
Current execution ID.
Definition driver.hh:352
unsigned int cur_port
Current port.
Definition driver.hh:351
unsigned int port(void) const
Return current port.
Definition options.hpp:184
int cur
Current value.
Definition driver.hh:183
int value(void) const
Return current option value.
Definition options.hpp:62
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
Value * lst
Last option value.
Definition driver.hh:185
Value * fst
First option value.
Definition driver.hh:184
const char * value(void) const
Return current option value.
Definition options.hpp:46
const char * cur
Current value.
Definition driver.hh:152
int cur
Current value.
Definition driver.hh:331
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
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:230
unsigned long long int cur
Current value.
Definition driver.hh:250
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:746
const char * instance(void) const
Return instance name.
Definition options.hpp:628
I_(void)
Constructor.
Definition options.hpp:572
void compare(Gist::Comparator *i)
Add comparator.
Definition options.hpp:589
void click(Gist::Inspector *i)
Add inspector that reacts on node double clicks.
Definition options.hpp:577
void move(Gist::Inspector *i)
Add inspector that reacts on each move of the cursor.
Definition options.hpp:585
void solution(Gist::Inspector *i)
Add inspector that reacts on each new solution that is found.
Definition options.hpp:581
Driver::DoubleOption _relax
Probability to relax variable.
Definition driver.hh:447
unsigned long long int restart_limit(void) const
Return restart cutoff.
Definition options.hpp:433
bool nogoods(void) const
Return whether nogoods are used.
Definition options.hpp:442
Driver::StringValueOption _log_file
Where to print statistics.
Definition driver.hh:458
unsigned int profiler_port(void) const
Return profiler execution id.
Definition options.hpp:565
Driver::StringOption _model
General model options.
Definition driver.hh:414
bool print_last(void) const
Return whether to print only last solution found.
Definition options.hpp:512
int model(void) const
Return model value.
Definition options.hpp:214
unsigned int a_d(void) const
Return adaptive recomputation distance.
Definition options.hpp:343
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:453
Driver::DoubleOption _decay
Decay option.
Definition driver.hh:419
Driver::UnsignedIntOption _nogoods_limit
Limit for no-good extraction.
Definition driver.hh:446
unsigned int iterations(void) const
Return number of iterations.
Definition options.hpp:503
Driver::BoolOption _nogoods
Whether to use no-goods.
Definition driver.hh:445
Driver::UnsignedIntOption _slice
Size of a portfolio slice.
Definition driver.hh:439
Driver::UnsignedLongLongIntOption _r_limit
Cutoff for number of restarts.
Definition driver.hh:444
Driver::TraceOption _trace
Trace flags for tracing.
Definition driver.hh:459
Driver::UnsignedLongLongIntOption _fail
Cutoff for number of failures.
Definition driver.hh:436
Driver::UnsignedIntOption _d_l
Discrepancy limit for LDS.
Definition driver.hh:432
Driver::UnsignedIntOption _assets
Number of assets in a portfolio.
Definition driver.hh:438
Driver::UnsignedLongLongIntOption _node
Cutoff for number of nodes.
Definition driver.hh:434
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:388
ScriptMode mode(void) const
Return mode.
Definition options.hpp:485
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:455
Driver::StringOption _search
Search options.
Definition driver.hh:426
Driver::StringOption _propagation
Propagation options.
Definition driver.hh:416
Driver::IplOption _ipl
Integer propagation level.
Definition driver.hh:417
Driver::UnsignedLongLongIntOption _solutions
How many solutions.
Definition driver.hh:428
const char * log_file(void) const
Get file name for Gecode stats.
Definition options.hpp:532
Driver::BoolOption _print_last
Print only last solution found.
Definition driver.hh:456
Driver::UnsignedIntOption _c_d
Copy recomputation distance.
Definition driver.hh:430
unsigned int c_d(void) const
Return copy recomputation distance.
Definition options.hpp:334
Driver::ProfilerOption _profiler
Options for the CP Profiler.
Definition driver.hh:462
Driver::DoubleOption _threads
How many threads to use.
Definition driver.hh:429
Driver::StringOption _branching
Branching options.
Definition driver.hh:418
int search(void) const
Return search value.
Definition options.hpp:307
Driver::StringOption _restart
Restart method option.
Definition driver.hh:440
Driver::UnsignedIntOption _seed
Seed option.
Definition driver.hh:420
Driver::DoubleOption _step
Step option.
Definition driver.hh:421
Driver::UnsignedIntOption _r_scale
Restart scale factor.
Definition driver.hh:442
Driver::DoubleOption _time
Cutoff for time.
Definition driver.hh:437
unsigned long long int fail(void) const
Return failure cutoff.
Definition options.hpp:370
Driver::BoolOption _interrupt
Whether to catch SIGINT.
Definition driver.hh:448
unsigned long long int node(void) const
Return node cutoff.
Definition options.hpp:361
double time(void) const
Return time cutoff.
Definition options.hpp:379
Driver::UnsignedIntOption _a_d
Adaptive recomputation distance.
Definition driver.hh:431
double decay(void) const
Return decay factor.
Definition options.hpp:271
Driver::DoubleOption _r_base
Restart base.
Definition driver.hh:441
Driver::StringOption _symmetry
General symmetry options.
Definition driver.hh:415
double step(void) const
Return step value.
Definition options.hpp:289
Driver::StringValueOption _out_file
Where to print solutions.
Definition driver.hh:457
unsigned int samples(void) const
Return number of samples.
Definition options.hpp:494
int profiler_id(void) const
Return profiler execution id.
Definition options.hpp:557
unsigned int d_l(void) const
Return discrepancy limit for LDS.
Definition options.hpp:352
RestartMode restart(void) const
Return restart mode.
Definition options.hpp:406
Driver::UnsignedIntOption _samples
How many samples.
Definition driver.hh:454
int trace(void) const
Return trace flags.
Definition options.hpp:542
const char * out_file(void) const
Get file name for solutions.
Definition options.hpp:522
double relax(void) const
Return default relax probability.
Definition options.hpp:460
bool interrupt(void) const
Return interrupt behavior.
Definition options.hpp:471
unsigned int slice(void) const
Return slice size in a portfolio.
Definition options.hpp:397
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:451
double restart_base(void) const
Return restart base.
Definition options.hpp:415
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:424
unsigned int size(void) const
Return size.
Definition options.hpp:619
unsigned int _size
Size value.
Definition driver.hh:725
Heap heap
The single global heap.
ScriptMode
Different modes for executing scripts.
Definition driver.hh:94
RestartMode
Different modes for restart-based search.
Definition driver.hh:105
IntPropLevel
Propagation levels for integer propagators.
Definition int.hh:1008
Script commandline driver.
Gecode toplevel namespace