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++) {