45static_assert(std::is_copy_constructible<Gecode::NoGoods>::value,
46 "NoGoods must remain copy constructible");
47static_assert(std::is_copy_assignable<Gecode::NoGoods>::value,
48 "NoGoods must remain copy assignable");
49static_assert(std::is_copy_constructible<Gecode::Search::NodeStop>::value,
50 "NodeStop must remain copy constructible");
51static_assert(std::is_copy_assignable<Gecode::Search::NodeStop>::value,
52 "NodeStop must remain copy assignable");
53static_assert(std::is_copy_constructible<Gecode::Search::FailStop>::value,
54 "FailStop must remain copy constructible");
55static_assert(std::is_copy_assignable<Gecode::Search::FailStop>::value,
56 "FailStop must remain copy assignable");
57static_assert(std::is_copy_constructible<Gecode::Search::TimeStop>::value,
58 "TimeStop must remain copy constructible");
59static_assert(std::is_copy_assignable<Gecode::Search::TimeStop>::value,
60 "TimeStop must remain copy assignable");
61static_assert(std::is_copy_constructible<Gecode::Search::RestartStop>::value,
62 "RestartStop must remain copy constructible");
63static_assert(std::is_copy_assignable<Gecode::Search::RestartStop>::value,
64 "RestartStop must remain copy assignable");
108 virtual bool best(
void)
const = 0;
112 if (mi.
last() !=
nullptr)
134 x.update(*
this, s.
x);
148 virtual bool best(
void)
const {
152 static std::string
name(
void) {
168 x.update(*
this, s.
x);
183 virtual bool best(
void)
const {
187 static std::string
name(
void) {
232 x.update(*
this, s.
x);
248 for (
int i=0; i<6; i++)
249 y[i] =
IntVar(*
this, s.
x[i].val(), s.
x[i].val());
257 for (
int i=0; i<6; i++)
258 y[i] =
IntVar(*
this, s.
x[i].val(), s.
x[i].val());
259 IntVar xs(*
this, -18, 18);
260 IntVar ys(*
this, -18, 18);
261 rel(*
this,
x[0]+
x[1]+
x[2]-
x[3]-
x[4]-
x[5] == xs);
262 rel(*
this, y[0]+y[1]+y[2]-y[3]-y[4]-y[5] == ys);
284 virtual bool best(
void)
const {
292 return ((
x[0].val()==4) && (
x[1].val()==5) &&
293 (
x[2].val()==2) && (
x[3].val()==3) &&
294 (
x[4].val()==0) && (
x[5].val()==1));
296 return ((
x[0].val()==5) && (
x[1].val()==4) &&
297 (
x[2].val()==3) && (
x[3].val()==2) &&
298 (
x[4].val()==1) && (
x[5].val()==0));
300 return ((
x[0].val()==4) && (
x[1].val()==5) &&
301 (
x[2].val()==2) && (
x[3].val()==3) &&
302 (
x[4].val()==0) && (
x[5].val()==1));
304 return ((
x[0].val()==4) && (
x[1].val()==5) &&
305 (
x[2].val()==3) && (
x[3].val()==2) &&
306 (
x[4].val()==0) && (
x[5].val()==1));
312 static std::string
name(
void) {
319 if (mi.
last() !=
nullptr) {
323 for (
int i=0; i<
x.size(); i++)
324 b <<
expr(*
this,
x[i] == s->
x[i]);
346 static std::string
str(
unsigned int i) {
380 :
Base(
"Search::"+s),
385 template<
class Model>
397 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
412 int n = m->solutions();
415 Model* s =
dfs.next();
419 if ((s ==
nullptr) && !
dfs.stopped())
421 f.limit(f.limit()+2);
428 template<
class Model>
449 int n = m->solutions();
452 Model* s =
lds.next();
456 if ((s ==
nullptr) && !
lds.stopped())
458 f.limit(f.limit()+2);
465 template<
class Model>
478 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
496 Model* s =
bab.next();
500 if ((s ==
nullptr) && !
bab.stopped())
502 f.limit(f.limit()+2);
504 bool ok = (b ==
nullptr) || b->best();
511 template<
class Model,
template<
class>
class Engine>
518 RBS(
const std::string& e,
unsigned int t0)
531 int n = m->solutions();
534 Model* s =
rbs.next();
538 if ((s ==
nullptr) && !
rbs.stopped())
540 f.limit(f.limit()+2);
547 template<
class Model,
template<
class>
class Engine>
558 PBS(
const std::string& e,
bool b,
unsigned int a0,
unsigned int t0)
574 Model* s =
pbs.next();
578 if ((s ==
nullptr) && !
pbs.stopped())
580 f.limit(f.limit()+2);
582 bool ok = (b ==
nullptr) || b->best();
586 int n = ((t > 1) ? std::min(a,t) : a) * m->solutions();
589 Model* s =
pbs.next();
593 if ((s ==
nullptr) && !
pbs.stopped())
595 f.limit(f.limit()+2);
603 template<
class Model>
614 SEBPBS(
const std::string& e,
bool b,
unsigned int mt0,
unsigned int st0)
615 :
Test(
"PBS::SEB::"+e+
"::"+Model::
name()+
"::"+
str(mt0)+
"::"+
str(st0),
642 Model* s =
pbs.next();
646 if ((s ==
nullptr) && !
pbs.stopped())
648 f.limit(f.limit()+2);
650 bool ok = (b ==
nullptr) || b->best();
660 int n = 3 * m->solutions();
664 Model* s =
pbs.next();
668 if ((s ==
nullptr) && !
pbs.stopped())
670 f.limit(f.limit()+2);
701 const HowToBranch BranchTypes::htbs[3] = {HTB_UNARY, HTB_BINARY, HTB_NARY};
727 const HowToConstrain ConstrainTypes::htcs[4] =
728 {HTC_LEX_LE, HTC_LEX_GR, HTC_BAL_LE, HTC_BAL_GR};
737 for (
unsigned int t = 1; t<=4; t++)
738 for (
unsigned int c_d = 1; c_d<10; c_d++)
739 for (
unsigned int a_d = 1; a_d<=c_d; a_d++) {
744 (htb1.htb(),htb2.htb(),htb3.htb(),c_d, a_d, t);
754 for (
unsigned int t = 1; t<=4; t++) {
765 for (
unsigned int t = 1; t<=4; t++)
766 for (
unsigned int c_d = 1; c_d<10; c_d++)
767 for (
unsigned int a_d = 1; a_d<=c_d; a_d++) {
773 (htc.htc(),htb1.htb(),htb2.htb(),htb3.htb(),
784 for (
unsigned int t=1; t<=4; t++) {
796 for (
unsigned int a=1; a<=4; a++)
797 for (
unsigned int t=1; t<=2*a; t++) {
809 for (
unsigned int mt=1; mt<=3; mt += 2)
810 for (
unsigned int st=1; st<=8; st++) {
Depth-first branch-and-bound search engine.
Passing Boolean variables.
Depth-first search engine.
Passing integer variables.
Limited discrepancy search engine.
Meta engine using a portfolio of search engines.
Meta-engine performing restart-based search.
Passing search engine builder arguments.
static Cutoff * constant(unsigned long long int scale=Config::slice)
Create generator for constant sequence with constant s.
static Cutoff * geometric(unsigned long long int scale=Config::slice, double base=Config::base)
Stop-object based on number of failures
unsigned int c_d
Create a clone after every c_d commits (commit distance).
unsigned int d_l
Discrepancy limit (for LDS).
Cutoff * cutoff
Cutoff for restart-based search.
unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance).
Stop * stop
Stop object for stopping search.
unsigned int assets
Number of assets (engines) in a portfolio.
double threads
Number of threads to use.
Base(std::string s)
Create and register test with name s.
const std::string & name(void) const
Return name of test.
BAB(HowToConstrain htc, HowToBranch htb1, HowToBranch htb2, HowToBranch htb3, unsigned int c_d0, unsigned int a_d0, unsigned int t0)
Initialize test.
virtual bool run(void)
Run test.
Iterator for branching types.
HowToBranch htb(void) const
Return current branching type.
BranchTypes(void)
Initialize iterator.
void operator++(void)
Increment to next branching type.
bool operator()(void) const
Test whether iterator is done.
Iterator for constrain types.
HowToConstrain htc(void) const
Return current constrain type.
void operator++(void)
Increment to next constrain type.
bool operator()(void) const
Test whether iterator is done.
ConstrainTypes(void)
Initialize iterator.
Help class to create and register tests.
Create(void)
Perform creation and registration.
virtual bool run(void)
Run test.
DFS(HowToBranch htb1, HowToBranch htb2, HowToBranch htb3, unsigned int c_d0, unsigned int a_d0, unsigned int t0)
Initialize test.
virtual int solutions(void) const
Return number of solutions.
virtual Space * copy(void)
Copy during cloning.
static std::string name(void)
Return name.
virtual bool best(void) const
Verify that this is best solution.
virtual void constrain(const Space &_s)
Add constraint for next better solution.
virtual bool master(const MetaInfo &mi)
Rule out that solution is found more than once during restarts.
HowToConstrain htc
How to constrain.
HasSolutions(HasSolutions &s)
Constructor for cloning s.
IntVarArray x
Variables used.
HowToBranch htb1
How to branch.
HasSolutions(HowToBranch _htb1, HowToBranch _htb2, HowToBranch _htb3, HowToConstrain _htc=HTC_NONE)
Constructor for space creation.
void branch(const IntVarArgs &x, HowToBranch htb)
Branch on x according to htb.
virtual bool run(void)
Run test.
LDS(HowToBranch htb1, HowToBranch htb2, HowToBranch htb3, unsigned int t0)
Initialize test.
PBS(const std::string &e, bool b, unsigned int a0, unsigned int t0)
Initialize test.
virtual bool run(void)
Run test.
RBS(const std::string &e, unsigned int t0)
Initialize test.
virtual bool run(void)
Run test.
Test for portfolio-based search using SEBs
SEBPBS(const std::string &e, bool b, unsigned int mt0, unsigned int st0)
Initialize test.
virtual bool run(void)
Run test.
virtual int solutions(void) const =0
Return number of solutions.
virtual bool master(const MetaInfo &mi)
Master configuration function that does not restart.
TestSpace(void)
Constructor for space creation.
TestSpace(TestSpace &s)
Constructor for cloning s.
virtual bool best(void) const =0
Verify that this is best solution.
static std::string str(unsigned int i)
Map unsigned integer to string.
Test(const std::string &s, HowToBranch _htb1, HowToBranch _htb2, HowToBranch _htb3, HowToConstrain _htc=HTC_NONE)
Initialize test.
HowToConstrain htc
How to constrain.
static std::string str(HowToBranch htb)
Map branching to string.
HowToBranch htb1
How to branch.
static std::string str(HowToConstrain htc)
Map constrain to string.
void fail(void)
Fail space.
void assign(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatAssign vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Assign all x with variable selection vars and value selection vals.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
@ IRT_LQ
Less or equal ( ).
Space(void)
Default constructor.
virtual void constrain(const Space &best)
Constrain function for best solution search.
T * pbs(T *s, const Search::Options &o=Search::Options::def)
Run a portfolio of search engines.
T * bab(T *s, const Search::Options &o=Search::Options::def)
Perform depth-first branch-and-bound search for subclass T of space s and options o.
T * lds(T *s, const Search::Options &o=Search::Options::def)
Invoke limited-discrepancy search for s as root node and optionso.
T * rbs(T *s, const Search::Options &o)
Perform restart-based search.
Gecode toplevel namespace
void lex(Home home, const IntVarArgs &x, IntRelType r, const IntVarArgs &y, IntPropLevel ipl=IPL_DEF)
Post lexical order between x and y.
IntVar expr(Home home, const LinIntExpr &e, const IntPropLevels &ipls=IntPropLevels::def)
Post linear expression and return its value.
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Post propagator for for all .
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
IntValBranch INT_VALUES_MIN(void)
Try all values starting from smallest.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
T * dfs(T *s, const Search::Options &o=Search::Options::def)
Invoke depth-first search engine for subclass T of space s with options o.
IntAssign INT_ASSIGN_MIN(void)
Select smallest value.
HowToBranch
Values for selecting branchers.
@ HTB_BINARY
Branch with two alternatives.
@ HTB_UNARY
Branch with single alternative.
@ HTB_NARY
Branch with many alternatives.
HowToConstrain
Values for selecting how to constrain.
@ HTC_BAL_GR
Constrain for largest balance.
@ HTC_LEX_LE
Constrain for lexically smallest.
@ HTC_LEX_GR
Constrain for lexically biggest.
@ HTC_BAL_LE
Constrain for smallest balance.
@ HTC_NONE
Do not constrain.
WhichModel
Values for selecting models.
@ WM_FAIL_SEARCH
Model without solutions.
@ WM_SOLUTIONS
Model with solutions.
@ WM_FAIL_IMMEDIATE
Model that fails immediately.
#define GECODE_NEVER
Assert that this command is never executed.