34#ifndef GECODE_DRIVER_HH
35#define GECODE_DRIVER_HH
50#if !defined(GECODE_STATIC_LIBS) && \
51 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
53#ifdef GECODE_BUILD_DRIVER
54#define GECODE_DRIVER_EXPORT __declspec( dllexport )
56#define GECODE_DRIVER_EXPORT __declspec( dllimport )
61#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
62#define GECODE_DRIVER_EXPORT __attribute__ ((visibility("default")))
64#define GECODE_DRIVER_EXPORT
70#ifndef GECODE_BUILD_DRIVER
71#define GECODE_LIBRARY_NAME "Driver"
136 virtual int parse(
int argc,
char* argv[]) = 0;
162 const char*
value(
void)
const;
164 virtual int parse(
int argc,
char* argv[]);
181 virtual int parse(
int argc,
char* argv[]);
208 int value(
void)
const;
210 void add(
int v,
const char* o,
const char* h =
nullptr);
212 virtual int parse(
int argc,
char* argv[]);
229 IntOption(
const char* o,
const char* e,
int v=0);
233 int value(
void)
const;
235 virtual int parse(
int argc,
char* argv[]);
251 void value(
unsigned int v);
253 unsigned int value(
void)
const;
255 virtual int parse(
int argc,
char* argv[]);
266 unsigned long long int cur;
270 unsigned long long int v=0);
272 void value(
unsigned long long int v);
274 unsigned long long int value(
void)
const;
276 virtual int parse(
int argc,
char* argv[]);
292 void value(
double v);
294 double value(
void)
const;
296 virtual int parse(
int argc,
char* argv[]);
310 BoolOption(
const char* o,
const char* e,
bool v=
false);
314 bool value(
void)
const;
316 virtual int parse(
int argc,
char* argv[]);
336 virtual int parse(
int argc,
char* argv[]);
354 int value(
void)
const;
356 virtual int parse(
int argc,
char* argv[]);
371 ProfilerOption(
const char* o,
const char* e,
unsigned int p = 0,
int v = -1);
373 void port(
unsigned int p);
375 unsigned int port(
void)
const;
381 virtual int parse(
int argc,
char* argv[]);
411 void parse(
int& argc,
char* argv[]);
414 const char*
name(
void)
const;
465#ifdef GECODE_HAS_EXPERIMENTAL
481#ifdef GECODE_HAS_CPPROFILER
496 void model(
int v,
const char* o,
const char* h =
nullptr);
498 int model(
void)
const;
503 void symmetry(
int v,
const char* o,
const char* h =
nullptr);
510 void propagation(
int v,
const char* o,
const char* h =
nullptr);
522 void branching(
int v,
const char* o,
const char* h =
nullptr);
527 void decay(
double d);
529 double decay(
void)
const;
532 void seed(
unsigned int s);
534 unsigned int seed(
void)
const;
539 double step(
void)
const;
547 void search(
int v,
const char* o,
const char* h =
nullptr);
552 void solutions(
unsigned long long int n);
554 unsigned long long int solutions(
void)
const;
562 void c_d(
unsigned int d);
564 unsigned int c_d(
void)
const;
567 void a_d(
unsigned int d);
569 unsigned int a_d(
void)
const;
572 void d_l(
unsigned int d);
574 unsigned int d_l(
void)
const;
577 void node(
unsigned long long int n);
579 unsigned long long int node(
void)
const;
582 void fail(
unsigned long long int n);
584 unsigned long long int fail(
void)
const;
589 double time(
void)
const;
592 void assets(
unsigned int n);
594 unsigned int assets(
void)
const;
597 void slice(
unsigned int n);
599 unsigned int slice(
void)
const;
632 void relax(
double d);
634 double relax(
void)
const;
652 unsigned int samples(
void)
const;
677 int trace(
void)
const;
679#ifdef GECODE_HAS_CPPROFILER
691#ifdef GECODE_HAS_EXPERIMENTAL
701#ifdef GECODE_HAS_GIST
708 unsigned int n_click;
712 unsigned int n_solution;
720 unsigned int n_compare;
762 void parse(
int& argc,
char* argv[]);
765 void size(
unsigned int s);
767 unsigned int size(
void)
const;
808 mutable std::unique_ptr<Instance::Data>
_data;
825 void parse(
int& argc,
char* argv[]);
840 bool builtin(
unsigned int& i)
const;
843 void spec(
const char* s);
851 void param(
const char* p);
872namespace Gecode {
namespace Driver {
881 template<
class BaseSpace>
889 virtual void print(std::ostream& os)
const;
903 template<
class Script,
template<
class>
class Engine,
class Options>
906 template<
class Script,
template<
class>
class Engine,
class Options,
907 template<
class,
template<
class>
class>
class Meta>
911#ifdef GECODE_HAS_FLOAT_VARS
914 template<
class BaseSpace>
919 : BaseSpace(opt.step()) {}
928 template<
class BaseSpace>
982#ifdef GECODE_HAS_FLOAT_VARS
Base class for script options.
BaseOptions(const char *s)
Initialize options for script with name s.
virtual ~BaseOptions(void)
Destructor.
void add(Driver::BaseOption &o)
Add new option o.
virtual void help(void)
Print help text.
const char * _name
Script name.
Driver::BaseOption * fst
First registered option.
Driver::BaseOption * lst
Last registered option.
const char * name(void) const
Return name of script.
void name(const char *)
Set name of script.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc).
static void strdel(const char *s)
Delete heap-allocated copy of string s.
static char * stredup(const char *s)
Create heap-allocated copy of string s with hyphen added.
virtual void help(void)=0
Print help text.
const char * eopt
String for option (excluding hyphen).
static char * strdup(const char *s)
Create heap-allocated copy of string s.
char * argument(int argc, char *argv[]) const
const char * exp
Short explanation.
const char * iopt
String for option (including hyphen).
virtual ~BaseOption(void)
Destructor.
BaseOption(const char *o, const char *e)
Initialize for option o and explanation e.
virtual int parse(int argc, char *argv[])=0
Parse option at first position and return number of parsed arguments.
BaseOption * next
Next option Check for option and return its argument.
BoolOption(const char *o, const char *e, bool v=false)
Initialize for option o and explanation e and default value v.
void value(bool v)
Set default value to v.
virtual void help(void)
Print help text.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
virtual void help(void)
Print help text.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
DoubleOption(const char *o, const char *e, double v=0)
Initialize for option o and explanation e and default value v.
void value(double v)
Set default value to v.
IgnoreStepOption(BaseSpace &e)
Constructor used for cloning.
IgnoreStepOption(const Options &)
Constructor.
void value(int v)
Set default value to v.
virtual void help(void)
Print help text.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
IntOption(const char *o, const char *e, int v=0)
Initialize for option o and explanation e and default value v.
Integer propagation level option.
IntPropLevel cur
Current value.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
IplOption(IntPropLevel ipl=IPL_DEF)
Initialize with default value ipl.
virtual void help(void)
Print help text.
void value(IntPropLevel l)
Set default level to l.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
void port(unsigned int p)
Set default port to p.
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.
void execution_id(int i)
Set default execution ID to i.
int cur_execution_id
Current execution ID.
unsigned int cur_port
Current port.
virtual void help(void)
Print help text.
Parametric base-class for scripts.
static void run(const Options &opt, Script *s=nullptr)
ScriptBase(ScriptBase &e)
Constructor used for cloning.
virtual void compare(const Space &home, std::ostream &os) const
Compare with s.
virtual void print(std::ostream &os) const
Print a solution to os.
static std::ostream & select_ostream(const char *sn, std::ofstream &ofs)
Choose output stream according to sn.
ScriptBase(const Options &opt)
Constructor.
String-valued option that may be given several times.
StringListOption(const char *o, const char *e)
Initialize for option o and explanation e.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
const char * help
Optional help text.
Value * next
Next option value.
int val
Value for an option value.
const char * opt
String for option value.
String-valued option (integer value defined by strings).
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
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.
virtual ~StringOption(void)
Destructor.
void value(int v)
Set default value to v.
Value * lst
Last option value.
Value * fst
First option value.
virtual void help(void)
Print help text.
virtual void help(void)
Print help text.
virtual ~StringValueOption(void)
Destructor.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
void value(const char *v)
Set default value to v.
StringValueOption(const char *o, const char *e, const char *v=nullptr)
Initialize for option o and explanation e and default value v.
const char * cur
Current value.
TraceOption(int f=0)
Initialize with no tracing.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
void value(int f)
Set default trace flags to f.
virtual void help(void)
Print help text.
void value(unsigned int v)
Set default value to v.
UnsignedIntOption(const char *o, const char *e, unsigned int v=0)
Initialize for option o and explanation e and default value v.
unsigned int cur
Current value.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
virtual void help(void)
Print help text.
Unsigned long long integer option.
void value(unsigned long long int v)
Set default value to v.
unsigned long long int cur
Current value.
virtual int parse(int argc, char *argv[])
Parse option at first position and return number of parsed arguments.
UnsignedLongLongIntOption(const char *o, const char *e, unsigned long long int v=0)
Initialize for option o and explanation e and default value v.
virtual void help(void)
Print help text.
Abstract base class for comparators.
Abstract base class for inspectors.
bool builtin(unsigned int &i) const
Test whether the instance is the number of a built-in instance.
const char * _inst
Instance string.
bool is_file(void) const
Test whether the instance names a readable file.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc).
void instance(const char *s)
Set default instance name.
Driver::StringListOption _param
Parameters for the spec.
const char * _spec
Reader spec for instance files.
Instance::Data data(void) const
Read the instance file.
void param(const char *p)
Set the spec parameters (name=value, separated by commas).
void spec_file(const char *f)
Set the file with a reader spec that replaces spec().
std::unique_ptr< Instance::Data > _data
Data read, or null Forget the data read.
virtual void help(void)
Print help text.
InstanceOptions(const char *s)
Initialize options for script with name s.
void spec(const char *s)
Set the reader spec for instance files.
Driver::StringValueOption _spec_file
File with a reader spec.
Named values read from an instance.
void compare(Gist::Comparator *i)
Add comparator.
void click(Gist::Inspector *i)
Add inspector that reacts on node double clicks.
void move(Gist::Inspector *i)
Add inspector that reacts on each move of the cursor.
void solution(Gist::Inspector *i)
Add inspector that reacts on each new solution that is found.
Driver::DoubleOption _relax
Probability to relax variable.
void trace(int f)
Set trace flags.
Driver::StringValueOption _log_file
Where to print statistics.
void c_d(unsigned int d)
Set default copy recomputation distance.
Driver::StringOption _model
General model options.
void log_file(const char *f)
Set default output file name for Gecode stats.
void print_last(bool p)
Set whether to print only last solution found.
Driver::StringOption _mode
Script mode to run.
void propagation(int v)
Set default propagation value.
void iterations(unsigned int i)
Set default number of iterations.
Driver::DoubleOption _decay
Decay option.
Driver::UnsignedIntOption _nogoods_limit
Limit for no-good extraction.
void a_d(unsigned int d)
Set default adaptive recomputation distance.
void profiler_id(int i)
Set profiler execution identifier.
void seed(unsigned int s)
Set default seed value.
Driver::BoolOption _nogoods
Whether to use no-goods.
void branching(int v)
Set default branching value.
Driver::UnsignedIntOption _slice
Size of a portfolio slice.
Driver::UnsignedLongLongIntOption _r_limit
Cutoff for number of restarts.
Driver::TraceOption _trace
Trace flags for tracing.
Driver::UnsignedLongLongIntOption _fail
Cutoff for number of failures.
Driver::UnsignedIntOption _d_l
Discrepancy limit for LDS.
void slice(unsigned int n)
Set default slice size in a portfolio.
Driver::UnsignedIntOption _assets
Number of assets in a portfolio.
void search(int v)
Set default search value.
Driver::UnsignedLongLongIntOption _node
Cutoff for number of nodes.
void nogoods(bool b)
Set default nogoods posting behavior.
void symmetry(int v)
Set default symmetry value.
void profiler_port(unsigned int p)
Set profiler port.
Driver::UnsignedIntOption _iterations
How many iterations per sample.
Driver::StringOption _search
Search options.
Driver::StringOption _propagation
Propagation options.
Driver::IplOption _ipl
Integer propagation level.
void restart(RestartMode r)
Set default restart mode.
Driver::UnsignedLongLongIntOption _solutions
How many solutions.
Options(const char *s)
Initialize options for script with name s.
Driver::BoolOption _print_last
Print only last solution found.
Driver::UnsignedIntOption _c_d
Copy recomputation distance.
void nogoods_limit(unsigned int l)
Set default nogoods depth limit.
void step(double s)
Set default step value.
const Search::HeuristicGuidance * _guidance
Guidance for heuristic search.
Driver::ProfilerOption _profiler
Options for the CP Profiler.
void relax(double d)
Set default relax probability.
void ipl(IntPropLevel i)
Set default integer propagation level.
Driver::DoubleOption _threads
How many threads to use.
Driver::StringOption _branching
Branching options.
Driver::StringOption _restart
Restart method option.
void assets(unsigned int n)
Set default number of assets in a portfolio.
Driver::UnsignedIntOption _seed
Seed option.
Driver::DoubleOption _step
Step option.
void time(double t)
Set default time cutoff.
Driver::UnsignedIntOption _r_scale
Restart scale factor.
void solutions(unsigned long long int n)
Set default number of solutions to search for.
Driver::DoubleOption _time
Cutoff for time.
void restart_scale(unsigned int scale)
Set default restart scale factor.
void interrupt(bool b)
Set default interrupt behavior.
void restart_base(double base)
Set default restart base.
Driver::BoolOption _interrupt
Whether to catch SIGINT.
void d_l(unsigned int d)
Set default discrepancy limit for LDS.
void model(int v)
Set default model value.
void decay(double d)
Set default decay factor.
Driver::UnsignedIntOption _a_d
Adaptive recomputation distance.
void samples(unsigned int s)
Set default number of samples.
void out_file(const char *f)
Set default output file name for solutions.
Driver::DoubleOption _r_base
Restart base.
Driver::StringOption _symmetry
General symmetry options.
void guidance(const Search::HeuristicGuidance *g)
Set guidance for heuristic search (not copied).
Driver::StringValueOption _out_file
Where to print solutions.
Driver::UnsignedIntOption _samples
How many samples.
void node(unsigned long long int n)
Set default node cutoff.
void mode(ScriptMode em)
Set default mode.
void fail(unsigned long long int n)
Set default failure cutoff.
void threads(double n)
Set number of parallel threads.
void restart_limit(unsigned long long int n)
Set default restart cutoff.
Guidance for heuristic search engines (experimental).
virtual void help(void)
Print help text.
SizeOptions(const char *s)
Initialize options for script with name s.
unsigned int _size
Size value.
void size(unsigned int s)
Set default size.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc).
Array with arbitrary number of elements.
#define GECODE_DRIVER_EXPORT
ScriptMode
Different modes for executing scripts.
RestartMode
Different modes for restart-based search.
@ SM_STAT
Print statistics for script.
@ SM_SOLUTION
Print solution and some statistics.
@ SM_GIST
Run script in Gist.
@ SM_TIME
Measure average runtime.
@ RM_CONSTANT
Restart with constant sequence.
@ RM_LINEAR
Restart with linear sequence.
@ RM_LUBY
Restart with Luby sequence.
@ RM_GEOMETRIC
Restart with geometric sequence.
Driver::ScriptBase< Driver::IgnoreStepOption< IntMaximizeSpace > > IntMaximizeScript
Base-class for scripts for finding solution of highest integer cost.
Driver::ScriptBase< Driver::IgnoreStepOption< Space > > Script
Base-class for scripts.
Driver::ScriptBase< Driver::ExtractStepOption< FloatMinimizeSpace > > FloatMinimizeScript
Base-class for scripts for finding solution of lowest float cost.
Driver::ScriptBase< Driver::ExtractStepOption< FloatMaximizeSpace > > FloatMaximizeScript
Base-class for scripts for finding solution of highest float cost.
Driver::ScriptBase< Driver::IgnoreStepOption< IntLexMaximizeSpace > > IntLexMaximizeScript
Base-class for scripts for finding solution of lexically highest integer costs.
Driver::ScriptBase< Driver::IgnoreStepOption< IntLexMinimizeSpace > > IntLexMinimizeScript
Base-class for scripts for finding solution of lexically lowest integer costs.
Driver::ScriptBase< Driver::IgnoreStepOption< IntMinimizeSpace > > IntMinimizeScript
Base-class for scripts for finding solution of lowest integer cost.
IntPropLevel
Propagation levels for integer propagators.
@ IPL_DEF
Simple propagation levels.
Gecode toplevel namespace