main page
modules
namespaces
classes
files
Gecode home
Generated on Wed Jan 1 2020 10:37:59 for Gecode by
doxygen
1.8.16
gecode
minimodel
set-rel.cpp
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
* Matthias Balzer <matthias.balzer@itwm.fraunhofer.de>
6
*
7
* Copyright:
8
* Christian Schulte, 2005
9
* Fraunhofer ITWM, 2017
10
*
11
* This file is part of Gecode, the generic constraint
12
* development environment:
13
* http://www.gecode.org
14
*
15
* Permission is hereby granted, free of charge, to any person obtaining
16
* a copy of this software and associated documentation files (the
17
* "Software"), to deal in the Software without restriction, including
18
* without limitation the rights to use, copy, modify, merge, publish,
19
* distribute, sublicense, and/or sell copies of the Software, and to
20
* permit persons to whom the Software is furnished to do so, subject to
21
* the following conditions:
22
*
23
* The above copyright notice and this permission notice shall be
24
* included in all copies or substantial portions of the Software.
25
*
26
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
*
34
*/
35
36
#include <
gecode/minimodel.hh
>
37
38
#ifdef GECODE_HAS_SET_VARS
39
40
namespace
Gecode
{
41
42
/*
43
* Operators
44
*
45
*/
46
SetRel
47
operator ==
(
const
SetExpr
& e0,
const
SetExpr
& e1) {
48
return
SetRel
(e0,
SRT_EQ
, e1);
49
}
50
SetRel
51
operator !=
(
const
SetExpr
& e0,
const
SetExpr
& e1) {
52
return
SetRel
(e0,
SRT_NQ
, e1);
53
}
54
SetCmpRel
55
operator <=
(
const
SetExpr
& e0,
const
SetExpr
& e1) {
56
return
SetCmpRel
(e0,
SRT_SUB
, e1);
57
}
58
BoolExpr
59
operator <=
(
const
SetCmpRel
&
r
,
const
SetExpr
&
l
) {
60
return
BoolExpr
(
r
) &&
BoolExpr
(
r
.r <=
l
);
61
}
62
SetCmpRel
63
operator >=
(
const
SetExpr
& e0,
const
SetExpr
& e1) {
64
return
SetCmpRel
(e0,
SRT_SUP
, e1);
65
}
66
BoolExpr
67
operator >=
(
const
SetCmpRel
&
r
,
const
SetExpr
&
l
) {
68
return
BoolExpr
(
r
) &&
BoolExpr
(
r
.r >=
l
);
69
}
70
SetRel
71
operator ||
(
const
SetExpr
& e0,
const
SetExpr
& e1) {
72
return
SetRel
(e0,
SRT_DISJ
, e1);
73
}
74
75
namespace
{
76
78
class
SetIRTRel :
public
BoolExpr::Misc {
80
SetExpr _s;
82
LinIntExpr _x;
84
IntRelType
_irt;
85
public
:
87
SetIRTRel(
const
SetExpr&,
IntRelType
,
const
LinIntExpr&);
89
virtual
void
post
(Home, BoolVar
b
,
bool
neg
,
90
const
IntPropLevels&)
override
;
91
};
92
93
SetIRTRel::SetIRTRel(
const
SetExpr& s,
IntRelType
irt,
const
LinIntExpr&
x
)
94
: _s(s), _x(
x
), _irt(irt) {}
95
96
void
97
SetIRTRel::post
(Home home, BoolVar
b
,
bool
neg
,
98
const
IntPropLevels& ipls) {
99
if
(
b
.zero()) {
100
rel
(home, _s.post(home),
neg
? _irt :
Gecode::neg
(_irt),
101
_x.post(home, ipls));
102
}
else
if
(
b
.one()) {
103
rel
(home, _s.post(home),
neg
?
Gecode::neg
(_irt) : _irt,
104
_x.
post
(home, ipls));
105
}
else
{
106
rel
(home, _s.post(home),
neg
?
Gecode::neg
(_irt) : _irt,
107
_x.
post
(home, ipls),
b
);
108
}
109
}
110
}
111
112
113
/*
114
* IRT relations with SetExpr
115
*
116
*/
117
BoolExpr
118
operator ==
(
const
SetExpr
&
x
,
const
LinIntExpr
&
y
) {
119
return
BoolExpr
(
new
SetIRTRel(
x
,
IRT_EQ
,
y
));
120
}
121
BoolExpr
122
operator ==
(
const
LinIntExpr
&
x
,
const
SetExpr
&
y
) {
123
return
operator ==
(
y
,
x
);
124
}
125
126
BoolExpr
127
operator !=
(
const
SetExpr
&
x
,
const
LinIntExpr
&
y
) {
128
return
BoolExpr
(
new
SetIRTRel(
x
,
IRT_NQ
,
y
));
129
}
130
131
BoolExpr
132
operator !=
(
const
LinIntExpr
&
x
,
const
SetExpr
&
y
) {
133
return
operator !=
(
y
,
x
);
134
}
135
136
BoolExpr
137
operator <=
(
const
SetExpr
&
x
,
const
LinIntExpr
&
y
) {
138
return
BoolExpr
(
new
SetIRTRel(
x
,
IRT_LQ
,
y
));
139
}
140
141
BoolExpr
142
operator <=
(
const
LinIntExpr
&
x
,
const
SetExpr
&
y
) {
143
return
operator >=
(
y
,
x
);
144
}
145
146
BoolExpr
147
operator <
(
const
SetExpr
&
x
,
const
LinIntExpr
&
y
) {
148
return
BoolExpr
(
new
SetIRTRel(
x
,
IRT_LE
,
y
));
149
}
150
151
BoolExpr
152
operator <
(
const
LinIntExpr
&
x
,
const
SetExpr
&
y
) {
153
return
operator >
(
y
,
x
);
154
}
155
156
BoolExpr
157
operator >=
(
const
SetExpr
&
x
,
const
LinIntExpr
&
y
) {
158
return
BoolExpr
(
new
SetIRTRel(
x
,
IRT_GQ
,
y
));
159
}
160
161
BoolExpr
162
operator >=
(
const
LinIntExpr
&
x
,
const
SetExpr
&
y
) {
163
return
operator <=
(
y
,
x
);
164
}
165
166
BoolExpr
167
operator >
(
const
SetExpr
&
x
,
const
LinIntExpr
&
y
) {
168
return
BoolExpr
(
new
SetIRTRel(
x
,
IRT_GR
,
y
));
169
}
170
171
BoolExpr
172
operator >
(
const
LinIntExpr
&
x
,
const
SetExpr
&
y
) {
173
return
operator <
(
y
,
x
);
174
}
175
176
}
177
178
#endif
179
180
// STATISTICS: minimodel-any
b
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::IntRelType
IntRelType
Relation types for integers.
Definition:
int.hh:925
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:767
minimodel.hh
Gecode::IRT_GQ
Greater or equal ( )
Definition:
int.hh:930
Gecode::IRT_LE
Less ( )
Definition:
int.hh:929
Gecode::Float::Linear::post
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition:
post.cpp:238
Gecode::SetCmpRel
Comparison relation (for two-sided comparisons)
Definition:
minimodel.hh:1221
Gecode::LinIntExpr
Linear expressions over integer variables.
Definition:
minimodel.hh:245
Gecode::SRT_SUB
Subset ( )
Definition:
set.hh:646
Gecode::SRT_SUP
Superset ( )
Definition:
set.hh:647
Gecode::SRT_DISJ
Disjoint ( )
Definition:
set.hh:648
Gecode
Gecode toplevel namespace
x
Node * x
Pointer to corresponding Boolean expression node.
Definition:
bool-expr.cpp:249
Gecode::SRT_EQ
Equality ( )
Definition:
set.hh:644
Gecode::operator>=
bool operator>=(const FloatVal &x, const FloatVal &y)
Definition:
val.hpp:277
Gecode::FloatVal::operator<=
bool operator<=(const FloatVal &x, const FloatVal &y)
Comparison operator.
Definition:
val.hpp:243
Gecode::r
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition:
set.hh:767
Gecode::post
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition:
filter.cpp:138
Gecode::Float::MinusView::operator!=
bool operator!=(const MinusView &x, const MinusView &y)
Test whether views x and y are not the same.
Definition:
minus.hpp:169
Gecode::SetExpr
Set expressions
Definition:
minimodel.hh:1164
Gecode::SRT_NQ
Disequality ( )
Definition:
set.hh:645
Gecode::operator!=
bool operator!=(const FloatVal &x, const FloatVal &y)
Definition:
val.hpp:317
Gecode::neg
IntRelType neg(IntRelType irt)
Return negated relation type of irt.
Definition:
irt.hpp:52
Gecode::operator<=
bool operator<=(const FloatVal &x, const FloatVal &y)
Definition:
val.hpp:243
Gecode::rel
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition:
rel.cpp:43
l
NNF * l
Left subtree.
Definition:
bool-expr.cpp:240
neg
bool neg
Is atomic formula negative.
Definition:
bool-expr.cpp:247
Gecode::BoolExpr
Boolean expressions.
Definition:
minimodel.hh:1329
Gecode::FloatVal::operator>=
bool operator>=(const FloatVal &x, const FloatVal &y)
Comparison operator.
Definition:
val.hpp:277
Gecode::IRT_EQ
Equality ( )
Definition:
int.hh:926
Gecode::IRT_NQ
Disequality ( )
Definition:
int.hh:927
Gecode::operator||
BoolExpr operator||(const BoolExpr &l, const BoolExpr &r)
Disjunction of Boolean expressions.
Definition:
bool-expr.cpp:591
Gecode::FloatVal::operator>
bool operator>(const FloatVal &x, const FloatVal &y)
Comparison operator.
Definition:
val.hpp:260
Gecode::Float::MinusView::operator==
bool operator==(const MinusView &x, const MinusView &y)
Test whether views x and y are the same.
Definition:
minus.hpp:165
Gecode::IRT_GR
Greater ( )
Definition:
int.hh:931
Gecode::SetRel
Set relations
Definition:
minimodel.hh:1234
Gecode::FloatVal::operator<
bool operator<(const FloatVal &x, const FloatVal &y)
Comparison operator.
Definition:
val.hpp:226
Gecode::IRT_LQ
Less or equal ( )
Definition:
int.hh:928
Gecode::operator==
bool operator==(const FloatVal &x, const FloatVal &y)
Definition:
val.hpp:294