Generated on Tue Apr 18 10:21:58 2017 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: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
00011  *     $Revision: 15137 $
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);
00091     void reschedule(Space& home, Propagator& p);
00092   };
00093 
00097   class FlexDim {
00098   protected:
00100     IntView c0;
00102     IntView s;
00104     IntView c1;
00106     ExecStatus ssc(Space& home, int n);
00108     ExecStatus lec(Space& home, int n);
00110     ExecStatus nooverlap(Space& home, int n, int m);
00111   public:
00113     FlexDim(void);
00115     FlexDim(IntView c0, IntView s, IntView c1);
00116 
00118     int ssc(void) const;
00120     int lsc(void) const;
00122     int sec(void) const;
00124     int lec(void) const;
00125 
00127     ExecStatus nooverlap(Space& home, FlexDim& d);
00128 
00130     void update(Space& home, bool share, FlexDim& d);
00131 
00133     void subscribe(Space& home, Propagator& p);
00135     void cancel(Space& home, Propagator& p);
00137     void reschedule(Space& home, Propagator& p);
00138   };
00139 
00140 }}}
00141 
00142 #include <gecode/int/no-overlap/dim.hpp>
00143 
00144 namespace Gecode { namespace Int { namespace NoOverlap {
00145 
00149   template<class Dim, int n>
00150   class ManBox {
00151   protected:
00153     Dim d[n];
00154   public:
00156     const Dim& operator [](int i) const;
00158     Dim& operator [](int i);
00160     static int dim(void);
00161 
00163     bool mandatory(void) const;
00165     bool optional(void) const;
00167     bool excluded(void) const;
00168 
00170     ExecStatus exclude(Space& home);
00171 
00173     bool nooverlap(const ManBox<Dim,n>& b) const;
00175     bool overlap(const ManBox<Dim,n>& b) const;
00176 
00178     ExecStatus nooverlap(Space& home, ManBox<Dim,n>& b);
00179 
00181     void update(Space& home, bool share, ManBox<Dim,n>& r);
00182 
00184     void subscribe(Space& home, Propagator& p);
00186     void cancel(Space& home, Propagator& p);
00188     void reschedule(Space& home, Propagator& p);
00189   };
00190 
00194   template<class Dim, int n>
00195   class OptBox : public ManBox<Dim,n> {
00196   protected:
00197     using ManBox<Dim,n>::d;
00199     BoolView o;
00200   public:
00202     void optional(BoolView o);
00204     bool mandatory(void) const;
00206     bool optional(void) const;
00208     bool excluded(void) const;
00209 
00211     ExecStatus exclude(Space& home);
00212 
00214     void update(Space& home, bool share, OptBox<Dim,n>& r);
00215 
00217     void subscribe(Space& home, Propagator& p);
00219     void cancel(Space& home, Propagator& p);
00221     void reschedule(Space& home, Propagator& p);
00222   };
00223 
00224 }}}
00225 
00226 #include <gecode/int/no-overlap/box.hpp>
00227 
00228 namespace Gecode { namespace Int { namespace NoOverlap {
00229 
00237   template<class Box>
00238   class Base : public Propagator {
00239   protected:
00241     Box* b;
00243     int n;
00245     Base(Home home, Box* b, int n);
00247     Base(Space& home, bool share, Base<Box>& p, int m);
00253     static int partition(Box* b, int i, int n);
00254   public:
00256     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00258     virtual void reschedule(Space& home);
00260     virtual size_t dispose(Space& home);
00261   };
00262 
00270   template<class Box>
00271   class ManProp : public Base<Box> {
00272   protected:
00273     using Base<Box>::b;
00274     using Base<Box>::n;
00276     ManProp(Home home, Box* b, int n);
00278     ManProp(Space& home, bool share, ManProp<Box>& p);
00279   public:
00281     static ExecStatus post(Home home, Box* b, int n);
00283     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00285     virtual Actor* copy(Space& home, bool share);
00287     virtual size_t dispose(Space& home);
00288   };
00289 
00297   template<class Box>
00298   class OptProp : public Base<Box> {
00299   protected:
00300     using Base<Box>::b;
00301     using Base<Box>::n;
00303     int m;
00305     OptProp(Home home, Box* b, int n, int m);
00307     OptProp(Space& home, bool share, OptProp<Box>& p);
00308   public:
00310     static ExecStatus post(Home home, Box* b, int n);
00312     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00314     virtual Actor* copy(Space& home, bool share);
00316     virtual size_t dispose(Space& home);
00317   };
00318 
00319 }}}
00320 
00321 #include <gecode/int/no-overlap/base.hpp>
00322 #include <gecode/int/no-overlap/man.hpp>
00323 #include <gecode/int/no-overlap/opt.hpp>
00324 
00325 #endif
00326 
00327 // STATISTICS: int-prop
00328