Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.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.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
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(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
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
206 inline void
207 Options::propagation(int v, const char* o, const char* h) {
208 _propagation.add(v,o,h);
209 }
210 inline int
212 return _propagation.value();
213 }
214
215 inline void
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) {
285 }
286 inline unsigned int
287 Options::solutions(void) const {
288 return _solutions.value();
289 }
290
291 inline void
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
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
387 return _r_base.value();
388 }
389
390 inline void
391 Options::restart_scale(unsigned int n) {
393 }
394 inline unsigned int
396 return _r_scale.value();
397 }
398
399 inline void
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) {
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
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) {
463 }
464 inline unsigned int
466 return _iterations.value();
467 }
468
469 inline void
473 inline bool
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
518 inline int
520 return _profiler_id.value();
521 }
522 inline void
523 Options::profiler_port(unsigned int p) {
525 }
526 inline unsigned int
528 return _profiler_port.value();
529 }
530 inline void
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
NNF * l
Left subtree.
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
NodeType t
Type of node.
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
const char * _name
Script name.
Definition driver.hh:335
const char * name(void) const
Return name of script.
Definition options.hpp:166
Base class for options.
Definition driver.hh:121
bool cur
Current value.
Definition driver.hh:271
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
void value(bool v)
Set default value to v.
Definition options.hpp:124
bool value(void) const
Return current option value.
Definition options.hpp:128
double value(void) const
Return current option value.
Definition options.hpp:112
double cur
Current value.
Definition driver.hh:251
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
void value(double v)
Set default value to v.
Definition options.hpp:108
void value(int v)
Set default value to v.
Definition options.hpp:74
int cur
Current value.
Definition driver.hh:211
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:291
IntPropLevel value(void) const
Return current option value.
Definition options.hpp:141
void value(IntPropLevel l)
Set default level to l.
Definition options.hpp:137
int cur
Current value.
Definition driver.hh:184
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
void value(int v)
Set default value to v.
Definition options.hpp:58
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:138
void value(const char *v)
Set default value to v.
Definition options.cpp:113
const char * value(void) const
Return current option value.
Definition options.hpp:46
const char * cur
Current value.
Definition driver.hh:153
int cur
Current value.
Definition driver.hh:311
void value(int f)
Set default trace flags to f.
Definition options.hpp:151
int value(void) const
Return current option value.
Definition options.hpp:155
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:231
Abstract base class for comparators.
Definition gist.hh:119
Abstract base class for inspectors.
Definition gist.hh:99
const char * instance(void) const
Return instance name.
Definition options.hpp:599
void click(Gist::Inspector *i)
Add inspector that reacts on node double clicks.
Definition options.hpp:548
void solution(Gist::Inspector *i)
Add inspector that reacts on each new solution that is found.
Definition options.hpp:552
void move(Gist::Inspector *i)
Add inspector that reacts on each move of the cursor.
Definition options.hpp:556
_I(void)
Constructor.
Definition options.hpp:543
void compare(Gist::Comparator *i)
Add comparator.
Definition options.hpp:560
Driver::DoubleOption _relax
Probability to relax variable.
Definition driver.hh:398
bool nogoods(void) const
Return whether nogoods are used.
Definition options.hpp:404
Driver::StringValueOption _log_file
Where to print statistics.
Definition driver.hh:409
unsigned int profiler_port(void) const
Return profiler execution id.
Definition options.hpp:527
Driver::StringOption _model
General model options.
Definition driver.hh:370
bool print_last(void) const
Return whether to print only last solution found.
Definition options.hpp:474
int model(void) const
Return model value.
Definition options.hpp:185
unsigned int a_d(void) const
Return adaptive recomputation distance.
Definition options.hpp:314
double threads(void) const
Return number of parallel threads.
Definition options.hpp:296
int symmetry(void) const
Return symmetry value.
Definition options.hpp:198
Driver::StringOption _mode
Script mode to run.
Definition driver.hh:404
Driver::DoubleOption _decay
Decay option.
Definition driver.hh:375
Driver::UnsignedIntOption _nogoods_limit
Limit for no-good extraction.
Definition driver.hh:397
unsigned int iterations(void) const
Return number of iterations.
Definition options.hpp:465
Driver::BoolOption _nogoods
Whether to use no-goods.
Definition driver.hh:396
Driver::UnsignedIntOption _slice
Size of a portfolio slice.
Definition driver.hh:392
Driver::TraceOption _trace
Trace flags for tracing.
Definition driver.hh:410
Driver::UnsignedIntOption _d_l
Discrepancy limit for LDS.
Definition driver.hh:387
Driver::UnsignedIntOption _assets
Number of assets in a portfolio.
Definition driver.hh:391
unsigned int node(void) const
Return node cutoff.
Definition options.hpp:332
int propagation(void) const
Return propagation value.
Definition options.hpp:211
Driver::UnsignedIntOption _solutions
How many solutions.
Definition driver.hh:383
unsigned int time(void) const
Return time cutoff.
Definition options.hpp:350
unsigned int seed(void) const
Return seed value.
Definition options.hpp:251
unsigned int assets(void) const
Return slice size in a portfolio.
Definition options.hpp:359
ScriptMode mode(void) const
Return mode.
Definition options.hpp:447
Driver::UnsignedIntOption _iterations
How many iterations per sample.
Definition driver.hh:406
Driver::StringOption _search
Search options.
Definition driver.hh:382
Driver::StringOption _propagation
Propagation options.
Definition driver.hh:372
Driver::IplOption _ipl
Integer propagation level.
Definition driver.hh:373
const char * log_file(void) const
Get file name for Gecode stats.
Definition options.hpp:494
Driver::BoolOption _profiler_info
Whether solution information should be sent to the CPProfiler.
Definition driver.hh:415
Driver::BoolOption _print_last
Print only last solution found.
Definition driver.hh:407
Driver::UnsignedIntOption _c_d
Copy recomputation distance.
Definition driver.hh:385
unsigned int c_d(void) const
Return copy recomputation distance.
Definition options.hpp:305
Driver::DoubleOption _threads
How many threads to use.
Definition driver.hh:384
Driver::StringOption _branching
Branching options.
Definition driver.hh:374
int search(void) const
Return search value.
Definition options.hpp:278
Driver::StringOption _restart
Restart method option.
Definition driver.hh:393
bool profiler_info(void) const
Return whether solution info should be sent to profiler.
Definition options.hpp:535
Driver::UnsignedIntOption _seed
Seed option.
Definition driver.hh:376
Driver::UnsignedIntOption _time
Cutoff for time.
Definition driver.hh:390
Driver::DoubleOption _step
Step option.
Definition driver.hh:377
Driver::UnsignedIntOption _profiler_port
Connect to this port.
Definition driver.hh:414
Driver::UnsignedIntOption _r_scale
Restart scale factor.
Definition driver.hh:395
Driver::IntOption _profiler_id
Use this execution id for the CP-profiler.
Definition driver.hh:413
unsigned int solutions(void) const
Return number of solutions to search for.
Definition options.hpp:287
Driver::BoolOption _interrupt
Whether to catch SIGINT.
Definition driver.hh:399
Driver::UnsignedIntOption _a_d
Adaptive recomputation distance.
Definition driver.hh:386
double decay(void) const
Return decay factor.
Definition options.hpp:242
Driver::DoubleOption _r_base
Restart base.
Definition driver.hh:394
Driver::StringOption _symmetry
General symmetry options.
Definition driver.hh:371
double step(void) const
Return step value.
Definition options.hpp:260
Driver::StringValueOption _out_file
Where to print solutions.
Definition driver.hh:408
unsigned int samples(void) const
Return number of samples.
Definition options.hpp:456
Driver::UnsignedIntOption _node
Cutoff for number of nodes.
Definition driver.hh:388
unsigned int fail(void) const
Return failure cutoff.
Definition options.hpp:341
int profiler_id(void) const
Return profiler execution id.
Definition options.hpp:519
unsigned int d_l(void) const
Return discrepancy limit for LDS.
Definition options.hpp:323
RestartMode restart(void) const
Return restart mode.
Definition options.hpp:377
Driver::UnsignedIntOption _samples
How many samples.
Definition driver.hh:405
int trace(void) const
Return trace flags.
Definition options.hpp:504
const char * out_file(void) const
Get file name for solutions.
Definition options.hpp:484
Driver::UnsignedIntOption _fail
Cutoff for number of failures.
Definition driver.hh:389
double relax(void) const
Return default relax probability.
Definition options.hpp:422
bool interrupt(void) const
Return interrupt behavior.
Definition options.hpp:433
unsigned int slice(void) const
Return slice size in a portfolio.
Definition options.hpp:368
int branching(void) const
Return branching value.
Definition options.hpp:233
unsigned int nogoods_limit(void) const
Return depth limit for nogoods.
Definition options.hpp:413
double restart_base(void) const
Return restart base.
Definition options.hpp:386
IntPropLevel ipl(void) const
Return integer propagation level.
Definition options.hpp:220
unsigned int restart_scale(void) const
Return restart scale factor.
Definition options.hpp:395
unsigned int size(void) const
Return size.
Definition options.hpp:590
Heap heap
The single global heap.
Definition heap.cpp:44
ScriptMode
Different modes for executing scripts.
Definition driver.hh:94
RestartMode
Different modes for restart-based search.
Definition driver.hh:106
IntPropLevel
Propagation levels for integer propagators.
Definition int.hh:974
Gecode toplevel namespace
#define forceinline
Definition config.hpp:187