Generated on Sat Feb 7 2015 02:01:22 for Gecode by doxygen 1.8.9.1
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  * Last modified:
16  * $Date: 2011-10-06 17:27:42 +0200 (Thu, 06 Oct 2011) $ by $Author: schulte $
17  * $Revision: 12423 $
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_INT_DISTINCT_HH__
45 #define __GECODE_INT_DISTINCT_HH__
46 
47 #include <gecode/int.hh>
48 
50 #include <gecode/int/rel.hh>
51 
57 namespace Gecode { namespace Int { namespace Distinct {
58 
67  template<class View>
68  class Val : public NaryPropagator<View,PC_INT_VAL> {
69  protected:
71 
73  Val(Home home, ViewArray<View>& x);
75  Val(Space& home, bool share, Val<View>& p);
76  public:
78  virtual Actor* copy(Space& home, bool share);
80  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
82  static ExecStatus post(Home home, ViewArray<View>& x);
83  };
84 
98  template<class View, bool complete>
100 
101 
102 
128  template<class View>
129  class Bnd : public Propagator {
130  protected:
136  int min_x;
138  int max_x;
140  Bnd(Home home, ViewArray<View>& x);
142  Bnd(Space& home, bool share, Bnd<View>& p);
143  public:
145  static ExecStatus post(Home home, ViewArray<View>& x);
147  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
154  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
156  virtual Actor* copy(Space& home, bool share);
158  virtual size_t dispose(Space& home);
159  };
160 
169  template<class View>
170  ExecStatus prop_bnd(Space& home, ViewArray<View>& x, int& min_x, int& max_x);
171 
180  template<class View>
182 
183 
185  template<class View>
186  class Graph : public ViewValGraph::Graph<View> {
187  public:
196  Graph(void);
200  bool mark(Space& home);
202  ExecStatus prune(Space& home, bool& assigned);
204  bool sync(Space& home);
205  };
206 
217  template<class View>
218  class DomCtrl {
219  protected:
222  public:
224  DomCtrl(void);
226  bool available(void);
230  ExecStatus sync(Space& home);
232  ExecStatus propagate(Space& home, bool& assigned);
233  };
234 
250  template<class View>
251  class Dom : public NaryPropagator<View,PC_INT_DOM> {
252  protected:
257  Dom(Space& home, bool share, Dom<View>& p);
259  Dom(Home home, ViewArray<View>& x);
260  public:
262  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
269  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
271  virtual Actor* copy(Space& home, bool share);
273  static ExecStatus post(Home home, ViewArray<View>& x);
274  };
275 
282  template<class View>
283  class TerDom : public TernaryPropagator<View,PC_INT_DOM> {
284  protected:
288 
290  TerDom(Space& home, bool share, TerDom<View>& p);
292  TerDom(Home home, View x0, View x1, View x2);
293  public:
295  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
297  virtual Actor* copy(Space& home, bool share);
299  static ExecStatus post(Home home, View x0, View x1, View x2);
300  };
301 
302 }}}
303 
310 
311 #endif
312 
313 // STATISTICS: int-prop
314 
bool mark(Space &home)
Mark edges in graph, return true if pruning is at all possible.
Definition: graph.hpp:178
static ExecStatus post(Home home, View x0, View x1, View x2)
Post propagator for views x.
Definition: ter-dom.hpp:53
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: val.hpp:167
DomCtrl< View > dc
Propagation controller.
Definition: distinct.hh:255
int min_x
Minimum (approximation) of view in x.
Definition: distinct.hh:136
ViewArray< View > x
Views on which to perform bounds-propagation.
Definition: distinct.hh:132
Dom(Space &home, bool share, Dom< View > &p)
Constructor for cloning p.
Definition: dom.hpp:64
ExecStatus init(Space &home, ViewArray< View > &x)
Initialize view-value graph for views x.
Definition: dom-ctrl.hpp:59
Val(Home home, ViewArray< View > &x)
Constructor for posting.
Definition: val.hpp:151
View-value graph for propagation.
Definition: distinct.hh:186
TerDom(Space &home, bool share, TerDom< View > &p)
Constructor for cloning p.
Definition: ter-dom.hpp:60
Domain consistent distinct propagator.
Definition: distinct.hh:251
ViewArray< View > x
Array of views.
Definition: propagator.hpp:146
Base-class for propagators.
Definition: core.hpp:755
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for views x.
Definition: dom.hpp:49
ExecStatus prune(Space &home, bool &assigned)
Prune unmarked edges, assigned is true if a view got assigned.
Definition: graph.hpp:242
Bnd(Home home, ViewArray< View > &x)
Constructor for posting.
Definition: bnd.hpp:42
Computation spaces.
Definition: core.hpp:1362
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: bnd.hpp:379
Base-class for both propagators and branchers.
Definition: core.hpp:666
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition: dom.hpp:69
Graph< View > g
Propagation is performed on a view-value graph.
Definition: distinct.hh:221
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: val.hpp:161
ExecStatus init(Space &home, ViewArray< View > &x)
Initialize graph.
Definition: graph.hpp:48
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
Graph(void)
Construct graph as not yet initialized.
Definition: graph.hpp:44
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for view array x.
Definition: bnd.hpp:459
ViewArray< View > y
Views on which to perform value-propagation (subset of x)
Definition: distinct.hh:134
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: bnd.hpp:76
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:764
Ternary propagator.
Definition: propagator.hpp:115
n-ary propagator
Definition: propagator.hpp:143
View arrays.
Definition: array.hpp:234
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: ter-dom.hpp:97
View-value graph base class.
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for view array x.
Definition: val.hpp:174
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: dom.hpp:78
ExecStatus sync(Space &home)
Synchronize available view-value graph.
Definition: dom-ctrl.hpp:65
ExecStatus prop_val(Space &home, ViewArray< View > &x)
Eliminate singletons by naive value propagation.
Definition: val.hpp:46
Naive value distinct propagator.
Definition: distinct.hh:68
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: ter-dom.hpp:65
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Ternary domain consistent distinct propagator.
Definition: distinct.hh:283
Propagation cost.
Definition: core.hpp:537
ExecStatus
Definition: core.hpp:523
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: dom.hpp:84
DomCtrl(void)
Initialize with non-initialized view-value graph.
Definition: dom-ctrl.hpp:49
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:47
int max_x
Maximum (approximation) of view in x.
Definition: distinct.hh:138
ExecStatus propagate(Space &home, bool &assigned)
Perform propagation, assigned is true if a view gets assigned.
Definition: dom-ctrl.hpp:72
Bounds consistent distinct propagator.
Definition: distinct.hh:129
Gecode toplevel namespace
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition: bnd.hpp:82
bool available(void)
Check whether a view-value graph is available.
Definition: dom-ctrl.hpp:53
ExecStatus prop_bnd(Space &home, ViewArray< View > &x, int *minsorted, int *maxsorted)
Definition: bnd.hpp:195
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
bool sync(Space &home)
Synchronize graph with new view domains.
Definition: graph.hpp:116
virtual size_t dispose(Space &home)
Destructor.
Definition: bnd.hpp:60
Home class for posting propagators
Definition: core.hpp:717
Propagation controller for domain consistent distinct.
Definition: distinct.hh:218