Generated on Mon Nov 30 23:53:22 2009 for Gecode by doxygen 1.6.1

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-10-20 13:28:57 +0200 (Tue, 20 Oct 2009) $ by $Author: schulte $
00011  *     $Revision: 9975 $
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 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     Support::RandomGenerator choice(Space& home);
00127     void commit(Space& home, const Support::RandomGenerator& c, 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 
00164   template<class View>
00165   class ValRangeMin : public ValSelBase<View,int> {
00166   public:
00168     ValRangeMin(void);
00170     ValRangeMin(Space& home, const ValBranchOptions& vbo);
00172     int val(Space& home, View x) const;
00174     ModEvent tell(Space& home, unsigned int a, View x, int n);
00175   };
00176 
00177 
00179   class NoValue {};
00180 
00188   template<class View>
00189   class ValZeroOne : public ValSelBase<View,NoValue> {
00190   public:
00192     ValZeroOne(void);
00194     ValZeroOne(Space& home, const ValBranchOptions& vbo);
00196     NoValue val(Space& home, View x) const;
00198     ModEvent tell(Space& home, unsigned int a, View x, NoValue n);
00199   };
00200 
00201 
00206   template<class ViewSel, class View>
00207   class ViewValuesBrancher : public ViewBrancher<ViewSel> {
00208   protected:
00209     using ViewBrancher<ViewSel>::x;
00210     using ViewBrancher<ViewSel>::viewsel;
00212     ViewValuesBrancher(Space& home, bool share, ViewValuesBrancher& b);
00213   public:
00215     ViewValuesBrancher(Home home, ViewArray<typename ViewSel::View>& x,
00216                         ViewSel& vi_s);
00218     virtual const Choice* choice(Space& home);
00220     virtual ExecStatus commit(Space& home, const Choice& c, unsigned int a);
00222     virtual Actor* copy(Space& home, bool share);
00223   };
00224 
00225 
00227   template<class View>
00228   class AssignValMin : public ValMin<View> {
00229   public:
00231     static const unsigned int alternatives = 1;
00233     AssignValMin(void);
00235     AssignValMin(Space& home, const ValBranchOptions& vbo);
00236   };
00237 
00239   template<class View>
00240   class AssignValMed : public ValMed<View> {
00241   public:
00243     static const unsigned int alternatives = 1;
00245     AssignValMed(void);
00247     AssignValMed(Space& home, const ValBranchOptions& vbo);
00248   };
00249 
00251   template<class View>
00252   class AssignValRnd : public ValRnd<View> {
00253   public:
00255     static const unsigned int alternatives = 1;
00257     AssignValRnd(void);
00259     AssignValRnd(Space& home, const ValBranchOptions& vbo);
00260   };
00261 
00263   template<class View>
00264   class AssignValZero : public ValZeroOne<View> {
00265   public:
00267     static const unsigned int alternatives = 1;
00269     AssignValZero(void);
00271     AssignValZero(Space& home, const ValBranchOptions& vbo);
00272   };
00273 
00274   /*
00275    * Variable selection classes
00276    *
00277    */
00278 
00285   class ByMinMin : public ViewSelBase<IntView> {
00286   protected:
00288     int min;
00289   public:
00291     ByMinMin(void);
00293     ByMinMin(Space& home, const VarBranchOptions& vbo);
00295     ViewSelStatus init(Space& home, IntView x);
00297     ViewSelStatus select(Space& home, IntView x);
00298   };
00299 
00306   class ByMinMax : public ViewSelBase<IntView> {
00307   protected:
00309     int min;
00310   public:
00312     ByMinMax(void);
00314     ByMinMax(Space& home, const VarBranchOptions& vbo);
00316     ViewSelStatus init(Space& home, IntView x);
00318     ViewSelStatus select(Space& home, IntView x);
00319   };
00320 
00327   class ByMaxMin : public ViewSelBase<IntView> {
00328   protected:
00330     int max;
00331   public:
00333     ByMaxMin(void);
00335     ByMaxMin(Space& home, const VarBranchOptions& vbo);
00337     ViewSelStatus init(Space& home, IntView x);
00339     ViewSelStatus select(Space& home, IntView x);
00340   };
00341 
00348   class ByMaxMax : public ViewSelBase<IntView> {
00349   protected:
00351     int max;
00352   public:
00354     ByMaxMax(void);
00356     ByMaxMax(Space& home, const VarBranchOptions& vbo);
00358     ViewSelStatus init(Space& home, IntView x);
00360     ViewSelStatus select(Space& home, IntView x);
00361   };
00362 
00369   class BySizeMin : public ViewSelBase<IntView> {
00370   protected:
00372     unsigned int size;
00373   public:
00375     BySizeMin(void);
00377     BySizeMin(Space& home, const VarBranchOptions& vbo);
00379     ViewSelStatus init(Space& home, IntView x);
00381     ViewSelStatus select(Space& home, IntView x);
00382   };
00383 
00390   class BySizeMax : public ViewSelBase<IntView> {
00391   protected:
00393     unsigned int size;
00394   public:
00396     BySizeMax(void);
00398     BySizeMax(Space& home, const VarBranchOptions& vbo);
00400     ViewSelStatus init(Space& home, IntView x);
00402     ViewSelStatus select(Space& home, IntView x);
00403   };
00404 
00412   class BySizeDegreeMin : public ViewSelBase<IntView> {
00413   protected:
00415     double sizedegree;
00416   public:
00418     BySizeDegreeMin(void);
00420     BySizeDegreeMin(Space& home, const VarBranchOptions& vbo);
00422     ViewSelStatus init(Space& home, IntView x);
00424     ViewSelStatus select(Space& home, IntView x);
00425   };
00426 
00434   class BySizeDegreeMax : public ViewSelBase<IntView> {
00435   protected:
00437     double sizedegree;
00438   public:
00440     BySizeDegreeMax(void);
00442     BySizeDegreeMax(Space& home, const VarBranchOptions& vbo);
00444     ViewSelStatus init(Space& home, IntView x);
00446     ViewSelStatus select(Space& home, IntView x);
00447   };
00448 
00456   class BySizeAfcMin : public ViewSelBase<IntView> {
00457   protected:
00459     double sizeafc;
00460   public:
00462     BySizeAfcMin(void);
00464     BySizeAfcMin(Space& home, const VarBranchOptions& vbo);
00466     ViewSelStatus init(Space& home, IntView x);
00468     ViewSelStatus select(Space& home, IntView x);
00469   };
00470 
00478   class BySizeAfcMax : public ViewSelBase<IntView> {
00479   protected:
00481     double sizeafc;
00482   public:
00484     BySizeAfcMax(void);
00486     BySizeAfcMax(Space& home, const VarBranchOptions& vbo);
00488     ViewSelStatus init(Space& home, IntView x);
00490     ViewSelStatus select(Space& home, IntView x);
00491   };
00492 
00499   class ByRegretMinMin : public ViewSelBase<IntView> {
00500   protected:
00502     unsigned int regret;
00503   public:
00505     ByRegretMinMin(void);
00507     ByRegretMinMin(Space& home, const VarBranchOptions& vbo);
00509     ViewSelStatus init(Space& home, IntView x);
00511     ViewSelStatus select(Space& home, IntView x);
00512   };
00513 
00520   class ByRegretMinMax : public ViewSelBase<IntView> {
00521   protected:
00523     unsigned int regret;
00524   public:
00526     ByRegretMinMax(void);
00528     ByRegretMinMax(Space& home, const VarBranchOptions& vbo);
00530     ViewSelStatus init(Space& home, IntView x);
00532     ViewSelStatus select(Space& home, IntView x);
00533   };
00534 
00541   class ByRegretMaxMin : public ViewSelBase<IntView> {
00542   protected:
00544     unsigned int regret;
00545   public:
00547     ByRegretMaxMin(void);
00549     ByRegretMaxMin(Space& home, const VarBranchOptions& vbo);
00551     ViewSelStatus init(Space& home, IntView x);
00553     ViewSelStatus select(Space& home, IntView x);
00554   };
00555 
00562   class ByRegretMaxMax : public ViewSelBase<IntView> {
00563   protected:
00565     unsigned int regret;
00566   public:
00568     ByRegretMaxMax(void);
00570     ByRegretMaxMax(Space& home, const VarBranchOptions& vbo);
00572     ViewSelStatus init(Space& home, IntView x);
00574     ViewSelStatus select(Space& home, IntView x);
00575   };
00576 
00577 }}}
00578 
00579 #include <gecode/int/branch/select-val.hpp>
00580 #include <gecode/int/branch/select-values.hpp>
00581 #include <gecode/int/branch/select-view.hpp>
00582 #include <gecode/int/branch/post-val-int.hpp>
00583 #include <gecode/int/branch/post-val-bool.hpp>
00584 
00585 #endif
00586 
00587 // STATISTICS: int-branch