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
bool
base.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, 2004
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 {
namespace
Bool {
39
40
/*
41
* Binary Boolean propagators
42
*
43
*/
44
template
<
class
BVA,
class
BVB>
45
forceinline
46
BoolBinary<BVA,BVB>::BoolBinary
(
Home
home, BVA b0, BVB
b1
)
47
:
Propagator
(home), x0(b0), x1(
b1
) {
48
x0.subscribe(home,*
this
,
PC_BOOL_VAL
);
49
x1.subscribe(home,*
this
,
PC_BOOL_VAL
);
50
}
51
52
template
<
class
BVA,
class
BVB>
53
forceinline
54
BoolBinary<BVA,BVB>::BoolBinary
(
Space
& home,
bool
share,
55
BoolBinary<BVA,BVB>
&
p
)
56
:
Propagator
(home,share,
p
) {
57
x0.update(home,share,
p
.x0);
58
x1.update(home,share,
p
.x1);
59
}
60
61
template
<
class
BVA,
class
BVB>
62
forceinline
63
BoolBinary<BVA,BVB>::BoolBinary
(
Space
& home,
bool
share,
Propagator
&
p
,
64
BVA b0, BVB
b1
)
65
:
Propagator
(home,share,
p
) {
66
x0.update(home,share,b0);
67
x1.update(home,share,
b1
);
68
}
69
70
template
<
class
BVA,
class
BVB>
71
PropCost
72
BoolBinary<BVA,BVB>::cost
(
const
Space
&,
const
ModEventDelta
&)
const
{
73
return
PropCost::unary
(PropCost::LO);
74
}
75
76
template
<
class
BVA,
class
BVB>
77
void
78
BoolBinary<BVA,BVB>::reschedule
(
Space
& home) {
79
x0.reschedule(home,*
this
,
PC_BOOL_VAL
);
80
x1.reschedule(home,*
this
,
PC_BOOL_VAL
);
81
}
82
83
template
<
class
BVA,
class
BVB>
84
forceinline
size_t
85
BoolBinary<BVA,BVB>::dispose
(
Space
& home) {
86
x0.cancel(home,*
this
,
PC_BOOL_VAL
);
87
x1.cancel(home,*
this
,
PC_BOOL_VAL
);
88
(void) Propagator::dispose(home);
89
return
sizeof
(*this);
90
}
91
92
/*
93
* Ternary Boolean propagators
94
*
95
*/
96
template
<
class
BVA,
class
BVB,
class
BVC>
97
forceinline
98
BoolTernary<BVA,BVB,BVC>::BoolTernary
99
(
Home
home, BVA b0, BVB
b1
, BVC
b2
)
100
:
Propagator
(home), x0(b0), x1(
b1
), x2(
b2
) {
101
x0.subscribe(home,*
this
,
PC_BOOL_VAL
);
102
x1.subscribe(home,*
this
,
PC_BOOL_VAL
);
103
x2.subscribe(home,*
this
,
PC_BOOL_VAL
);
104
}
105
106
template
<
class
BVA,
class
BVB,
class
BVC>
107
forceinline
108
BoolTernary<BVA,BVB,BVC>::BoolTernary
(
Space
& home,
bool
share,
109
BoolTernary<BVA,BVB,BVC>
&
p
)
110
:
Propagator
(home,share,
p
) {
111
x0
.update(home,share,
p
.x0);
112
x1
.update(home,share,
p
.x1);
113
x2
.update(home,share,
p
.x2);
114
}
115
116
template
<
class
BVA,
class
BVB,
class
BVC>
117
forceinline
118
BoolTernary<BVA,BVB,BVC>::BoolTernary
(
Space
& home,
bool
share,
Propagator
&
p
,
119
BVA b0, BVB
b1
, BVC
b2
)
120
:
Propagator
(home,share,
p
) {
121
x0
.update(home,share,b0);
122
x1
.update(home,share,
b1
);
123
x2
.update(home,share,
b2
);
124
}
125
126
template
<
class
BVA,
class
BVB,
class
BVC>
127
PropCost
128
BoolTernary<BVA,BVB,BVC>::cost
(
const
Space
&,
const
ModEventDelta
&)
const
{
129
return
PropCost::binary
(
PropCost::LO
);
130
}
131
132
template
<
class
BVA,
class
BVB,
class
BVC>
133
void
134
BoolTernary<BVA,BVB,BVC>::reschedule
(
Space
& home) {
135
x0.reschedule(home,*
this
,
PC_BOOL_VAL
);
136
x1.reschedule(home,*
this
,
PC_BOOL_VAL
);
137
x2.reschedule(home,*
this
,
PC_BOOL_VAL
);
138
}
139
140
template
<
class
BVA,
class
BVB,
class
BVC>
141
forceinline
size_t
142
BoolTernary<BVA,BVB,BVC>::dispose
(
Space
& home) {
143
x0.cancel(home,*
this
,
PC_BOOL_VAL
);
144
x1.cancel(home,*
this
,
PC_BOOL_VAL
);
145
x2.cancel(home,*
this
,
PC_BOOL_VAL
);
146
(void)
Propagator::dispose
(home);
147
return
sizeof
(*this);
148
}
149
150
}}}
151
152
// STATISTICS: int-prop
Gecode::Int::Bool::BoolTernary::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition:
base.hpp:142
Gecode::Int::PC_BOOL_VAL
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
Definition:
var-type.hpp:126
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::PropCost::binary
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
Definition:
core.hpp:4854
Gecode::Int::Bool::BoolTernary::x1
BVB x1
Boolean view.
Definition:
bool.hh:84
Gecode::Int::Bool::BoolTernary::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition:
base.hpp:134
Gecode::Int::Bool::BoolTernary::x0
BVA x0
Boolean view.
Definition:
bool.hh:83
Gecode::PropCost::LO
@ LO
Cheap.
Definition:
core.hpp:581
Gecode::Int::Bool::BoolBinary::BoolBinary
BoolBinary(Home home, BVA b0, BVB b1)
Definition:
base.hpp:46
Gecode::Int::Bool::BoolTernary::x2
BVC x2
Boolean view Constructor for posting.
Definition:
bool.hh:85
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode
Gecode toplevel namespace
Gecode::Propagator
Base-class for propagators.
Definition:
core.hpp:1092
Gecode::Int::Count::reschedule
void reschedule(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:96
Test::Int::Basic::b1
Basic b1(3)
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:922
Gecode::Int::Bool::BoolTernary::BoolTernary
BoolTernary(Home home, BVA b0, BVB b1, BVC b2)
Definition:
base.hpp:99
Test::Int::Basic::b2
Basic b2(i)
Gecode::Int::Bool::BoolTernary::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition:
base.hpp:128
Gecode::Int::Bool::BoolBinary
Base-class for binary Boolean propagators.
Definition:
bool.hh:59
Gecode::Int::Bool::BoolTernary
Base-class for ternary Boolean propagators.
Definition:
bool.hh:81
Gecode::PropCost
Propagation cost.
Definition:
core.hpp:554
Gecode::Actor::dispose
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition:
core.hpp:3354
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:169
Gecode::unary
void unary(Home home, const IntVarArgs &s, const IntArgs &p, IntPropLevel ipl)
Post propagators for scheduling tasks on unary resources.
Definition:
unary.cpp:48
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:236