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  *     Guido Tack <tack@gecode.org>
00005  *     Christian Schulte <schulte@gecode.org>
00006  *
00007  *  Contributing authors:
00008  *     Gabor Szokoli <szokoli@gecode.org>
00009  *
00010  *  Copyright:
00011  *     Guido Tack, 2004
00012  *     Christian Schulte, 2004
00013  *     Gabor Szokoli, 2004
00014  *
00015  *  Last modified:
00016  *     $Date: 2011-05-11 12:44:17 +0200 (Wed, 11 May 2011) $ by $Author: tack $
00017  *     $Revision: 12001 $
00018  *
00019  *  This file is part of Gecode, the generic constraint
00020  *  development environment:
00021  *     http://www.gecode.org
00022  *
00023  *  Permission is hereby granted, free of charge, to any person obtaining
00024  *  a copy of this software and associated documentation files (the
00025  *  "Software"), to deal in the Software without restriction, including
00026  *  without limitation the rights to use, copy, modify, merge, publish,
00027  *  distribute, sublicense, and/or sell copies of the Software, and to
00028  *  permit persons to whom the Software is furnished to do so, subject to
00029  *  the following conditions:
00030  *
00031  *  The above copyright notice and this permission notice shall be
00032  *  included in all copies or substantial portions of the Software.
00033  *
00034  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00035  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00036  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00037  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00038  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00039  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00040  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00041  *
00042  */
00043 
00044 #ifndef __GECODE_SET_BRANCH_HH__
00045 #define __GECODE_SET_BRANCH_HH__
00046 
00047 #include <gecode/set.hh>
00048 
00054 namespace Gecode { namespace Set { namespace Branch {
00055 
00056   /*
00057    * Value selection classes
00058    *
00059    */
00060 
00061 
00069   template<bool inc>
00070   class ValMin : public ValSelBase<SetView,int> {
00071   public:
00073     ValMin(void);
00075     ValMin(Space& home, const ValBranchOptions& vbo);
00077     int val(Space& home, SetView x) const;
00079     ModEvent tell(Space& home, unsigned int a, SetView x, int v);
00080   };
00081 
00089   template<bool inc>
00090   class ValMed : public ValSelBase<SetView,int> {
00091   public:
00093     ValMed(void);
00095     ValMed(Space& home, const ValBranchOptions& vbo);
00097     int val(Space& home, SetView x) const;
00099     ModEvent tell(Space& home, unsigned int a, SetView x, int v);
00100   };
00101 
00109   template<bool inc>
00110   class ValMax : public ValSelBase<SetView,int> {
00111   public:
00113     ValMax(void);
00115     ValMax(Space& home, const ValBranchOptions& vbo);
00117     int val(Space& home, SetView x) const;
00119     ModEvent tell(Space& home, unsigned int a, SetView x, int v);
00120   };
00121 
00129   template<bool inc>
00130   class ValRnd {
00131   protected:
00133     ArchivedRandomGenerator r;
00134   public:
00136     typedef SetView View;
00138     typedef int Val;
00140     typedef ArchivedRandomGenerator Choice;
00142     static const unsigned int alternatives = 2;
00144     ValRnd(void);
00146     ValRnd(Space& home, const ValBranchOptions& vbo);
00148     int val(Space& home, SetView x);
00150     ModEvent tell(Space& home, unsigned int a, SetView x, int n);
00152     Choice choice(Space& home);
00154     Choice choice(const Space& home, Archive& e);
00156     void commit(Space& home, const Choice& c, unsigned a);
00158     void update(Space& home, bool share, ValRnd& vs);
00160     void dispose(Space& home);
00161   };
00162 
00164   template<bool inc>
00165   class AssignValMin : public ValMin<inc> {
00166   public:
00168     static const unsigned int alternatives = 1;
00170     AssignValMin(void);
00172     AssignValMin(Space& home, const ValBranchOptions& vbo);
00173   };
00174 
00176   template<bool inc>
00177   class AssignValMed : public ValMed<inc> {
00178   public:
00180     static const unsigned int alternatives = 1;
00182     AssignValMed(void);
00184     AssignValMed(Space& home, const ValBranchOptions& vbo);
00185   };
00186 
00188   template<bool inc>
00189   class AssignValMax : public ValMax<inc> {
00190   public:
00192     static const unsigned int alternatives = 1;
00194     AssignValMax(void);
00196     AssignValMax(Space& home, const ValBranchOptions& vbo);
00197   };
00198 
00200   template<bool inc>
00201   class AssignValRnd : public ValRnd<inc> {
00202   public:
00204     static const unsigned int alternatives = 1;
00206     AssignValRnd(void);
00208     AssignValRnd(Space& home, const ValBranchOptions& vbo);
00209   };
00210 
00211   /*
00212    * View selection classes
00213    *
00214    */
00215 
00222   class ByMinMin : public ViewSelBase<SetView> {
00223   private:
00225     int min;
00226   public:
00228     ByMinMin(void);
00230     ByMinMin(Space& home, const VarBranchOptions& vbo);
00232     ViewSelStatus init(Space& home, SetView x);
00234     ViewSelStatus select(Space& home, SetView x);
00235   };
00236 
00243   class ByMinMax : public ViewSelBase<SetView> {
00244   private:
00246     int min;
00247   public:
00249     ByMinMax(void);
00251     ByMinMax(Space& home, const VarBranchOptions& vbo);
00253     ViewSelStatus init(Space& home, SetView x);
00255     ViewSelStatus select(Space& home, SetView x);
00256   };
00257 
00264   class ByMaxMin : public ViewSelBase<SetView> {
00265   private:
00267     int max;
00268   public:
00270     ByMaxMin(void);
00272     ByMaxMin(Space& home, const VarBranchOptions& vbo);
00274     ViewSelStatus init(Space& home, SetView x);
00276     ViewSelStatus select(Space& home, SetView x);
00277   };
00278 
00285   class ByMaxMax : public ViewSelBase<SetView> {
00286   private:
00288     int max;
00289   public:
00291     ByMaxMax(void);
00293     ByMaxMax(Space& home, const VarBranchOptions& vbo);
00295     ViewSelStatus init(Space& home, SetView x);
00297     ViewSelStatus select(Space& home, SetView x);
00298   };
00299 
00306   class BySizeMin : public ViewSelBase<SetView> {
00307   private:
00309     unsigned int size;
00310   public:
00312     BySizeMin(void);
00314     BySizeMin(Space& home, const VarBranchOptions& vbo);
00316     ViewSelStatus init(Space& home, SetView x);
00318     ViewSelStatus select(Space& home, SetView x);
00319   };
00320 
00327   class BySizeMax : public ViewSelBase<SetView> {
00328   private:
00330     unsigned int size;
00331   public:
00333     BySizeMax(void);
00335     BySizeMax(Space& home, const VarBranchOptions& vbo);
00337     ViewSelStatus init(Space& home, SetView x);
00339     ViewSelStatus select(Space& home, SetView x);
00340   };
00341 
00349   class BySizeDegreeMin : public ViewSelBase<SetView> {
00350   protected:
00352     double sizedegree;
00353   public:
00355     BySizeDegreeMin(void);
00357     BySizeDegreeMin(Space& home, const VarBranchOptions& vbo);
00359     ViewSelStatus init(Space& home, SetView x);
00361     ViewSelStatus select(Space& home, SetView x);
00362   };
00363 
00371   class BySizeDegreeMax : public ViewSelBase<SetView> {
00372   protected:
00374     double sizedegree;
00375   public:
00377     BySizeDegreeMax(void);
00379     BySizeDegreeMax(Space& home, const VarBranchOptions& vbo);
00381     ViewSelStatus init(Space& home, SetView x);
00383     ViewSelStatus select(Space& home, SetView x);
00384   };
00385 
00393   class BySizeAfcMin : public ViewSelBase<SetView> {
00394   protected:
00396     double sizeafc;
00397   public:
00399     BySizeAfcMin(void);
00401     BySizeAfcMin(Space& home, const VarBranchOptions& vbo);
00403     ViewSelStatus init(Space& home, SetView x);
00405     ViewSelStatus select(Space& home, SetView x);
00406   };
00407 
00415   class BySizeAfcMax : public ViewSelBase<SetView> {
00416   protected:
00418     double sizeafc;
00419   public:
00421     BySizeAfcMax(void);
00423     BySizeAfcMax(Space& home, const VarBranchOptions& vbo);
00425     ViewSelStatus init(Space& home, SetView x);
00427     ViewSelStatus select(Space& home, SetView x);
00428   };
00429 
00430 }}}
00431 
00432 #include <gecode/set/branch/select-val.hpp>
00433 #include <gecode/set/branch/select-view.hpp>
00434 #include <gecode/set/branch/post-val.hpp>
00435 
00436 #endif
00437 // STATISTICS: set-branch
00438