main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Mar 5 2013 22:37:16 for Gecode by
doxygen
1.8.3.1
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: 2009-10-13 02:36:53 +1100 (Tue, 13 Oct 2009) $ by $Author: schulte $
11
* $Revision: 9878 $
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
forceinline
size_t
78
BoolBinary<BVA,BVB>::dispose
(
Space
& home) {
79
x0.cancel(home,*
this
,
PC_BOOL_VAL
);
80
x1.cancel(home,*
this
,
PC_BOOL_VAL
);
81
(void)
Propagator::dispose
(home);
82
return
sizeof
(*this);
83
}
84
85
/*
86
* Ternary Boolean propagators
87
*
88
*/
89
template
<
class
BVA,
class
BVB,
class
BVC>
90
forceinline
91
BoolTernary<BVA,BVB,BVC>::BoolTernary
92
(
Home
home, BVA b0, BVB
b1
, BVC
b2
)
93
:
Propagator
(home), x0(b0), x1(b1), x2(b2) {
94
x0.subscribe(home,*
this
,
PC_BOOL_VAL
);
95
x1.subscribe(home,*
this
,
PC_BOOL_VAL
);
96
x2.subscribe(home,*
this
,
PC_BOOL_VAL
);
97
}
98
99
template
<
class
BVA,
class
BVB,
class
BVC>
100
forceinline
101
BoolTernary<BVA,BVB,BVC>::BoolTernary
(
Space
& home,
bool
share,
102
BoolTernary<BVA,BVB,BVC>
& p)
103
:
Propagator
(home,share,p) {
104
x0
.update(home,share,p.
x0
);
105
x1
.update(home,share,p.
x1
);
106
x2
.update(home,share,p.
x2
);
107
}
108
109
template
<
class
BVA,
class
BVB,
class
BVC>
110
forceinline
111
BoolTernary<BVA,BVB,BVC>::BoolTernary
(
Space
& home,
bool
share,
Propagator
& p,
112
BVA b0, BVB b1, BVC b2)
113
:
Propagator
(home,share,p) {
114
x0
.update(home,share,b0);
115
x1
.update(home,share,b1);
116
x2
.update(home,share,b2);
117
}
118
119
template
<
class
BVA,
class
BVB,
class
BVC>
120
PropCost
121
BoolTernary<BVA,BVB,BVC>::cost
(
const
Space
&,
const
ModEventDelta
&)
const
{
122
return
PropCost::binary
(
PropCost::LO
);
123
}
124
125
template
<
class
BVA,
class
BVB,
class
BVC>
126
forceinline
size_t
127
BoolTernary<BVA,BVB,BVC>::dispose
(
Space
& home) {
128
x0.cancel(home,*
this
,
PC_BOOL_VAL
);
129
x1.cancel(home,*
this
,
PC_BOOL_VAL
);
130
x2.cancel(home,*
this
,
PC_BOOL_VAL
);
131
(void)
Propagator::dispose
(home);
132
return
sizeof
(*this);
133
}
134
135
}}}
136
137
// STATISTICS: int-prop