Generated on Fri Oct 19 11:25:08 2018 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  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 #ifndef __GECODE_INT_NO_OVERLAP_HH__
00035 #define __GECODE_INT_NO_OVERLAP_HH__
00036 
00037 #include <gecode/int.hh>
00038 
00044 namespace Gecode { namespace Int { namespace NoOverlap {
00045 
00049   class FixDim {
00050   protected:
00052     IntView c;
00054     int s;
00056     ExecStatus ssc(Space& home, int n);
00058     ExecStatus lec(Space& home, int n);
00060     ExecStatus nooverlap(Space& home, int n, int m);
00061   public:
00063     FixDim(void);
00065     FixDim(IntView c, int s);
00066 
00068     int ssc(void) const;
00070     int lsc(void) const;
00072     int sec(void) const;
00074     int lec(void) const;
00075 
00077     ExecStatus nooverlap(Space& home, FixDim& d);
00078 
00080     void update(Space& home, FixDim& d);
00081 
00083     void subscribe(Space& home, Propagator& p);
00085     void cancel(Space& home, Propagator& p);
00087     void reschedule(Space& home, Propagator& p);
00088   };
00089 
00093   class FlexDim {
00094   protected:
00096     IntView c0;
00098     IntView s;
00100     IntView c1;
00102     ExecStatus ssc(Space& home, int n);
00104     ExecStatus lec(Space& home, int n);
00106     ExecStatus nooverlap(Space& home, int n, int m);
00107   public:
00109     FlexDim(void);
00111     FlexDim(IntView c0, IntView s, IntView c1);
00112 
00114     int ssc(void) const;
00116     int lsc(void) const;
00118     int sec(void) const;
00120     int lec(void) const;
00121 
00123     ExecStatus nooverlap(Space& home, FlexDim& d);
00124 
00126     void update(Space& home, FlexDim& d);
00127 
00129     void subscribe(Space& home, Propagator& p);
00131     void cancel(Space& home, Propagator& p);
00133     void reschedule(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, ManBox<Dim,n>& r);
00178 
00180     void subscribe(Space& home, Propagator& p);
00182     void cancel(Space& home, Propagator& p);
00184     void reschedule(Space& home, Propagator& p);
00185   };
00186 
00190   template<class Dim, int n>
00191   class OptBox : public ManBox<Dim,n> {
00192   protected:
00193     using ManBox<Dim,n>::d;
00195     BoolView o;
00196   public:
00198     void optional(BoolView o);
00200     bool mandatory(void) const;
00202     bool optional(void) const;
00204     bool excluded(void) const;
00205 
00207     ExecStatus exclude(Space& home);
00208 
00210     void update(Space& home, OptBox<Dim,n>& r);
00211 
00213     void subscribe(Space& home, Propagator& p);
00215     void cancel(Space& home, Propagator& p);
00217     void reschedule(Space& home, Propagator& p);
00218   };
00219 
00220 }}}
00221 
00222 #include <gecode/int/no-overlap/box.hpp>
00223 
00224 namespace Gecode { namespace Int { namespace NoOverlap {
00225 
00233   template<class Box>
00234   class Base : public Propagator {
00235   protected:
00237     Box* b;
00239     int n;
00241     Base(Home home, Box* b, int n);
00243     Base(Space& home, Base<Box>& p, int m);
00249     static int partition(Box* b, int i, int n);
00250   public:
00252     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00254     virtual void reschedule(Space& home);
00256     virtual size_t dispose(Space& home);
00257   };
00258 
00266   template<class Box>
00267   class ManProp : public Base<Box> {
00268   protected:
00269     using Base<Box>::b;
00270     using Base<Box>::n;
00272     ManProp(Home home, Box* b, int n);
00274     ManProp(Space& home, ManProp<Box>& p);
00275   public:
00277     static ExecStatus post(Home home, Box* b, int n);
00279     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00281     virtual Actor* copy(Space& home);
00283     virtual size_t dispose(Space& home);
00284   };
00285 
00293   template<class Box>
00294   class OptProp : public Base<Box> {
00295   protected:
00296     using Base<Box>::b;
00297     using Base<Box>::n;
00299     int m;
00301     OptProp(Home home, Box* b, int n, int m);
00303     OptProp(Space& home, OptProp<Box>& p);
00304   public:
00306     static ExecStatus post(Home home, Box* b, int n);
00308     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00310     virtual Actor* copy(Space& home);
00312     virtual size_t dispose(Space& home);
00313   };
00314 
00315 }}}
00316 
00317 #include <gecode/int/no-overlap/base.hpp>
00318 #include <gecode/int/no-overlap/man.hpp>
00319 #include <gecode/int/no-overlap/opt.hpp>
00320 
00321 #endif
00322 
00323 // STATISTICS: int-prop
00324