Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
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 * Denys Duchier <denys.duchier@univ-orleans.fr>
5 * Guido Tack <tack@gecode.org>
6 * Christian Schulte <schulte@gecode.org>
7 *
8 * Copyright:
9 * Denys Duchier, 2011
10 * Guido Tack, 2011
11 * Christian Schulte, 2004
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_SET_CHANNEL_HH__
39#define __GECODE_SET_CHANNEL_HH__
40
41#include <gecode/set.hh>
42
43namespace Gecode { namespace Set { namespace Channel {
44
49
50
51
52
59 template<class View>
60 class ChannelSorted : public Propagator {
61 protected:
66
71 public:
73 virtual Actor* copy(Space& home);
75 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
77 virtual void reschedule(Space& home);
79 virtual size_t dispose(Space& home);
81 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
83 static ExecStatus post(Home home, View s,
85 };
86
104 template<class View>
105 class ChannelInt : public Propagator {
106 protected:
111
113 ChannelInt(Space& home, ChannelInt& p);
115 ChannelInt(Home home,
118 public:
120 virtual Actor* copy(Space& home);
122 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
124 virtual void reschedule(Space& home);
126 virtual size_t dispose(Space& home);
128 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
130 static ExecStatus post(Home home,
134 };
135
147 template<class View>
149 : public MixNaryOnePropagator<Gecode::Int::BoolView,
150 Gecode::Int::PC_BOOL_VAL,
151 View,PC_GEN_NONE> {
152 protected:
156 using Super::x;
157 using Super::y;
158
160 ChannelBool(Space& home, ChannelBool& p);
163 View);
164
166 class IndexAdvisor : public Advisor {
167 protected:
169 int idx;
170 public:
172 template<class A>
174 int index);
178 int index(void) const;
180 template<class A>
181 void dispose(Space& home, Council<A>& c);
182 };
183
194 public:
196 virtual Actor* copy(Space& home);
198 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
200 virtual void reschedule(Space& home);
202 virtual size_t dispose(Space& home);
204 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
206 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
209 View y);
210 };
211
224
225 template<typename View>
226 class ChannelSet: public Propagator {
227 protected:
232
234 ChannelSet(Space& home, ChannelSet& p);
236 ChannelSet(Home home,
239 public:
241 virtual Actor* copy(Space& home);
243 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
245 virtual void reschedule(Space& home);
247 virtual size_t dispose(Space& home);
249 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
251 static ExecStatus post(Home home,
254 };
255
256}}}
257
262
263#endif
264
265// STATISTICS: set-prop
Advisor(Space &home, Propagator &p, Council< A > &c)
Constructor for creation.
Definition core.hpp:3838
friend class Council
Definition core.hpp:1296
Generic domain change information to be supplied to advisors.
Definition core.hpp:204
Home class for posting propagators
Definition core.hpp:856
Boolean view for Boolean variables.
Definition view.hpp:1380
Cached integer view.
Definition view.hpp:1166
Integer view for integer variables.
Definition view.hpp:129
Propagation cost.
Definition core.hpp:486
friend class Space
Definition core.hpp:1068
friend class Advisor
Definition core.hpp:1070
friend class Council
Definition core.hpp:1071
ModEventDelta med
A set of modification events (used during propagation)
Definition core.hpp:1077
Propagator(Home home)
Constructor for posting.
Definition core.hpp:3505
IndexAdvisor(Space &home, ChannelBool< View > &p, Council< A > &c, int index)
Constructor for creation.
Definition bool.hpp:41
int index(void) const
Access index.
Definition bool.hpp:59
void dispose(Space &home, Council< A > &c)
Delete advisor.
Definition bool.hpp:66
GLBndSet zeros
Accumulated zero Booleans.
Definition channel.hh:189
ChannelBool(Space &home, ChannelBool &p)
Constructor for cloning p.
Definition bool.hpp:111
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition bool.hpp:204
virtual void reschedule(Space &home)
Schedule function.
Definition bool.hpp:133
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition bool.hpp:140
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition bool.hpp:154
Council< IndexAdvisor > co
Council for managing advisors.
Definition channel.hh:185
SetDelta delta
Accumulated delta information.
Definition channel.hh:187
GLBndSet ones
Accumulated one Booleans.
Definition channel.hh:191
bool running
Flag whether propagation is currently running.
Definition channel.hh:193
MixNaryOnePropagator< Gecode::Int::BoolView, Gecode::Int::PC_BOOL_VAL, View, PC_GEN_NONE > Super
Definition channel.hh:155
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition bool.hpp:148
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_QUADRATIC_LO)
Definition bool.hpp:127
static ExecStatus post(Home home, ViewArray< Gecode::Int::BoolView > &x, View y)
Post propagator for .
Definition bool.hpp:118
ViewArray< Gecode::Int::BoolView > x
Array of views.
Definition pattern.hpp:275
static ExecStatus post(Home home, ViewArray< Gecode::Int::CachedView< Gecode::Int::IntView > > &x, ViewArray< CachedView< View > > &y)
Post propagator for .
Definition int.hpp:67
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_QUADRATIC_LO)
Definition int.hpp:93
ChannelInt(Space &home, ChannelInt &p)
Constructor for cloning p.
Definition int.hpp:59
ViewArray< Gecode::Int::CachedView< Gecode::Int::IntView > > xs
IntViews, reflects which set contains element .
Definition channel.hh:108
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition int.hpp:121
virtual void reschedule(Space &home)
Schedule function.
Definition int.hpp:99
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition int.hpp:115
ViewArray< CachedView< View > > ys
SetViews that are constrained to be disjoint.
Definition channel.hh:110
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition int.hpp:106
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition set.hpp:92
virtual void reschedule(Space &home)
Schedule function.
Definition set.hpp:85
static ExecStatus post(Home home, ViewArray< CachedView< View > > &x, ViewArray< CachedView< View > > &y)
Post propagator for .
Definition set.hpp:60
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_QUADRATIC_HI)
Definition set.hpp:79
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition set.hpp:101
ChannelSet(Space &home, ChannelSet &p)
Constructor for cloning p.
Definition set.hpp:52
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition set.hpp:107
ViewArray< CachedView< View > > xs
SetViews, reflects the successors of .
Definition channel.hh:229
ViewArray< CachedView< View > > ys
SetViews, reflects the predecessors of .
Definition channel.hh:231
virtual void reschedule(Space &home)
Schedule function.
Definition sorted.hpp:90
ChannelSorted(Space &home, ChannelSorted &p)
Constructor for cloning p.
Definition sorted.hpp:57
static ExecStatus post(Home home, View s, ViewArray< Gecode::Int::IntView > &x)
Post propagator that propagates that s contains the , which are sorted in non-descending order.
Definition sorted.hpp:65
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition sorted.hpp:106
virtual size_t dispose(Space &home)
Delete Propagator.
Definition sorted.hpp:97
View x0
SetView for the match.
Definition channel.hh:63
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition sorted.hpp:112
ViewArray< Gecode::Int::IntView > xs
IntViews that together form the set x0.
Definition channel.hh:65
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_LINEAR_LO)
Definition sorted.hpp:84
Growing sets of integers.
Definition var-imp.hpp:205
Finite set delta information for advisors.
Definition var-imp.hpp:52
View arrays.
Definition array.hpp:253
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
Channel propagators
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
Definition var-type.hpp:126
Finite integer sets.
Definition var-imp.hpp:137
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:773
ExecStatus
Definition core.hpp:472
Post propagator for SetVar x
Definition set.hh:773
const PropCond PC_GEN_NONE
Propagation condition to be ignored (convenience)
Definition core.hpp:74