Generated on Tue May 22 09:39:40 2018 for Gecode by doxygen 1.6.3

branch.hh

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, 2012
00008  *
00009  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 #ifndef __GECODE_INT_BRANCH_HH__
00035 #define __GECODE_INT_BRANCH_HH__
00036 
00037 #include <gecode/int.hh>
00038 
00044 namespace Gecode { namespace Int { namespace Branch {
00045 
00064   template<class View>
00065   class MeritMin : public MeritBase<View,int> {
00066   public:
00067     using typename MeritBase<View,int>::Var;
00069     MeritMin(Space& home, const VarBranch<Var>& vb);
00071     MeritMin(Space& home, MeritMin& m);
00073     int operator ()(const Space& home, View x, int i);
00074   };
00075 
00082   template<class View>
00083   class MeritMax : public MeritBase<View,int> {
00084   public:
00085     using typename MeritBase<View,int>::Var;
00087     MeritMax(Space& home, const VarBranch<Var>& vb);
00089     MeritMax(Space& home, MeritMax& m);
00091     int operator ()(const Space& home, View x, int i);
00092   };
00093 
00100   template<class View>
00101   class MeritSize : public MeritBase<View,unsigned int> {
00102   public:
00103     using typename MeritBase<View,unsigned int>::Var;
00105     MeritSize(Space& home, const VarBranch<Var>& vb);
00107     MeritSize(Space& home, MeritSize& m);
00109     unsigned int operator ()(const Space& home, View x, int i);
00110   };
00111 
00118   template<class View>
00119   class MeritDegreeSize : public MeritBase<View,double> {
00120   public:
00121     using typename MeritBase<View,double>::Var;
00123     MeritDegreeSize(Space& home, const VarBranch<Var>& vb);
00125     MeritDegreeSize(Space& home, MeritDegreeSize& m);
00127     double operator ()(const Space& home, View x, int i);
00128   };
00129 
00136   template<class View>
00137   class MeritAFCSize : public MeritBase<View,double> {
00138     using typename MeritBase<View,double>::Var;
00139   protected:
00141     AFC afc;
00142   public:
00144     MeritAFCSize(Space& home, const VarBranch<Var>& vb);
00146     MeritAFCSize(Space& home, MeritAFCSize& m);
00148     double operator ()(const Space& home, View x, int i);
00150     bool notice(void) const;
00152     void dispose(Space& home);
00153   };
00154 
00161   template<class View>
00162   class MeritActionSize : public MeritBase<View,double> {
00163     using typename MeritBase<View,double>::Var;
00164   protected:
00166     Action action;
00167   public:
00169     MeritActionSize(Space& home, const VarBranch<Var>& vb);
00171     MeritActionSize(Space& home, MeritActionSize& m);
00173     double operator ()(const Space& home, View x, int i);
00175     bool notice(void) const;
00177     void dispose(Space& home);
00178   };
00179 
00186   template<class View>
00187   class MeritCHBSize : public MeritBase<View,double> {
00188     using typename MeritBase<View,double>::Var;
00189   protected:
00191     CHB chb;
00192   public:
00194     MeritCHBSize(Space& home, const VarBranch<Var>& vb);
00196     MeritCHBSize(Space& home, MeritCHBSize& m);
00198     double operator ()(const Space& home, View x, int i);
00200     bool notice(void) const;
00202     void dispose(Space& home);
00203   };
00204 
00211   template<class View>
00212   class MeritRegretMin : public MeritBase<View,unsigned int> {
00213   public:
00214     using typename MeritBase<View,unsigned int>::Var;
00216     MeritRegretMin(Space& home, const VarBranch<Var>& vb);
00218     MeritRegretMin(Space& home, MeritRegretMin& m);
00220     unsigned int operator ()(const Space& home, View x, int i);
00221   };
00222 
00229   template<class View>
00230   class MeritRegretMax : public MeritBase<View,unsigned int> {
00231   public:
00232     using typename MeritBase<View,unsigned int>::Var;
00234     MeritRegretMax(Space& home, const VarBranch<Var>& vb);
00236     MeritRegretMax(Space& home, MeritRegretMax& m);
00238     unsigned int operator ()(const Space& home, View x, int i);
00239   };
00240 
00241 }}}
00242 
00243 #include <gecode/int/branch/merit.hpp>
00244 
00245 namespace Gecode { namespace Int { namespace Branch {
00246 
00248   GECODE_INT_EXPORT
00249   ViewSel<IntView>* viewsel(Space& home, const IntVarBranch& ivb);
00251   GECODE_INT_EXPORT
00252   ViewSel<BoolView>* viewsel(Space& home, const BoolVarBranch& bvb);
00253 
00254 }}}
00255 
00256 namespace Gecode { namespace Int { namespace Branch {
00257 
00276   template<class View>
00277   class ValSelMin : public ValSel<View,int> {
00278   public:
00279     using typename ValSel<View,int>::Var;
00281     ValSelMin(Space& home, const ValBranch<Var>& vb);
00283     ValSelMin(Space& home, ValSelMin& vs);
00285     int val(const Space& home, View x, int i);
00286   };
00287 
00294   template<class View>
00295   class ValSelMax : public ValSel<View,int> {
00296   public:
00297     using typename ValSel<View,int>::Var;
00299     ValSelMax(Space& home, const ValBranch<Var>& vb);
00301     ValSelMax(Space& home, ValSelMax& vs);
00303     int val(const Space& home, View x, int i);
00304   };
00305 
00312   template<class View>
00313   class ValSelMed : public ValSel<View,int> {
00314   public:
00315     using typename ValSel<View,int>::Var;
00317     ValSelMed(Space& home, const ValBranch<Var>& vb);
00319     ValSelMed(Space& home, ValSelMed& vs);
00321     int val(const Space& home, View x, int i);
00322   };
00323 
00330   template<class View>
00331   class ValSelAvg : public ValSel<View,int> {
00332   public:
00333     using typename ValSel<View,int>::Var;
00335     ValSelAvg(Space& home, const ValBranch<Var>& vb);
00337     ValSelAvg(Space& home, ValSelAvg& vs);
00339     int val(const Space& home, View x, int i);
00340   };
00341 
00348   template<class View>
00349   class ValSelRnd : public ValSel<View,int> {
00350     using typename ValSel<View,int>::Var;
00351   protected:
00353     Rnd r;
00354   public:
00356     ValSelRnd(Space& home, const ValBranch<Var>& vb);
00358     ValSelRnd(Space& home, ValSelRnd& vs);
00360     int val(const Space& home, View x, int i);
00362     bool notice(void) const;
00364     void dispose(Space& home);
00365   };
00366 
00373   class ValSelRangeMin : public ValSel<IntView,int> {
00374   public:
00376     ValSelRangeMin(Space& home, const ValBranch<IntVar>& vb);
00378     ValSelRangeMin(Space& home, ValSelRangeMin& vs);
00380     int val(const Space& home, IntView x, int i);
00381   };
00382 
00389   class ValSelRangeMax : public ValSel<IntView,int> {
00390   public:
00392     ValSelRangeMax(Space& home, const ValBranch<IntVar>& vb);
00394     ValSelRangeMax(Space& home, ValSelRangeMax& vs);
00396     int val(const Space& home, IntView x, int i);
00397   };
00398 
00399 }}}
00400 
00401 #include <gecode/int/branch/val-sel.hpp>
00402 
00403 namespace Gecode { namespace Int { namespace Branch {
00404 
00406   template<class View>
00407   class EqNGL : public ViewValNGL<View,int,PC_INT_VAL> {
00408     using ViewValNGL<View,int,PC_INT_VAL>::x;
00409     using ViewValNGL<View,int,PC_INT_VAL>::n;
00410   public:
00412     EqNGL(Space& home, View x, int n);
00414     EqNGL(Space& home, EqNGL& ngl);
00416     virtual NGL::Status status(const Space& home) const;
00418     virtual ExecStatus prune(Space& home);
00420     virtual NGL* copy(Space& home);
00421   };
00422 
00424   template<class View>
00425   class NqNGL : public ViewValNGL<View,int,PC_INT_DOM> {
00426     using ViewValNGL<View,int,PC_INT_DOM>::x;
00427     using ViewValNGL<View,int,PC_INT_DOM>::n;
00428   public:
00430     NqNGL(Space& home, View x, int n);
00432     NqNGL(Space& home, NqNGL& ngl);
00434     virtual NGL::Status status(const Space& home) const;
00436     virtual ExecStatus prune(Space& home);
00438     virtual NGL* copy(Space& home);
00439   };
00440 
00442   template<class View>
00443   class LqNGL : public ViewValNGL<View,int,PC_INT_BND> {
00444     using ViewValNGL<View,int,PC_INT_BND>::x;
00445     using ViewValNGL<View,int,PC_INT_BND>::n;
00446   public:
00448     LqNGL(Space& home, View x, int n);
00450     LqNGL(Space& home, LqNGL& ngl);
00452     virtual NGL::Status status(const Space& home) const;
00454     virtual ExecStatus prune(Space& home);
00456     virtual NGL* copy(Space& home);
00457   };
00458 
00460   template<class View>
00461   class GqNGL : public ViewValNGL<View,int,PC_INT_BND> {
00462     using ViewValNGL<View,int,PC_INT_BND>::x;
00463     using ViewValNGL<View,int,PC_INT_BND>::n;
00464   public:
00466     GqNGL(Space& home, View x, int n);
00468     GqNGL(Space& home, GqNGL& ngl);
00470     virtual NGL::Status status(const Space& home) const;
00472     virtual ExecStatus prune(Space& home);
00474     virtual NGL* copy(Space& home);
00475   };
00476 
00477 }}}
00478 
00479 #include <gecode/int/branch/ngl.hpp>
00480 
00481 namespace Gecode { namespace Int { namespace Branch {
00482 
00501   template<class View>
00502   class ValCommitEq : public ValCommit<View,int> {
00503   public:
00504     using typename ValCommit<View,int>::Var;
00506     ValCommitEq(Space& home, const ValBranch<Var>& vb);
00508     ValCommitEq(Space& home, ValCommitEq& vc);
00510     ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00512     NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00514     void print(const Space& home, unsigned int a, View x, int i, int n,
00515                std::ostream& o) const;
00516   };
00517 
00524   template<class View>
00525   class ValCommitLq : public ValCommit<View,int> {
00526   public:
00527     using typename ValCommit<View,int>::Var;
00529     ValCommitLq(Space& home, const ValBranch<Var>& vb);
00531     ValCommitLq(Space& home, ValCommitLq& vc);
00533     ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00535     NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00537     void print(const Space& home, unsigned int a, View x, int i, int n,
00538                std::ostream& o) const;
00539   };
00540 
00547   template<class View>
00548   class ValCommitGq : public ValCommit<View,int> {
00549   public:
00550     using typename ValCommit<View,int>::Var;
00552     ValCommitGq(Space& home, const ValBranch<Var>& vb);
00554     ValCommitGq(Space& home, ValCommitGq& vc);
00556     ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00558     NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00560     void print(const Space& home, unsigned int a, View x, int i, int n,
00561                std::ostream& o) const;
00562   };
00563 
00570   template<class View>
00571   class ValCommitGr : public ValCommit<View,int> {
00572   public:
00573     using typename ValCommit<View,int>::Var;
00575     ValCommitGr(Space& home, const ValBranch<Var>& vb);
00577     ValCommitGr(Space& home, ValCommitGr& vc);
00579     ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00581     NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00583     void print(const Space& home, unsigned int a, View x, int i, int n,
00584                std::ostream& o) const;
00585   };
00586 
00587 }}}
00588 
00589 #include <gecode/int/branch/val-commit.hpp>
00590 
00591 namespace Gecode { namespace Int { namespace Branch {
00592 
00594   GECODE_INT_EXPORT
00595   ValSelCommitBase<IntView,int>*
00596   valselcommit(Space& home, const IntValBranch& ivb);
00597 
00599   GECODE_INT_EXPORT
00600   ValSelCommitBase<BoolView,int>*
00601   valselcommit(Space& home, const BoolValBranch& bvb);
00602 
00604   GECODE_INT_EXPORT
00605   ValSelCommitBase<IntView,int>*
00606   valselcommit(Space& home, const IntAssign& ia);
00607 
00609   GECODE_INT_EXPORT
00610   ValSelCommitBase<BoolView,int>*
00611   valselcommit(Space& home, const BoolAssign& ba);
00612 
00613 }}}
00614 
00615 namespace Gecode { namespace Int { namespace Branch {
00616 
00621   template<int n, bool min, class Filter, class Print>
00622   class ViewValuesBrancher : public ViewBrancher<IntView,Filter,n> {
00623   protected:
00624     using ViewBrancher<IntView,Filter,n>::x;
00625     using ViewBrancher<IntView,Filter,n>::f;
00627     Print p;
00629     ViewValuesBrancher(Space& home, ViewValuesBrancher& b);
00631     ViewValuesBrancher(Home home, ViewArray<IntView>& x,
00632                        ViewSel<IntView>* vs[n],
00633                        IntBranchFilter bf,
00634                        IntVarValPrint vvp);
00635   public:
00637     virtual const Choice* choice(Space& home);
00639     virtual const Choice* choice(const Space& home, Archive& e);
00641     virtual ExecStatus commit(Space& home, const Choice& c, unsigned int a);
00643     virtual NGL* ngl(Space& home, const Choice& c, unsigned int a) const;
00651     virtual void print(const Space& home, const Choice& c, unsigned int a,
00652                        std::ostream& o) const;
00654     virtual Actor* copy(Space& home);
00656     static void post(Home home, ViewArray<IntView>& x,
00657                      ViewSel<IntView>* vs[n],
00658                      IntBranchFilter bf,
00659                      IntVarValPrint vvp);
00661     virtual size_t dispose(Space& home);
00662   };
00663 
00665   template<int n, bool min>
00666   void postviewvaluesbrancher(Home home, ViewArray<IntView>& x,
00667                               ViewSel<IntView>* vs[n],
00668                               IntBranchFilter bf,
00669                               IntVarValPrint vvp);
00670 
00671 }}}
00672 
00673 #include <gecode/int/branch/view-values.hpp>
00674 
00675 #endif
00676 
00677 // STATISTICS: int-branch