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) {
152 :
x(*this,6,0,5), htb1(_htb1), htb2(_htb2), htb3(_htb3), htc(_htc) {
163 htb1(s.htb1), htb2(s.htb2), htb3(s.htb3), htc(s.htc) {
164 x.update(*
this, share, s.
x);
180 for (
int i=0;
i<6;
i++)
189 for (
int i=0;
i<6;
i++)
191 IntVar xs(*
this, -18, 18);
192 IntVar ys(*
this, -18, 18);
193 rel(*
this,
x[0]+
x[1]+
x[2]-
x[3]-
x[4]-
x[5] == xs);
194 rel(*
this, y[0]+y[1]+y[2]-y[3]-y[4]-y[5] == ys);
216 virtual bool best(
void)
const {
224 return ((
x[0].val()==4) && (
x[1].val()==5) &&
225 (
x[2].val()==2) && (
x[3].val()==3) &&
226 (
x[4].val()==0) && (
x[5].val()==1));
228 return ((
x[0].val()==5) && (
x[1].val()==4) &&
229 (
x[2].val()==3) && (
x[3].val()==2) &&
230 (
x[4].val()==1) && (
x[5].val()==0));
232 return ((
x[0].val()==4) && (
x[1].val()==5) &&
233 (
x[2].val()==2) && (
x[3].val()==3) &&
234 (
x[4].val()==0) && (
x[5].val()==1));
236 return ((
x[0].val()==4) && (
x[1].val()==5) &&
237 (
x[2].val()==3) && (
x[3].val()==2) &&
238 (
x[4].val()==0) && (
x[5].val()==1));
244 static std::string
name(
void) {
252 for (
int i=0; i<
x.size(); i++)
253 b <<
expr(*
this,
x[i] == s->
x[i]);
267 static std::string
str(
unsigned int i) {
301 :
Base(
"Search::"+s),
302 htb1(_htb1), htb2(_htb2), htb3(_htb3), htc(_htc) {}
306 template<
class Model>
318 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
319 :
Test(
"DFS::"+Model::name()+
"::"+
320 str(htb1)+
"::"+str(htb2)+
"::"+str(htb3)+
"::"+
321 str(c_d0)+
"::"+str(a_d0)+
"::"+str(t0),
322 htb1,htb2,htb3),
c_d(c_d0),
a_d(a_d0),
t(t0) {}
325 Model* m =
new Model(htb1,htb2,htb3);
333 int n = m->solutions();
336 Model* s = dfs.
next();
340 if ((s == NULL) && !dfs.
stopped())
349 template<
class Model,
template<
class>
class Engine>
362 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
363 :
Test(b+
"::"+Model::name()+
"::"+str(htc)+
"::"+
364 str(htb1)+
"::"+str(htb2)+
"::"+str(htb3)+
"::"+
365 str(c_d0)+
"::"+str(a_d0)+
"::"+str(t0),
366 htb1,htb2,htb3,htc),
c_d(c_d0),
a_d(a_d0),
t(t0) {}
369 Model* m =
new Model(htb1,htb2,htb3,htc);
376 Engine<Model> best(m,o);
380 Model* s = best.next();
384 if ((s == NULL) && !best.stopped())
388 bool ok = (b == NULL) || b->best();
395 template<
class Model,
template<
class>
class Engine>
402 RBS(
const std::string& e,
unsigned int t0)
403 :
Test(
"RBS::"+e+
"::"+Model::name()+
"::"+str(t0),
407 Model* m =
new Model(htb1,htb2,htb3);
414 int n = m->solutions();
417 Model* s = rbs.
next();
421 if ((s == NULL) && !rbs.
stopped())
489 for (
unsigned int t = 1;
t<=4;
t++)
490 for (
unsigned int c_d = 1;
c_d<10;
c_d++)
504 for (
unsigned int t = 1;
t<=4;
t++)
505 for (
unsigned int c_d = 1;
c_d<10;
c_d++)
512 (
"BAB",htc.htc(),htb1.htb(),htb2.htb(),htb3.htb(),
521 for (
unsigned int t = 1;
t<=4;
t++) {