48 using namespace Gecode;
49 using namespace Gecode::Int;
85 virtual bool best(
void)
const = 0;
101 x.update(*
this, share, s.
x);
115 virtual bool best(
void)
const {
119 static std::string
name(
void) {
135 x.update(*
this, share, s.
x);
150 virtual bool best(
void)
const {
154 static std::string
name(
void) {
187 :
x(*this,6,0,5), htb1(_htb1), htb2(_htb2), htb3(_htb3), htc(_htc) {
198 htb1(s.htb1), htb2(s.htb2), htb3(s.htb3), htc(s.htc) {
199 x.update(*
this, share, s.
x);
215 for (
int i=0;
i<6;
i++)
224 for (
int i=0;
i<6;
i++)
226 IntVar xs(*
this, -18, 18);
227 IntVar ys(*
this, -18, 18);
228 rel(*
this,
x[0]+
x[1]+
x[2]-
x[3]-
x[4]-
x[5] == xs);
229 rel(*
this, y[0]+y[1]+y[2]-y[3]-y[4]-y[5] == ys);
251 virtual bool best(
void)
const {
259 return ((
x[0].val()==4) && (
x[1].val()==5) &&
260 (
x[2].val()==2) && (
x[3].val()==3) &&
261 (
x[4].val()==0) && (
x[5].val()==1));
263 return ((
x[0].val()==5) && (
x[1].val()==4) &&
264 (
x[2].val()==3) && (
x[3].val()==2) &&
265 (
x[4].val()==1) && (
x[5].val()==0));
267 return ((
x[0].val()==4) && (
x[1].val()==5) &&
268 (
x[2].val()==2) && (
x[3].val()==3) &&
269 (
x[4].val()==0) && (
x[5].val()==1));
271 return ((
x[0].val()==4) && (
x[1].val()==5) &&
272 (
x[2].val()==3) && (
x[3].val()==2) &&
273 (
x[4].val()==0) && (
x[5].val()==1));
279 static std::string
name(
void) {
288 for (
int i=0; i<
x.size(); i++)
289 b <<
expr(*
this,
x[i] == s->
x[i]);
303 static std::string
str(
unsigned int i) {
337 :
Base(
"Search::"+s),
338 htb1(_htb1), htb2(_htb2), htb3(_htb3), htc(_htc) {}
342 template<
class Model>
354 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
355 :
Test(
"DFS::"+Model::name()+
"::"+
356 str(htb1)+
"::"+str(htb2)+
"::"+str(htb3)+
"::"+
357 str(c_d0)+
"::"+str(a_d0)+
"::"+str(t0),
358 htb1,htb2,htb3),
c_d(c_d0),
a_d(a_d0),
t(t0) {}
361 Model* m =
new Model(htb1,htb2,htb3);
369 int n = m->solutions();
372 Model* s = dfs.
next();
376 if ((s == NULL) && !dfs.
stopped())
385 template<
class Model>
398 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
399 :
Test(
"BAB::"+Model::name()+
"::"+str(htc)+
"::"+
400 str(htb1)+
"::"+str(htb2)+
"::"+str(htb3)+
"::"+
401 str(c_d0)+
"::"+str(a_d0)+
"::"+str(t0),
402 htb1,htb2,htb3,htc),
c_d(c_d0),
a_d(a_d0),
t(t0) {}
405 Model* m =
new Model(htb1,htb2,htb3,htc);
416 Model* s = bab.
next();
420 if ((s == NULL) && !bab.
stopped())
424 bool ok = (b == NULL) || b->best();
431 template<
class Model,
template<
class>
class Engine>
438 RBS(
const std::string& e,
unsigned int t0)
439 :
Test(
"RBS::"+e+
"::"+Model::name()+
"::"+str(t0),
443 Model* m =
new Model(htb1,htb2,htb3);
450 int n = m->solutions();
453 Model* s = rbs.
next();
457 if ((s == NULL) && !rbs.
stopped())
525 for (
unsigned int t = 1;
t<=4;
t++)
526 for (
unsigned int c_d = 1;
c_d<10;
c_d++)
532 (htb1.htb(),htb2.htb(),htb3.htb(),
c_d,
a_d,
t);
542 for (
unsigned int t = 1;
t<=4;
t++)
543 for (
unsigned int c_d = 1;
c_d<10;
c_d++)
550 (htc.htc(),htb1.htb(),htb2.htb(),htb3.htb(),
561 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.
Base class for search tests
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.
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)
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
struct Gecode::@512::NNF::@54::@55 b
For binary nodes (and, or, eqv)
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.
Node * x
Pointer to corresponding Boolean expression node.
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.
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)
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.