85 virtual bool best(
void)
const = 0;
88 if (cri.
last() != NULL)
89 constrain(*cri.
last());
121 virtual bool best(
void)
const {
125 static std::string
name(
void) {
156 virtual bool best(
void)
const {
160 static std::string
name(
void) {
193 : x(*this,6,0,5), htb1(_htb1), htb2(_htb2), htb3(_htb3), htc(_htc) {
204 htb1(s.htb1), htb2(s.htb2), htb3(s.htb3), htc(s.htc) {
221 for (
int i=0;
i<6;
i++)
230 for (
int i=0;
i<6;
i++)
232 IntVar xs(*
this, -18, 18);
233 IntVar ys(*
this, -18, 18);
234 rel(*
this, x[0]+x[1]+x[2]-x[3]-x[4]-x[5] == xs);
235 rel(*
this, y[0]+y[1]+y[2]-y[3]-y[4]-y[5] == ys);
257 virtual bool best(
void)
const {
265 return ((x[0].val()==4) && (x[1].val()==5) &&
266 (x[2].val()==2) && (x[3].val()==3) &&
267 (x[4].val()==0) && (x[5].val()==1));
269 return ((x[0].val()==5) && (x[1].val()==4) &&
270 (x[2].val()==3) && (x[3].val()==2) &&
271 (x[4].val()==1) && (x[5].val()==0));
273 return ((x[0].val()==4) && (x[1].val()==5) &&
274 (x[2].val()==2) && (x[3].val()==3) &&
275 (x[4].val()==0) && (x[5].val()==1));
277 return ((x[0].val()==4) && (x[1].val()==5) &&
278 (x[2].val()==3) && (x[3].val()==2) &&
279 (x[4].val()==0) && (x[5].val()==1));
285 static std::string
name(
void) {
294 for (
int i=0; i<x.
size(); i++)
295 b <<
expr(*
this, x[i] == s->
x[i]);
309 static std::string
str(
unsigned int i) {
343 :
Base(
"Search::"+s),
344 htb1(_htb1), htb2(_htb2), htb3(_htb3), htc(_htc) {}
348 template<
class Model>
360 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
361 :
Test(
"DFS::"+Model::name()+
"::"+
362 str(htb1)+
"::"+str(htb2)+
"::"+str(htb3)+
"::"+
363 str(c_d0)+
"::"+str(a_d0)+
"::"+str(t0),
364 htb1,htb2,htb3), c_d(c_d0), a_d(a_d0), t(t0) {}
367 Model* m =
new Model(htb1,htb2,htb3);
375 int n = m->solutions();
378 Model* s = dfs.
next();
382 if ((s == NULL) && !dfs.
stopped())
391 template<
class Model>
404 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
405 :
Test(
"BAB::"+Model::name()+
"::"+str(htc)+
"::"+
406 str(htb1)+
"::"+str(htb2)+
"::"+str(htb3)+
"::"+
407 str(c_d0)+
"::"+str(a_d0)+
"::"+str(t0),
408 htb1,htb2,htb3,htc), c_d(c_d0), a_d(a_d0), t(t0) {}
411 Model* m =
new Model(htb1,htb2,htb3,htc);
422 Model* s = bab.
next();
426 if ((s == NULL) && !bab.
stopped())
430 bool ok = (b == NULL) || b->best();
437 template<
class Model,
template<
class>
class Engine>
444 RBS(
const std::string& e,
unsigned int t0)
445 :
Test(
"RBS::"+e+
"::"+Model::name()+
"::"+str(t0),
449 Model* m =
new Model(htb1,htb2,htb3);
456 int n = m->solutions();
459 Model* s = rbs.
next();
463 if ((s == NULL) && !rbs.
stopped())
531 for (
unsigned int t = 1;
t<=4;
t++)
532 for (
unsigned int c_d = 1;
c_d<10;
c_d++)
538 (htb1.htb(),htb2.htb(),htb3.htb(),
c_d,
a_d,
t);
548 for (
unsigned int t = 1;
t<=4;
t++)
549 for (
unsigned int c_d = 1;
c_d<10;
c_d++)
556 (htc.htc(),htb1.htb(),htb2.htb(),htb3.htb(),
567 for (
unsigned int t = 1;
t<=4;
t++) {
unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
bool stopped(void) const
Check whether engine has been stopped.
virtual int solutions(void) const
Return number of solutions.
Iterator for branching types.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
static std::string name(void)
Return name.
TestSpace(bool share, TestSpace &s)
Constructor for cloning s.
Meta-engine performing restart-based search.
static Cutoff * geometric(unsigned long int scale=1U, double base=1.5)
unsigned int c_d
Create a clone after every c_d commits (commit distance)
static std::string str(HowToConstrain htc)
Map constrain to string.
BAB(HowToConstrain htc, HowToBranch htb1, HowToBranch htb2, HowToBranch htb3, unsigned int c_d0, unsigned int a_d0, unsigned int t0)
Initialize test.
HasSolutions(bool share, HasSolutions &s)
Constructor for cloning s.
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
HowToConstrain htc
How to constrain.
DFS(HowToBranch htb1, HowToBranch htb2, HowToBranch htb3, unsigned int c_d0, unsigned int a_d0, unsigned int t0)
Initialize test.
void operator++(void)
Increment to next branching type.
HowToConstrain htc
How to constrain.
Current restart information during search.
void branch(const IntVarArgs &x, HowToBranch htb)
Branch on x according to htb.
virtual void master(unsigned long int i, const Space *_s, NoGoods &)
Rule out that solution is found more than once during restarts.
IntAssign INT_ASSIGN_MIN(void)
Select smallest value.
Create(void)
Perform creation and registration.
virtual Space * copy(bool share)
Copy during cloning.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
Test(const std::string &s, HowToBranch _htb1, HowToBranch _htb2, HowToBranch _htb3, HowToConstrain _htc=HTC_NONE)
Initialize test.
Model that fails immediately.
Cutoff * cutoff
Cutoff for restart-based search.
double threads
Number of threads to use.
Constrain for lexically smallest.
Gecode::IntArgs i(4, 1, 2, 3, 4)
const Space * last(void) const
Return last solution found (possibly NULL)
int n
Number of negative literals for node type.
virtual bool run(void)
Run test.
static std::string str(HowToBranch htb)
Map branching to string.
bool operator()(void) const
Test whether iterator is done.
int dfs(Space *root, const Gist::Options &opt)
Create a new stand-alone Gist for root.
Depth-first branch-and-bound search engine.
unsigned long int limit(void) const
Return current limit.
void operator++(void)
Increment to next constrain type.
HowToBranch htb(void) const
Return current branching type.
static std::string str(unsigned int i)
Map unsigned integer to string.
const unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
HowToConstrain htc(void) const
Return current constrain type.
WhichModel
Values for selecting models.
Branch with two alternatives.
void lex(Home home, const IntVarArgs &x, IntRelType r, const IntVarArgs &y, IntConLevel icl=ICL_DEF)
Post lexical order between x and y.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
TestSpace(void)
Constructor for space creation.
Base class for all tests to be run
virtual bool master(const CRI &cri)
Master configuration function that does not restart.
Branch with many alternatives.
Passing integer variables.
Passing Boolean variables.
Space that requires propagation and has solutions.
Branch with single alternative.
T * next(void)
Return next solution (NULL, if non exists or search has been stopped)
bool stopped(void) const
Check whether engine has been stopped.
bool stopped(void) const
Check whether engine has been stopped.
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
IntValBranch INT_VALUES_MIN(void)
Try all values starting from smallest.
Iterator for constrain types.
BrancherHandle assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
Constrain for smallest balance.
Help class to create and register tests.
bool operator()(void) const
Test whether iterator is done.
HowToConstrain
Values for selecting how to constrain.
No-goods recorded from restarts.
HasSolutions(HowToBranch _htb1, HowToBranch _htb2, HowToBranch _htb3, HowToConstrain _htc=HTC_NONE)
Constructor for space creation.
ConstrainTypes(void)
Initialize iterator.
IntVarArray x
Variables used.
T * next(void)
Return next solution (NULL, if none exists or search has been stopped)
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
HowToBranch
Values for selecting branchers.
Constrain for lexically biggest.
virtual bool run(void)
Run test.
int bab(Space *root, const Gist::Options &opt)
Create a new stand-alone Gist for branch-and-bound search of root.
void distinct(Home home, const IntVarArgs &x, IntConLevel icl)
Post propagator for for all .
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
BranchTypes(void)
Initialize iterator.
Stop * stop
Stop object for stopping search.
virtual void constrain(const Space &_s)
Add constraint for next better solution.
virtual bool run(void)
Run test.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
Constrain for largest balance.
BrancherHandle branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
T * next(void)
Return next better solution (NULL, if none exists or search has been stopped)
int size(void) const
Return size of array (number of elements)
RBS(const std::string &e, unsigned int t0)
Initialize test.
#define GECODE_NEVER
Assert that this command is never executed.
Engine * rbs(Space *s, MetaStop *stop, Engine *e, const Options &o)
Depth-first search engine.
Stop-object based on number of failures
int solutions(TestSpace *c, Gecode::Search::Options &o, int maxNbSol=-1)
Find number of solutions.
virtual bool best(void) const
Verify that this is best solution.