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