Generated on Fri Mar 20 15:55:58 2015 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  *  Last modified:
00010  *     $Date: 2013-07-08 19:23:25 +0200 (Mon, 08 Jul 2013) $ by $Author: schulte $
00011  *     $Revision: 13827 $
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 #ifndef __GECODE_INT_BRANCH_HH__
00039 #define __GECODE_INT_BRANCH_HH__
00040 
00041 #include <gecode/int.hh>
00042 
00048 namespace Gecode { namespace Int { namespace Branch {
00049 
00068   template<class View>
00069   class MeritMin : public MeritBase<View,int> {
00070   public:
00072     MeritMin(Space& home, const VarBranch& vb);
00074     MeritMin(Space& home, bool shared, MeritMin& m);
00076     int operator ()(const Space& home, View x, int i);
00077   };
00078 
00085   template<class View>
00086   class MeritMax : public MeritBase<View,int> {
00087   public:
00089     MeritMax(Space& home, const VarBranch& vb);
00091     MeritMax(Space& home, bool shared, MeritMax& m);
00093     int operator ()(const Space& home, View x, int i);
00094   };
00095 
00102   template<class View>
00103   class MeritSize : public MeritBase<View,unsigned int> {
00104   public:
00106     MeritSize(Space& home, const VarBranch& vb);
00108     MeritSize(Space& home, bool shared, MeritSize& m);
00110     unsigned int operator ()(const Space& home, View x, int i);
00111   };
00112 
00119   template<class View>
00120   class MeritDegreeSize : public MeritBase<View,double> {
00121   public:
00123     MeritDegreeSize(Space& home, const VarBranch& vb);
00125     MeritDegreeSize(Space& home, bool shared, 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   protected:
00140     AFC afc;
00141   public:
00143     MeritAFCSize(Space& home, const VarBranch& vb);
00145     MeritAFCSize(Space& home, bool shared, MeritAFCSize& m);
00147     double operator ()(const Space& home, View x, int i);
00149     bool notice(void) const;
00151     void dispose(Space& home);
00152   };
00153 
00160   template<class View>
00161   class MeritActivitySize : public MeritBase<View,double> {
00162   protected:
00164     Activity activity;
00165   public:
00167     MeritActivitySize(Space& home, const VarBranch& vb);
00169     MeritActivitySize(Space& home, bool shared, MeritActivitySize& m);
00171     double operator ()(const Space& home, View x, int i);
00173     bool notice(void) const;
00175     void dispose(Space& home);
00176   };
00177 
00184   template<class View>
00185   class MeritRegretMin : public MeritBase<View,unsigned int> {
00186   public:
00188     MeritRegretMin(Space& home, const VarBranch& vb);
00190     MeritRegretMin(Space& home, bool shared, MeritRegretMin& m);
00192     unsigned int operator ()(const Space& home, View x, int i);
00193   };
00194 
00201   template<class View>
00202   class MeritRegretMax : public MeritBase<View,unsigned int> {
00203   public:
00205     MeritRegretMax(Space& home, const VarBranch& vb);
00207     MeritRegretMax(Space& home, bool shared, MeritRegretMax& m);
00209     unsigned int operator ()(const Space& home, View x, int i);
00210   };
00211 
00212 }}}
00213 
00214 #include <gecode/int/branch/merit.hpp>
00215 
00216 namespace Gecode { namespace Int { namespace Branch {
00217 
00219   GECODE_INT_EXPORT
00220   ViewSel<IntView>* viewselint(Space& home, const IntVarBranch& ivb);
00222   GECODE_INT_EXPORT
00223   ViewSel<BoolView>* viewselbool(Space& home, const IntVarBranch& ivb);
00224 
00225 }}}
00226 
00227 namespace Gecode { namespace Int { namespace Branch {
00228 
00247   template<class View>
00248   class ValSelMin : public ValSel<View,int> {
00249   public:
00251     ValSelMin(Space& home, const ValBranch& vb);
00253     ValSelMin(Space& home, bool shared, ValSelMin& vs);
00255     int val(const Space& home, View x, int i);
00256   };
00257 
00264   template<class View>
00265   class ValSelMax : public ValSel<View,int> {
00266   public:
00268     ValSelMax(Space& home, const ValBranch& vb);
00270     ValSelMax(Space& home, bool shared, ValSelMax& vs);
00272     int val(const Space& home, View x, int i);
00273   };
00274 
00281   template<class View>
00282   class ValSelMed : public ValSel<View,int> {
00283   public:
00285     ValSelMed(Space& home, const ValBranch& vb);
00287     ValSelMed(Space& home, bool shared, ValSelMed& vs);
00289     int val(const Space& home, View x, int i);
00290   };
00291 
00298   template<class View>
00299   class ValSelAvg : public ValSel<View,int> {
00300   public:
00302     ValSelAvg(Space& home, const ValBranch& vb);
00304     ValSelAvg(Space& home, bool shared, ValSelAvg& vs);
00306     int val(const Space& home, View x, int i);
00307   };
00308 
00315   template<class View>
00316   class ValSelRnd : public ValSel<View,int> {
00317   protected:
00319     Rnd r;
00320   public:
00322     ValSelRnd(Space& home, const ValBranch& vb);
00324     ValSelRnd(Space& home, bool shared, ValSelRnd& vs);
00326     int val(const Space& home, View x, int i);
00328     bool notice(void) const;
00330     void dispose(Space& home);
00331   };
00332 
00339   class ValSelRangeMin : public ValSel<IntView,int> {
00340   public:
00342     ValSelRangeMin(Space& home, const ValBranch& vb);
00344     ValSelRangeMin(Space& home, bool shared, ValSelRangeMin& vs);
00346     int val(const Space& home, IntView x, int i);
00347   };
00348 
00355   class ValSelRangeMax : public ValSel<IntView,int> {
00356   public:
00358     ValSelRangeMax(Space& home, const ValBranch& vb);
00360     ValSelRangeMax(Space& home, bool shared, ValSelRangeMax& vs);
00362     int val(const Space& home, IntView x, int i);
00363   };
00364 
00371   template<class View, bool min>
00372   class ValSelNearMinMax : public ValSel<View,int> {
00373   protected:
00375     IntSharedArray c;
00376   public:
00378     ValSelNearMinMax(Space& home, const ValBranch& vb);
00380     ValSelNearMinMax(Space& home, bool shared, ValSelNearMinMax& vs);
00382     int val(const Space& home, View x, int i);
00384     bool notice(void) const;
00386     void dispose(Space& home);
00387   };
00388 
00395   template<class View, bool inc>
00396   class ValSelNearIncDec : public ValSel<View,int> {
00397   protected:
00399     IntSharedArray c;
00400   public:
00402     ValSelNearIncDec(Space& home, const ValBranch& vb);
00404     ValSelNearIncDec(Space& home, bool shared, ValSelNearIncDec& vs);
00406     int val(const Space& home, View x, int i);
00408     bool notice(void) const;
00410     void dispose(Space& home);
00411   };
00412 
00413 }}}
00414 
00415 #include <gecode/int/branch/val-sel.hpp>
00416 
00417 namespace Gecode { namespace Int { namespace Branch {
00418 
00420   template<class View>
00421   class EqNGL : public ViewValNGL<View,int,PC_INT_VAL> {
00422     using ViewValNGL<View,int,PC_INT_VAL>::x;
00423     using ViewValNGL<View,int,PC_INT_VAL>::n;
00424   public:
00426     EqNGL(Space& home, View x, int n);
00428     EqNGL(Space& home, bool share, EqNGL& ngl);
00430     virtual NGL::Status status(const Space& home) const;
00432     virtual ExecStatus prune(Space& home);
00434     virtual NGL* copy(Space& home, bool share);
00435   };
00436 
00438   template<class View>
00439   class NqNGL : public ViewValNGL<View,int,PC_INT_DOM> {
00440     using ViewValNGL<View,int,PC_INT_DOM>::x;
00441     using ViewValNGL<View,int,PC_INT_DOM>::n;
00442   public:
00444     NqNGL(Space& home, View x, int n);
00446     NqNGL(Space& home, bool share, NqNGL& ngl);
00448     virtual NGL::Status status(const Space& home) const;
00450     virtual ExecStatus prune(Space& home);
00452     virtual NGL* copy(Space& home, bool share);
00453   };
00454 
00456   template<class View>
00457   class LqNGL : public ViewValNGL<View,int,PC_INT_BND> {
00458     using ViewValNGL<View,int,PC_INT_BND>::x;
00459     using ViewValNGL<View,int,PC_INT_BND>::n;
00460   public:
00462     LqNGL(Space& home, View x, int n);
00464     LqNGL(Space& home, bool share, LqNGL& ngl);
00466     virtual NGL::Status status(const Space& home) const;
00468     virtual ExecStatus prune(Space& home);
00470     virtual NGL* copy(Space& home, bool share);
00471   };
00472 
00474   template<class View>
00475   class GqNGL : public ViewValNGL<View,int,PC_INT_BND> {
00476     using ViewValNGL<View,int,PC_INT_BND>::x;
00477     using ViewValNGL<View,int,PC_INT_BND>::n;
00478   public:
00480     GqNGL(Space& home, View x, int n);
00482     GqNGL(Space& home, bool share, GqNGL& ngl);
00484     virtual NGL::Status status(const Space& home) const;
00486     virtual ExecStatus prune(Space& home);
00488     virtual NGL* copy(Space& home, bool share);
00489   };
00490 
00491 }}}
00492 
00493 #include <gecode/int/branch/ngl.hpp>
00494 
00495 namespace Gecode { namespace Int { namespace Branch {
00496 
00515   template<class View>
00516   class ValCommitEq : public ValCommit<View,int> {
00517   public:
00519     ValCommitEq(Space& home, const ValBranch& vb);
00521     ValCommitEq(Space& home, bool shared, ValCommitEq& vc);
00523     ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00525     NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00527     void print(const Space& home, unsigned int a, View x, int i, int n,
00528                std::ostream& o) const;
00529   };
00530 
00537   template<class View>
00538   class ValCommitLq : public ValCommit<View,int> {
00539   public:
00541     ValCommitLq(Space& home, const ValBranch& vb);
00543     ValCommitLq(Space& home, bool shared, ValCommitLq& vc);
00545     ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00547     NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00549     void print(const Space& home, unsigned int a, View x, int i, int n,
00550                std::ostream& o) const;
00551   };
00552 
00559   template<class View>
00560   class ValCommitGq : public ValCommit<View,int> {
00561   public:
00563     ValCommitGq(Space& home, const ValBranch& vb);
00565     ValCommitGq(Space& home, bool shared, ValCommitGq& vc);
00567     ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00569     NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00571     void print(const Space& home, unsigned int a, View x, int i, int n,
00572                std::ostream& o) const;
00573   };
00574 
00581   template<class View>
00582   class ValCommitGr : public ValCommit<View,int> {
00583   public:
00585     ValCommitGr(Space& home, const ValBranch& vb);
00587     ValCommitGr(Space& home, bool shared, ValCommitGr& vc);
00589     ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00591     NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00593     void print(const Space& home, unsigned int a, View x, int i, int n,
00594                std::ostream& o) const;
00595   };
00596 
00597 }}}
00598 
00599 #include <gecode/int/branch/val-commit.hpp>
00600 
00601 namespace Gecode { namespace Int { namespace Branch {
00602 
00604   GECODE_INT_EXPORT
00605   ValSelCommitBase<IntView,int>* 
00606   valselcommitint(Space& home, int n, const IntValBranch& ivb);
00607 
00609   GECODE_INT_EXPORT
00610   ValSelCommitBase<BoolView,int>* 
00611   valselcommitbool(Space& home, int n, const IntValBranch& ivb);
00612 
00614   GECODE_INT_EXPORT
00615   ValSelCommitBase<IntView,int>* 
00616   valselcommitint(Space& home, const IntAssign& ia);
00617 
00619   GECODE_INT_EXPORT
00620   ValSelCommitBase<BoolView,int>* 
00621   valselcommitbool(Space& home, const IntAssign& ia);
00622 
00623 }}}
00624 
00625 namespace Gecode { namespace Int { namespace Branch {
00626 
00631   template<int n, bool min>
00632   class ViewValuesBrancher : public ViewBrancher<IntView,n> {
00633     typedef typename ViewBrancher<IntView,n>::BranchFilter BranchFilter;
00634   protected:
00635     using ViewBrancher<IntView,n>::x;
00637     IntVarValPrint vvp;
00639     ViewValuesBrancher(Space& home, bool shared, ViewValuesBrancher& b);
00641     ViewValuesBrancher(Home home, ViewArray<IntView>& x,
00642                        ViewSel<IntView>* vs[n], 
00643                        BranchFilter bf, IntVarValPrint vvp);
00644   public:
00646     virtual const Choice* choice(Space& home);
00648     virtual const Choice* choice(const Space& home, Archive& e);
00650     virtual ExecStatus commit(Space& home, const Choice& c, unsigned int a);
00652     virtual NGL* ngl(Space& home, const Choice& c, unsigned int a) const;
00660     virtual void print(const Space& home, const Choice& c, unsigned int a,
00661                        std::ostream& o) const;
00663     virtual Actor* copy(Space& home, bool share);
00665     static BrancherHandle post(Home home, ViewArray<IntView>& x,
00666                                ViewSel<IntView>* vs[n], 
00667                                BranchFilter bf, IntVarValPrint vvp);
00668   };
00669 
00670 }}}
00671 
00672 #include <gecode/int/branch/view-values.hpp>
00673 
00674 #endif
00675 
00676 // STATISTICS: int-branch