Generated on Mon Jul 27 2020 00:00:00 for Gecode by doxygen 1.8.18
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  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 #ifndef __GECODE_INT_CHANNEL_HH__
35 #define __GECODE_INT_CHANNEL_HH__
36 
37 #include <gecode/int.hh>
38 #include <gecode/int/distinct.hh>
39 
45 namespace Gecode { namespace Int { namespace Channel {
46 
49 
54  template<class Info, class Offset, PropCond pc>
55  class Base : public Propagator {
56  protected:
58  int n;
60  int n_na;
66  Info* xy;
70  Base(Home home, int n, Info* xy, Offset& ox, Offset& oy);
71  public:
73  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
75  virtual void reschedule(Space& home);
77  virtual size_t dispose(Space& home);
78  };
79 
80 
85  template<class View> class ValInfo;
86 
96  template<class View, class Offset, bool shared>
97  class Val : public Base<ValInfo<View>,Offset,PC_INT_VAL> {
98  protected:
105  Val(Space& home, Val& p);
107  Val(Home home, int n, ValInfo<View>* xy, Offset& ox, Offset& oy);
108  public:
110  virtual Actor* copy(Space& home);
112  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
114  static ExecStatus post(Home home, int n, ValInfo<View>* xy,
115  Offset& ox, Offset& oy);
116  };
117 
122  template<class View, class Offset> class DomInfo;
123 
133  template<class View, class Offset, bool shared>
134  class Dom : public Base<DomInfo<View,Offset>,Offset,PC_INT_DOM> {
135  protected:
144  Dom(Space& home, Dom& p);
146  Dom(Home home, int n, DomInfo<View,Offset>* xy, Offset& ox, Offset& oy);
147  public:
149  virtual Actor* copy(Space& home);
156  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
158  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
160  static ExecStatus post(Home home, int n, DomInfo<View,Offset>* xy,
161  Offset& ox, Offset& oy);
162  };
163 
170  class LinkSingle :
171  public MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
172  private:
175 
177  LinkSingle(Space& home, LinkSingle& p);
180  public:
182  virtual Actor* copy(Space& home);
184  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
186  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
188  static ExecStatus post(Home home, BoolView x0, IntView x1);
189  };
190 
197  class LinkMulti :
198  public MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM> {
199  private:
205  static const int S_NONE = 0;
207  static const int S_ONE = 1;
209  static const int S_RUN = 2;
211  int status;
213  int o;
215  LinkMulti(Space& home, LinkMulti& p);
217  LinkMulti(Home home, ViewArray<BoolView>& x, IntView y, int o0);
218  public:
221  virtual Actor* copy(Space& home);
224  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
227  virtual void reschedule(Space& home);
230  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
233  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
235  static ExecStatus post(Home home,
236  ViewArray<BoolView>& x, IntView y, int o);
239  virtual size_t dispose(Space& home);
240  };
241 
242 }}}
243 
247 
250 
251 #endif
252 
253 // STATISTICS: int-prop
254 
IntView y
Single view.
Definition: pattern.hpp:277
Converter with fixed offset.
Definition: view.hpp:650
static ExecStatus post(Home home, BoolView x0, IntView x1)
Post propagator for .
Definition: link-single.hpp:42
Base(Space &home, Base< Info, Offset, pc > &p)
Constructor for cloning p.
Definition: base.hpp:47
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: dom.hpp:180
ViewArray< BoolView > x
Array of views.
Definition: pattern.hpp:275
BoolView x0
View of type View0.
Definition: pattern.hpp:207
Stack with fixed number of elements.
Computation spaces.
Definition: core.hpp:1742
static ExecStatus post(Home home, ViewArray< BoolView > &x, IntView y, int o)
Post propagator for .
Definition: link-multi.hpp:53
Base-class for both propagators and branchers.
Definition: core.hpp:628
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: link-multi.cpp:87
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: link-multi.cpp:82
static ExecStatus post(Home home, int n, ValInfo< View > *xy, Offset &ox, Offset &oy)
Post propagator for channeling.
Definition: val.hpp:230
Link propagator for a single Boolean view.
Definition: channel.hh:171
Info * xy
View and information for both x and y.
Definition: channel.hh:66
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition: link-multi.cpp:112
Mixed (n+1)-ary propagator.
Definition: pattern.hpp:272
Base-class for channel propagators.
Definition: channel.hh:55
Offset ox
Offset transformation for x variables.
Definition: channel.hh:62
Distinct::DomCtrl< View > dc
Propagation controller for propagating distinct.
Definition: channel.hh:142
IntView x1
View of type View1.
Definition: pattern.hpp:209
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: link-multi.cpp:122
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: val.hpp:199
Boolean view for Boolean variables.
Definition: view.hpp:1380
Gecode toplevel namespace
Base-class for propagators.
Definition: core.hpp:1064
Mixed binary propagator.
Definition: pattern.hpp:204
static ExecStatus post(Home home, int n, DomInfo< View, Offset > *xy, Offset &ox, Offset &oy)
Post propagator for channeling on xy.
Definition: dom.hpp:307
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Propagation cost (defined as low quadratic)
Definition: base.hpp:58
Propagation controller for domain consistent distinct.
Definition: distinct.hh:250
int n
Number of views (actually twice as many for both x and y)
Definition: channel.hh:58
Link propagator for multiple Boolean views.
Definition: channel.hh:198
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: val.hpp:193
Generic domain change information to be supplied to advisors.
Definition: core.hpp:204
Domain consistent channel propagator.
Definition: channel.hh:134
#define GECODE_INT_EXPORT
Definition: int.hh:81
Home class for posting propagators
Definition: core.hpp:856
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: link-single.cpp:44
virtual void reschedule(Space &home)
Schedule function.
Definition: link-multi.cpp:105
Support::StaticStack< int, Region > ProcessStack
Processing stack.
Definition: channel.hh:48
Offset oy
Offset transformation for y variables.
Definition: channel.hh:64
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
Definition: link-single.cpp:49
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:1075
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:97
Dom(Space &home, Dom &p)
Constructor for cloning p.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: base.hpp:71
int n_na
Total number of not assigned views (not known to be assigned)
Definition: channel.hh:60
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: link-single.cpp:54
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
virtual void reschedule(Space &home)
Schedule function.
Definition: base.hpp:64
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: dom.hpp:196
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition: dom.hpp:186
Propagation cost.
Definition: core.hpp:486
Combine view with information for domain propagation.
Definition: dom.hpp:45
Council of advisors
Definition: core.hpp:155
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:82
Gecode::IntSet d(v, 7)
Base-class for advisors.
Definition: core.hpp:1292
Naive channel propagator.
Definition: channel.hh:97
Integer view for integer variables.
Definition: view.hpp:129
Val(Space &home, Val &p)
Constructor for cloning p.
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition: var-type.hpp:100
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
ExecStatus
Definition: core.hpp:472
Combine view with information for value propagation.
Definition: val.hpp:45