Generated on for Gecode by doxygen 1.15.0
options.cpp
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 <gecode/driver.hh>
36
37#include <iostream>
38#include <iomanip>
39
40#include <cstdlib>
41#include <cstring>
42
43namespace Gecode {
44
45 namespace Driver {
46
47 /*
48 * Option baseclass
49 *
50 */
51 char*
52 BaseOption::strdup(const char* s) {
53 if (s == nullptr)
54 return nullptr;
55 size_t l = strlen(s) + 1;
56 char* d = static_cast<char*>(heap.ralloc(l));
57 (void) memcpy(d,s,l);
58 return d;
59 }
60
61 char*
62 BaseOption::stredup(const char* s) {
63 if (s == nullptr)
64 return nullptr;
65 size_t l = strlen(s) + 1;
66 char* d = static_cast<char*>(heap.ralloc(l+1));
67 d[0] = '-';
68 (void) memcpy(d+1,s,l);
69 return d;
70 }
71
72 void
73 BaseOption::strdel(const char* s) {
74 if (s == nullptr)
75 return;
76 heap.rfree(const_cast<char*>(s));
77 }
78
79 char*
80 BaseOption::argument(int argc, char* argv[]) const {
81 if (argc < 2)
82 return nullptr;
83 const char* s = argv[1];
84 if (s[0] == '-') {
85 s++;
86 if (s[0] == '-')
87 s++;
88 } else {
89 return nullptr;
90 }
91 if (strcmp(s,eopt))
92 return nullptr;
93 if (argc == 2) {
94 std::cerr << "Missing argument for option \"" << iopt << "\""
95 << std::endl;
96 exit(EXIT_FAILURE);
97 }
98 return argv[2];
99 }
100
101 BaseOption::BaseOption(const char* o, const char* e)
102 : eopt(strdup(o)), iopt(stredup(o)), exp(strdup(e)) {}
103
105 strdel(eopt);
106 strdel(iopt);
107 strdel(exp);
108 }
109
110
111 StringValueOption::StringValueOption(const char* o, const char* e,
112 const char* v)
113 : BaseOption(o,e), cur(strdup(v)) {}
114 void
116 strdel(cur);
117 cur = strdup(v);
118 }
119 int
120 StringValueOption::parse(int argc, char* argv[]) {
121 if (char* a = argument(argc,argv)) {
122 cur = strdup(a);
123 return 2;
124 }
125 return 0;
126 }
127 void
129 std::cerr << '\t' << iopt << " (string) default: "
130 << ((cur == nullptr) ? "NONE" : cur) << std::endl
131 << "\t\t" << exp << std::endl;
132 }
136
137
138
139 void
140 StringOption::add(int v, const char* o, const char* h) {
141 Value* n = new Value;
142 n->val = v;
143 n->opt = strdup(o);
144 n->help = strdup(h);
145 n->next = nullptr;
146 if (fst == nullptr) {
147 fst = n;
148 } else {
149 lst->next = n;
150 }
151 lst = n;
152 }
153 int
154 StringOption::parse(int argc, char* argv[]) {
155 if (char* a = argument(argc,argv)) {
156 for (Value* v = fst; v != nullptr; v = v->next)
157 if (!strcmp(a,v->opt)) {
158 cur = v->val;
159 return 2;
160 }
161 std::cerr << "Wrong argument \"" << a
162 << "\" for option \"" << iopt << "\""
163 << std::endl;
164 exit(EXIT_FAILURE);
165 }
166 return 0;
167 }
168 void
170 if (fst == nullptr)
171 return;
172 std::cerr << '\t' << iopt << " (";
173 const char* d = nullptr;
174 for (Value* v = fst; v != nullptr; v = v->next) {
175 std::cerr << v->opt << ((v->next != nullptr) ? ", " : "");
176 if (v->val == cur)
177 d = v->opt;
178 }
179 std::cerr << ")";
180 if (d != nullptr)
181 std::cerr << " default: " << d;
182 std::cerr << std::endl << "\t\t" << exp << std::endl;
183 for (Value* v = fst; v != nullptr; v = v->next)
184 if (v->help != nullptr)
185 std::cerr << "\t\t " << v->opt << ": " << v->help << std::endl;
186 }
187
189 Value* v = fst;
190 while (v != nullptr) {
191 strdel(v->opt);
192 strdel(v->help);
193 Value* n = v->next;
194 delete v;
195 v = n;
196 }
197 }
198
199
200 int
201 IntOption::parse(int argc, char* argv[]) {
202 if (char* a = argument(argc,argv)) {
203 cur = atoi(a);
204 return 2;
205 }
206 return 0;
207 }
208
209 void
211 std::cerr << '\t' << iopt << " (int) default: " << cur << std::endl
212 << "\t\t" << exp << std::endl;
213 }
214
215
216 int
217 UnsignedIntOption::parse(int argc, char* argv[]) {
218 if (char* a = argument(argc,argv)) {
219 cur = static_cast<unsigned int>(atoi(a));
220 return 2;
221 }
222 return 0;
223 }
224
225 void
227 std::cerr << '\t' << iopt << " (unsigned int) default: "
228 << cur << std::endl
229 << "\t\t" << exp << std::endl;
230 }
231
232
233 int
234 UnsignedLongLongIntOption::parse(int argc, char* argv[]) {
235 if (char* a = argument(argc,argv)) {
236 cur = static_cast<unsigned int>(atoll(a));
237 return 2;
238 }
239 return 0;
240 }
241
242 void
244 std::cerr << '\t' << iopt << " (unsigned long long int) default: "
245 << cur << std::endl
246 << "\t\t" << exp << std::endl;
247 }
248
249
250 int
251 DoubleOption::parse(int argc, char* argv[]) {
252 if (char* a = argument(argc,argv)) {
253 cur = atof(a);
254 return 2;
255 }
256 return 0;
257 }
258
259 void
261 using namespace std;
262 cerr << '\t' << iopt << " (double) default: " << cur << endl
263 << "\t\t" << exp << endl;
264 }
265
266
267 int
268 BoolOption::parse(int argc, char* argv[]) {
269 if (argc < 2)
270 return 0;
271 const char* s = argv[1];
272 if (s[0] == '-') {
273 s++;
274 if (s[0] == '-')
275 s++;
276 } else {
277 return 0;
278 }
279 if (strcmp(s,eopt))
280 return 0;
281 if (argc == 2) {
282 // Option without argument
283 cur = true;
284 return 1;
285 } else if (!strcmp(argv[2],"true") || !strcmp(argv[2],"1")) {
286 cur = true;
287 return 2;
288 } else if (!strcmp(argv[2],"false") || !strcmp(argv[2],"0")) {
289 cur = false;
290 return 2;
291 } else {
292 // Option without argument
293 cur = true;
294 return 1;
295 }
296 return 0;
297 }
298
299 void
301 using namespace std;
302 cerr << '\t' << iopt << " (optional: false, 0, true, 1) default: "
303 << (cur ? "true" : "false") << endl
304 << "\t\t" << exp << endl;
305 }
306
307 /*
308 * Integer propagation level option
309 *
310 */
312 : BaseOption("ipl","integer propagation level (comma-separated list)"),
313 cur(ipl) {}
314
315 int
316 IplOption::parse(int argc, char* argv[]) {
317 if (char* a = argument(argc,argv)) {
318 int b = IPL_DEF;
319 int m = IPL_DEF;
320 do {
321 // Search for a comma
322 char* c = a;
323 while ((*c != ',') && (*c != 0))
324 c++;
325 unsigned int e = static_cast<unsigned int>(c-a);
326 if (!strncmp("def",a,e)) { b = IPL_DEF; }
327 else if (!strncmp("val",a,e)) { b = IPL_VAL; }
328 else if (!strncmp("bnd",a,e)) { b = IPL_BND; }
329 else if (!strncmp("dom",a,e)) { b = IPL_DOM; }
330 else if (!strncmp("basic",a,e)) { m |= IPL_BASIC; }
331 else if (!strncmp("advanced",a,e)) { m |= IPL_ADVANCED; }
332 else if (!strncmp("full",a,e)) { m |= IPL_FULL; }
333 else {
334 std::cerr << "Wrong argument \"" << a
335 << "\" for option \"" << iopt << "\""
336 << std::endl;
337 exit(EXIT_FAILURE);
338 }
339
340 if (*c == ',') a = c+1; else a = c;
341
342 } while (*a != 0);
343
344 cur = static_cast<IntPropLevel>(b | m);
345 return 2;
346 }
347 return 0;
348 }
349
350 void
352 using namespace std;
353 cerr << '\t' << iopt
354 << " (def,val,bnd,dom,basic,advanced,full)" << endl
355 << "\t\tdefault: ";
356 switch (vbd(cur)) {
357 case IPL_DEF: cerr << "def"; break;
358 case IPL_VAL: cerr << "val"; break;
359 case IPL_BND: cerr << "bnd"; break;
360 case IPL_DOM: cerr << "dom"; break;
361 default: GECODE_NEVER;
362 }
363 if ((cur & IPL_FULL) == IPL_FULL)
364 cerr << ",full";
365 else {
366 if (cur & IPL_BASIC) cerr << ",basic";
367 if (cur & IPL_ADVANCED) cerr << ",advanced";
368 }
369 cerr << endl << "\t\t" << exp << endl;
370 }
371
372
373 /*
374 * Trace flag option
375 *
376 */
378 : BaseOption("trace","trace flags (comma-separated list)"),
379 cur(f) {}
380
381 int
382 TraceOption::parse(int argc, char* argv[]) {
383 if (char* a = argument(argc,argv)) {
384 cur = 0;
385 do {
386 // Search for a comma
387 char* c = a;
388 while ((*c != ',') && (*c != 0))
389 c++;
390 unsigned int e = static_cast<unsigned int>(c-a);
391 if (!strncmp("init",a,e)) { cur |= TE_INIT; }
392 else if (!strncmp("prune",a,e)) { cur |= TE_PRUNE; }
393 else if (!strncmp("fix",a,e)) { cur |= TE_FIX; }
394 else if (!strncmp("fail",a,e)) { cur |= TE_FAIL; }
395 else if (!strncmp("done",a,e)) { cur |= TE_DONE ; }
396 else if (!strncmp("propagate",a,e)) { cur |= TE_PROPAGATE; }
397 else if (!strncmp("commit",a,e)) { cur |= TE_COMMIT; }
398 else if (!strncmp("post",a,e)) { cur |= TE_POST; }
399 else if (!strncmp("none",a,e) ||
400 !strncmp("false",a,e) ||
401 !strncmp("0",a,e)) { cur = 0; }
402 else if (!strncmp("all",a,e) ||
403 !strncmp("1",a,e)) { cur = (TE_INIT |
404 TE_PRUNE |
405 TE_FIX |
406 TE_FAIL |
407 TE_DONE |
409 TE_COMMIT |
410 TE_POST); }
411 else if (!strncmp("variable",a,e)) { cur = (TE_INIT |
412 TE_PRUNE |
413 TE_FIX |
414 TE_FAIL |
415 TE_DONE); }
416 else if (!strncmp("general",a,e)) { cur = (TE_PROPAGATE |
417 TE_COMMIT |
418 TE_POST); }
419 else {
420 std::cerr << "Wrong argument \"" << a
421 << "\" for option \"" << iopt << "\""
422 << std::endl;
423 exit(EXIT_FAILURE);
424 }
425
426 if (*c == ',') a = c+1; else a = c;
427
428 } while (*a != 0);
429
430 return 2;
431 }
432 return 0;
433 }
434
435 void
437 using namespace std;
438 cerr << '\t' << iopt
439 << " (init,prune,fix,fail,done,propagate,commit,post,none,all,variable,general)"
440 << " default: ";
441 if (cur == 0) {
442 cerr << "none";
443 } else if (cur == (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE |
445 cerr << "all";
446 } else if (cur == (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE)) {
447 cerr << "variable";
448 } else if (cur == (TE_PROPAGATE | TE_COMMIT | TE_POST)) {
449 cerr << "general";
450 } else {
451 int f = cur;
452 if ((f & TE_INIT) != 0) {
453 cerr << "init";
454 f -= TE_INIT;
455 if (f != 0) cerr << ',';
456 }
457 if ((f & TE_PRUNE) != 0) {
458 cerr << "prune";
459 f -= TE_PRUNE;
460 if (f != 0) cerr << ',';
461 }
462 if ((f & TE_FIX) != 0) {
463 cerr << "fix";
464 f -= TE_FIX;
465 if (f != 0) cerr << ',';
466 }
467 if ((f & TE_FAIL) != 0) {
468 cerr << "fail";
469 f -= TE_FAIL;
470 if (f != 0) cerr << ',';
471 }
472 if ((f & TE_DONE) != 0) {
473 cerr << "done";
474 f -= TE_DONE;
475 if (f != 0) cerr << ',';
476 }
477 if ((f & TE_PROPAGATE) != 0) {
478 cerr << "propagate";
479 f -= TE_PROPAGATE;
480 if (f != 0) cerr << ',';
481 }
482 if ((f & TE_COMMIT) != 0) {
483 cerr << "commit";
484 f -= TE_COMMIT;
485 if (f != 0) cerr << ',';
486 }
487 if ((f & TE_POST) != 0) {
488 cerr << "post";
489 }
490 }
491 cerr << endl << "\t\t" << exp << endl;
492 }
493
494
495 int ProfilerOption::parse(int argc, char* argv[]) {
496 if (char* a = argument(argc, argv)) {
497 char* sep = strchr(a, ',');
498 if (!sep) {
499 std::cerr << "Wrong argument \"" << a << "\" for option \"" << iopt << "\"" << std::endl;
500 exit(EXIT_FAILURE);
501 }
502 cur_execution_id = static_cast<unsigned int>(atoi(a));
503 cur_port = atoi(sep + 1);
504 return 2;
505 }
506 return 0;
507 }
508
509 void ProfilerOption::help(void) { std::cerr << '\t' << iopt << " (unsigned int,int) default: " << cur_port << "," << cur_execution_id << std::endl << "\t\t" << exp << std::endl; }
510
511
512 }
513
514 void
516 o.next = nullptr;
517 if (fst == nullptr) {
518 fst=&o;
519 } else {
520 lst->next=&o;
521 }
522 lst=&o;
523 }
525 : fst(nullptr), lst(nullptr),
526 _name(Driver::BaseOption::strdup(n)) {}
527
528 void
533
534 void
536 std::cerr << "Gecode configuration information:" << std::endl
537 << " - Version: " << GECODE_VERSION << std::endl
538 << " - Variable types: ";
539#ifdef GECODE_HAS_INT_VARS
540 std::cerr << "BoolVar IntVar ";
541#endif
542#ifdef GECODE_HAS_SET_VARS
543 std::cerr << "SetVar ";
544#endif
545#ifdef GECODE_HAS_FLOAT_VARS
546 std::cerr << "FloatVar "
547 << std::endl
548 << " - Trigonometric and transcendental float constraints: ";
549#ifdef GECODE_HAS_MPFR
550 std::cerr << "enabled";
551#else
552 std::cerr << "disabled";
553#endif
554#endif
555 std::cerr << std::endl;
556 std::cerr << " - Thread support: ";
557#ifdef GECODE_HAS_THREADS
558 if (Support::Thread::npu() == 1)
559 std::cerr << "enabled (1 processing unit)";
560 else
561 std::cerr << "enabled (" << Support::Thread::npu()
562 << " processing units)";
563#else
564 std::cerr << "disabled";
565#endif
566 std::cerr << std::endl
567 << " - Gist support: ";
568#ifdef GECODE_HAS_GIST
569 std::cerr << "enabled";
570#else
571 std::cerr << "disabled";
572#endif
573 std::cerr << std::endl
574 << " - CPProfiler support: ";
575#ifdef GECODE_HAS_CPPROFILER
576 std::cerr << "enabled";
577#else
578 std::cerr << "disabled";
579#endif
580 std::cerr << std::endl << std::endl
581 << "Options for " << name() << ":" << std::endl
582 << "\t-help, --help, -?" << std::endl
583 << "\t\tprint this help message" << std::endl;
584 for (Driver::BaseOption* o = fst; o != nullptr; o = o->next)
585 o->help();
586 }
587
588 void
589 BaseOptions::parse(int& argc, char* argv[]) {
590 int c = argc;
591 char** v = argv;
592 next:
593 for (Driver::BaseOption* o = fst; o != nullptr; o = o->next)
594 if (int a = o->parse(c,v)) {
595 c -= a; v += a;
596 goto next;
597 }
598 if (c >= 2) {
599 if (!strcmp(v[1],"-help") || !strcmp(v[1],"--help") ||
600 !strcmp(v[1],"-?")) {
601 help();
602 exit(EXIT_SUCCESS);
603 }
604 }
605 // Copy remaining arguments
606 argc = c;
607 for (int i=1; i<argc; i++)
608 argv[i] = v[i];
609 return;
610 }
611
615
616
617 Options::Options(const char* n)
618 : BaseOptions(n),
619
620 _model("model","model variants"),
621 _symmetry("symmetry","symmetry variants"),
622 _propagation("propagation","propagation variants"),
623 _branching("branching","branching variants"),
624 _decay("decay","decay factor",1.0),
625 _seed("seed","random number generator seed",1U),
626 _step("step","step distance for float optimization",0.0),
627
628 _search("search","search engine variants"),
629 _solutions("solutions","number of solutions (0 = all)",1),
630 _threads("threads","number of threads (0 = #processing units)",
631 Search::Config::threads),
632 _c_d("c-d","recomputation commit distance",Search::Config::c_d),
633 _a_d("a-d","recomputation adaptation distance",Search::Config::a_d),
634 _d_l("d-l","discrepancy limit for LDS",Search::Config::d_l),
635 _node("node","node cutoff (0 = none, solution mode)"),
636 _fail("fail","failure cutoff (0 = none, solution mode)"),
637 _time("time","time (in ms) cutoff (0 = none, solution mode)"),
638 _assets("assets","#portfolio assets (#engines)",0),
639 _slice("slice","portfolio slice (in #failures)",Search::Config::slice),
640 _restart("restart","restart sequence type",RM_NONE),
641 _r_base("restart-base","base for geometric restart sequence",
642 Search::Config::base),
643 _r_scale("restart-scale","scale factor for restart sequence",
644 Search::Config::slice),
645 _r_limit("restart-limit","restart cutoff (0 = none, solution mode)"),
646 _nogoods("nogoods","whether to use no-goods from restarts",false),
647 _nogoods_limit("nogoods-limit","depth limit for no-good extraction",
648 Search::Config::nogoods_limit),
649 _relax("relax","probability for relaxing variable", 0.0),
650 _interrupt("interrupt","whether to catch Ctrl-C (true) or not (false)",
651 true),
652
653 _mode("mode","how to execute script",SM_SOLUTION),
654 _samples("samples","how many samples (time mode)",1),
655 _iterations("iterations","iterations per sample (time mode)",1),
656 _print_last("print-last",
657 "whether to only print the last solution (solution mode)",
658 false),
659 _out_file("file-sol", "where to print solutions "
660 "(supports stdout, stdlog, stderr)","stdout"),
661 _log_file("file-stat", "where to print statistics "
662 "(supports stdout, stdlog, stderr)","stdout"),
663 _trace(0)
664
666 ,
667 _profiler("cp-profiler", "use this execution id and port (comma separated) with CP-profiler")
668#endif
669 {
670
671 _mode.add(SM_SOLUTION, "solution");
672 _mode.add(SM_TIME, "time");
673 _mode.add(SM_STAT, "stat");
674 _mode.add(SM_GIST, "gist");
675
676 _restart.add(RM_NONE,"none");
677 _restart.add(RM_CONSTANT,"constant");
678 _restart.add(RM_LINEAR,"linear");
679 _restart.add(RM_LUBY,"luby");
680 _restart.add(RM_GEOMETRIC,"geometric");
681
685 add(_d_l);
690 add(_relax);
693#ifdef GECODE_HAS_CPPROFILER
694 add(_profiler);
695#endif
696 }
697
698
700 : Options(e), _size(0) {}
701
702 void
705 std::cerr << "\t(unsigned int) default: " << size() << std::endl
706 << "\t\twhich version/size for script" << std::endl;
707 }
708
709 void
710 SizeOptions::parse(int& argc, char* argv[]) {
711 Options::parse(argc,argv);
712 if (argc < 2)
713 return;
714 size(static_cast<unsigned int>(atoi(argv[1])));
715 }
716
717
718
720 : Options(e), _inst(nullptr) {}
721
722 void
727
728 void
731 std::cerr << "\t(string) default: " << instance() << std::endl
732 << "\t\twhich instance for script" << std::endl;
733 }
734
735 void
736 InstanceOptions::parse(int& argc, char* argv[]) {
737 Options::parse(argc,argv);
738 if (argc < 2)
739 return;
740 instance(argv[1]);
741 }
742
746
747}
748
749// STATISTICS: driver-any
BaseOptions(const char *s)
Initialize options for script with name s.
Definition options.cpp:524
void add(Driver::BaseOption &o)
Add new option o.
Definition options.cpp:515
const char * _name
Script name.
Definition driver.hh:379
virtual ~BaseOptions(void)
Destructor.
Definition options.cpp:612
Driver::BaseOption * fst
First registered option.
Definition driver.hh:377
Driver::BaseOption * lst
Last registered option.
Definition driver.hh:378
const char * name(void) const
Return name of script.
Definition options.hpp:195
virtual void help(void)
Print help text.
Definition options.cpp:535
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc).
Definition options.cpp:589
Base class for options.
Definition driver.hh:120
static void strdel(const char *s)
Delete heap-allocated copy of string s.
Definition options.cpp:73
static char * stredup(const char *s)
Create heap-allocated copy of string s with hyphen added.
Definition options.cpp:62
const char * eopt
String for option (excluding hyphen).
Definition driver.hh:123
virtual ~BaseOption(void)
Destructor.
Definition options.cpp:104
char * argument(int argc, char *argv[]) const
Definition options.cpp:80
static char * strdup(const char *s)
Create heap-allocated copy of string s.
Definition options.cpp:52
const char * exp
Short explanation.
Definition driver.hh:125
const char * iopt
String for option (including hyphen).
Definition driver.hh:124
BaseOption(const char *o, const char *e)
Initialize for option o and explanation e.
Definition options.cpp:101
BaseOption * next
Next option Check for option and return its argument.
Definition driver.hh:126
bool cur
Current value.
Definition driver.hh:291
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:268
virtual void help(void)
Print help text.
Definition options.cpp:300
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:251
double cur
Current value.
Definition driver.hh:271
virtual void help(void)
Print help text.
Definition options.cpp:260
virtual void help(void)
Print help text.
Definition options.cpp:210
int cur
Current value.
Definition driver.hh:210
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:201
IntPropLevel cur
Current value.
Definition driver.hh:311
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:316
IplOption(IntPropLevel ipl=IPL_DEF)
Initialize with default value ipl.
Definition options.cpp:311
virtual void help(void)
Print help text.
Definition options.cpp:351
int cur_execution_id
Current execution ID.
Definition driver.hh:352
unsigned int cur_port
Current port.
Definition driver.hh:351
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:495
virtual void help(void)
Print help text.
Definition options.cpp:509
const char * help
Optional help text.
Definition driver.hh:180
Value * next
Next option value.
Definition driver.hh:181
int val
Value for an option value.
Definition driver.hh:178
const char * opt
String for option value.
Definition driver.hh:179
virtual ~StringOption(void)
Destructor.
Definition options.cpp:188
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:154
int cur
Current value.
Definition driver.hh:183
void add(int v, const char *o, const char *h=nullptr)
Add option value for value v, string o, and help text h.
Definition options.cpp:140
virtual void help(void)
Print help text.
Definition options.cpp:169
Value * lst
Last option value.
Definition driver.hh:185
Value * fst
First option value.
Definition driver.hh:184
virtual void help(void)
Print help text.
Definition options.cpp:128
virtual ~StringValueOption(void)
Destructor.
Definition options.cpp:133
StringValueOption(const char *o, const char *e, const char *v=nullptr)
Initialize for option o and explanation e and default value v.
Definition options.cpp:111
const char * value(void) const
Return current option value.
Definition options.hpp:46
const char * cur
Current value.
Definition driver.hh:152
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:120
virtual void help(void)
Print help text.
Definition options.cpp:436
int cur
Current value.
Definition driver.hh:331
TraceOption(int f=0)
Initialize with no tracing.
Definition options.cpp:377
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:382
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:217
unsigned int cur
Current value.
Definition driver.hh:230
virtual void help(void)
Print help text.
Definition options.cpp:226
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
Definition options.cpp:234
unsigned long long int cur
Current value.
Definition driver.hh:250
virtual void help(void)
Print help text.
Definition options.cpp:243
const char * _inst
Instance string.
Definition driver.hh:746
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc).
Definition options.cpp:736
virtual void help(void)
Print help text.
Definition options.cpp:729
const char * instance(void) const
Return instance name.
Definition options.hpp:628
~InstanceOptions(void)
Destructor.
Definition options.cpp:743
InstanceOptions(const char *s)
Initialize options for script with name s.
Definition options.cpp:719
Driver::DoubleOption _relax
Probability to relax variable.
Definition driver.hh:447
Driver::StringValueOption _log_file
Where to print statistics.
Definition driver.hh:458
void c_d(unsigned int d)
Set default copy recomputation distance.
Definition options.hpp:330
Driver::StringOption _model
General model options.
Definition driver.hh:414
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
void a_d(unsigned int d)
Set default adaptive recomputation distance.
Definition options.hpp:339
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
void slice(unsigned int n)
Set default slice size in a portfolio.
Definition options.hpp:393
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
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
Options(const char *s)
Initialize options for script with name s.
Definition options.cpp:617
Driver::BoolOption _print_last
Print only last solution found.
Definition driver.hh:456
Driver::UnsignedIntOption _c_d
Copy recomputation distance.
Definition driver.hh:430
void nogoods_limit(unsigned int l)
Set default nogoods depth limit.
Definition options.hpp:447
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
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
Driver::BoolOption _interrupt
Whether to catch SIGINT.
Definition driver.hh:448
void d_l(unsigned int d)
Set default discrepancy limit for LDS.
Definition options.hpp:348
Driver::UnsignedIntOption _a_d
Adaptive recomputation distance.
Definition driver.hh:431
Driver::DoubleOption _r_base
Restart base.
Definition driver.hh:441
Driver::StringOption _symmetry
General symmetry options.
Definition driver.hh:415
Driver::StringValueOption _out_file
Where to print solutions.
Definition driver.hh:457
Driver::UnsignedIntOption _samples
How many samples.
Definition driver.hh:454
void threads(double n)
Set number of parallel threads.
Definition options.hpp:321
unsigned int size(void) const
Return size.
Definition options.hpp:619
virtual void help(void)
Print help text.
Definition options.cpp:703
SizeOptions(const char *s)
Initialize options for script with name s.
Definition options.cpp:699
unsigned int _size
Size value.
Definition driver.hh:725
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc).
Definition options.cpp:710
static unsigned int npu(void)
Return number of processing units (1 if information not available).
Definition thread.hpp:164
Heap heap
The single global heap.
Definition heap.cpp:44
@ SM_STAT
Print statistics for script.
Definition driver.hh:97
@ SM_SOLUTION
Print solution and some statistics.
Definition driver.hh:95
@ SM_GIST
Run script in Gist.
Definition driver.hh:98
@ SM_TIME
Measure average runtime.
Definition driver.hh:96
@ RM_CONSTANT
Restart with constant sequence.
Definition driver.hh:107
@ RM_LINEAR
Restart with linear sequence.
Definition driver.hh:108
@ RM_LUBY
Restart with Luby sequence.
Definition driver.hh:109
@ RM_NONE
No restarts.
Definition driver.hh:106
@ RM_GEOMETRIC
Restart with geometric sequence.
Definition driver.hh:110
IntPropLevel
Propagation levels for integer propagators.
Definition int.hh:1008
@ IPL_BASIC
Use basic propagation algorithm.
Definition int.hh:1015
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
Definition int.hh:1013
@ IPL_FULL
Use full propagation.
Definition int.hh:1018
@ IPL_VAL
Value propagation.
Definition int.hh:1011
@ IPL_ADVANCED
Use advanced propagation algorithm.
Definition int.hh:1016
@ IPL_DEF
Simple propagation levels.
Definition int.hh:1010
@ IPL_BND
Bounds propagation.
Definition int.hh:1012
@ TE_INIT
Trace init events.
Definition recorder.hpp:43
@ TE_POST
Trace propagator posting.
Definition recorder.hpp:52
@ TE_COMMIT
Trace commit operations by branchers.
Definition recorder.hpp:51
@ TE_PRUNE
Trace prune events.
Definition recorder.hpp:44
@ TE_PROPAGATE
Trace propagator executions.
Definition recorder.hpp:50
@ TE_FIX
Trace fixpoint events.
Definition recorder.hpp:45
@ TE_FAIL
Trace fail events.
Definition recorder.hpp:46
@ TE_DONE
Trace done events.
Definition recorder.hpp:47
Script commandline driver.
Search engines
Gecode toplevel namespace
IntPropLevel vbd(IntPropLevel ipl)
Extract value, bounds, or domain propagation from propagation level.
Definition ipl.hpp:37
#define GECODE_VERSION
Definition config.hpp:135
#define GECODE_HAS_CPPROFILER
Definition config.hpp:69
#define GECODE_NEVER
Assert that this command is never executed.
Definition macros.hpp:56