Generated on Mon Jul 6 18:09:05 2009 for Gecode by doxygen 1.5.9

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: 2009-05-14 00:24:31 +0200 (Thu, 14 May 2009) $ by $Author: tack $
00011  *     $Revision: 9095 $
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     Support::RandomGenerator r;
00107   public:
00109     typedef _View View;
00111     typedef int Val;
00113     typedef Support::RandomGenerator Desc;
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     Support::RandomGenerator description(Space& home);
00127     void commit(Space& home, const Support::RandomGenerator& d, unsigned a);
00129     void update(Space& home, bool share, ValRnd& vs);
00131     void dispose(Space& home);
00132   };
00133 
00142   template<class View>
00143   class ValSplitMin : public ValSelBase<View,int> {
00144   public:
00146     ValSplitMin(void);
00148     ValSplitMin(Space& home, const ValBranchOptions& vbo);
00150     int val(Space& home, View x) const;
00152     ModEvent tell(Space& home, unsigned int a, View x, int n);
00153   };
00154 
00155 
00157   class NoValue {};
00158 
00166   template<class View>
00167   class ValZeroOne : public ValSelBase<View,NoValue> {
00168   public:
00170     ValZeroOne(void);
00172     ValZeroOne(Space& home, const ValBranchOptions& vbo);
00174     NoValue val(Space& home, View x) const;
00176     ModEvent tell(Space& home, unsigned int a, View x, NoValue n);
00177   };
00178 
00179 
00184   template <class ViewSel, class View>
00185   class ViewValuesBranching : public ViewBranching<ViewSel> {
00186   protected:
00187     using ViewBranching<ViewSel>::x;
00188     using ViewBranching<ViewSel>::viewsel;
00190     ViewValuesBranching(Space& home, bool share, ViewValuesBranching& b);
00191   public:
00193     ViewValuesBranching(Space& home, ViewArray<typename ViewSel::View>& x,
00194                         ViewSel& vi_s);
00196     virtual const BranchingDesc* description(Space& home);
00198     virtual ExecStatus commit(Space& home, const BranchingDesc& d,
00199                               unsigned int a);
00201     virtual Actor* copy(Space& home, bool share);
00202   };
00203 
00204 
00206   template<class View>
00207   class AssignValMin : public ValMin<View> {
00208   public:
00210     static const unsigned int alternatives = 1;
00212     AssignValMin(void);
00214     AssignValMin(Space& home, const ValBranchOptions& vbo);
00215   };
00216 
00218   template<class View>
00219   class AssignValMed : public ValMed<View> {
00220   public:
00222     static const unsigned int alternatives = 1;
00224     AssignValMed(void);
00226     AssignValMed(Space& home, const ValBranchOptions& vbo);
00227   };
00228 
00230   template<class View>
00231   class AssignValRnd : public ValRnd<View> {
00232   public:
00234     static const unsigned int alternatives = 1;
00236     AssignValRnd(void);
00238     AssignValRnd(Space& home, const ValBranchOptions& vbo);
00239   };
00240 
00242   template<class View>
00243   class AssignValZero : public ValZeroOne<View> {
00244   public:
00246     static const unsigned int alternatives = 1;
00248     AssignValZero(void);
00250     AssignValZero(Space& home, const ValBranchOptions& vbo);
00251   };
00252 
00253   /*
00254    * Variable selection classes
00255    *
00256    */
00257 
00264   class ByMinMin : public ViewSelBase<IntView> {
00265   protected:
00267     int min;
00268   public:
00270     ByMinMin(void);
00272     ByMinMin(Space& home, const VarBranchOptions& vbo);
00274     ViewSelStatus init(Space& home, IntView x);
00276     ViewSelStatus select(Space& home, IntView x);
00277   };
00278 
00285   class ByMinMax : public ViewSelBase<IntView> {
00286   protected:
00288     int min;
00289   public:
00291     ByMinMax(void);
00293     ByMinMax(Space& home, const VarBranchOptions& vbo);
00295     ViewSelStatus init(Space& home, IntView x);
00297     ViewSelStatus select(Space& home, IntView x);
00298   };
00299 
00306   class ByMaxMin : public ViewSelBase<IntView> {
00307   protected:
00309     int max;
00310   public:
00312     ByMaxMin(void);
00314     ByMaxMin(Space& home, const VarBranchOptions& vbo);
00316     ViewSelStatus init(Space& home, IntView x);
00318     ViewSelStatus select(Space& home, IntView x);
00319   };
00320 
00327   class ByMaxMax : public ViewSelBase<IntView> {
00328   protected:
00330     int max;
00331   public:
00333     ByMaxMax(void);
00335     ByMaxMax(Space& home, const VarBranchOptions& vbo);
00337     ViewSelStatus init(Space& home, IntView x);
00339     ViewSelStatus select(Space& home, IntView x);
00340   };
00341 
00348   class BySizeMin : public ViewSelBase<IntView> {
00349   protected:
00351     unsigned int size;
00352   public:
00354     BySizeMin(void);
00356     BySizeMin(Space& home, const VarBranchOptions& vbo);
00358     ViewSelStatus init(Space& home, IntView x);
00360     ViewSelStatus select(Space& home, IntView x);
00361   };
00362 
00369   class BySizeMax : public ViewSelBase<IntView> {
00370   protected:
00372     unsigned int size;
00373   public:
00375     BySizeMax(void);
00377     BySizeMax(Space& home, const VarBranchOptions& vbo);
00379     ViewSelStatus init(Space& home, IntView x);
00381     ViewSelStatus select(Space& home, IntView x);
00382   };
00383 
00391   class BySizeDegreeMin : public ViewSelBase<IntView> {
00392   protected:
00394     double sizedegree;
00395   public:
00397     BySizeDegreeMin(void);
00399     BySizeDegreeMin(Space& home, const VarBranchOptions& vbo);
00401     ViewSelStatus init(Space& home, IntView x);
00403     ViewSelStatus select(Space& home, IntView x);
00404   };
00405 
00413   class BySizeDegreeMax : public ViewSelBase<IntView> {
00414   protected:
00416     double sizedegree;
00417   public:
00419     BySizeDegreeMax(void);
00421     BySizeDegreeMax(Space& home, const VarBranchOptions& vbo);
00423     ViewSelStatus init(Space& home, IntView x);
00425     ViewSelStatus select(Space& home, IntView x);
00426   };
00427 
00434   class ByRegretMinMin : public ViewSelBase<IntView> {
00435   protected:
00437     unsigned int regret;
00438   public:
00440     ByRegretMinMin(void);
00442     ByRegretMinMin(Space& home, const VarBranchOptions& vbo);
00444     ViewSelStatus init(Space& home, IntView x);
00446     ViewSelStatus select(Space& home, IntView x);
00447   };
00448 
00455   class ByRegretMinMax : public ViewSelBase<IntView> {
00456   protected:
00458     unsigned int regret;
00459   public:
00461     ByRegretMinMax(void);
00463     ByRegretMinMax(Space& home, const VarBranchOptions& vbo);
00465     ViewSelStatus init(Space& home, IntView x);
00467     ViewSelStatus select(Space& home, IntView x);
00468   };
00469 
00476   class ByRegretMaxMin : public ViewSelBase<IntView> {
00477   protected:
00479     unsigned int regret;
00480   public:
00482     ByRegretMaxMin(void);
00484     ByRegretMaxMin(Space& home, const VarBranchOptions& vbo);
00486     ViewSelStatus init(Space& home, IntView x);
00488     ViewSelStatus select(Space& home, IntView x);
00489   };
00490 
00497   class ByRegretMaxMax : public ViewSelBase<IntView> {
00498   protected:
00500     unsigned int regret;
00501   public:
00503     ByRegretMaxMax(void);
00505     ByRegretMaxMax(Space& home, const VarBranchOptions& vbo);
00507     ViewSelStatus init(Space& home, IntView x);
00509     ViewSelStatus select(Space& home, IntView x);
00510   };
00511 
00512 }}
00513 
00514   template <class View>
00515   class ViewValuesBranchingToString {};
00516 
00517 }
00518 
00519 #include <gecode/int/branch/select-val.hpp>
00520 #include <gecode/int/branch/select-values.hpp>
00521 #include <gecode/int/branch/select-view.hpp>
00522 #include <gecode/int/branch/post-val-int.hpp>
00523 #include <gecode/int/branch/post-val-bool.hpp>
00524 
00525 #endif
00526 
00527 // STATISTICS: int-branch