Generated on Mon Sep 17 2012 22:20:40 for Gecode by doxygen 1.8.1.1
no-overlap.hh
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2011
8  *
9  * Last modified:
10  * $Date: 2011-07-14 02:55:08 +1000 (Thu, 14 Jul 2011) $ by $Author: schulte $
11  * $Revision: 12194 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef __GECODE_INT_NO_OVERLAP_HH__
39 #define __GECODE_INT_NO_OVERLAP_HH__
40 
41 #include <gecode/int.hh>
42 
48 namespace Gecode { namespace Int { namespace NoOverlap {
49 
53  class FixDim {
54  protected:
58  int s;
60  ExecStatus ssc(Space& home, int n);
62  ExecStatus lec(Space& home, int n);
64  ExecStatus nooverlap(Space& home, int n, int m);
65  public:
67  FixDim(void);
69  FixDim(IntView c, int s);
70 
72  int ssc(void) const;
74  int lsc(void) const;
76  int sec(void) const;
78  int lec(void) const;
79 
82 
84  void update(Space& home, bool share, FixDim& d);
85 
87  void subscribe(Space& home, Propagator& p);
89  void cancel(Space& home, Propagator& p);
90  };
91 
95  class FlexDim {
96  protected:
104  ExecStatus ssc(Space& home, int n);
106  ExecStatus lec(Space& home, int n);
108  ExecStatus nooverlap(Space& home, int n, int m);
109  public:
111  FlexDim(void);
114 
116  int ssc(void) const;
118  int lsc(void) const;
120  int sec(void) const;
122  int lec(void) const;
123 
126 
128  void update(Space& home, bool share, FlexDim& d);
129 
131  void subscribe(Space& home, Propagator& p);
133  void cancel(Space& home, Propagator& p);
134  };
135 
136 }}}
137 
139 
140 namespace Gecode { namespace Int { namespace NoOverlap {
141 
145  template<class Dim, int n>
146  class ManBox {
147  protected:
149  Dim d[n];
150  public:
152  const Dim& operator [](int i) const;
154  Dim& operator [](int i);
156  static int dim(void);
157 
159  bool mandatory(void) const;
161  bool optional(void) const;
163  bool excluded(void) const;
164 
166  ExecStatus exclude(Space& home);
167 
169  bool nooverlap(const ManBox<Dim,n>& b) const;
171  bool overlap(const ManBox<Dim,n>& b) const;
172 
175 
177  void update(Space& home, bool share, ManBox<Dim,n>& r);
178 
180  void subscribe(Space& home, Propagator& p);
182  void cancel(Space& home, Propagator& p);
183  };
184 
188  template<class Dim, int n>
189  class OptBox : public ManBox<Dim,n> {
190  protected:
191  using ManBox<Dim,n>::d;
194  public:
196  void optional(BoolView o);
198  bool mandatory(void) const;
200  bool optional(void) const;
202  bool excluded(void) const;
203 
205  ExecStatus exclude(Space& home);
206 
208  void update(Space& home, bool share, OptBox<Dim,n>& r);
209 
211  void subscribe(Space& home, Propagator& p);
213  void cancel(Space& home, Propagator& p);
214  };
215 
216 }}}
217 
219 
220 namespace Gecode { namespace Int { namespace NoOverlap {
221 
229  template<class Box>
230  class Base : public Propagator {
231  protected:
233  Box* b;
235  int n;
237  Base(Home home, Box* b, int n);
239  Base(Space& home, bool share, Base<Box>& p, int m);
245  static int partition(Box* b, int i, int n);
246  public:
248  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
250  virtual size_t dispose(Space& home);
251  };
252 
260  template<class Dim, int d>
261  class ManProp : public Base<ManBox<Dim,d> > {
262  protected:
263  using Base<ManBox<Dim,d> >::b;
264  using Base<ManBox<Dim,d> >::n;
266  ManProp(Home home, ManBox<Dim,d>* b, int n);
268  ManProp(Space& home, bool share, ManProp<Dim,d>& p);
269  public:
271  static ExecStatus post(Home home, ManBox<Dim,d>* b, int n);
273  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
275  virtual Actor* copy(Space& home, bool share);
277  virtual size_t dispose(Space& home);
278  };
279 
287  template<class Dim, int d>
288  class OptProp : public Base<OptBox<Dim,d> > {
289  protected:
290  using Base<OptBox<Dim,d> >::b;
291  using Base<OptBox<Dim,d> >::n;
293  int m;
295  OptProp(Home home, OptBox<Dim,d>* b, int n, int m);
297  OptProp(Space& home, bool share, OptProp<Dim,d>& p);
298  public:
300  static ExecStatus post(Home home, OptBox<Dim,d>* b, int n);
302  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
304  virtual Actor* copy(Space& home, bool share);
306  virtual size_t dispose(Space& home);
307  };
308 
309 }}}
310 
314 
315 #endif
316 
317 // STATISTICS: int-prop
318