main page
modules
namespaces
classes
files
Gecode home
Generated on Sun Aug 9 2020 05:34:08 for Gecode by
doxygen
1.8.18
gecode
set
rel-op
post.hpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Guido Tack <tack@gecode.org>
5
*
6
* Contributing authors:
7
* Gabor Szokoli <szokoli@gecode.org>
8
*
9
* Copyright:
10
* Guido Tack, 2004, 2005
11
*
12
* This file is part of Gecode, the generic constraint
13
* development environment:
14
* http://www.gecode.org
15
*
16
* Permission is hereby granted, free of charge, to any person obtaining
17
* a copy of this software and associated documentation files (the
18
* "Software"), to deal in the Software without restriction, including
19
* without limitation the rights to use, copy, modify, merge, publish,
20
* distribute, sublicense, and/or sell copies of the Software, and to
21
* permit persons to whom the Software is furnished to do so, subject to
22
* the following conditions:
23
*
24
* The above copyright notice and this permission notice shall be
25
* included in all copies or substantial portions of the Software.
26
*
27
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
*
35
*/
36
37
#include <
gecode/set.hh
>
38
#include <
gecode/set/rel.hh
>
39
#include <
gecode/set/rel-op.hh
>
40
41
namespace
Gecode
{
namespace
Set {
namespace
RelOp {
42
43
template
<
class
View0,
class
View1,
class
Res>
44
forceinline
void
45
rel_eq
(
Home
home, View0 x0,
SetOpType
op
, View1 x1, Res x2) {
46
switch
(
op
) {
47
case
SOT_DUNION
:
48
{
49
EmptyView
emptyset;
50
GECODE_ES_FAIL
((
SuperOfInter<View0,View1,EmptyView>
51
::
post
(home, x0, x1, emptyset)));
52
// fall through to SOT_UNION
53
}
54
case
SOT_UNION
:
55
{
56
GECODE_ES_FAIL
(
57
(
Union<View0,View1,Res>
58
::
post
(home, x0, x1, x2)));
59
}
60
break
;
61
case
SOT_INTER
:
62
{
63
GECODE_ES_FAIL
((
Intersection<View0,View1,Res>
64
::
post
(home, x0,x1,x2)));
65
}
66
break
;
67
case
SOT_MINUS
:
68
{
69
ComplementView<View1>
cx1(x1);
70
GECODE_ES_FAIL
(
71
(
Intersection
<View0,
72
ComplementView<View1>
,Res>
73
::
post
(home,x0,cx1,x2)));
74
}
75
break
;
76
}
77
}
78
79
template
<
class
View0,
class
View1,
class
View2>
80
forceinline
void
81
rel_sub
(
Home
home, View0 x0,
SetOpType
op
, View1 x1, View2 x2) {
82
switch
(
op
) {
83
case
SOT_DUNION
:
84
{
85
EmptyView
emptyset;
86
GECODE_ES_FAIL
((
SuperOfInter<View0,View1,EmptyView>
87
::
post
(home, x0, x1, emptyset)));
88
// fall through to SOT_UNION
89
}
90
case
SOT_UNION
:
91
{
92
SetVar
tmp(home);
93
GECODE_ES_FAIL
(
94
(
Rel::Subset<SetView,View2>::post
(home,tmp,x2)));
95
96
GECODE_ES_FAIL
(
97
(
Union<View0,View1,SetView>
98
::
post
(home, x0, x1, tmp)));
99
}
100
break
;
101
case
SOT_INTER
:
102
{
103
GECODE_ES_FAIL
((
SuperOfInter<View0,View1,View2>
104
::
post
(home, x0,x1,x2)));
105
}
106
break
;
107
case
SOT_MINUS
:
108
{
109
ComplementView<View1>
cx1(x1);
110
GECODE_ES_FAIL
(
111
(
SuperOfInter
<View0,
112
ComplementView<View1>
,View2>
113
::
post
(home,x0,cx1,x2)));
114
}
115
break
;
116
}
117
118
}
119
120
template
<
class
View0,
class
View1,
class
View2>
121
forceinline
void
122
rel_sup
(
Home
home, View0 x0,
SetOpType
op
, View1 x1, View2 x2) {
123
switch
(
op
) {
124
case
SOT_DUNION
:
125
{
126
EmptyView
emptyset;
127
GECODE_ES_FAIL
((
SuperOfInter<View0,View1,EmptyView>
128
::
post
(home, x0, x1, emptyset)));
129
// fall through to SOT_UNION
130
}
131
case
SOT_UNION
:
132
{
133
GECODE_ES_FAIL
(
134
(
SubOfUnion<View0,View1,View2>
135
::
post
(home, x0, x1, x2)));
136
}
137
break
;
138
case
SOT_INTER
:
139
{
140
SetVar
tmp(home);
141
GECODE_ES_FAIL
(
142
(
Rel::Subset<View2,SetView>::post
(home,x2,tmp)));
143
144
GECODE_ES_FAIL
((
Intersection<View0,View1,SetView>
145
::
post
(home, x0,x1,tmp)));
146
}
147
break
;
148
case
SOT_MINUS
:
149
{
150
SetVar
tmp(home);
151
GECODE_ES_FAIL
(
152
(
Rel::Subset<View2,SetView>::post
(home,x2,tmp)));
153
154
ComplementView<View1>
cx1(x1);
155
GECODE_ES_FAIL
(
156
(
Intersection
<View0,
157
ComplementView<View1>
,
SetView
>
158
::
post
(home,x0,cx1,tmp)));
159
}
160
break
;
161
}
162
163
}
164
165
template
<
class
View>
166
forceinline
void
167
rel_op_post_lex
(
Home
home,
SetView
x0,
SetRelType
r
, View x1) {
168
switch
(
r
) {
169
case
SRT_LQ
:
170
GECODE_ES_FAIL
((
Rel::Lq<SetView,View,false>::post
(home,x0,x1)));
171
break
;
172
case
SRT_LE
:
173
GECODE_ES_FAIL
((
Rel::Lq<SetView,View,true>::post
(home,x0,x1)));
174
break
;
175
case
SRT_GQ
:
176
GECODE_ES_FAIL
((
Rel::Lq<View,SetView,false>::post
(home,x1,x0)));
177
break
;
178
case
SRT_GR
:
179
GECODE_ES_FAIL
((
Rel::Lq<View,SetView,true>::post
(home,x1,x0)));
180
break
;
181
default
:
182
throw
UnknownRelation
(
"Set::rel"
);
183
}
184
}
185
186
template
<
class
View0,
class
View1,
class
View2>
187
forceinline
void
188
rel_op_post_nocompl
(
Home
home, View0
x
,
SetOpType
op
, View1
y
,
189
SetRelType
r
, View2
z
) {
190
if
(home.
failed
())
return
;
191
switch
(
r
) {
192
case
SRT_EQ
:
193
rel_eq<View0,View1,View2>(home,
x
,
op
,
y
,
z
);
194
break
;
195
case
SRT_LQ
:
case
SRT_LE
:
case
SRT_GQ
:
case
SRT_GR
:
196
{
197
SetVar
tmp(home,
IntSet::empty
,
Set::Limits::min
,
Set::Limits::max
);
198
rel_eq<View0,View1,SetView>(home,
x
,
op
,
y
, tmp);
199
rel_op_post_lex<View2>(home,tmp,
r
,
z
);
200
}
201
break
;
202
case
SRT_NQ
:
203
{
204
SetVar
tmp(home);
205
GECODE_ES_FAIL
(
206
(
Rel::Distinct<SetView,View2>
207
::
post
(home,tmp,
z
)));
208
rel_eq<View0,View1,SetView>(home,
x
,
op
,
y
, tmp);
209
}
210
break
;
211
case
SRT_SUB
:
212
rel_sub<View0,View1,View2>(home,
x
,
op
,
y
,
z
);
213
break
;
214
case
SRT_SUP
:
215
rel_sup<View0,View1,View2>(home,
x
,
op
,
y
,
z
);
216
break
;
217
case
SRT_DISJ
:
218
{
219
SetVar
tmp(home);
220
EmptyView
emptyset;
221
GECODE_ES_FAIL
((
SuperOfInter<View2,SetView,EmptyView>
222
::
post
(home,
z
, tmp, emptyset)));
223
rel_eq<View0,View1,SetView>(home,
x
,
op
,
y
, tmp);
224
}
225
break
;
226
default
:
227
GECODE_NEVER
;
228
}
229
230
}
231
232
GECODE_SET_EXPORT
void
233
post_nocompl
(
Home
home,
SetView
x
,
SetOpType
op
,
SetView
y
,
234
SetRelType
r
,
SetView
z
);
235
GECODE_SET_EXPORT
void
236
post_nocompl
(
Home
home,
ConstSetView
x
,
SetOpType
op
,
SetView
y
,
237
SetRelType
r
,
SetView
z
);
238
239
GECODE_SET_EXPORT
void
240
post_nocompl
(
Home
home,
SetView
x
,
SetOpType
op
,
SetView
y
,
241
SetRelType
r
,
ConstSetView
z
);
242
243
GECODE_SET_EXPORT
void
244
post_nocompl
(
Home
home,
ConstSetView
x
,
SetOpType
op
,
SetView
y
,
245
SetRelType
r
,
ConstSetView
z
);
246
247
GECODE_SET_EXPORT
void
248
post_compl
(
Home
home,
SetView
x
,
SetOpType
op
,
SetView
y
,
SetView
z
);
249
250
GECODE_SET_EXPORT
void
251
post_compl
(
Home
home,
ConstSetView
x
,
SetOpType
op
,
SetView
y
,
SetView
z
);
252
253
GECODE_SET_EXPORT
void
254
post_compl
(
Home
home,
SetView
x
,
SetOpType
op
,
SetView
y
,
ConstSetView
z
);
255
256
GECODE_SET_EXPORT
void
257
post_compl
(
Home
home,
ConstSetView
x
,
SetOpType
op
,
SetView
y
,
258
ConstSetView
z
);
259
260
}}}
261
262
// STATISTICS: set-prop
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::Set::RelOp::Union
Propagator for ternary union
Definition:
rel-op.hh:154
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:767
GECODE_ES_FAIL
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition:
macros.hpp:103
Gecode::Set::ConstSetView
Constant view.
Definition:
view.hpp:186
Gecode::Set::RelOp::post_compl
void post_compl(Home home, ConstSetView x, SetOpType op, SetView y, ConstSetView z)
Definition:
post-compl-cvc.cpp:43
Gecode::IntSet::empty
static const IntSet empty
Empty set.
Definition:
int.hh:283
Gecode::Set::Limits::min
const int min
Smallest allowed integer in integer set.
Definition:
set.hh:99
Gecode::z
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
Definition:
set.hh:767
Gecode::Set::RelOp::SubOfUnion
Propagator for the subset of union
Definition:
rel-op.hh:93
Gecode::SRT_LQ
@ SRT_LQ
Less or equal ( )
Definition:
set.hh:650
Gecode::SetOpType
SetOpType
Common operations for sets.
Definition:
set.hh:660
Gecode::SRT_GQ
@ SRT_GQ
Greater or equal ( )
Definition:
set.hh:652
Gecode::SRT_SUB
@ SRT_SUB
Subset ( )
Definition:
set.hh:646
Gecode::Set::Rel::Subset
Propagator for the subset constraint
Definition:
rel.hh:65
Gecode::SRT_SUP
@ SRT_SUP
Superset ( )
Definition:
set.hh:647
rel.hh
Gecode::SOT_INTER
@ SOT_INTER
Intersection
Definition:
set.hh:663
Gecode::SRT_DISJ
@ SRT_DISJ
Disjoint ( )
Definition:
set.hh:648
Gecode::Set::RelOp::rel_eq
void rel_eq(Home home, View0 x0, SetOpType op, View1 x1, Res x2)
Definition:
post.hpp:45
Gecode
Gecode toplevel namespace
Gecode::Set::Limits::max
const int max
Largest allowed integer in integer set.
Definition:
set.hh:97
Gecode::SRT_EQ
@ SRT_EQ
Equality ( )
Definition:
set.hh:644
Gecode::Set::RelOp::Intersection
Propagator for ternary intersection
Definition:
rel-op.hh:124
Gecode::Set::EmptyView
Constant view for the empty set.
Definition:
view.hpp:336
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
GECODE_SET_EXPORT
#define GECODE_SET_EXPORT
Definition:
set.hh:67
Gecode::SOT_UNION
@ SOT_UNION
Union.
Definition:
set.hh:661
Gecode::r
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition:
set.hh:767
Gecode::Set::RelOp::rel_op_post_nocompl
void rel_op_post_nocompl(Home home, View0 x, SetOpType op, View1 y, SetRelType r, View2 z)
Definition:
post.hpp:188
Gecode::post
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition:
filter.cpp:138
Gecode::SetVar
Set variables
Definition:
set.hh:127
Gecode::Set::RelOp::rel_sup
void rel_sup(Home home, View0 x0, SetOpType op, View1 x1, View2 x2)
Definition:
post.hpp:122
Gecode::Set::RelOp::rel_op_post_lex
void rel_op_post_lex(Home home, SetView x0, SetRelType r, View x1)
Definition:
post.hpp:167
rel-op.hh
Gecode::SetRelType
SetRelType
Common relation types for sets.
Definition:
set.hh:643
Gecode::SRT_LE
@ SRT_LE
Less ( )
Definition:
set.hh:651
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition:
macros.hpp:56
Gecode::SRT_GR
@ SRT_GR
Greater ( )
Definition:
set.hh:653
Gecode::SRT_NQ
@ SRT_NQ
Disequality ( )
Definition:
set.hh:645
Gecode::SOT_DUNION
@ SOT_DUNION
Disjoint union.
Definition:
set.hh:662
Gecode::Home::failed
bool failed(void) const
Check whether corresponding space is failed.
Definition:
core.hpp:4048
Gecode::Set::Rel::Distinct
Propagator for negated equality
Definition:
rel.hh:268
Gecode::Set::SetView
Set view for set variables
Definition:
view.hpp:56
set.hh
Gecode::op
Post propagator for SetVar SetOpType op
Definition:
set.hh:767
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Set::RelOp::SuperOfInter
Propagator for the superset of intersection
Definition:
rel-op.hh:63
Gecode::Int::UnknownRelation
Exception: Unknown relation passed as argument
Definition:
exception.hpp:87
Gecode::Set::ComplementView
Complement set view.
Definition:
view.hpp:769
Gecode::Set::Rel::Lq
Propagator for set less than or equal
Definition:
rel.hh:208
Gecode::SOT_MINUS
@ SOT_MINUS
Difference.
Definition:
set.hh:664
Gecode::Set::RelOp::post_nocompl
void post_nocompl(Home home, ConstSetView x, SetOpType op, SetView y, SetRelType r, ConstSetView z)
Definition:
post-nocompl-cvc.cpp:43
Gecode::Set::RelOp::rel_sub
void rel_sub(Home home, View0 x0, SetOpType op, View1 x1, View2 x2)
Definition:
post.hpp:81