Generated on Thu Jan 31 2019 20:56:32 for Gecode by doxygen 1.8.15
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: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
11  * $Revision: 15137 $
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 void reschedule(Space& home);
81  virtual size_t dispose(Space& home);
82  };
83 
84 
89  template<class View> class ValInfo;
90 
100  template<class View, class Offset, bool shared>
101  class Val : public Base<ValInfo<View>,Offset,PC_INT_VAL> {
102  protected:
109  Val(Space& home, bool share, Val& p);
111  Val(Home home, int n, ValInfo<View>* xy, Offset& ox, Offset& oy);
112  public:
114  virtual Actor* copy(Space& home, bool share);
116  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
118  static ExecStatus post(Home home, int n, ValInfo<View>* xy,
119  Offset& ox, Offset& oy);
120  };
121 
126  template<class View, class Offset> class DomInfo;
127 
137  template<class View, class Offset, bool shared>
138  class Dom : public Base<DomInfo<View,Offset>,Offset,PC_INT_DOM> {
139  protected:
148  Dom(Space& home, bool share, Dom& p);
150  Dom(Home home, int n, DomInfo<View,Offset>* xy, Offset& ox, Offset& oy);
151  public:
153  virtual Actor* copy(Space& home, bool share);
160  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
162  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
164  static ExecStatus post(Home home, int n, DomInfo<View,Offset>* xy,
165  Offset& ox, Offset& oy);
166  };
167 
174  class LinkSingle :
175  public MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
176  private:
179 
181  LinkSingle(Space& home, bool share, LinkSingle& p);
184  public:
186  virtual Actor* copy(Space& home, bool share);
188  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
190  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
192  static ExecStatus post(Home home, BoolView x0, IntView x1);
193  };
194 
201  class LinkMulti :
202  public MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM> {
203  private:
209  static const int S_NONE = 0;
211  static const int S_ONE = 1;
213  static const int S_RUN = 2;
215  int status;
217  int o;
219  LinkMulti(Space& home, bool share, LinkMulti& p);
221  LinkMulti(Home home, ViewArray<BoolView>& x, IntView y, int o0);
222  public:
225  virtual Actor* copy(Space& home, bool share);
228  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
231  virtual void reschedule(Space& home);
234  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
237  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
239  static ExecStatus post(Home home,
240  ViewArray<BoolView>& x, IntView y, int o);
243  virtual size_t dispose(Space& home);
244  };
245 
246 }}}
247 
251 
254 
255 #endif
256 
257 // STATISTICS: int-prop
258 
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: link-single.cpp:48
Council of advisors
Definition: core.hpp:232
Distinct::DomCtrl< View > dc
Propagation controller for propagating distinct.
Definition: channel.hh:146
virtual void reschedule(Space &home)
Schedule function.
Definition: link-multi.cpp:109
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:126
Offset ox
Offset transformation for x variables.
Definition: channel.hh:66
Mixed (n+1)-ary propagator.
Definition: propagator.hpp:282
Base-class for propagators.
Definition: core.hpp:1092
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:116
Base-class for advisors.
Definition: core.hpp:1294
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: link-multi.cpp:91
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition: dom.hpp:192
Computation spaces.
Definition: core.hpp:1748
Combine view with information for value propagation.
Definition: val.hpp:49
Naive channel propagator.
Definition: channel.hh:101
Base-class for both propagators and branchers.
Definition: core.hpp:696
Gecode::IntSet d(v, 7)
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
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:1103
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:138
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition: var-type.hpp:100
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 PropCost cost(const Space &home, const ModEventDelta &med) const
Propagation cost (defined as low quadratic)
Definition: base.hpp:62
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:57
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:281
Mixed binary propagator.
Definition: propagator.hpp:213
Base-class for channel propagators.
Definition: channel.hh:59
Propagation cost.
Definition: core.hpp:554
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: link-multi.cpp:86
Link propagator for a single Boolean view.
Definition: channel.hh:174
ExecStatus
Definition: core.hpp:540
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:101
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: base.hpp:75
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
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
Definition: link-single.cpp:53
Base(Space &home, bool share, Base< Info, Offset, pc > &p)
Constructor for cloning p.
Definition: base.hpp:51
Gecode toplevel namespace
Link propagator for multiple Boolean views.
Definition: channel.hh:201
virtual void reschedule(Space &home)
Schedule function.
Definition: base.hpp:68
#define GECODE_INT_EXPORT
Definition: int.hh:81
int ModEventDelta
Modification event deltas.
Definition: core.hpp:169
Home class for posting propagators
Definition: core.hpp:922
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:220
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