Generated on Tue Apr 18 10:22:19 2017 for Gecode by doxygen 1.6.3

search.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2008
00008  *
00009  *  Last modified:
00010  *     $Date: 2017-03-28 16:18:06 +0200 (Tue, 28 Mar 2017) $ by $Author: schulte $
00011  *     $Revision: 15620 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #include <gecode/minimodel.hh>
00039 #include <gecode/search.hh>
00040 
00041 #include "test/test.hh"
00042 
00043 namespace Test {
00044 
00046   namespace Search {
00047 
00048     using namespace Gecode;
00049     using namespace Gecode::Int;
00050 
00052     enum HowToBranch {
00053       HTB_NONE,   
00054       HTB_UNARY,  
00055       HTB_BINARY, 
00056       HTB_NARY    
00057     };
00058 
00060     enum HowToConstrain {
00061       HTC_NONE,   
00062       HTC_LEX_LE, 
00063       HTC_LEX_GR, 
00064       HTC_BAL_LE, 
00065       HTC_BAL_GR  
00066     };
00067 
00069     enum WhichModel {
00070       WM_FAIL_IMMEDIATE, 
00071       WM_FAIL_SEARCH,    
00072       WM_SOLUTIONS       
00073     };
00074 
00076     class TestSpace : public Space {
00077     public:
00079       TestSpace(void) {}
00081       TestSpace(bool share, TestSpace& s) : Space(share,s) {}
00083       virtual int solutions(void) const = 0;
00085       virtual bool best(void) const = 0;
00087       virtual bool master(const MetaInfo& mi) {
00088         if (mi.type() == MetaInfo::RESTART) {
00089           if (mi.last() != NULL)
00090             constrain(*mi.last());
00091           return false;
00092         } else {
00093           return false;
00094         }
00095       }
00096     };
00097 
00099     class FailImmediate : public TestSpace {
00100     public:
00102       IntVarArray x;
00104       FailImmediate(HowToBranch, HowToBranch, HowToBranch,
00105                     HowToConstrain=HTC_NONE)
00106         : x(*this,1,0,0) {
00107         rel(*this, x[0], IRT_EQ, 1);
00108       }
00110       FailImmediate(bool share, FailImmediate& s) : TestSpace(share,s) {
00111         x.update(*this, share, s.x);
00112       }
00114       virtual Space* copy(bool share) {
00115         return new FailImmediate(share,*this);
00116       }
00118       virtual void constrain(const Space&) {
00119       }
00121       virtual int solutions(void) const {
00122         return 0;
00123       }
00125       virtual bool best(void) const {
00126         return false;
00127       }
00129       static std::string name(void) {
00130         return "Fail";
00131       }
00132     };
00133 
00135     class SolveImmediate : public TestSpace {
00136     public:
00138       IntVarArray x;
00140       SolveImmediate(HowToBranch, HowToBranch, HowToBranch,
00141                      HowToConstrain=HTC_NONE)
00142         : x(*this,1,0,0) {}
00144       SolveImmediate(bool share, SolveImmediate& s) : TestSpace(share,s) {
00145         x.update(*this, share, s.x);
00146       }
00148       virtual Space* copy(bool share) {
00149         return new SolveImmediate(share,*this);
00150       }
00152       virtual void constrain(const Space&) {
00153         fail();
00154       }
00156       virtual int solutions(void) const {
00157         return 1;
00158       }
00160       virtual bool best(void) const {
00161         return true;
00162       }
00164       static std::string name(void) {
00165         return "Solve";
00166       }
00167     };
00168 
00170     class HasSolutions : public TestSpace {
00171     public:
00173       IntVarArray x;
00175       HowToBranch htb1, htb2, htb3;
00177       HowToConstrain htc;
00179       void branch(const IntVarArgs& x, HowToBranch htb) {
00180         switch (htb) {
00181         case HTB_NONE:
00182           break;
00183         case HTB_UNARY:
00184           assign(*this, x, INT_ASSIGN_MIN());
00185           break;
00186         case HTB_BINARY:
00187           Gecode::branch(*this, x, INT_VAR_NONE(), INT_VAL_MIN());
00188           break;
00189         case HTB_NARY:
00190           Gecode::branch(*this, x, INT_VAR_NONE(), INT_VALUES_MIN());
00191           break;
00192         }
00193       }
00195       HasSolutions(HowToBranch _htb1, HowToBranch _htb2, HowToBranch _htb3,
00196                    HowToConstrain _htc=HTC_NONE)
00197         : x(*this,6,0,5), htb1(_htb1), htb2(_htb2), htb3(_htb3), htc(_htc) {
00198         distinct(*this, x);
00199         rel(*this, x[2], IRT_LQ, 3); rel(*this, x[3], IRT_LQ, 3);
00200         rel(*this, x[4], IRT_LQ, 1); rel(*this, x[5], IRT_LQ, 1);
00201         IntVarArgs x1(2); x1[0]=x[0]; x1[1]=x[1]; branch(x1, htb1);
00202         IntVarArgs x2(2); x2[0]=x[2]; x2[1]=x[3]; branch(x2, htb2);
00203         IntVarArgs x3(2); x3[0]=x[4]; x3[1]=x[5]; branch(x3, htb3);
00204       }
00206       HasSolutions(bool share, HasSolutions& s)
00207         : TestSpace(share,s),
00208           htb1(s.htb1), htb2(s.htb2), htb3(s.htb3), htc(s.htc) {
00209         x.update(*this, share, s.x);
00210       }
00212       virtual Space* copy(bool share) {
00213         return new HasSolutions(share,*this);
00214       }
00216       virtual void constrain(const Space& _s) {
00217         const HasSolutions& s = static_cast<const HasSolutions&>(_s);
00218         switch (htc) {
00219         case HTC_NONE:
00220           break;
00221         case HTC_LEX_LE:
00222         case HTC_LEX_GR:
00223           {
00224             IntVarArgs y(6);
00225             for (int i=0; i<6; i++)
00226               y[i] = IntVar(*this, s.x[i].val(), s.x[i].val());
00227             lex(*this, x, (htc == HTC_LEX_LE) ? IRT_LE : IRT_GR, y);
00228             break;
00229           }
00230         case HTC_BAL_LE:
00231         case HTC_BAL_GR:
00232           {
00233             IntVarArgs y(6);
00234             for (int i=0; i<6; i++)
00235               y[i] = IntVar(*this, s.x[i].val(), s.x[i].val());
00236             IntVar xs(*this, -18, 18);
00237             IntVar ys(*this, -18, 18);
00238             rel(*this, x[0]+x[1]+x[2]-x[3]-x[4]-x[5] == xs);
00239             rel(*this, y[0]+y[1]+y[2]-y[3]-y[4]-y[5] == ys);
00240             rel(*this,
00241                 expr(*this,abs(xs)),
00242                 (htc == HTC_BAL_LE) ? IRT_LE : IRT_GR,
00243                 expr(*this,abs(ys)));
00244             break;
00245           }
00246         }
00247       }
00249       virtual int solutions(void) const {
00250         if (htb1 == HTB_NONE) {
00251           assert((htb2 == HTB_NONE) && (htb3 == HTB_NONE));
00252           return 1;
00253         }
00254         if ((htb1 == HTB_UNARY) || (htb2 == HTB_UNARY))
00255           return 0;
00256         if (htb3 == HTB_UNARY)
00257           return 4;
00258         return 8;
00259       }
00261       virtual bool best(void) const {
00262         if ((htb1 == HTB_NONE) || (htb2 == HTB_NONE) || (htb3 == HTB_NONE) ||
00263             (htb1 == HTB_UNARY) || (htb2 == HTB_UNARY) || (htb3 == HTB_UNARY))
00264           return true;
00265         switch (htc) {
00266         case HTC_NONE:
00267           return true;
00268         case HTC_LEX_LE:
00269           return ((x[0].val()==4) && (x[1].val()==5) &&
00270                   (x[2].val()==2) && (x[3].val()==3) &&
00271                   (x[4].val()==0) && (x[5].val()==1));
00272         case HTC_LEX_GR:
00273           return ((x[0].val()==5) && (x[1].val()==4) &&
00274                   (x[2].val()==3) && (x[3].val()==2) &&
00275                   (x[4].val()==1) && (x[5].val()==0));
00276         case HTC_BAL_LE:
00277           return ((x[0].val()==4) && (x[1].val()==5) &&
00278                   (x[2].val()==2) && (x[3].val()==3) &&
00279                   (x[4].val()==0) && (x[5].val()==1));
00280         case HTC_BAL_GR:
00281           return ((x[0].val()==4) && (x[1].val()==5) &&
00282                   (x[2].val()==3) && (x[3].val()==2) &&
00283                   (x[4].val()==0) && (x[5].val()==1));
00284         default: GECODE_NEVER;
00285         }
00286         return false;
00287       }
00289       static std::string name(void) {
00290         return "Sol";
00291       }
00293       virtual bool master(const MetaInfo& mi) {
00294         switch (mi.type()) {
00295         case MetaInfo::RESTART:
00296           if (mi.last() != NULL) {
00297             const HasSolutions* s
00298               = static_cast<const HasSolutions*>(mi.last());
00299             BoolVarArgs b;
00300             for (int i=0; i<x.size(); i++)
00301               b << expr(*this, x[i] == s->x[i]);
00302             rel(*this, BOT_AND, b, 0);
00303           }
00304           break;
00305         case MetaInfo::PORTFOLIO:
00306           // Do not kill the brancher!
00307           break;
00308         default:
00309           break;
00310         }
00311         return false;
00312       }
00313     };
00314 
00316     class Test : public Base {
00317     public:
00319       HowToBranch htb1, htb2, htb3;
00321       HowToConstrain htc;
00323       static std::string str(unsigned int i) {
00324         std::stringstream s;
00325         s << i;
00326         return s.str();
00327       }
00329       static std::string str(HowToBranch htb) {
00330         switch (htb) {
00331         case HTB_NONE:   return "None";
00332         case HTB_UNARY:  return "Unary";
00333         case HTB_BINARY: return "Binary";
00334         case HTB_NARY:   return "Nary";
00335         default: GECODE_NEVER;
00336         }
00337         GECODE_NEVER;
00338         return "";
00339       }
00341       static std::string str(HowToConstrain htc) {
00342         switch (htc) {
00343         case HTC_NONE:   return "None";
00344         case HTC_LEX_LE: return "LexLe";
00345         case HTC_LEX_GR: return "LexGr";
00346         case HTC_BAL_LE: return "BalLe";
00347         case HTC_BAL_GR: return "BalGr";
00348         default: GECODE_NEVER;
00349         }
00350         GECODE_NEVER;
00351         return "";
00352       }
00354       Test(const std::string& s,
00355            HowToBranch _htb1, HowToBranch _htb2, HowToBranch _htb3,
00356            HowToConstrain _htc=HTC_NONE)
00357         : Base("Search::"+s),
00358           htb1(_htb1), htb2(_htb2), htb3(_htb3), htc(_htc) {}
00359     };
00360 
00362     template<class Model>
00363     class DFS : public Test {
00364     private:
00366       unsigned int c_d;
00368       unsigned int a_d;
00370       unsigned int t;
00371     public:
00373       DFS(HowToBranch htb1, HowToBranch htb2, HowToBranch htb3,
00374           unsigned int c_d0, unsigned int a_d0, unsigned int t0)
00375         : Test("DFS::"+Model::name()+"::"+
00376                str(htb1)+"::"+str(htb2)+"::"+str(htb3)+"::"+
00377                str(c_d0)+"::"+str(a_d0)+"::"+str(t0),
00378                htb1,htb2,htb3), c_d(c_d0), a_d(a_d0), t(t0) {}
00380       virtual bool run(void) {
00381         Model* m = new Model(htb1,htb2,htb3);
00382         Gecode::Search::FailStop f(2);
00383         Gecode::Search::Options o;
00384         o.c_d = c_d;
00385         o.a_d = a_d;
00386         o.threads = t;
00387         o.stop = &f;
00388         Gecode::DFS<Model> dfs(m,o);
00389         int n = m->solutions();
00390         delete m;
00391         while (true) {
00392           Model* s = dfs.next();
00393           if (s != NULL) {
00394             n--; delete s;
00395           }
00396           if ((s == NULL) && !dfs.stopped())
00397             break;
00398           f.limit(f.limit()+2);
00399         }
00400         return n == 0;
00401       }
00402     };
00403 
00405     template<class Model>
00406     class LDS : public Test {
00407     private:
00409       unsigned int t;
00410     public:
00412       LDS(HowToBranch htb1, HowToBranch htb2, HowToBranch htb3,
00413           unsigned int t0)
00414         : Test("LDS::"+Model::name()+"::"+
00415                str(htb1)+"::"+str(htb2)+"::"+str(htb3)+"::"+str(t0),
00416                htb1,htb2,htb3), t(t0) {}
00418       virtual bool run(void) {
00419         Model* m = new Model(htb1,htb2,htb3);
00420         Gecode::Search::FailStop f(2);
00421         Gecode::Search::Options o;
00422         o.threads = t;
00423         o.d_l = 50;
00424         o.stop = &f;
00425         Gecode::LDS<Model> lds(m,o);
00426         int n = m->solutions();
00427         delete m;
00428         while (true) {
00429           Model* s = lds.next();
00430           if (s != NULL) {
00431             n--; delete s;
00432           }
00433           if ((s == NULL) && !lds.stopped())
00434             break;
00435           f.limit(f.limit()+2);
00436         }
00437         return n == 0;
00438       }
00439     };
00440 
00442     template<class Model>
00443     class BAB : public Test {
00444     private:
00446       unsigned int c_d;
00448       unsigned int a_d;
00450       unsigned int t;
00451     public:
00453       BAB(HowToConstrain htc,
00454           HowToBranch htb1, HowToBranch htb2, HowToBranch htb3,
00455           unsigned int c_d0, unsigned int a_d0, unsigned int t0)
00456         : Test("BAB::"+Model::name()+"::"+str(htc)+"::"+
00457                str(htb1)+"::"+str(htb2)+"::"+str(htb3)+"::"+
00458                str(c_d0)+"::"+str(a_d0)+"::"+str(t0),
00459                htb1,htb2,htb3,htc), c_d(c_d0), a_d(a_d0), t(t0) {}
00461       virtual bool run(void) {
00462         Model* m = new Model(htb1,htb2,htb3,htc);
00463         Gecode::Search::FailStop f(2);
00464         Gecode::Search::Options o;
00465         o.c_d = c_d;
00466         o.a_d = a_d;
00467         o.threads = t;
00468         o.stop = &f;
00469         Gecode::BAB<Model> bab(m,o);
00470         delete m;
00471         Model* b = NULL;
00472         while (true) {
00473           Model* s = bab.next();
00474           if (s != NULL) {
00475             delete b; b=s;
00476           }
00477           if ((s == NULL) && !bab.stopped())
00478             break;
00479           f.limit(f.limit()+2);
00480         }
00481         bool ok = (b == NULL) || b->best();
00482         delete b;
00483         return ok;
00484       }
00485     };
00486 
00488     template<class Model, template<class> class Engine>
00489     class RBS : public Test {
00490     private:
00492       unsigned int t;
00493     public:
00495       RBS(const std::string& e, unsigned int t0)
00496         : Test("RBS::"+e+"::"+Model::name()+"::"+str(t0),
00497                HTB_BINARY,HTB_BINARY,HTB_BINARY), t(t0) {}
00499       virtual bool run(void) {
00500         Model* m = new Model(htb1,htb2,htb3);
00501         Gecode::Search::FailStop f(2);
00502         Gecode::Search::Options o;
00503         o.threads = t;
00504         o.stop = &f;
00505         o.d_l = 100;
00506         o.cutoff = Gecode::Search::Cutoff::geometric(1,2);
00507         Gecode::RBS<Model,Engine> rbs(m,o);
00508         int n = m->solutions();
00509         delete m;
00510         while (true) {
00511           Model* s = rbs.next();
00512           if (s != NULL) {
00513             n--; delete s;
00514           }
00515           if ((s == NULL) && !rbs.stopped())
00516             break;
00517           f.limit(f.limit()+2);
00518         }
00519         return n == 0;
00520       }
00521     };
00522 
00524     template<class Model, template<class> class Engine>
00525     class PBS : public Test {
00526     private:
00528       bool best;
00530       unsigned int a;
00532       unsigned int t;
00533     public:
00535       PBS(const std::string& e, bool b, unsigned int a0, unsigned int t0)
00536         : Test("PBS::"+e+"::"+Model::name()+"::"+str(a0)+"::"+str(t0),
00537                HTB_BINARY,HTB_BINARY,HTB_BINARY), best(b), a(a0), t(t0) {}
00539       virtual bool run(void) {
00540         Model* m = new Model(htb1,htb2,htb3);
00541         Gecode::Search::FailStop f(2);
00542         Gecode::Search::Options o;
00543         o.assets = a;
00544         o.threads = t;
00545         o.d_l = 100;
00546         o.stop = &f;
00547         Gecode::PBS<Model,Engine> pbs(m,o);
00548         if (best) {
00549           Model* b = NULL;
00550           while (true) {
00551             Model* s = pbs.next();
00552             if (s != NULL) {
00553               delete b; b=s;
00554             }
00555             if ((s == NULL) && !pbs.stopped())
00556               break;
00557             f.limit(f.limit()+2);
00558           }
00559           bool ok = (b == NULL) || b->best();
00560           delete b;
00561           return ok;
00562         } else {
00563           int n = ((t > 1) ? std::min(a,t) : a) * m->solutions();
00564           delete m;
00565           while (true) {
00566             Model* s = pbs.next();
00567             if (s != NULL) {
00568               n--; delete s;
00569             }
00570             if ((s == NULL) && !pbs.stopped())
00571               break;
00572             f.limit(f.limit()+2);
00573           }
00574           return n == 0;
00575         }
00576       }
00577     };
00578 
00580     template<class Model>
00581     class SEBPBS : public Test {
00582     private:
00584       bool best;
00586       unsigned int mt;
00588       unsigned int st;
00589     public:
00591       SEBPBS(const std::string& e, bool b, unsigned int mt0, unsigned int st0)
00592         : Test("PBS::SEB::"+e+"::"+Model::name()+"::"+str(mt0)+"::"+str(st0),
00593                HTB_BINARY,HTB_BINARY,HTB_BINARY), best(b), mt(mt0), st(st0) {}
00595       virtual bool run(void) {
00596         using namespace Gecode;
00597         Model* m = new Model(htb1,htb2,htb3);
00598         Gecode::Search::FailStop f(2);
00599 
00600         Gecode::Search::Options mo;
00601         mo.threads = mt;
00602         mo.d_l = 100;
00603         mo.stop = &f;
00604 
00605         Gecode::Search::Options so;
00606         so.threads = st;
00607         so.d_l = 100;
00608         so.cutoff = Gecode::Search::Cutoff::constant(1000000);
00609         if (best) {
00610           SEBs sebs(3);
00611           sebs[0] = bab<Model>(so);
00612           sebs[1] = bab<Model>(so);
00613           sebs[2] = rbs<Model,Gecode::BAB>(so);
00614           Gecode::PBS<Model,Gecode::BAB> pbs(m, sebs, mo);
00615           delete m;
00616 
00617           Model* b = NULL;
00618           while (true) {
00619             Model* s = pbs.next();
00620             if (s != NULL) {
00621               delete b; b=s;
00622             }
00623             if ((s == NULL) && !pbs.stopped())
00624               break;
00625             f.limit(f.limit()+2);
00626           }
00627           bool ok = (b == NULL) || b->best();
00628           delete b;
00629           return ok;
00630         } else {
00631           SEBs sebs(3);
00632           sebs[0] = dfs<Model>(so);
00633           sebs[1] = lds<Model>(so);
00634           sebs[2] = rbs<Model,Gecode::DFS>(so);
00635           Gecode::PBS<Model,Gecode::DFS> pbs(m, sebs, mo);
00636 
00637           int n = 3 * m->solutions();
00638           delete m;
00639 
00640           while (true) {
00641             Model* s = pbs.next();
00642             if (s != NULL) {
00643               n--; delete s;
00644             }
00645             if ((s == NULL) && !pbs.stopped())
00646               break;
00647             f.limit(f.limit()+2);
00648           }
00649           return n == 0;
00650         }
00651       }
00652     };
00653 
00655     class BranchTypes {
00656     private:
00658       static const HowToBranch htbs[3];
00660       int i;
00661     public:
00663       BranchTypes(void) : i(0) {}
00665       bool operator()(void) const {
00666         return i<3;
00667       }
00669       void operator++(void) {
00670         i++;
00671       }
00673       HowToBranch htb(void) const {
00674         return htbs[i];
00675       }
00676     };
00677 
00678     const HowToBranch BranchTypes::htbs[3] = {HTB_UNARY, HTB_BINARY, HTB_NARY};
00679 
00681     class ConstrainTypes {
00682     private:
00684       static const HowToConstrain htcs[4];
00686       int i;
00687     public:
00689       ConstrainTypes(void) : i(0) {}
00691       bool operator()(void) const {
00692         return i<4;
00693       }
00695       void operator++(void) {
00696         i++;
00697       }
00699       HowToConstrain htc(void) const {
00700         return htcs[i];
00701       }
00702     };
00703 
00704     const HowToConstrain ConstrainTypes::htcs[4] =
00705       {HTC_LEX_LE, HTC_LEX_GR, HTC_BAL_LE, HTC_BAL_GR};
00706 
00707 
00709     class Create {
00710     public:
00712       Create(void) {
00713         // Depth-first search
00714         for (unsigned int t = 1; t<=4; t++)
00715           for (unsigned int c_d = 1; c_d<10; c_d++)
00716             for (unsigned int a_d = 1; a_d<=c_d; a_d++) {
00717               for (BranchTypes htb1; htb1(); ++htb1)
00718                 for (BranchTypes htb2; htb2(); ++htb2)
00719                   for (BranchTypes htb3; htb3(); ++htb3)
00720                     (void) new DFS<HasSolutions>
00721                       (htb1.htb(),htb2.htb(),htb3.htb(),c_d, a_d, t);
00722               new DFS<FailImmediate>(HTB_NONE, HTB_NONE, HTB_NONE,
00723                                      c_d, a_d, t);
00724               new DFS<SolveImmediate>(HTB_NONE, HTB_NONE, HTB_NONE,
00725                                       c_d, a_d, t);
00726               new DFS<HasSolutions>(HTB_NONE, HTB_NONE, HTB_NONE,
00727                                     c_d, a_d, t);
00728             }
00729 
00730         // Limited discrepancy search
00731         for (unsigned int t = 1; t<=4; t++) {
00732           for (BranchTypes htb1; htb1(); ++htb1)
00733             for (BranchTypes htb2; htb2(); ++htb2)
00734               for (BranchTypes htb3; htb3(); ++htb3)
00735                 (void) new LDS<HasSolutions>(htb1.htb(),htb2.htb(),htb3.htb()
00736                                              ,t);
00737           new LDS<FailImmediate>(HTB_NONE, HTB_NONE, HTB_NONE, t);
00738           new LDS<HasSolutions>(HTB_NONE, HTB_NONE, HTB_NONE, t);
00739         }
00740 
00741         // Best solution search
00742         for (unsigned int t = 1; t<=4; t++)
00743           for (unsigned int c_d = 1; c_d<10; c_d++)
00744             for (unsigned int a_d = 1; a_d<=c_d; a_d++) {
00745               for (ConstrainTypes htc; htc(); ++htc)
00746                 for (BranchTypes htb1; htb1(); ++htb1)
00747                   for (BranchTypes htb2; htb2(); ++htb2)
00748                     for (BranchTypes htb3; htb3(); ++htb3) {
00749                       (void) new BAB<HasSolutions>
00750                         (htc.htc(),htb1.htb(),htb2.htb(),htb3.htb(),
00751                          c_d,a_d,t);
00752                   }
00753               (void) new BAB<FailImmediate>
00754                 (HTC_NONE,HTB_NONE,HTB_NONE,HTB_NONE,c_d,a_d,t);
00755               (void) new BAB<SolveImmediate>
00756                 (HTC_NONE,HTB_NONE,HTB_NONE,HTB_NONE,c_d,a_d,t);
00757               (void) new BAB<HasSolutions>
00758                 (HTC_NONE,HTB_NONE,HTB_NONE,HTB_NONE,c_d,a_d,t);
00759             }
00760         // Restart-based search
00761         for (unsigned int t=1; t<=4; t++) {
00762           (void) new RBS<HasSolutions,Gecode::DFS>("DFS",t);
00763           (void) new RBS<HasSolutions,Gecode::LDS>("LDS",t);
00764           (void) new RBS<HasSolutions,Gecode::BAB>("BAB",t);
00765           (void) new RBS<FailImmediate,Gecode::DFS>("DFS",t);
00766           (void) new RBS<FailImmediate,Gecode::LDS>("LDS",t);
00767           (void) new RBS<FailImmediate,Gecode::BAB>("BAB",t);
00768           (void) new RBS<SolveImmediate,Gecode::DFS>("DFS",t);
00769           (void) new RBS<SolveImmediate,Gecode::LDS>("LDS",t);
00770           (void) new RBS<SolveImmediate,Gecode::BAB>("BAB",t);
00771         }
00772         // Portfolio-based search
00773         for (unsigned int a=1; a<=4; a++)
00774           for (unsigned int t=1; t<=2*a; t++) {
00775             (void) new PBS<HasSolutions,Gecode::DFS>("DFS",false,a,t);
00776             (void) new PBS<HasSolutions,Gecode::LDS>("LDS",false,a,t);
00777             (void) new PBS<HasSolutions,Gecode::BAB>("BAB",true,a,t);
00778             (void) new PBS<FailImmediate,Gecode::DFS>("DFS",false,a,t);
00779             (void) new PBS<FailImmediate,Gecode::LDS>("LDS",false,a,t);
00780             (void) new PBS<FailImmediate,Gecode::BAB>("BAB",true,a,t);
00781             (void) new PBS<SolveImmediate,Gecode::DFS>("DFS",false,a,t);
00782             (void) new PBS<SolveImmediate,Gecode::LDS>("LDS",false,a,t);
00783             (void) new PBS<SolveImmediate,Gecode::BAB>("BAB",true,a,t);
00784           }
00785         // Portfolio-based search using SEBs
00786         for (unsigned int mt=1; mt<=3; mt += 2)
00787           for (unsigned int st=1; st<=8; st++) {
00788             (void) new SEBPBS<HasSolutions>("BAB",true,mt,st);
00789             (void) new SEBPBS<FailImmediate>("BAB",true,mt,st);
00790             (void) new SEBPBS<SolveImmediate>("BAB",true,mt,st);
00791             (void) new SEBPBS<HasSolutions>("DFS+LDS",false,mt,st);
00792             (void) new SEBPBS<FailImmediate>("DFS+LDS",false,mt,st);
00793             (void) new SEBPBS<SolveImmediate>("DFS+LDS",false,mt,st);
00794           }
00795       }
00796     };
00797 
00798     Create c;
00799   }
00800 
00801 }
00802 
00803 // STATISTICS: test-search