Generated on Sat Apr 10 2021 00:00:00 for Gecode by doxygen 1.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  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 namespace Gecode { namespace Int {
35 
53  template<class View, PropCond pc, class CtrlView>
54  class ReUnaryPropagator : public Propagator {
55  protected:
57  View x0;
59  CtrlView b;
64  View x0, CtrlView b);
66  ReUnaryPropagator(Home home, View x0, CtrlView b);
67  public:
69  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
71  virtual void reschedule(Space& home);
73  virtual size_t dispose(Space& home);
74  };
75 
86  template<class View, PropCond pc, class CtrlView>
87  class ReBinaryPropagator : public Propagator {
88  protected:
90  View x0, x1;
92  CtrlView b;
97  View x0, View x1, CtrlView b);
99  ReBinaryPropagator(Home home, View x0, View x1, CtrlView b);
100  public:
102  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
104  virtual void reschedule(Space& home);
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;
135  ReMixBinaryPropagator(Home home, View0 x0, View1 x1, CtrlView b);
138  View0 x0, View1 x1, CtrlView b);
139  public:
141  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
143  virtual void reschedule(Space& home);
145  virtual size_t dispose(Space& home);
146  };
147 
148 
149  /*
150  * Reified unary propagators
151  *
152  */
153  template<class View, PropCond pc, class CtrlView>
155  (Home home, View y0, CtrlView b0)
156  : Propagator(home), x0(y0), b(b0) {
157  if (pc != PC_GEN_NONE)
158  x0.subscribe(home,*this,pc);
159  b.subscribe(home,*this,Int::PC_INT_VAL);
160  }
161 
162  template<class View, PropCond pc, class CtrlView>
166  : Propagator(home,p) {
167  x0.update(home,p.x0);
168  b.update(home,p.b);
169  }
170 
171  template<class View, PropCond pc, class CtrlView>
174  (Space& home, Propagator& p, View y0, CtrlView b0)
175  : Propagator(home,p) {
176  x0.update(home,y0);
177  b.update(home,b0);
178  }
179 
180  template<class View, PropCond pc, class CtrlView>
181  PropCost
184  }
185 
186  template<class View, PropCond pc, class CtrlView>
187  void
189  if (pc != PC_GEN_NONE)
190  x0.reschedule(home,*this,pc);
191  b.reschedule(home,*this,Int::PC_INT_VAL);
192  }
193 
194  template<class View, PropCond pc, class CtrlView>
195  forceinline size_t
197  if (pc != PC_GEN_NONE)
198  x0.cancel(home,*this,pc);
199  b.cancel(home,*this,Int::PC_INT_VAL);
200  (void) Propagator::dispose(home);
201  return sizeof(*this);
202  }
203 
204  /*
205  * Reified binary propagators
206  *
207  */
208  template<class View, PropCond pc, class CtrlView>
210  (Home home, View y0, View y1, CtrlView b1)
211  : Propagator(home), x0(y0), x1(y1), b(b1) {
212  if (pc != PC_GEN_NONE) {
213  x0.subscribe(home,*this,pc);
214  x1.subscribe(home,*this,pc);
215  }
216  b.subscribe(home,*this,Int::PC_INT_VAL);
217  }
218 
219  template<class View, PropCond pc, class CtrlView>
223  : Propagator(home,p) {
224  x0.update(home,p.x0);
225  x1.update(home,p.x1);
226  b.update(home,p.b);
227  }
228 
229  template<class View, PropCond pc, class CtrlView>
232  (Space& home, Propagator& p, View y0, View y1, CtrlView b0)
233  : Propagator(home,p) {
234  x0.update(home,y0);
235  x1.update(home,y1);
236  b.update(home,b0);
237  }
238 
239  template<class View, PropCond pc, class CtrlView>
240  PropCost
243  }
244 
245  template<class View, PropCond pc, class CtrlView>
246  void
248  if (pc != PC_GEN_NONE) {
249  x0.reschedule(home,*this,pc);
250  x1.reschedule(home,*this,pc);
251  }
252  b.reschedule(home,*this,Int::PC_INT_VAL);
253  }
254 
255  template<class View, PropCond pc, class CtrlView>
256  forceinline size_t
258  if (pc != PC_GEN_NONE) {
259  x0.cancel(home,*this,pc);
260  x1.cancel(home,*this,pc);
261  }
262  b.cancel(home,*this,Int::PC_INT_VAL);
263  (void) Propagator::dispose(home);
264  return sizeof(*this);
265  }
266 
267  /*
268  * Reified mixed binary propagator
269  *
270  */
271  template<class View0, PropCond pc0, class View1, PropCond pc1,
272  class CtrlView>
274  ::ReMixBinaryPropagator(Home home, View0 y0, View1 y1, CtrlView b1)
275  : Propagator(home), x0(y0), x1(y1), b(b1) {
276  if (pc0 != PC_GEN_NONE)
277  x0.subscribe(home,*this,pc0);
278  if (pc1 != PC_GEN_NONE)
279  x1.subscribe(home,*this,pc1);
280  b.subscribe(home,*this,Int::PC_INT_VAL);
281  }
282 
283  template<class View0, PropCond pc0, class View1, PropCond pc1,
284  class CtrlView>
287  (Space& home,
289  : Propagator(home,p) {
290  x0.update(home,p.x0);
291  x1.update(home,p.x1);
292  b.update(home,p.b);
293  }
294 
295  template<class View0, PropCond pc0, class View1, PropCond pc1,
296  class CtrlView>
300  (Space& home, Propagator& p, View0 y0, View1 y1, CtrlView b0)
301  : Propagator(home,p) {
302  x0.update(home,y0);
303  x1.update(home,y1);
304  b.update(home,b0);
305  }
306 
307  template<class View0, PropCond pc0, class View1, PropCond pc1,
308  class CtrlView>
309  PropCost
311  ::cost(const Space&, const ModEventDelta&) const {
313  }
314 
315  template<class View0, PropCond pc0, class View1, PropCond pc1,
316  class CtrlView>
317  void
319  if (pc0 != PC_GEN_NONE)
320  x0.reschedule(home,*this,pc0);
321  if (pc1 != PC_GEN_NONE)
322  x1.reschedule(home,*this,pc1);
323  b.reschedule(home,*this,Int::PC_INT_VAL);
324  }
325 
326  template<class View0, PropCond pc0, class View1, PropCond pc1,
327  class CtrlView>
328  forceinline size_t
330  if (pc0 != PC_GEN_NONE)
331  x0.cancel(home,*this,pc0);
332  if (pc1 != PC_GEN_NONE)
333  x1.cancel(home,*this,pc1);
334  b.cancel(home,*this,Int::PC_INT_VAL);
335  (void) Propagator::dispose(home);
336  return sizeof(*this);
337  }
338 
339 }}
340 
341 // STATISTICS: int-prop
342 
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition: core.hpp:3252
Home class for posting propagators
Definition: core.hpp:856
Reified binary propagator.
Definition: propagator.hpp:87
ReBinaryPropagator(Space &home, Propagator &p, View x0, View x1, CtrlView b)
Constructor for rewriting p during cloning.
Definition: propagator.hpp:232
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition: propagator.hpp:241
ReBinaryPropagator(Space &home, ReBinaryPropagator &p)
Constructor for cloning p.
Definition: propagator.hpp:222
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: propagator.hpp:257
ReBinaryPropagator(Home home, View x0, View x1, CtrlView b)
Constructor for creation.
Definition: propagator.hpp:210
virtual void reschedule(Space &home)
Schedule function.
Definition: propagator.hpp:247
CtrlView b
Boolean control view.
Definition: propagator.hpp:92
Reified mixed binary propagator.
Definition: propagator.hpp:124
ReMixBinaryPropagator(Space &home, ReMixBinaryPropagator &p)
Constructor for cloning p.
Definition: propagator.hpp:287
View1 x1
View of type View1.
Definition: propagator.hpp:129
virtual void reschedule(Space &home)
Schedule function.
Definition: propagator.hpp:318
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: propagator.hpp:329
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition: propagator.hpp:311
ReMixBinaryPropagator(Space &home, Propagator &p, View0 x0, View1 x1, CtrlView b)
Constructor for rewriting p during cloning.
Definition: propagator.hpp:300
CtrlView b
Boolean control view.
Definition: propagator.hpp:131
View0 x0
View of type View0.
Definition: propagator.hpp:127
ReMixBinaryPropagator(Home home, View0 x0, View1 x1, CtrlView b)
Constructor for creation.
Definition: propagator.hpp:274
Reified unary propagator.
Definition: propagator.hpp:54
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
Definition: propagator.hpp:182
ReUnaryPropagator(Space &home, Propagator &p, View x0, CtrlView b)
Constructor for rewriting p during cloning.
Definition: propagator.hpp:174
CtrlView b
Boolean control view.
Definition: propagator.hpp:59
ReUnaryPropagator(Home home, View x0, CtrlView b)
Constructor for creation.
Definition: propagator.hpp:155
ReUnaryPropagator(Space &home, ReUnaryPropagator &p)
Constructor for cloning p.
Definition: propagator.hpp:165
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: propagator.hpp:196
virtual void reschedule(Space &home)
Schedule function.
Definition: propagator.hpp:188
Propagation cost.
Definition: core.hpp:486
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition: core.hpp:4813
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
Definition: core.hpp:4809
@ LO
Cheap.
Definition: core.hpp:513
Base-class for propagators.
Definition: core.hpp:1064
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:1075
Computation spaces.
Definition: core.hpp:1742
int PropCond
Type for propagation conditions.
Definition: core.hpp:72
const PropCond PC_GEN_NONE
Propagation condition to be ignored (convenience)
Definition: core.hpp:74
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:82
#define forceinline
Definition: config.hpp:192