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