Generated on Thu Mar 22 10:39:34 2012 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, 2002
00008  *
00009  *  Last modified:
00010  *     $Date: 2011-05-11 12:44:17 +0200 (Wed, 11 May 2011) $ by $Author: tack $
00011  *     $Revision: 12001 $
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 
00050   /*
00051    * Value selection classes
00052    *
00053    */
00054 
00062   template<class View>
00063   class ValMin : public ValSelBase<View,int> {
00064   public:
00066     ValMin(void);
00068     ValMin(Space& home, const ValBranchOptions& vbo);
00070     int val(Space& home, View x) const;
00072     ModEvent tell(Space& home, unsigned int a, View x, int n);
00073   };
00074 
00082   template<class View>
00083   class ValMed : public ValSelBase<View,int> {
00084   public:
00086     ValMed(void);
00088     ValMed(Space& home, const ValBranchOptions& vbo);
00090     int val(Space& home, View x) const;
00092     ModEvent tell(Space& home, unsigned int a, View x, int n);
00093   };
00094 
00102   template<class _View>
00103   class ValRnd {
00104   protected:
00106     ArchivedRandomGenerator r;
00107   public:
00109     typedef _View View;
00111     typedef int Val;
00113     typedef ArchivedRandomGenerator Choice;
00115     static const unsigned int alternatives = 2;
00117     ValRnd(void);
00119     ValRnd(Space& home, const ValBranchOptions& vbo);
00121     int val(Space& home, _View x);
00123     ModEvent tell(Space& home, unsigned int a, _View x, int n);
00125     Choice choice(Space& home);
00127     Choice choice(const Space& home, Archive& e);
00129     void commit(Space& home, const Choice& c, unsigned a);
00131     void update(Space& home, bool share, ValRnd& vs);
00133     void dispose(Space& home);
00134   };
00135 
00144   template<class View>
00145   class ValSplitMin : public ValSelBase<View,int> {
00146   public:
00148     ValSplitMin(void);
00150     ValSplitMin(Space& home, const ValBranchOptions& vbo);
00152     int val(Space& home, View x) const;
00154     ModEvent tell(Space& home, unsigned int a, View x, int n);
00155   };
00156 
00157 
00166   template<class View>
00167   class ValRangeMin : public ValSelBase<View,int> {
00168   public:
00170     ValRangeMin(void);
00172     ValRangeMin(Space& home, const ValBranchOptions& vbo);
00174     int val(Space& home, View x) const;
00176     ModEvent tell(Space& home, unsigned int a, View x, int n);
00177   };
00178 
00179 
00181   class NoValue {};
00182 
00183 }}}
00184 
00185 namespace Gecode {
00186   forceinline Archive&
00187   operator >>(Archive& e, Gecode::Int::Branch::NoValue&) {
00188     return e;
00189   }
00190   forceinline Archive&
00191   operator <<(Archive& e, const Gecode::Int::Branch::NoValue&) {
00192     return e;
00193   }
00194 }
00195 
00196 namespace Gecode { namespace Int { namespace Branch {
00197 
00205   template<class View>
00206   class ValZeroOne : public ValSelBase<View,NoValue> {
00207   public:
00209     ValZeroOne(void);
00211     ValZeroOne(Space& home, const ValBranchOptions& vbo);
00213     NoValue val(Space& home, View x) const;
00215     ModEvent tell(Space& home, unsigned int a, View x, NoValue n);
00216   };
00217 
00218 
00223   template<class ViewSel, class View>
00224   class ViewValuesBrancher : public ViewBrancher<ViewSel> {
00225   protected:
00226     using ViewBrancher<ViewSel>::x;
00227     using ViewBrancher<ViewSel>::viewsel;
00229     ViewValuesBrancher(Space& home, bool share, ViewValuesBrancher& b);
00231     ViewValuesBrancher(Home home, ViewArray<typename ViewSel::View>& x,
00232                        ViewSel& vi_s, BranchFilter bf);
00233   public:
00235     virtual const Choice* choice(Space& home);
00237     virtual const Choice* choice(const Space& home, Archive& e);
00239     virtual ExecStatus commit(Space& home, const Choice& c, unsigned int a);
00241     virtual Actor* copy(Space& home, bool share);
00243     static void post(Home home, ViewArray<typename ViewSel::View>& x,
00244                      ViewSel& vi_s, BranchFilter bf=NULL);
00245   };
00246 
00247 
00249   template<class View>
00250   class AssignValMin : public ValMin<View> {
00251   public:
00253     static const unsigned int alternatives = 1;
00255     AssignValMin(void);
00257     AssignValMin(Space& home, const ValBranchOptions& vbo);
00258   };
00259 
00261   template<class View>
00262   class AssignValMed : public ValMed<View> {
00263   public:
00265     static const unsigned int alternatives = 1;
00267     AssignValMed(void);
00269     AssignValMed(Space& home, const ValBranchOptions& vbo);
00270   };
00271 
00273   template<class View>
00274   class AssignValRnd : public ValRnd<View> {
00275   public:
00277     static const unsigned int alternatives = 1;
00279     AssignValRnd(void);
00281     AssignValRnd(Space& home, const ValBranchOptions& vbo);
00282   };
00283 
00285   template<class View>
00286   class AssignValZero : public ValZeroOne<View> {
00287   public:
00289     static const unsigned int alternatives = 1;
00291     AssignValZero(void);
00293     AssignValZero(Space& home, const ValBranchOptions& vbo);
00294   };
00295 
00296   /*
00297    * Variable selection classes
00298    *
00299    */
00300 
00307   class ByMinMin : public ViewSelBase<IntView> {
00308   protected:
00310     int min;
00311   public:
00313     ByMinMin(void);
00315     ByMinMin(Space& home, const VarBranchOptions& vbo);
00317     ViewSelStatus init(Space& home, IntView x);
00319     ViewSelStatus select(Space& home, IntView x);
00320   };
00321 
00328   class ByMinMax : public ViewSelBase<IntView> {
00329   protected:
00331     int min;
00332   public:
00334     ByMinMax(void);
00336     ByMinMax(Space& home, const VarBranchOptions& vbo);
00338     ViewSelStatus init(Space& home, IntView x);
00340     ViewSelStatus select(Space& home, IntView x);
00341   };
00342 
00349   class ByMaxMin : public ViewSelBase<IntView> {
00350   protected:
00352     int max;
00353   public:
00355     ByMaxMin(void);
00357     ByMaxMin(Space& home, const VarBranchOptions& vbo);
00359     ViewSelStatus init(Space& home, IntView x);
00361     ViewSelStatus select(Space& home, IntView x);
00362   };
00363 
00370   class ByMaxMax : public ViewSelBase<IntView> {
00371   protected:
00373     int max;
00374   public:
00376     ByMaxMax(void);
00378     ByMaxMax(Space& home, const VarBranchOptions& vbo);
00380     ViewSelStatus init(Space& home, IntView x);
00382     ViewSelStatus select(Space& home, IntView x);
00383   };
00384 
00391   class BySizeMin : public ViewSelBase<IntView> {
00392   protected:
00394     unsigned int size;
00395   public:
00397     BySizeMin(void);
00399     BySizeMin(Space& home, const VarBranchOptions& vbo);
00401     ViewSelStatus init(Space& home, IntView x);
00403     ViewSelStatus select(Space& home, IntView x);
00404   };
00405 
00412   class BySizeMax : public ViewSelBase<IntView> {
00413   protected:
00415     unsigned int size;
00416   public:
00418     BySizeMax(void);
00420     BySizeMax(Space& home, const VarBranchOptions& vbo);
00422     ViewSelStatus init(Space& home, IntView x);
00424     ViewSelStatus select(Space& home, IntView x);
00425   };
00426 
00434   class BySizeDegreeMin : public ViewSelBase<IntView> {
00435   protected:
00437     double sizedegree;
00438   public:
00440     BySizeDegreeMin(void);
00442     BySizeDegreeMin(Space& home, const VarBranchOptions& vbo);
00444     ViewSelStatus init(Space& home, IntView x);
00446     ViewSelStatus select(Space& home, IntView x);
00447   };
00448 
00456   class BySizeDegreeMax : public ViewSelBase<IntView> {
00457   protected:
00459     double sizedegree;
00460   public:
00462     BySizeDegreeMax(void);
00464     BySizeDegreeMax(Space& home, const VarBranchOptions& vbo);
00466     ViewSelStatus init(Space& home, IntView x);
00468     ViewSelStatus select(Space& home, IntView x);
00469   };
00470 
00477   class BySizeAfcMin : public ViewSelBase<IntView> {
00478   protected:
00480     double sizeafc;
00481   public:
00483     BySizeAfcMin(void);
00485     BySizeAfcMin(Space& home, const VarBranchOptions& vbo);
00487     ViewSelStatus init(Space& home, IntView x);
00489     ViewSelStatus select(Space& home, IntView x);
00490   };
00491 
00498   class BySizeAfcMax : public ViewSelBase<IntView> {
00499   protected:
00501     double sizeafc;
00502   public:
00504     BySizeAfcMax(void);
00506     BySizeAfcMax(Space& home, const VarBranchOptions& vbo);
00508     ViewSelStatus init(Space& home, IntView x);
00510     ViewSelStatus select(Space& home, IntView x);
00511   };
00512 
00519   class ByRegretMinMin : public ViewSelBase<IntView> {
00520   protected:
00522     unsigned int regret;
00523   public:
00525     ByRegretMinMin(void);
00527     ByRegretMinMin(Space& home, const VarBranchOptions& vbo);
00529     ViewSelStatus init(Space& home, IntView x);
00531     ViewSelStatus select(Space& home, IntView x);
00532   };
00533 
00540   class ByRegretMinMax : public ViewSelBase<IntView> {
00541   protected:
00543     unsigned int regret;
00544   public:
00546     ByRegretMinMax(void);
00548     ByRegretMinMax(Space& home, const VarBranchOptions& vbo);
00550     ViewSelStatus init(Space& home, IntView x);
00552     ViewSelStatus select(Space& home, IntView x);
00553   };
00554 
00561   class ByRegretMaxMin : public ViewSelBase<IntView> {
00562   protected:
00564     unsigned int regret;
00565   public:
00567     ByRegretMaxMin(void);
00569     ByRegretMaxMin(Space& home, const VarBranchOptions& vbo);
00571     ViewSelStatus init(Space& home, IntView x);
00573     ViewSelStatus select(Space& home, IntView x);
00574   };
00575 
00582   class ByRegretMaxMax : public ViewSelBase<IntView> {
00583   protected:
00585     unsigned int regret;
00586   public:
00588     ByRegretMaxMax(void);
00590     ByRegretMaxMax(Space& home, const VarBranchOptions& vbo);
00592     ViewSelStatus init(Space& home, IntView x);
00594     ViewSelStatus select(Space& home, IntView x);
00595   };
00596 
00597 }}}
00598 
00599 #include <gecode/int/branch/select-val.hpp>
00600 #include <gecode/int/branch/select-values.hpp>
00601 #include <gecode/int/branch/select-view.hpp>
00602 #include <gecode/int/branch/post-val-int.hpp>
00603 #include <gecode/int/branch/post-val-bool.hpp>
00604 
00605 #endif
00606 
00607 // STATISTICS: int-branch