main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Mar 24 2020 14:04:04 for Gecode by
doxygen
1.8.17
gecode
int
propagator.hpp
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, 2002
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
namespace
Gecode
{
namespace
Int {
35
53
template
<
class
View, PropCond pc,
class
CtrlView>
54
class
ReUnaryPropagator
:
public
Propagator
{
55
protected
:
57
View
x0
;
59
CtrlView
b
;
61
ReUnaryPropagator
(
Space
& home,
ReUnaryPropagator
&
p
);
63
ReUnaryPropagator
(
Space
& home,
Propagator
&
p
,
64
View
x0
, CtrlView
b
);
66
ReUnaryPropagator
(
Home
home, View
x0
, CtrlView
b
);
67
public
:
69
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
71
virtual
void
reschedule
(
Space
& home);
73
virtual
size_t
dispose
(
Space
& home);
74
};
75
86
template
<
class
View, PropCond pc,
class
CtrlView>
87
class
ReBinaryPropagator
:
public
Propagator
{
88
protected
:
90
View
x0
,
x1
;
92
CtrlView
b
;
94
ReBinaryPropagator
(
Space
& home,
ReBinaryPropagator
&
p
);
96
ReBinaryPropagator
(
Space
& home,
Propagator
&
p
,
97
View
x0
, View
x1
, CtrlView
b
);
99
ReBinaryPropagator
(
Home
home, View
x0
, View
x1
, CtrlView
b
);
100
public
:
102
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
104
virtual
void
reschedule
(
Space
& home);
106
virtual
size_t
dispose
(
Space
& home);
107
};
109
110
122
template
<
class
View0,
PropCond
pc0,
class
View1,
PropCond
pc1,
123
class
CtrlView>
124
class
ReMixBinaryPropagator
:
public
Propagator
{
125
protected
:
127
View0
x0
;
129
View1
x1
;
131
CtrlView
b
;
133
ReMixBinaryPropagator
(
Space
& home,
ReMixBinaryPropagator
&
p
);
135
ReMixBinaryPropagator
(
Home
home, View0
x0
, View1
x1
, CtrlView
b
);
137
ReMixBinaryPropagator
(
Space
& home,
Propagator
&
p
,
138
View0
x0
, View1
x1
, CtrlView
b
);
139
public
:
141
virtual
PropCost
cost
(
const
Space
& home,
const
ModEventDelta
&
med
)
const
;
143
virtual
void
reschedule
(
Space
& home);
145
virtual
size_t
dispose
(
Space
& home);
146
};
147
148
149
/*
150
* Reified unary propagators
151
*
152
*/
153
template
<
class
View, PropCond pc,
class
CtrlView>
154
ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
155
(
Home
home, View y0, CtrlView b0)
156
:
Propagator
(home), x0(y0),
b
(b0) {
157
if
(pc !=
PC_GEN_NONE
)
158
x0.subscribe(home,*
this
,pc);
159
b
.subscribe(home,*
this
,
Int::PC_INT_VAL
);
160
}
161
162
template
<
class
View, PropCond pc,
class
CtrlView>
163
forceinline
164
ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
165
(
Space
& home,
ReUnaryPropagator<View,pc,CtrlView>
&
p
)
166
:
Propagator
(home,
p
) {
167
x0.update(home,
p
.x0);
168
b
.update(home,
p
.b);
169
}
170
171
template
<
class
View, PropCond pc,
class
CtrlView>
172
forceinline
173
ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
174
(
Space
& home,
Propagator
&
p
, View y0, CtrlView b0)
175
:
Propagator
(home,
p
) {
176
x0.update(home,y0);
177
b
.update(home,b0);
178
}
179
180
template
<
class
View, PropCond pc,
class
CtrlView>
181
PropCost
182
ReUnaryPropagator<View,pc,CtrlView>::cost
(
const
Space
&,
const
ModEventDelta
&)
const
{
183
return
PropCost::unary
(
PropCost::LO
);
184
}
185
186
template
<
class
View, PropCond pc,
class
CtrlView>
187
void
188
ReUnaryPropagator<View,pc,CtrlView>::reschedule
(
Space
& home) {
189
if
(pc !=
PC_GEN_NONE
)
190
x0.reschedule(home,*
this
,pc);
191
b
.reschedule(home,*
this
,
Int::PC_INT_VAL
);
192
}
193
194
template
<
class
View, PropCond pc,
class
CtrlView>
195
forceinline
size_t
196
ReUnaryPropagator<View,pc,CtrlView>::dispose
(
Space
& home) {
197
if
(pc !=
PC_GEN_NONE
)
198
x0.cancel(home,*
this
,pc);
199
b
.cancel(home,*
this
,
Int::PC_INT_VAL
);
200
(void)
Propagator::dispose
(home);
201
return
sizeof
(*this);
202
}
203
204
/*
205
* Reified binary propagators
206
*
207
*/
208
template
<
class
View, PropCond pc,
class
CtrlView>
209
ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
210
(
Home
home, View y0, View y1, CtrlView
b1
)
211
:
Propagator
(home), x0(y0), x1(y1),
b
(
b1
) {
212
if
(pc !=
PC_GEN_NONE
) {
213
x0.subscribe(home,*
this
,pc);
214
x1.subscribe(home,*
this
,pc);
215
}
216
b
.subscribe(home,*
this
,
Int::PC_INT_VAL
);
217
}
218
219
template
<
class
View, PropCond pc,
class
CtrlView>
220
forceinline
221
ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
222
(
Space
& home,
ReBinaryPropagator<View,pc,CtrlView>
&
p
)
223
:
Propagator
(home,
p
) {
224
x0.update(home,
p
.x0);
225
x1.update(home,
p
.x1);
226
b
.update(home,
p
.b);
227
}
228
229
template
<
class
View, PropCond pc,
class
CtrlView>
230
forceinline
231
ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
232
(
Space
& home,
Propagator
&
p
, View y0, View y1, CtrlView b0)
233
:
Propagator
(home,
p
) {
234
x0.update(home,y0);
235
x1.update(home,y1);
236
b
.update(home,b0);
237
}
238
239
template
<
class
View, PropCond pc,
class
CtrlView>
240
PropCost
241
ReBinaryPropagator<View,pc,CtrlView>::cost
(
const
Space
&,
const
ModEventDelta
&)
const
{
242
return
PropCost::binary
(
PropCost::LO
);
243
}
244
245
template
<
class
View, PropCond pc,
class
CtrlView>
246
void
247
ReBinaryPropagator<View,pc,CtrlView>::reschedule
(
Space
& home) {
248
if
(pc !=
PC_GEN_NONE
) {
249
x0.reschedule(home,*
this
,pc);
250
x1.reschedule(home,*
this
,pc);
251
}
252
b
.reschedule(home,*
this
,
Int::PC_INT_VAL
);
253
}
254
255
template
<
class
View, PropCond pc,
class
CtrlView>
256
forceinline
size_t
257
ReBinaryPropagator<View,pc,CtrlView>::dispose
(
Space
& home) {
258
if
(pc !=
PC_GEN_NONE
) {
259
x0.cancel(home,*
this
,pc);
260
x1.cancel(home,*
this
,pc);
261
}
262
b
.cancel(home,*
this
,
Int::PC_INT_VAL
);
263
(void)
Propagator::dispose
(home);
264
return
sizeof
(*this);
265
}
266
267
/*
268
* Reified mixed binary propagator
269
*
270
*/
271
template
<
class
View0,
PropCond
pc0,
class
View1,
PropCond
pc1,
272
class
CtrlView>
273
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>
274
::ReMixBinaryPropagator
(
Home
home, View0 y0, View1 y1, CtrlView
b1
)
275
:
Propagator
(home), x0(y0), x1(y1),
b
(
b1
) {
276
if
(pc0 !=
PC_GEN_NONE
)
277
x0.subscribe(home,*
this
,pc0);
278
if
(pc1 !=
PC_GEN_NONE
)
279
x1.subscribe(home,*
this
,pc1);
280
b
.subscribe(home,*
this
,
Int::PC_INT_VAL
);
281
}
282
283
template
<
class
View0,
PropCond
pc0,
class
View1,
PropCond
pc1,
284
class
CtrlView>
285
forceinline
286
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>::ReMixBinaryPropagator
287
(
Space
& home,
288
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>
&
p
)
289
:
Propagator
(home,
p
) {
290
x0.update(home,
p
.x0);
291
x1.update(home,
p
.x1);
292
b
.update(home,
p
.b);
293
}
294
295
template
<
class
View0,
PropCond
pc0,
class
View1,
PropCond
pc1,
296
class
CtrlView>
297
forceinline
298
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>
299
::ReMixBinaryPropagator
300
(
Space
& home,
Propagator
&
p
, View0 y0, View1 y1, CtrlView b0)
301
:
Propagator
(home,
p
) {
302
x0.update(home,y0);
303
x1.update(home,y1);
304
b
.update(home,b0);
305
}
306
307
template
<
class
View0,
PropCond
pc0,
class
View1,
PropCond
pc1,
308
class
CtrlView>
309
PropCost
310
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>
311
::cost
(
const
Space
&,
const
ModEventDelta
&)
const
{
312
return
PropCost::binary
(
PropCost::LO
);
313
}
314
315
template
<
class
View0,
PropCond
pc0,
class
View1,
PropCond
pc1,
316
class
CtrlView>
317
void
318
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>::reschedule
(
Space
& home) {
319
if
(pc0 !=
PC_GEN_NONE
)
320
x0.reschedule(home,*
this
,pc0);
321
if
(pc1 !=
PC_GEN_NONE
)
322
x1.reschedule(home,*
this
,pc1);
323
b
.reschedule(home,*
this
,
Int::PC_INT_VAL
);
324
}
325
326
template
<
class
View0,
PropCond
pc0,
class
View1,
PropCond
pc1,
327
class
CtrlView>
328
forceinline
size_t
329
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>::dispose
(
Space
& home) {
330
if
(pc0 !=
PC_GEN_NONE
)
331
x0.cancel(home,*
this
,pc0);
332
if
(pc1 !=
PC_GEN_NONE
)
333
x1.cancel(home,*
this
,pc1);
334
b
.cancel(home,*
this
,
Int::PC_INT_VAL
);
335
(void)
Propagator::dispose
(home);
336
return
sizeof
(*this);
337
}
338
339
}}
340
341
// STATISTICS: int-prop
342
Gecode::Int::ReMixBinaryPropagator::ReMixBinaryPropagator
ReMixBinaryPropagator(Space &home, ReMixBinaryPropagator &p)
Constructor for cloning p.
Definition:
propagator.hpp:287
Gecode::PropCost::binary
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
Definition:
core.hpp:4809
Gecode::Int::ReBinaryPropagator::x1
View x1
Definition:
propagator.hpp:90
Gecode::PropCost::LO
@ LO
Cheap.
Definition:
core.hpp:513
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Int::ReUnaryPropagator::x0
View x0
Single view.
Definition:
propagator.hpp:57
Gecode::Int::ReMixBinaryPropagator::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition:
propagator.hpp:329
Gecode::Int::ReUnaryPropagator
Reified unary propagator.
Definition:
propagator.hpp:54
Gecode::Int::ReBinaryPropagator::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition:
propagator.hpp:241
Gecode::Int::ReUnaryPropagator::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition:
propagator.hpp:196
Gecode::Int::ReBinaryPropagator::x0
View x0
Two views.
Definition:
propagator.hpp:90
Gecode
Gecode toplevel namespace
Gecode::Propagator
Base-class for propagators.
Definition:
core.hpp:1064
Gecode::Int::ReUnaryPropagator::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition:
propagator.hpp:188
Gecode::Int::ReMixBinaryPropagator::x1
View1 x1
View of type View1.
Definition:
propagator.hpp:129
Gecode::Int::ReMixBinaryPropagator
Reified mixed binary propagator.
Definition:
propagator.hpp:124
Test::Int::Basic::b1
Basic b1(3)
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
Gecode::PropCost::unary
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition:
core.hpp:4813
Gecode::Int::ReBinaryPropagator
Reified binary propagator.
Definition:
propagator.hpp:87
Gecode::Propagator::med
ModEventDelta med
A set of modification events (used during propagation)
Definition:
core.hpp:1075
Gecode::Int::ReUnaryPropagator::ReUnaryPropagator
ReUnaryPropagator(Space &home, ReUnaryPropagator &p)
Constructor for cloning p.
Definition:
propagator.hpp:165
b
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Gecode::Int::ReUnaryPropagator::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
Definition:
propagator.hpp:182
Gecode::PropCond
int PropCond
Type for propagation conditions.
Definition:
core.hpp:72
Gecode::PropCost
Propagation cost.
Definition:
core.hpp:486
Gecode::Int::PC_INT_VAL
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition:
var-type.hpp:82
Gecode::Int::ReMixBinaryPropagator::x0
View0 x0
View of type View0.
Definition:
propagator.hpp:127
Gecode::Int::ReUnaryPropagator::b
CtrlView b
Boolean control view.
Definition:
propagator.hpp:59
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Actor::dispose
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition:
core.hpp:3252
Gecode::Int::ReMixBinaryPropagator::b
CtrlView b
Boolean control view.
Definition:
propagator.hpp:131
Gecode::PC_GEN_NONE
const PropCond PC_GEN_NONE
Propagation condition to be ignored (convenience)
Definition:
core.hpp:74
Gecode::Int::ReMixBinaryPropagator::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition:
propagator.hpp:311
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:89
Gecode::Int::ReMixBinaryPropagator::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition:
propagator.hpp:318
Gecode::Int::ReBinaryPropagator::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition:
propagator.hpp:257
Gecode::Int::ReBinaryPropagator::b
CtrlView b
Boolean control view.
Definition:
propagator.hpp:92
Gecode::Int::ReBinaryPropagator::ReBinaryPropagator
ReBinaryPropagator(Space &home, ReBinaryPropagator &p)
Constructor for cloning p.
Definition:
propagator.hpp:222
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:232
Gecode::Int::ReBinaryPropagator::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition:
propagator.hpp:247