Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
rel.hh
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  * Christian Schulte <schulte@gecode.org>
6  *
7  * Contributing authors:
8  * Gabor Szokoli <szokoli@gecode.org>
9  *
10  * Copyright:
11  * Guido Tack, 2004
12  * Christian Schulte, 2004
13  * Gabor Szokoli, 2004
14  *
15  * Last modified:
16  * $Date$ by $Author$
17  * $Revision$
18  *
19  * This file is part of Gecode, the generic constraint
20  * development environment:
21  * http://www.gecode.org
22  *
23  * Permission is hereby granted, free of charge, to any person obtaining
24  * a copy of this software and associated documentation files (the
25  * "Software"), to deal in the Software without restriction, including
26  * without limitation the rights to use, copy, modify, merge, publish,
27  * distribute, sublicense, and/or sell copies of the Software, and to
28  * permit persons to whom the Software is furnished to do so, subject to
29  * the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be
32  * included in all copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
38  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
39  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41  *
42  */
43 
44 #ifndef __GECODE_SET_REL_HH__
45 #define __GECODE_SET_REL_HH__
46 
47 #include <gecode/set.hh>
48 
49 namespace Gecode { namespace Set { namespace Rel {
50 
56  template<class VX, class VY>
58  bool same(VX c, VY y);
59 
67  template<class View0, class View1>
68  class Subset :
69  public MixBinaryPropagator<View0,PC_SET_CGLB,View1,PC_SET_CLUB> {
70  protected:
74  Subset(Space& home, Subset& p);
76  Subset(Home home, View0 x0, View1 x1);
77  public:
79  virtual Actor* copy(Space& home);
81  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
83  static ExecStatus post(Home home, View0 x, View1 y);
84  };
85 
93  template<class View0, class View1>
94  class NoSubset :
95  public MixBinaryPropagator<View0,PC_SET_CLUB,View1,PC_SET_CGLB> {
96  protected:
100  NoSubset(Space& home, NoSubset& p);
102  NoSubset(Home home, View0 x0, View1 x1);
103  public:
105  virtual Actor* copy(Space& home);
107  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
109  static ExecStatus post(Home home,View0 x,View1 y);
110  };
111 
118  template<class View0, class View1, class CtrlView, ReifyMode rm>
119  class ReSubset : public Propagator {
120  protected:
122  View0 x0;
124  View1 x1;
126  CtrlView b;
128  ReSubset(Space& home, ReSubset& p);
130  ReSubset(Home home, View0 x0, View1 x1, CtrlView b);
131  public:
133  virtual Actor* copy(Space& home);
135  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
137  virtual void reschedule(Space& home);
139  virtual size_t dispose(Space& home);
141  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
143  static ExecStatus post(Home home, View0 x, View1 y,
144  CtrlView b);
145  };
146 
153  template<class View0, class View1>
154  class Eq : public MixBinaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY> {
155  protected:
159  Eq(Space& home, Eq& p);
161  Eq(Home home, View0 x0, View1 x1);
162  public:
164  virtual Actor* copy(Space& home);
166  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
168  static ExecStatus post(Home home, View0 x, View1 y);
169  };
170 
177  template<class View0, class View1, class CtrlView, ReifyMode rm>
178  class ReEq : public Propagator {
179  protected:
180  View0 x0;
181  View1 x1;
182  CtrlView b;
184  ReEq(Space& home, ReEq&);
186  ReEq(Home home, View0 x0, View1 x1, CtrlView b);
187  public:
189  virtual Actor* copy(Space& home);
191  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
193  virtual void reschedule(Space& home);
195  virtual size_t dispose(Space& home);
197  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
199  static ExecStatus post(Home home, View0 x, View1 y,
200  CtrlView b);
201  };
202 
211  template<class View0, class View1, bool strict=false>
212  class Lq : public MixBinaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY> {
213  protected:
217  Lq(Space& home, Lq& p);
219  Lq(Home home, View0 x0, View1 x1);
220  public:
222  virtual Actor* copy(Space& home);
224  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
226  static ExecStatus post(Home home, View0 x, View1 y);
227  };
228 
237  template<class View0, class View1, ReifyMode rm, bool strict=false>
238  class ReLq : public Propagator {
239  protected:
240  View0 x0;
241  View1 x1;
244  ReLq(Space& home, ReLq& p);
246  ReLq(Home home, View0 x0, View1 x1, Gecode::Int::BoolView b);
247  public:
249  virtual Actor* copy(Space& home);
251  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
253  virtual void reschedule(Space& home);
255  virtual size_t dispose(Space& home);
257  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
259  static ExecStatus post(Home home, View0 x, View1 y,
261  };
262 
270  template<class View0, class View1>
271  class Distinct :
272  public MixBinaryPropagator<View0,PC_SET_VAL,View1,PC_SET_VAL> {
273  protected:
277  Distinct(Space& home, Distinct& p);
279  Distinct(Home home, View0 x0, View1 x1);
280  public:
282  virtual Actor* copy(Space& home);
284  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
286  static ExecStatus post(Home home, View0 x, View1 y);
287  };
288 
299  template<class View0>
300  class DistinctDoit : public UnaryPropagator<View0,PC_SET_ANY> {
301  protected:
308  DistinctDoit(Home home, View0 x0, ConstSetView y);
309  public:
311  virtual Actor* copy(Space& home);
313  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
315  static ExecStatus post(Home home, View0 x, ConstSetView y);
316  };
317 
318 }}}
319 
320 #include <gecode/set/rel/common.hpp>
321 #include <gecode/set/rel/subset.hpp>
324 #include <gecode/set/rel/eq.hpp>
325 #include <gecode/set/rel/re-eq.hpp>
326 #include <gecode/set/rel/nq.hpp>
327 #include <gecode/set/rel/lq.hpp>
328 #include <gecode/set/rel/re-lq.hpp>
329 
330 #endif
331 
332 // STATISTICS: set-prop
Propagator for negated equality
Definition: rel.hh:271
CtrlView b
Boolean control view.
Definition: rel.hh:126
Unary propagator.
Definition: pattern.hpp:59
Propagator for the subset constraint
Definition: rel.hh:68
Subset(Space &home, Subset &p)
Constructor for cloning p.
Definition: subset.hpp:54
Base-class for propagators.
Definition: core.hpp:1016
Propagator for set less than or equal
Definition: rel.hh:212
virtual void reschedule(Space &home)
Schedule function.
Definition: pattern.hpp:625
Computation spaces.
Definition: core.hpp:1668
Base-class for both propagators and branchers.
Definition: core.hpp:620
Gecode::FloatVal c(-8, 8)
Reified equality propagator
Definition: rel.hh:178
static ExecStatus post(Home home, View0 x, View1 y)
Post propagator .
Definition: subset.hpp:59
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: subset.hpp:73
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:1027
bool same(VX, VY)
Test whether two views are in fact the same.
Definition: common.hpp:61
Reified propagator for set less than or equal
Definition: rel.hh:238
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: subset.hpp:67
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:769
Constant view.
Definition: view.hpp:190
Reified subset propagator
Definition: rel.hh:119
Mixed binary propagator.
Definition: pattern.hpp:208
View1 x1
Variable view.
Definition: rel.hh:124
Propagation cost.
Definition: core.hpp:478
ExecStatus
Definition: core.hpp:464
ConstSetView y
The view that is already assigned.
Definition: rel.hh:304
Gecode::Int::BoolView b
Definition: rel.hh:242
Propagator for set equality
Definition: rel.hh:154
Propagator for negated equality
Definition: rel.hh:300
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition: pattern.hpp:618
Post propagator for SetVar x
Definition: set.hh:769
Propagator for the negated subset constraint
Definition: rel.hh:94
Gecode toplevel namespace
View0 x0
Variable view.
Definition: rel.hh:122
int ModEventDelta
Modification event deltas.
Definition: core.hpp:91
Home class for posting propagators
Definition: core.hpp:846
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: pattern.hpp:634
Boolean view for Boolean variables.
Definition: view.hpp:1329