Generated on Tue Jan 19 2021 06:15:49 for Gecode by doxygen 1.8.13
distinct.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  * Guido Tack <tack@gecode.org>
6  *
7  * Contributing authors:
8  * Gabor Szokoli <szokoli@gecode.org>
9  *
10  * Copyright:
11  * Christian Schulte, 2002
12  * Guido Tack, 2004
13  * Gabor Szokoli, 2003
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 #ifndef __GECODE_INT_DISTINCT_HH__
41 #define __GECODE_INT_DISTINCT_HH__
42 
43 #include <gecode/int.hh>
44 
46 #include <gecode/int/rel.hh>
47 
53 namespace Gecode { namespace Int { namespace Distinct {
54 
63  template<class View>
64  class Val : public NaryPropagator<View,PC_INT_VAL> {
65  protected:
67 
69  Val(Home home, ViewArray<View>& x);
71  Val(Space& home, Val<View>& p);
72  public:
73 #ifdef GECODE_HAS_CBS
74  virtual void solndistrib(Space& home, Propagator::SendMarginal send) const;
77  virtual void domainsizesum(Propagator::InDecision in,
78  unsigned int& size, unsigned int& size_b) const;
79 #endif
80  virtual Actor* copy(Space& home);
83  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
85  static ExecStatus post(Home home, ViewArray<View>& x);
86  };
87 
88 #ifdef GECODE_HAS_CBS
89 
99  template<class View>
100  void cbsdistinct(Space& home, unsigned int prop_id, const ViewArray<View>& x,
101  Propagator::SendMarginal send);
102 
103  template<class View>
104  void cbssize(const ViewArray<View>& x, Propagator::InDecision in,
105  unsigned int& size, unsigned int& size_b);
106 #endif
107 
121  template<class View, bool complete>
123 
124 
125 
151  template<class View>
152  class Bnd : public Propagator {
153  protected:
159  int min_x;
161  int max_x;
163  Bnd(Home home, ViewArray<View>& x);
165  Bnd(Space& home, Bnd<View>& p);
166  public:
167 #ifdef GECODE_HAS_CBS
168  virtual void solndistrib(Space& home, Propagator::SendMarginal send) const;
171  virtual void domainsizesum(Propagator::InDecision in,
172  unsigned int& size, unsigned int& size_b) const;
173 #endif
174  static ExecStatus post(Home home, ViewArray<View>& x);
177  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
184  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
186  virtual void reschedule(Space& home);
188  virtual Actor* copy(Space& home);
190  virtual size_t dispose(Space& home);
191  };
192 
201  template<class View>
202  ExecStatus prop_bnd(Space& home, ViewArray<View>& x, int& min_x, int& max_x);
203 
212  template<class View>
214 
215 
217  template<class View>
218  class Graph : public ViewValGraph::Graph<View> {
219  public:
228  Graph(void);
232  bool mark(void);
234  ExecStatus prune(Space& home, bool& assigned);
236  bool sync(void);
237  };
238 
249  template<class View>
250  class DomCtrl {
251  protected:
254  public:
256  DomCtrl(void);
258  bool available(void);
262  ExecStatus sync(void);
264  ExecStatus propagate(Space& home, bool& assigned);
265  };
266 
282  template<class View>
283  class Dom : public NaryPropagator<View,PC_INT_DOM> {
284  protected:
289  Dom(Space& home, Dom<View>& p);
291  Dom(Home home, ViewArray<View>& x);
292  public:
293 #ifdef GECODE_HAS_CBS
294  virtual void solndistrib(Space& home, Propagator::SendMarginal send) const;
297  virtual void domainsizesum(Propagator::InDecision in,
298  unsigned int& size, unsigned int& size_b) const;
299 #endif
300  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
308  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
310  virtual Actor* copy(Space& home);
312  static ExecStatus post(Home home, ViewArray<View>& x);
313  };
314 
321  template<class View>
322  class TerDom : public TernaryPropagator<View,PC_INT_DOM> {
323  protected:
327 
329  TerDom(Space& home, TerDom<View>& p);
331  TerDom(Home home, View x0, View x1, View x2);
332  public:
334  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
336  virtual Actor* copy(Space& home);
338  static ExecStatus post(Home home, View x0, View x1, View x2);
339  };
340 
349  class EqIte : public BinaryPropagator<IntView,PC_INT_DOM> {
350  protected:
354  int c0, c1;
356  EqIte(Space& home, EqIte& p);
358  EqIte(Home home, IntView x0, IntView x1, int c0, int c1);
359  public:
362  virtual Actor* copy(Space& home);
365  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
368  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
370  static ExecStatus post(Home home, IntView x0, IntView x1, int c0, int c1);
371  };
372 
373 }}}
374 
383 
384 #endif
385 
386 // STATISTICS: int-prop
387 
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: val.hpp:178
DomCtrl< View > dc
Propagation controller.
Definition: distinct.hh:287
int min_x
Minimum (approximation) of view in x.
Definition: distinct.hh:159
ViewArray< View > x
Views on which to perform bounds-propagation.
Definition: distinct.hh:155
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: pattern.hpp:513
Val(Home home, ViewArray< View > &x)
Constructor for posting.
Definition: val.hpp:147
View-value graph for propagation.
Definition: distinct.hh:218
Domain consistent distinct propagator.
Definition: distinct.hh:283
ViewArray< View > x
Array of views.
Definition: pattern.hpp:145
Base-class for propagators.
Definition: core.hpp:1023
void * mark(void *p)
Return marked pointer for unmarked pointer p.
Computation spaces.
Definition: core.hpp:1701
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition: rel.hpp:264
Base-class for both propagators and branchers.
Definition: core.hpp:627
Graph< View > g
Propagation is performed on a view-value graph.
Definition: distinct.hh:253
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
ViewArray< View > y
Views on which to perform value-propagation (subset of x)
Definition: distinct.hh:157
Binary propagator.
Definition: pattern.hpp:84
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:1034
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear)
Definition: pattern.hpp:500
Ternary propagator.
Definition: pattern.hpp:113
size_t size
The size of the propagator (used during subsumption)
Definition: core.hpp:1036
n-ary propagator
Definition: pattern.hpp:142
View arrays.
Definition: array.hpp:235
View-value graph base class.
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for view array x.
Definition: val.hpp:185
ExecStatus prop_val(Space &home, ViewArray< View > &x)
Eliminate singletons by naive value propagation.
Definition: val.hpp:42
Naive value distinct propagator.
Definition: distinct.hh:64
Integer view for integer variables.
Definition: view.hpp:129
Ternary domain consistent distinct propagator.
Definition: distinct.hh:322
Propagation cost.
Definition: core.hpp:485
ExecStatus
Definition: core.hpp:471
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:43
int max_x
Maximum (approximation) of view in x.
Definition: distinct.hh:161
Equal-if-then-else domain-consistent propagator.
Definition: distinct.hh:349
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: val.hpp:172
Bounds consistent distinct propagator.
Definition: distinct.hh:152
Gecode toplevel namespace
#define GECODE_INT_EXPORT
Definition: int.hh:81
virtual void reschedule(Space &home)
Schedule function.
Definition: pattern.hpp:506
ExecStatus prop_bnd(Space &home, ViewArray< View > &x, int *minsorted, int *maxsorted)
Definition: bnd.hpp:197
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
Home class for posting propagators
Definition: core.hpp:853
Propagation controller for domain consistent distinct.
Definition: distinct.hh:250