main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Mar 24 2020 14:04:04 for Gecode by
doxygen
1.8.17
gecode
float
view
offset.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
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
6
*
7
* Copyright:
8
* Christian Schulte, 2002
9
* Vincent Barichard, 2012
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
namespace
Gecode
{
namespace
Float {
37
38
/*
39
* Constructors and initialization
40
*
41
*/
42
forceinline
43
OffsetView::OffsetView
(
void
) {}
44
forceinline
45
OffsetView::OffsetView
(
const
FloatView
&
y
,
FloatNum
d
)
46
:
DerivedView
<
FloatView
>(
y
),
c
(
d
) {}
47
48
49
/*
50
* Value access
51
*
52
*/
53
forceinline
FloatNum
54
OffsetView::offset
(
void
)
const
{
55
return
c
;
56
}
57
forceinline
void
58
OffsetView::offset
(
FloatNum
n
) {
59
c
=
n
;
60
}
61
forceinline
FloatVal
62
OffsetView::domain
(
void
)
const
{
63
return
x
.domain()+
c
;
64
}
65
forceinline
FloatNum
66
OffsetView::min
(
void
)
const
{
67
return
x
.min()+
c
;
68
}
69
forceinline
FloatNum
70
OffsetView::max
(
void
)
const
{
71
return
x
.max()+
c
;
72
}
73
forceinline
FloatNum
74
OffsetView::med
(
void
)
const
{
75
return
x
.med()+
c
;
76
}
77
forceinline
FloatVal
78
OffsetView::val
(
void
)
const
{
79
return
x
.val()+
c
;
80
}
81
82
forceinline
FloatNum
83
OffsetView::size
(
void
)
const
{
84
return
x
.size();
85
}
86
87
88
/*
89
* Domain tests
90
*
91
*/
92
forceinline
bool
93
OffsetView::zero_in
(
void
)
const
{
94
return
x
.in(-
c
);
95
}
96
forceinline
bool
97
OffsetView::in
(
FloatNum
n
)
const
{
98
return
x
.in(
n
-
c
);
99
}
100
forceinline
bool
101
OffsetView::in
(
const
FloatVal
&
n
)
const
{
102
return
x
.in(
n
-
c
);
103
}
104
105
106
/*
107
* Domain update by value
108
*
109
*/
110
forceinline
ModEvent
111
OffsetView::lq
(
Space
& home,
int
n
) {
112
return
x
.lq(home,
n
-
c
);
113
}
114
forceinline
ModEvent
115
OffsetView::lq
(
Space
& home,
FloatNum
n
) {
116
return
x
.lq(home,
n
-
c
);
117
}
118
forceinline
ModEvent
119
OffsetView::lq
(
Space
& home,
FloatVal
n
) {
120
return
x
.lq(home,
n
-
c
);
121
}
122
123
forceinline
ModEvent
124
OffsetView::gq
(
Space
& home,
int
n
) {
125
return
x
.gq(home,
n
-
c
);
126
}
127
forceinline
ModEvent
128
OffsetView::gq
(
Space
& home,
FloatNum
n
) {
129
return
x
.gq(home,
n
-
c
);
130
}
131
forceinline
ModEvent
132
OffsetView::gq
(
Space
& home,
FloatVal
n
) {
133
return
x
.gq(home,
n
-
c
);
134
}
135
136
forceinline
ModEvent
137
OffsetView::eq
(
Space
& home,
int
n
) {
138
return
x
.eq(home,
n
-
c
);
139
}
140
forceinline
ModEvent
141
OffsetView::eq
(
Space
& home,
FloatNum
n
) {
142
return
x
.eq(home,
n
-
c
);
143
}
144
forceinline
ModEvent
145
OffsetView::eq
(
Space
& home,
const
FloatVal
&
n
) {
146
return
x
.eq(home,
n
-
c
);
147
}
148
149
150
/*
151
* Delta information for advisors
152
*
153
*/
154
forceinline
FloatNum
155
OffsetView::min
(
const
Delta
&
d
)
const
{
156
return
x
.min(
d
)+
c
;
157
}
158
forceinline
FloatNum
159
OffsetView::max
(
const
Delta
&
d
)
const
{
160
return
x
.max(
d
)+
c
;
161
}
162
163
forceinline
ModEventDelta
164
OffsetView::med
(
ModEvent
me) {
165
return
VarImpView<FloatVar>::med
(
me
);
166
}
167
168
169
/*
170
* Cloning
171
*
172
*/
173
forceinline
void
174
OffsetView::update
(
Space
& home,
OffsetView
&
y
) {
175
DerivedView<FloatView>::update
(home,
y
);
176
c
=
y
.c;
177
}
178
179
/*
180
* Ordering
181
*
182
*/
183
forceinline
bool
184
OffsetView::operator <
(
const
OffsetView
&
y
)
const
{
185
return
((
base
() <
y
.base())
186
|| ((
base
() ==
y
.base()) && (
offset
() <
y
.offset())));
187
}
188
189
190
/*
191
* View comparison
192
*
193
*/
194
forceinline
bool
195
operator ==
(
const
OffsetView
&
x
,
const
OffsetView
&
y
) {
196
return
(
x
.base() ==
y
.base()) && (
x
.offset() ==
y
.offset());
197
}
198
forceinline
bool
199
operator !=
(
const
OffsetView
&
x
,
const
OffsetView
&
y
) {
200
return
!(
x
==
y
);
201
}
202
203
}}
204
205
// STATISTICS: float-var
206
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:767
Gecode::Float::OffsetView::update
void update(Space &home, OffsetView &y)
Definition:
offset.hpp:174
Gecode::DerivedView::update
void update(Space &home, DerivedView< View > &y)
Update this view to be a clone of view y.
Definition:
view.hpp:681
Gecode::Float::OffsetView::gq
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition:
offset.hpp:124
Gecode::Float::OffsetView::min
FloatNum min(void) const
Return minimum of domain.
Definition:
offset.hpp:66
Gecode::Float::OffsetView::val
FloatVal val(void) const
Return assigned value.
Definition:
offset.hpp:78
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Float::OffsetView::size
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition:
offset.hpp:83
Gecode::Float::OffsetView::operator<
bool operator<(const OffsetView &y) const
Whether this view comes before view y (arbitray order)
Definition:
offset.hpp:184
Gecode::Float::OffsetView
OffsetView float view.
Definition:
view.hpp:266
Gecode::Float::OffsetView::domain
FloatVal domain(void) const
Return domain.
Definition:
offset.hpp:62
Gecode::DerivedView
Base-class for derived views.
Definition:
view.hpp:230
Gecode
Gecode toplevel namespace
Gecode::Float::OffsetView::eq
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition:
offset.hpp:137
Gecode::Float::operator!=
bool operator!=(const MinusView &x, const MinusView &y)
Definition:
minus.hpp:169
Gecode::Float::OffsetView::OffsetView
OffsetView(void)
Default constructor.
Definition:
offset.hpp:43
Gecode::Float::FloatView
Float view for float variables.
Definition:
view.hpp:52
Gecode::Delta
Generic domain change information to be supplied to advisors.
Definition:
core.hpp:204
Gecode::FloatNum
double FloatNum
Floating point number base type.
Definition:
float.hh:106
Gecode::Float::OffsetView::offset
FloatNum offset(void) const
Return offset.
Definition:
offset.hpp:54
Gecode::Float::operator==
bool operator==(const MinusView &x, const MinusView &y)
Definition:
minus.hpp:165
Gecode::Float::OffsetView::med
FloatNum med(void) const
Return median of domain (closest representation)
Definition:
offset.hpp:74
Gecode::ModEvent
int ModEvent
Type for modification events.
Definition:
core.hpp:62
Gecode::DerivedView< FloatView >::me
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
Definition:
view.hpp:639
Gecode::Float::OffsetView::max
FloatNum max(void) const
Return maximum of domain.
Definition:
offset.hpp:70
Gecode::DerivedView< FloatView >::x
FloatView x
View from which this view is derived.
Definition:
view.hpp:238
Gecode::FloatVal
Float value type.
Definition:
float.hh:334
Gecode::DerivedView< FloatView >::base
FloatView base(void) const
Return view from which this view is derived.
Definition:
view.hpp:605
Gecode::Float::OffsetView::zero_in
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition:
offset.hpp:93
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::Float::OffsetView::in
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition:
offset.hpp:97
Gecode::Float::OffsetView::lq
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition:
offset.hpp:111
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::VarImpView::med
static ModEventDelta med(ModEvent me)
Translate modification event me to modification event delta for view.
Definition:
view.hpp:557
Test::Float::Arithmetic::c
Gecode::FloatVal c(-8, 8)
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Gecode::Float::OffsetView::c
FloatNum c
Offset.
Definition:
view.hpp:269
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:89