main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Mar 5 2013 22:37:29 for Gecode by
doxygen
1.8.3.1
gecode
set
rel-op-const-vcv.cpp
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-25 00:34:16 +1000 (Thu, 25 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 {
46
using namespace
Gecode::Set;
47
using namespace
Gecode::Set::Rel;
48
using namespace
Gecode::Set::RelOp;
49
50
void
51
rel
(
Home
home,
SetVar
x,
SetOpType
op,
const
IntSet
& y,
SetRelType
r
,
52
SetVar
z) {
53
Set::Limits::check
(y,
"Set::rel"
);
54
ConstSetView
yv(home, y);
55
56
if
(op==
SOT_MINUS
) {
57
switch
(r) {
58
case
SRT_EQ
:
59
{
60
GlbRanges<ConstSetView>
yr(yv);
61
RangesCompl<GlbRanges<ConstSetView>
> yrc(yr);
62
IntSet
yc(yrc);
63
ConstSetView
cy(home, yc);
64
GECODE_ES_FAIL
(
65
(
Intersection
<
ConstSetView
,
66
SetView
,
SetView
>
67
::
post
(home,cy,x,z)));
68
}
69
break
;
70
case
SRT_LQ
:
case
SRT_LE
:
case
SRT_GQ
:
case
SRT_GR
:
71
{
72
GlbRanges<ConstSetView>
yr(yv);
73
RangesCompl<GlbRanges<ConstSetView>
> yrc(yr);
74
IntSet
yc(yrc);
75
ConstSetView
cy(home, yc);
76
SetVar
tmp(home,
IntSet::empty
,
Set::Limits::min
,
Set::Limits::max
);
77
GECODE_ES_FAIL
(
78
(
Intersection
<
ConstSetView
,
79
SetView
,
SetView
>
80
::
post
(home,cy,x,tmp)));
81
rel
(home,tmp,r,z);
82
}
83
break
;
84
case
SRT_NQ
:
85
{
86
SetVar
tmp(home);
87
GECODE_ES_FAIL
(
88
(
Distinct<SetView,SetView>
89
::
post
(home,z,tmp)));
90
GlbRanges<ConstSetView>
yr(yv);
91
RangesCompl<GlbRanges<ConstSetView>
> yrc(yr);
92
IntSet
yc(yrc);
93
ConstSetView
cy(home, yc);
94
GECODE_ES_FAIL
(
95
(
Intersection
<
ConstSetView
,
96
SetView
,
SetView
>
97
::
post
(home,cy,x,tmp)));
98
}
99
break
;
100
case
SRT_SUB
:
101
{
102
GlbRanges<ConstSetView>
yr(yv);
103
RangesCompl<GlbRanges<ConstSetView>
> yrc(yr);
104
IntSet
yc(yrc);
105
ConstSetView
cy(home, yc);
106
GECODE_ES_FAIL
(
107
(
SuperOfInter<ConstSetView,SetView,SetView>
108
::
post
(home,cy,x,z)));
109
110
}
111
break
;
112
case
SRT_SUP
:
113
{
114
SetVar
tmp(home);
115
GECODE_ES_FAIL
(
116
(
Subset<SetView,SetView>::post
(home,z,tmp)));
117
118
GlbRanges<ConstSetView>
yr(yv);
119
RangesCompl<GlbRanges<ConstSetView>
> yrc(yr);
120
IntSet
yc(yrc);
121
ConstSetView
cy(home, yc);
122
123
SetView
xv(x);
124
GECODE_ES_FAIL
(
125
(
Intersection
<
ConstSetView
,
126
SetView
,
SetView
>
127
::
post
(home,cy,xv,tmp)));
128
}
129
break
;
130
case
SRT_DISJ
:
131
{
132
SetVar
tmp(home);
133
EmptyView
emptyset;
134
GECODE_ES_FAIL
((
SuperOfInter<SetView,SetView,EmptyView>
135
::
post
(home, z, tmp, emptyset)));
136
137
GlbRanges<ConstSetView>
yr(yv);
138
RangesCompl<GlbRanges<ConstSetView>
> yrc(yr);
139
IntSet
yc(yrc);
140
ConstSetView
cy(home, yc);
141
GECODE_ES_FAIL
(
142
(
Intersection
<
ConstSetView
,
143
SetView
,
SetView
>
144
::
post
(home,cy,x,tmp)));
145
}
146
break
;
147
case
SRT_CMPL
:
148
{
149
SetView
xv(x);
150
ComplementView<SetView>
cx(xv);
151
GECODE_ES_FAIL
(
152
(
Union
<
ConstSetView
,
153
ComplementView<SetView>
,
154
SetView
>::
post
(home, yv, cx, z)));
155
}
156
break
;
157
default
:
158
throw
UnknownRelation
(
"Set::rel"
);
159
}
160
}
else
{
161
rel
(home, y, op, x, r, z);
162
}
163
}
164
}
165
166
// STATISTICS: set-post