Generated on for Gecode by doxygen 1.17.0

Options for scripts with additional instance parameter More...

#include <gecode/driver.hh>

Public Member Functions

 InstanceOptions (const char *s)
 Initialize options for script with name s.
 InstanceOptions (const char *s, const char *spec)
 Initialize options for script s that reads instance files.
virtual void help (void)
 Print help text.
void parse (int &argc, char *argv[])
 Parse options from arguments argv (number is argc).
void parse (int &argc, char *argv[], bool strict)
 Parse options, optionally rejecting unrecognised arguments.
void parse_strict (int &argc, char *argv[])
 Parse options with strict checking (equivalent to parse() with true).
void parse_permissive (int &argc, char *argv[])
 Parse options partially (equivalent to parse() with false).
void instance (const char *s)
 Set default instance name.
const char * instance (void) const
 Return instance name.
bool builtin (unsigned int &i) const
 Test whether the instance is the number of a built-in instance.
void spec (const char *s)
 Set the reader spec for instance files.
const char * spec (void) const
 Return the reader spec for instance files (may be null).
void spec_file (const char *f)
 Set the file with a reader spec that replaces spec().
const char * spec_file (void) const
 Return the file with a reader spec (may be null).
void param (const char *p)
 Set the spec parameters (name=value, separated by commas).
const char * param (void) const
 Return the spec parameters (may be null).
bool is_file (void) const
 Test whether the instance names a readable file.
Instance::Data data (void) const
 Read the instance file.
 ~InstanceOptions (void)
 Destructor.
void model (int v)
 Set default model value.
void model (int v, const char *o, const char *h=nullptr)
 Add model option value for value v, string o, and help h.
int model (void) const
 Return model value.
void symmetry (int v)
 Set default symmetry value.
void symmetry (int v, const char *o, const char *h=nullptr)
 Add symmetry option value for value v, string o, and help h.
int symmetry (void) const
 Return symmetry value.
void propagation (int v)
 Set default propagation value.
void propagation (int v, const char *o, const char *h=nullptr)
 Add propagation option value for value v, string o, and help h.
int propagation (void) const
 Return propagation value.
void ipl (IntPropLevel i)
 Set default integer propagation level.
IntPropLevel ipl (void) const
 Return integer propagation level.
void branching (int v)
 Set default branching value.
void branching (int v, const char *o, const char *h=nullptr)
 Add branching option value for value v, string o, and help h.
int branching (void) const
 Return branching value.
void decay (double d)
 Set default decay factor.
double decay (void) const
 Return decay factor.
void seed (unsigned int s)
 Set default seed value.
unsigned int seed (void) const
 Return seed value.
void step (double s)
 Set default step value.
double step (void) const
 Return step value.
void search (int v)
 Set default search value.
void search (int v, const char *o, const char *h=nullptr)
 Add search option value for value v, string o, and help h.
int search (void) const
 Return search value.
void solutions (unsigned long long int n)
 Set default number of solutions to search for.
unsigned long long int solutions (void) const
 Return number of solutions to search for.
void threads (double n)
 Set number of parallel threads.
double threads (void) const
 Return number of parallel threads.
void c_d (unsigned int d)
 Set default copy recomputation distance.
unsigned int c_d (void) const
 Return copy recomputation distance.
void a_d (unsigned int d)
 Set default adaptive recomputation distance.
unsigned int a_d (void) const
 Return adaptive recomputation distance.
void d_l (unsigned int d)
 Set default discrepancy limit for LDS.
unsigned int d_l (void) const
 Return discrepancy limit for LDS.
void node (unsigned long long int n)
 Set default node cutoff.
unsigned long long int node (void) const
 Return node cutoff.
void fail (unsigned long long int n)
 Set default failure cutoff.
unsigned long long int fail (void) const
 Return failure cutoff.
void time (double t)
 Set default time cutoff.
double time (void) const
 Return time cutoff.
void assets (unsigned int n)
 Set default number of assets in a portfolio.
unsigned int assets (void) const
 Return slice size in a portfolio.
void slice (unsigned int n)
 Set default slice size in a portfolio.
unsigned int slice (void) const
 Return slice size in a portfolio.
void restart (RestartMode r)
 Set default restart mode.
RestartMode restart (void) const
 Return restart mode.
void restart_base (double base)
 Set default restart base.
double restart_base (void) const
 Return restart base.
void restart_scale (unsigned int scale)
 Set default restart scale factor.
unsigned int restart_scale (void) const
 Return restart scale factor.
void restart_limit (unsigned long long int n)
 Set default restart cutoff.
unsigned long long int restart_limit (void) const
 Return restart cutoff.
void nogoods (bool b)
 Set default nogoods posting behavior.
bool nogoods (void) const
 Return whether nogoods are used.
void nogoods_limit (unsigned int l)
 Set default nogoods depth limit.
unsigned int nogoods_limit (void) const
 Return depth limit for nogoods.
void relax (double d)
 Set default relax probability.
double relax (void) const
 Return default relax probability.
void interrupt (bool b)
 Set default interrupt behavior.
bool interrupt (void) const
 Return interrupt behavior.
 Options (const char *s)
 Initialize options for script with name s.
void mode (ScriptMode em)
 Set default mode.
ScriptMode mode (void) const
 Return mode.
void samples (unsigned int s)
 Set default number of samples.
unsigned int samples (void) const
 Return number of samples.
void iterations (unsigned int i)
 Set default number of iterations.
unsigned int iterations (void) const
 Return number of iterations.
void print_last (bool p)
 Set whether to print only last solution found.
bool print_last (void) const
 Return whether to print only last solution found.
void out_file (const char *f)
 Set default output file name for solutions.
const char * out_file (void) const
 Get file name for solutions.
void log_file (const char *f)
 Set default output file name for Gecode stats.
const char * log_file (void) const
 Get file name for Gecode stats.
void trace (int f)
 Set trace flags.
int trace (void) const
 Return trace flags.
void profiler_id (int i)
 Set profiler execution identifier.
int profiler_id (void) const
 Return profiler execution id.
void profiler_port (unsigned int p)
 Set profiler port.
unsigned int profiler_port (void) const
 Return profiler execution id.
void guidance (const Search::HeuristicGuidance *g)
 Set guidance for heuristic search (not copied).
const Search::HeuristicGuidance * guidance (void) const
 Return guidance for heuristic search.
Public Member Functions inherited from Gecode::BaseOptions
 BaseOptions (const char *s)
 Initialize options for script with name s.
void add (Driver::BaseOption &o)
 Add new option o.
void parse (int &argc, char *argv[])
 Parse options from arguments argv (number is argc).
void parse (int &argc, char *argv[], bool strict)
 Parse options, optionally rejecting unrecognised arguments.
void parse_strict (int &argc, char *argv[])
 Parse options with strict checking (equivalent to parse() with true).
void parse_permissive (int &argc, char *argv[])
 Parse options partially (equivalent to parse() with false).
const char * name (void) const
 Return name of script.
void name (const char *)
 Set name of script.
virtual ~BaseOptions (void)
 Destructor.

Protected Member Functions

void forget (void) const

Protected Attributes

const char * _inst
 Instance string.
const char * _spec
 Reader spec for instance files.
Driver::StringValueOption _spec_file
 File with a reader spec.
Driver::StringListOption _param
 Parameters for the spec.
std::unique_ptr< Instance::Data > _data
 Data read, or null Forget the data read.
Driver::StringOption _model
 General model options.
Driver::StringOption _symmetry
 General symmetry options.
Driver::StringOption _propagation
 Propagation options.
Driver::IplOption _ipl
 Integer propagation level.
Driver::StringOption _branching
 Branching options.
Driver::DoubleOption _decay
 Decay option.
Driver::UnsignedIntOption _seed
 Seed option.
Driver::DoubleOption _step
 Step option.
Driver::StringOption _search
 Search options.
Driver::UnsignedLongLongIntOption _solutions
 How many solutions.
Driver::DoubleOption _threads
 How many threads to use.
Driver::UnsignedIntOption _c_d
 Copy recomputation distance.
Driver::UnsignedIntOption _a_d
 Adaptive recomputation distance.
Driver::UnsignedIntOption _d_l
 Discrepancy limit for LDS.
Driver::UnsignedLongLongIntOption _node
 Cutoff for number of nodes.
Driver::UnsignedLongLongIntOption _fail
 Cutoff for number of failures.
Driver::DoubleOption _time
 Cutoff for time.
Driver::UnsignedIntOption _assets
 Number of assets in a portfolio.
Driver::UnsignedIntOption _slice
 Size of a portfolio slice.
Driver::StringOption _restart
 Restart method option.
Driver::DoubleOption _r_base
 Restart base.
Driver::UnsignedIntOption _r_scale
 Restart scale factor.
Driver::UnsignedLongLongIntOption _r_limit
 Cutoff for number of restarts.
Driver::BoolOption _nogoods
 Whether to use no-goods.
Driver::UnsignedIntOption _nogoods_limit
 Limit for no-good extraction.
Driver::DoubleOption _relax
 Probability to relax variable.
Driver::BoolOption _interrupt
 Whether to catch SIGINT.
const Search::HeuristicGuidance * _guidance
 Guidance for heuristic search.
Driver::StringOption _mode
 Script mode to run.
Driver::UnsignedIntOption _samples
 How many samples.
Driver::UnsignedIntOption _iterations
 How many iterations per sample.
Driver::BoolOption _print_last
 Print only last solution found.
Driver::StringValueOption _out_file
 Where to print solutions.
Driver::StringValueOption _log_file
 Where to print statistics.
Driver::TraceOption _trace
 Trace flags for tracing.
Driver::ProfilerOption _profiler
 Options for the CP Profiler.
Protected Attributes inherited from Gecode::BaseOptions
Driver::BaseOption * fst
 First registered option.
Driver::BaseOption * lst
 Last registered option.
const char * _name
 Script name.

Additional Inherited Members

class Gecode::Options::I_ inspect
 Set guidance for heuristic search (not copied).

Detailed Description

Options for scripts with additional instance parameter

The instance is given as the last command line argument. It is either the name of an instance built into the script, or an instance file. A script that reads instance files gives the reader spec for its file format (see Instance::Spec) to the constructor, for example

const char* dimacs = R"(
comment "c"
line "p cnf {vars:int} {clauses:int}"
repeat clauses { list clause: int until 0 }
)";
InstanceOptions opt("SAT", dimacs);
opt.parse(argc, argv);
Instance::Data d = opt.data();
InstanceOptions(const char *s)
Initialize options for script with name s.
Definition options.cpp:783
Named values read from an instance.
Definition instance.hh:406
void parse(int argc, char *argv[])
Parse commandline arguments.
Definition test.cpp:177

The option -spec then reads instance files with the spec in another file instead, and -param gives a value to one of the spec's parameters as name=value (for example instance=3 to select an instance in a file with several instances). For several parameters, -param is given several times, or the pairs are separated by commas as in -param a=1,b=2. A script may rely on the checks in its own spec, so a replacement spec must define the same data and is responsible for the same checks.

Reading an instance reports errors by throwing Instance::Error; the command line itself is parsed as for all options. The driver library requires the instance library.

Definition at line 834 of file driver.hh.

Constructor & Destructor Documentation

◆ InstanceOptions() [1/2]

Gecode::InstanceOptions::InstanceOptions ( const char * s)

Initialize options for script with name s.

Definition at line 783 of file options.cpp.

◆ InstanceOptions() [2/2]

Gecode::InstanceOptions::InstanceOptions ( const char * s,
const char * spec )

Initialize options for script s that reads instance files.

Instance files are read with the reader spec spec. Only scripts created with this constructor accept the options -spec and -param.

Definition at line 788 of file options.cpp.

◆ ~InstanceOptions()

Gecode::InstanceOptions::~InstanceOptions ( void )

Destructor.

Definition at line 912 of file options.cpp.

Member Function Documentation

◆ forget()

void Gecode::InstanceOptions::forget ( void ) const
protected

Definition at line 795 of file options.cpp.

◆ help()

void Gecode::InstanceOptions::help ( void )
virtual

Print help text.

Reimplemented from Gecode::BaseOptions.

Reimplemented in JobShopOptions.

Definition at line 826 of file options.cpp.

◆ parse() [1/2]

void Gecode::InstanceOptions::parse ( int & argc,
char * argv[] )

Parse options from arguments argv (number is argc).

Definition at line 833 of file options.cpp.

◆ parse() [2/2]

void Gecode::InstanceOptions::parse ( int & argc,
char * argv[],
bool strict )

Parse options, optionally rejecting unrecognised arguments.

With strict set to true, the only argument that may remain after the options is the instance. An argument that starts with a hyphen is an unrecognised option rather than an instance. Any other remaining argument causes an error message and help text to be printed, followed by exit with failure.

Definition at line 843 of file options.cpp.

◆ parse_strict()

void Gecode::InstanceOptions::parse_strict ( int & argc,
char * argv[] )
inline

Parse options with strict checking (equivalent to parse() with true).

Definition at line 657 of file options.hpp.

◆ parse_permissive()

void Gecode::InstanceOptions::parse_permissive ( int & argc,
char * argv[] )
inline

Parse options partially (equivalent to parse() with false).

Definition at line 661 of file options.hpp.

◆ instance() [1/2]

void Gecode::InstanceOptions::instance ( const char * s)

Set default instance name.

Definition at line 800 of file options.cpp.

◆ instance() [2/2]

const char * Gecode::InstanceOptions::instance ( void ) const
inline

Return instance name.

Definition at line 666 of file options.hpp.

◆ builtin()

bool Gecode::InstanceOptions::builtin ( unsigned int & i) const

Test whether the instance is the number of a built-in instance.

Returns true and sets i to the number if the instance is a non-negative decimal number of at most nine digits (so that it cannot overflow). Otherwise returns false and leaves i unchanged. Whether there is a built-in instance with that number is up to the script.

Definition at line 862 of file options.cpp.

◆ spec() [1/2]

void Gecode::InstanceOptions::spec ( const char * s)

Set the reader spec for instance files.

Definition at line 807 of file options.cpp.

◆ spec() [2/2]

const char * Gecode::InstanceOptions::spec ( void ) const
inline

Return the reader spec for instance files (may be null).

Definition at line 671 of file options.hpp.

◆ spec_file() [1/2]

void Gecode::InstanceOptions::spec_file ( const char * f)

Set the file with a reader spec that replaces spec().

Definition at line 814 of file options.cpp.

◆ spec_file() [2/2]

const char * Gecode::InstanceOptions::spec_file ( void ) const
inline

Return the file with a reader spec (may be null).

Definition at line 676 of file options.hpp.

◆ param() [1/2]

void Gecode::InstanceOptions::param ( const char * p)

Set the spec parameters (name=value, separated by commas).

Definition at line 820 of file options.cpp.

◆ param() [2/2]

const char * Gecode::InstanceOptions::param ( void ) const
inline

Return the spec parameters (may be null).

Definition at line 681 of file options.hpp.

◆ is_file()

bool Gecode::InstanceOptions::is_file ( void ) const

Test whether the instance names a readable file.

Definition at line 882 of file options.cpp.

◆ data()

Instance::Data Gecode::InstanceOptions::data ( void ) const

Read the instance file.

The file is read once; later calls return the same data. Throws Instance::Error if there is no spec, if the file cannot be read, or if it does not match the spec.

Definition at line 893 of file options.cpp.

Member Data Documentation

◆ _inst

const char* Gecode::InstanceOptions::_inst
protected

Instance string.

Definition at line 836 of file driver.hh.

◆ _spec

const char* Gecode::InstanceOptions::_spec
protected

Reader spec for instance files.

Definition at line 837 of file driver.hh.

◆ _spec_file

Driver::StringValueOption Gecode::InstanceOptions::_spec_file
protected

File with a reader spec.

Definition at line 838 of file driver.hh.

◆ _param

Driver::StringListOption Gecode::InstanceOptions::_param
protected

Parameters for the spec.

Definition at line 839 of file driver.hh.

◆ _data

std::unique_ptr<Instance::Data> Gecode::InstanceOptions::_data
mutableprotected

Data read, or null Forget the data read.

Definition at line 840 of file driver.hh.


The documentation for this class was generated from the following files: