Generated on Sat Feb 7 2015 02:01:25 for Gecode by doxygen 1.8.9.1
propagator.hpp
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, 2002
8  *
9  * Last modified:
10  * $Date: 2013-04-17 16:39:27 +0200 (Wed, 17 Apr 2013) $ by $Author: schulte $
11  * $Revision: 13579 $
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 namespace Gecode { namespace Int {
39 
57  template<class View, PropCond pc, class CtrlView>
58  class ReUnaryPropagator : public Propagator {
59  protected:
61  View x0;
63  CtrlView b;
65  ReUnaryPropagator(Space& home, bool share, ReUnaryPropagator& p);
67  ReUnaryPropagator(Space& home, bool share, Propagator& p,
68  View x0, CtrlView b);
70  ReUnaryPropagator(Home home, View x0, CtrlView b);
71  public:
73  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
75  virtual size_t dispose(Space& home);
76  };
77 
88  template<class View, PropCond pc, class CtrlView>
89  class ReBinaryPropagator : public Propagator {
90  protected:
92  View x0, x1;
94  CtrlView b;
96  ReBinaryPropagator(Space& home, bool share, ReBinaryPropagator& p);
98  ReBinaryPropagator(Space& home, bool share, Propagator& p,
99  View x0, View x1, CtrlView b);
101  ReBinaryPropagator(Home home, View x0, View x1, CtrlView b);
102  public:
104  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
106  virtual size_t dispose(Space& home);
107  };
109 
110 
122  template<class View0, PropCond pc0, class View1, PropCond pc1,
123  class CtrlView>
125  protected:
127  View0 x0;
129  View1 x1;
131  CtrlView b;
133  ReMixBinaryPropagator(Space& home, bool share, ReMixBinaryPropagator& p);
135  ReMixBinaryPropagator(Home home, View0 x0, View1 x1, CtrlView b);
137  ReMixBinaryPropagator(Space& home, bool share, Propagator& p,
138  View0 x0, View1 x1, CtrlView b);
139  public:
141  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
143  virtual size_t dispose(Space& home);
144  };
145 
146 
147  /*
148  * Reified unary propagators
149  *
150  */
151  template<class View, PropCond pc, class CtrlView>
153  (Home home, View y0, CtrlView b0)
154  : Propagator(home), x0(y0), b(b0) {
155  if (pc != PC_GEN_NONE)
156  x0.subscribe(home,*this,pc);
157  b.subscribe(home,*this,Int::PC_INT_VAL);
158  }
159 
160  template<class View, PropCond pc, class CtrlView>
164  : Propagator(home,share,p) {
165  x0.update(home,share,p.x0);
166  b.update(home,share,p.b);
167  }
168 
169  template<class View, PropCond pc, class CtrlView>
172  (Space& home, bool share, Propagator& p, View y0, CtrlView b0)
173  : Propagator(home,share,p) {
174  x0.update(home,share,y0);
175  b.update(home,share,b0);
176  }
177 
178  template<class View, PropCond pc, class CtrlView>
179  PropCost
182  }
183 
184  template<class View, PropCond pc, class CtrlView>
185  forceinline size_t
187  if (pc != PC_GEN_NONE)
188  x0.cancel(home,*this,pc);
189  b.cancel(home,*this,Int::PC_INT_VAL);
190  (void) Propagator::dispose(home);
191  return sizeof(*this);
192  }
193 
194  /*
195  * Reified binary propagators
196  *
197  */
198  template<class View, PropCond pc, class CtrlView>
200  (Home home, View y0, View y1, CtrlView b1)
201  : Propagator(home), x0(y0), x1(y1), b(b1) {
202  if (pc != PC_GEN_NONE) {
203  x0.subscribe(home,*this,pc);
204  x1.subscribe(home,*this,pc);
205  }
206  b.subscribe(home,*this,Int::PC_INT_VAL);
207  }
208 
209  template<class View, PropCond pc, class CtrlView>
213  : Propagator(home,share,p) {
214  x0.update(home,share,p.x0);
215  x1.update(home,share,p.x1);
216  b.update(home,share,p.b);
217  }
218 
219  template<class View, PropCond pc, class CtrlView>
222  (Space& home, bool share, Propagator& p, View y0, View y1, CtrlView b0)
223  : Propagator(home,share,p) {
224  x0.update(home,share,y0);
225  x1.update(home,share,y1);
226  b.update(home,share,b0);
227  }
228 
229  template<class View, PropCond pc, class CtrlView>
230  PropCost
233  }
234 
235  template<class View, PropCond pc, class CtrlView>
236  forceinline size_t
238  if (pc != PC_GEN_NONE) {
239  x0.cancel(home,*this,pc);
240  x1.cancel(home,*this,pc);
241  }
242  b.cancel(home,*this,Int::PC_INT_VAL);
243  (void) Propagator::dispose(home);
244  return sizeof(*this);
245  }
246 
247  /*
248  * Reified mixed binary propagator
249  *
250  */
251  template<class View0, PropCond pc0, class View1, PropCond pc1,
252  class CtrlView>
254  ::ReMixBinaryPropagator(Home home, View0 y0, View1 y1, CtrlView b1)
255  : Propagator(home), x0(y0), x1(y1), b(b1) {
256  if (pc0 != PC_GEN_NONE)
257  x0.subscribe(home,*this,pc0);
258  if (pc1 != PC_GEN_NONE)
259  x1.subscribe(home,*this,pc1);
260  b.subscribe(home,*this,Int::PC_INT_VAL);
261  }
262 
263  template<class View0, PropCond pc0, class View1, PropCond pc1,
264  class CtrlView>
267  (Space& home, bool share,
269  : Propagator(home,share,p) {
270  x0.update(home,share,p.x0);
271  x1.update(home,share,p.x1);
272  b.update(home,share,p.b);
273  }
274 
275  template<class View0, PropCond pc0, class View1, PropCond pc1,
276  class CtrlView>
280  (Space& home, bool share, Propagator& p, View0 y0, View1 y1, CtrlView b0)
281  : Propagator(home,share,p) {
282  x0.update(home,share,y0);
283  x1.update(home,share,y1);
284  b.update(home,share,b0);
285  }
286 
287  template<class View0, PropCond pc0, class View1, PropCond pc1,
288  class CtrlView>
289  PropCost
291  ::cost(const Space&, const ModEventDelta&) const {
293  }
294 
295  template<class View0, PropCond pc0, class View1, PropCond pc1,
296  class CtrlView>
297  forceinline size_t
299  if (pc0 != PC_GEN_NONE)
300  x0.cancel(home,*this,pc0);
301  if (pc1 != PC_GEN_NONE)
302  x1.cancel(home,*this,pc1);
303  b.cancel(home,*this,Int::PC_INT_VAL);
304  (void) Propagator::dispose(home);
305  return sizeof(*this);
306  }
307 
308 }}
309 
310 // STATISTICS: int-prop
311 
const PropCond PC_GEN_NONE
Propagation condition to be ignored (convenience)
Definition: core.hpp:158
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
Definition: propagator.hpp:180
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition: propagator.hpp:291
ReBinaryPropagator(Space &home, bool share, ReBinaryPropagator &p)
Constructor for cloning p.
Definition: propagator.hpp:212
Reified unary propagator.
Definition: propagator.hpp:58
Reified binary propagator.
Definition: propagator.hpp:89
Reified mixed binary propagator.
Definition: propagator.hpp:124
Base-class for propagators.
Definition: core.hpp:755
ReUnaryPropagator(Space &home, bool share, ReUnaryPropagator &p)
Constructor for cloning p.
Definition: propagator.hpp:163
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition: core.hpp:4058
Computation spaces.
Definition: core.hpp:1362
CtrlView b
Boolean control view.
Definition: propagator.hpp:63
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
int PropCond
Type for propagation conditions.
Definition: core.hpp:156
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:764
View0 x0
View of type View0.
Definition: propagator.hpp:127
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition: core.hpp:2877
Propagation cost.
Definition: core.hpp:537
CtrlView b
Boolean control view.
Definition: propagator.hpp:131
#define forceinline
Definition: config.hpp:132
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: propagator.hpp:298
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition: propagator.hpp:231
ReMixBinaryPropagator(Space &home, bool share, ReMixBinaryPropagator &p)
Constructor for cloning p.
Definition: propagator.hpp:267
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: propagator.hpp:186
CtrlView b
Boolean control view.
Definition: propagator.hpp:94
View1 x1
View of type View1.
Definition: propagator.hpp:129
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
Home class for posting propagators
Definition: core.hpp:717
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
Definition: core.hpp:4054
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: propagator.hpp:237
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:82