Generated on Sat Feb 7 2015 02:01:20 for Gecode by doxygen 1.8.9.1
channel.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  *
6  * Copyright:
7  * Christian Schulte, 2006
8  *
9  * Last modified:
10  * $Date: 2011-07-07 11:23:22 +0200 (Thu, 07 Jul 2011) $ by $Author: schulte $
11  * $Revision: 12155 $
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 #ifndef __GECODE_INT_CHANNEL_HH__
39 #define __GECODE_INT_CHANNEL_HH__
40 
41 #include <gecode/int.hh>
42 #include <gecode/int/distinct.hh>
43 
49 namespace Gecode { namespace Int { namespace Channel {
50 
53 
58  template<class Info, class Offset, PropCond pc>
59  class Base : public Propagator {
60  protected:
62  int n;
64  int n_na;
70  Info* xy;
72  Base(Space& home, bool share, Base<Info,Offset,pc>& p);
74  Base(Home home, int n, Info* xy, Offset& ox, Offset& oy);
75  public:
77  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
79  virtual size_t dispose(Space& home);
80  };
81 
82 
87  template<class View> class ValInfo;
88 
98  template<class View, class Offset, bool shared>
99  class Val : public Base<ValInfo<View>,Offset,PC_INT_VAL> {
100  protected:
102  using Base<ValInfo<View>,Offset,PC_INT_VAL>::n_na;
103  using Base<ValInfo<View>,Offset,PC_INT_VAL>::xy;
104  using Base<ValInfo<View>,Offset,PC_INT_VAL>::ox;
105  using Base<ValInfo<View>,Offset,PC_INT_VAL>::oy;
107  Val(Space& home, bool share, Val& p);
109  Val(Home home, int n, ValInfo<View>* xy, Offset& ox, Offset& oy);
110  public:
112  virtual Actor* copy(Space& home, bool share);
114  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
116  static ExecStatus post(Home home, int n, ValInfo<View>* xy,
117  Offset& ox, Offset& oy);
118  };
119 
124  template<class View, class Offset> class DomInfo;
125 
135  template<class View, class Offset, bool shared>
136  class Dom : public Base<DomInfo<View,Offset>,Offset,PC_INT_DOM> {
137  protected:
146  Dom(Space& home, bool share, Dom& p);
148  Dom(Home home, int n, DomInfo<View,Offset>* xy, Offset& ox, Offset& oy);
149  public:
151  virtual Actor* copy(Space& home, bool share);
158  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
160  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
162  static ExecStatus post(Home home, int n, DomInfo<View,Offset>* xy,
163  Offset& ox, Offset& oy);
164  };
165 
172  class LinkSingle :
173  public MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
174  private:
177 
179  LinkSingle(Space& home, bool share, LinkSingle& p);
182  public:
184  virtual Actor* copy(Space& home, bool share);
186  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
188  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
190  static ExecStatus post(Home home, BoolView x0, IntView x1);
191  };
192 
199  class LinkMulti :
200  public MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM> {
201  private:
207  static const int S_NONE = 0;
209  static const int S_ONE = 1;
211  static const int S_RUN = 2;
213  int status;
215  int o;
217  LinkMulti(Space& home, bool share, LinkMulti& p);
219  LinkMulti(Home home, ViewArray<BoolView>& x, IntView y, int o0);
220  public:
222  virtual Actor* copy(Space& home, bool share);
224  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
226  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
228  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
231  static ExecStatus post(Home home,
232  ViewArray<BoolView>& x, IntView y, int o);
234  virtual size_t dispose(Space& home);
235  };
236 
237 }}}
238 
242 
245 
246 #endif
247 
248 // STATISTICS: int-prop
249 
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: link-single.cpp:48
Council of advisors
Definition: core.hpp:226
Distinct::DomCtrl< View > dc
Propagation controller for propagating distinct.
Definition: channel.hh:144
static ExecStatus post(Home home, BoolView x0, IntView x1)
Post propagator for .
Definition: link-single.hpp:46
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: link-multi.cpp:127
Offset ox
Offset transformation for x variables.
Definition: channel.hh:66
Mixed (n+1)-ary propagator.
Definition: propagator.hpp:268
Base-class for propagators.
Definition: core.hpp:755
Info * xy
View and information for both x and y.
Definition: channel.hh:70
static ExecStatus post(Home home, int n, ValInfo< View > *xy, Offset &ox, Offset &oy)
Post propagator for channeling.
Definition: val.hpp:235
Offset oy
Offset transformation for y variables.
Definition: channel.hh:68
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition: link-multi.cpp:117
Base-class for advisors.
Definition: core.hpp:926
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: link-multi.cpp:99
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Propagation cost (defined as low quadratic)
Definition: base.hpp:62
Computation spaces.
Definition: core.hpp:1362
Combine view with information for value propagation.
Definition: val.hpp:49
Naive channel propagator.
Definition: channel.hh:99
Base-class for both propagators and branchers.
Definition: core.hpp:666
Gecode::IntSet d(v, 7)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
Dom(Space &home, bool share, Dom &p)
Constructor for cloning p.
int n
Number of views (actually twice as many for both x and y)
Definition: channel.hh:62
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:764
static ExecStatus post(Home home, int n, DomInfo< View, Offset > *xy, Offset &ox, Offset &oy)
Post propagator for channeling on xy.
Definition: dom.hpp:311
Domain consistent channel propagator.
Definition: channel.hh:136
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition: var-type.hpp:100
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition: dom.hpp:192
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: val.hpp:198
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: dom.hpp:202
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: link-single.cpp:58
static ExecStatus post(Home home, ViewArray< BoolView > &x, IntView y, int o)
Post propagator for .
Definition: link-multi.hpp:49
Converter with fixed offset.
Definition: view.hpp:617
Combine view with information for domain propagation.
Definition: dom.hpp:49
Integer view for integer variables.
Definition: view.hpp:129
Val(Space &home, bool share, Val &p)
Constructor for cloning p.
Generic domain change information to be supplied to advisors.
Definition: core.hpp:275
Mixed binary propagator.
Definition: propagator.hpp:203
Base-class for channel propagators.
Definition: channel.hh:59
Propagation cost.
Definition: core.hpp:537
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: link-multi.cpp:94
Link propagator for a single Boolean view.
Definition: channel.hh:172
ExecStatus
Definition: core.hpp:523
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: base.hpp:68
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
Definition: link-single.cpp:53
Stack with fixed number of elements.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: val.hpp:204
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: dom.hpp:186
Base(Space &home, bool share, Base< Info, Offset, pc > &p)
Constructor for cloning p.
Definition: base.hpp:51
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (low unary if y is assigned, low linear otherwise)
Definition: link-multi.cpp:109
Gecode toplevel namespace
Link propagator for multiple Boolean views.
Definition: channel.hh:199
#define GECODE_INT_EXPORT
Definition: int.hh:78
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
Home class for posting propagators
Definition: core.hpp:717
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
Support::StaticStack< int, Region > ProcessStack
Processing stack.
Definition: channel.hh:52
int n_na
Total number of not assigned views (not known to be assigned)
Definition: channel.hh:64
Propagation controller for domain consistent distinct.
Definition: distinct.hh:218
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:82
Boolean view for Boolean variables.
Definition: view.hpp:1315