Generated on Thu Mar 22 10:39:39 2012 for Gecode by doxygen 1.6.3

no-overlap.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, 2011
00008  *
00009  *  Last modified:
00010  *     $Date: 2011-07-13 18:55:08 +0200 (Wed, 13 Jul 2011) $ by $Author: schulte $
00011  *     $Revision: 12194 $
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_NO_OVERLAP_HH__
00039 #define __GECODE_INT_NO_OVERLAP_HH__
00040 
00041 #include <gecode/int.hh>
00042 
00048 namespace Gecode { namespace Int { namespace NoOverlap {
00049 
00053   class FixDim {
00054   protected:
00056     IntView c;
00058     int s;
00060     ExecStatus ssc(Space& home, int n);
00062     ExecStatus lec(Space& home, int n);
00064     ExecStatus nooverlap(Space& home, int n, int m);
00065   public:
00067     FixDim(void);
00069     FixDim(IntView c, int s);
00070 
00072     int ssc(void) const;
00074     int lsc(void) const;
00076     int sec(void) const;
00078     int lec(void) const;
00079 
00081     ExecStatus nooverlap(Space& home, FixDim& d);
00082 
00084     void update(Space& home, bool share, FixDim& d);
00085 
00087     void subscribe(Space& home, Propagator& p);
00089     void cancel(Space& home, Propagator& p);
00090   };
00091 
00095   class FlexDim {
00096   protected:
00098     IntView c0;
00100     IntView s;
00102     IntView c1;
00104     ExecStatus ssc(Space& home, int n);
00106     ExecStatus lec(Space& home, int n);
00108     ExecStatus nooverlap(Space& home, int n, int m);
00109   public:
00111     FlexDim(void);
00113     FlexDim(IntView c0, IntView s, IntView c1);
00114 
00116     int ssc(void) const;
00118     int lsc(void) const;
00120     int sec(void) const;
00122     int lec(void) const;
00123 
00125     ExecStatus nooverlap(Space& home, FlexDim& d);
00126 
00128     void update(Space& home, bool share, FlexDim& d);
00129 
00131     void subscribe(Space& home, Propagator& p);
00133     void cancel(Space& home, Propagator& p);
00134   };
00135 
00136 }}}
00137 
00138 #include <gecode/int/no-overlap/dim.hpp>
00139 
00140 namespace Gecode { namespace Int { namespace NoOverlap {
00141 
00145   template<class Dim, int n>
00146   class ManBox {
00147   protected:
00149     Dim d[n];
00150   public:
00152     const Dim& operator [](int i) const;
00154     Dim& operator [](int i);
00156     static int dim(void);
00157 
00159     bool mandatory(void) const;
00161     bool optional(void) const;
00163     bool excluded(void) const;
00164 
00166     ExecStatus exclude(Space& home);
00167 
00169     bool nooverlap(const ManBox<Dim,n>& b) const;
00171     bool overlap(const ManBox<Dim,n>& b) const;
00172 
00174     ExecStatus nooverlap(Space& home, ManBox<Dim,n>& b);
00175 
00177     void update(Space& home, bool share, ManBox<Dim,n>& r);
00178 
00180     void subscribe(Space& home, Propagator& p);
00182     void cancel(Space& home, Propagator& p);
00183   };
00184 
00188   template<class Dim, int n>
00189   class OptBox : public ManBox<Dim,n> {
00190   protected:
00191     using ManBox<Dim,n>::d;
00193     BoolView o;
00194   public:
00196     void optional(BoolView o);
00198     bool mandatory(void) const;
00200     bool optional(void) const;
00202     bool excluded(void) const;
00203 
00205     ExecStatus exclude(Space& home);
00206 
00208     void update(Space& home, bool share, OptBox<Dim,n>& r);
00209 
00211     void subscribe(Space& home, Propagator& p);
00213     void cancel(Space& home, Propagator& p);
00214   };
00215 
00216 }}}
00217 
00218 #include <gecode/int/no-overlap/box.hpp>
00219 
00220 namespace Gecode { namespace Int { namespace NoOverlap {
00221 
00229   template<class Box>
00230   class Base : public Propagator {
00231   protected:
00233     Box* b;
00235     int n;
00237     Base(Home home, Box* b, int n);
00239     Base(Space& home, bool share, Base<Box>& p, int m);
00245     static int partition(Box* b, int i, int n);
00246   public:
00248     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00250     virtual size_t dispose(Space& home);
00251   };
00252 
00260   template<class Dim, int d>
00261   class ManProp : public Base<ManBox<Dim,d> > {
00262   protected:
00263     using Base<ManBox<Dim,d> >::b;
00264     using Base<ManBox<Dim,d> >::n;
00266     ManProp(Home home, ManBox<Dim,d>* b, int n);
00268     ManProp(Space& home, bool share, ManProp<Dim,d>& p);
00269   public:
00271     static ExecStatus post(Home home, ManBox<Dim,d>* b, int n);
00273     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00275     virtual Actor* copy(Space& home, bool share);
00277     virtual size_t dispose(Space& home);
00278   };
00279 
00287   template<class Dim, int d>
00288   class OptProp : public Base<OptBox<Dim,d> > {
00289   protected:
00290     using Base<OptBox<Dim,d> >::b;
00291     using Base<OptBox<Dim,d> >::n;
00293     int m;
00295     OptProp(Home home, OptBox<Dim,d>* b, int n, int m);
00297     OptProp(Space& home, bool share, OptProp<Dim,d>& p);
00298   public:
00300     static ExecStatus post(Home home, OptBox<Dim,d>* b, int n);
00302     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00304     virtual Actor* copy(Space& home, bool share);
00306     virtual size_t dispose(Space& home);
00307   };
00308 
00309 }}}
00310 
00311 #include <gecode/int/no-overlap/base.hpp>
00312 #include <gecode/int/no-overlap/man.hpp>
00313 #include <gecode/int/no-overlap/opt.hpp>
00314 
00315 #endif
00316 
00317 // STATISTICS: int-prop
00318