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) {
257 static std::string
str(
unsigned int i) {
291 :
Base(
"Search::"+s),
292 htb1(_htb1), htb2(_htb2), htb3(_htb3), htc(_htc) {}
296 template<
class Model>
308 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
309 :
Test(
"DFS::"+Model::name()+
"::"+
310 str(htb1)+
"::"+str(htb2)+
"::"+str(htb3)+
"::"+
311 str(c_d0)+
"::"+str(a_d0)+
"::"+str(t0),
312 htb1,htb2,htb3),
c_d(c_d0),
a_d(a_d0), t(t0) {}
315 Model*
m =
new Model(htb1,htb2,htb3);
323 int n = m->solutions();
326 Model* s = dfs.
next();
330 if ((s == NULL) && !dfs.
stopped())
339 template<
class Model,
template<
class>
class Engine>
352 unsigned int c_d0,
unsigned int a_d0,
unsigned int t0)
353 :
Test(b+
"::"+Model::name()+
"::"+str(htc)+
"::"+
354 str(htb1)+
"::"+str(htb2)+
"::"+str(htb3)+
"::"+
355 str(c_d0)+
"::"+str(a_d0)+
"::"+str(t0),
356 htb1,htb2,htb3,htc),
c_d(c_d0),
a_d(a_d0), t(t0) {}
359 Model*
m =
new Model(htb1,htb2,htb3,htc);
366 Engine<Model> best(m,o);
370 Model* s = best.next();
374 if ((s == NULL) && !best.stopped())
378 bool ok = (b == NULL) || b->best();
444 for (
unsigned int t = 1; t<=4; t++)
445 for (
unsigned int c_d = 1;
c_d<10;
c_d++)
459 for (
unsigned int t = 1; t<=4; t++)
460 for (
unsigned int c_d = 1;
c_d<10;
c_d++)
467 (
"BAB",htc.htc(),htb1.htb(),htb2.htb(),htb3.htb(),
470 (
"Restart",htc.htc(),htb1.htb(),htb2.htb(),htb3.htb(),