main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Jul 27 2020 00:00:00 for Gecode by
doxygen
1.8.18
gecode
float
view
scale.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
ScaleView::ScaleView
(
void
) {}
44
forceinline
45
ScaleView::ScaleView
(
FloatVal
d
,
const
FloatView
&
y
)
46
:
DerivedView
<
FloatView
>(
y
),
a
(
d
) {}
47
48
49
/*
50
* Value access
51
*
52
*/
53
forceinline
FloatVal
54
ScaleView::scale
(
void
)
const
{
55
return
a
;
56
}
57
forceinline
FloatVal
58
ScaleView::domain
(
void
)
const
{
59
return
x
.domain()*
a
;
60
}
61
forceinline
FloatNum
62
ScaleView::min
(
void
)
const
{
63
FloatVal
c
=
x
.min();
c
*=
a
;
return
c
.
min
();
64
}
65
forceinline
FloatNum
66
ScaleView::max
(
void
)
const
{
67
FloatVal
c
=
x
.max();
c
*=
a
;
return
c
.
max
();
68
}
69
forceinline
FloatNum
70
ScaleView::med
(
void
)
const
{
71
FloatVal
c
=
x
.med();
c
*=
a
;
return
(
c
.
min
()+
c
.
max
())/2;
72
}
73
forceinline
FloatVal
74
ScaleView::val
(
void
)
const
{
75
FloatVal
c
=
x
.val();
c
*=
a
;
return
c
;
76
}
77
78
forceinline
FloatNum
79
ScaleView::size
(
void
)
const
{
80
FloatVal
c
=
x
.size();
c
*=
a
;
return
c
.
max
();
81
}
82
83
84
/*
85
* Domain tests
86
*
87
*/
88
forceinline
bool
89
ScaleView::zero_in
(
void
)
const
{
90
return
x
.zero_in();
91
}
92
forceinline
bool
93
ScaleView::in
(
FloatNum
n
)
const
{
94
return
x
.in(
n
/
a
);
95
}
96
forceinline
bool
97
ScaleView::in
(
const
FloatVal
&
n
)
const
{
98
return
x
.in(
n
/
a
);
99
}
100
101
102
/*
103
* Domain update by value
104
*
105
*/
106
forceinline
ModEvent
107
ScaleView::lq
(
Space
& home,
int
n
) {
108
FloatVal
c
=
n
;
c
/=
a
;
109
return
x
.lq(home,
c
.
max
());
110
}
111
forceinline
ModEvent
112
ScaleView::lq
(
Space
& home,
FloatNum
n
) {
113
FloatVal
c
=
n
;
c
/=
a
;
114
return
x
.lq(home,
c
.
max
());
115
}
116
forceinline
ModEvent
117
ScaleView::lq
(
Space
& home,
FloatVal
n
) {
118
FloatVal
c
=
n
;
c
/=
a
;
119
return
x
.lq(home,
c
.
max
());
120
}
121
122
forceinline
ModEvent
123
ScaleView::gq
(
Space
& home,
int
n
) {
124
FloatVal
c
=
n
;
c
/=
a
;
125
return
x
.gq(home,
c
.
min
());
126
}
127
forceinline
ModEvent
128
ScaleView::gq
(
Space
& home,
FloatNum
n
) {
129
FloatVal
c
=
n
;
c
/=
a
;
130
return
x
.gq(home,
c
.
min
());
131
}
132
forceinline
ModEvent
133
ScaleView::gq
(
Space
& home,
FloatVal
n
) {
134
FloatVal
c
=
n
;
c
/=
a
;
135
return
x
.gq(home,
c
.
min
());
136
}
137
138
forceinline
ModEvent
139
ScaleView::eq
(
Space
& home,
int
n
) {
140
FloatVal
c
=
n
;
c
/=
a
;
141
return
x
.eq(home,
c
);
142
}
143
forceinline
ModEvent
144
ScaleView::eq
(
Space
& home,
FloatNum
n
) {
145
FloatVal
c
=
n
;
c
/=
a
;
146
return
x
.eq(home,
c
);
147
}
148
forceinline
ModEvent
149
ScaleView::eq
(
Space
& home,
const
FloatVal
&
n
) {
150
FloatVal
c
=
n
;
c
/=
a
;
151
return
x
.eq(home,
c
);
152
}
153
154
155
/*
156
* Delta information for advisors
157
*
158
*/
159
forceinline
FloatNum
160
ScaleView::min
(
const
Delta
&
d
)
const
{
161
FloatVal
c
=
x
.min(
d
);
c
*=
a
;
return
c
.
min
();
162
}
163
forceinline
FloatNum
164
ScaleView::max
(
const
Delta
&
d
)
const
{
165
FloatVal
c
=
x
.max(
d
);
c
*=
a
;
return
c
.
max
();
166
}
167
168
forceinline
ModEventDelta
169
ScaleView::med
(
ModEvent
me) {
170
return
VarImpView<FloatVar>::med
(
me
);
171
}
172
173
174
/*
175
* Cloning
176
*
177
*/
178
forceinline
void
179
ScaleView::update
(
Space
& home,
ScaleView
&
y
) {
180
DerivedView<FloatView>::update
(home,
y
);
181
a
=
y
.a;
182
}
183
184
/*
185
* Ordering
186
*
187
*/
188
forceinline
bool
189
ScaleView::operator <
(
const
ScaleView
&
y
)
const
{
190
return
((
base
() <
y
.base())
191
|| ((
base
() ==
y
.base()) && (
scale
() <
y
.scale())));
192
}
193
194
195
/*
196
* View comparison
197
*
198
*/
199
forceinline
bool
200
operator ==
(
const
ScaleView
&
x
,
const
ScaleView
&
y
) {
201
return
(
x
.base() ==
y
.base()) && (
x
.scale() ==
y
.scale());
202
}
203
forceinline
bool
204
operator !=
(
const
ScaleView
&
x
,
const
ScaleView
&
y
) {
205
return
!(
x
==
y
);
206
}
207
208
}}
209
210
// STATISTICS: float-var
211
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::FloatVal::max
friend FloatVal max(const FloatVal &x, const FloatVal &y)
Definition:
val.hpp:386
Gecode::FloatVal::min
friend FloatVal min(const FloatVal &x, const FloatVal &y)
Definition:
val.hpp:398
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::ScaleView::in
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition:
scale.hpp:93
Gecode::Float::ScaleView::ScaleView
ScaleView(void)
Default constructor.
Definition:
scale.hpp:43
Gecode::Float::ScaleView
Scale float view.
Definition:
view.hpp:395
Gecode::Float::ScaleView::a
FloatVal a
Scale factor.
Definition:
view.hpp:399
Gecode::Float::ScaleView::val
FloatVal val(void) const
Return assigned value.
Definition:
scale.hpp:74
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Float::ScaleView::update
void update(Space &home, ScaleView &y)
Definition:
scale.hpp:179
Gecode::DerivedView
Base-class for derived views.
Definition:
view.hpp:230
Gecode
Gecode toplevel namespace
Gecode::Float::operator!=
bool operator!=(const MinusView &x, const MinusView &y)
Definition:
minus.hpp:169
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::Float::ScaleView::domain
FloatVal domain(void) const
Return domain.
Definition:
scale.hpp:58
Gecode::Float::ScaleView::min
FloatNum min(void) const
Return minimum of domain.
Definition:
scale.hpp:62
Gecode::Float::ScaleView::max
FloatNum max(void) const
Return maximum of domain.
Definition:
scale.hpp:66
Gecode::FloatNum
double FloatNum
Floating point number base type.
Definition:
float.hh:106
Gecode::Float::operator==
bool operator==(const MinusView &x, const MinusView &y)
Definition:
minus.hpp:165
Gecode::Float::ScaleView::size
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition:
scale.hpp:79
Gecode::Float::ScaleView::eq
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition:
scale.hpp:139
a
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
Gecode::Float::ScaleView::zero_in
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition:
scale.hpp:89
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::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
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::Float::ScaleView::lq
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition:
scale.hpp:107
Gecode::Float::ScaleView::operator<
bool operator<(const ScaleView &y) const
Whether this view comes before view y (arbitray order)
Definition:
scale.hpp:189
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)
Gecode::Float::ScaleView::med
FloatNum med(void) const
Return median of domain (closest representation)
Definition:
scale.hpp:70
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:89
Gecode::Float::ScaleView::scale
FloatVal scale(void) const
Return scale factor of scale view.
Definition:
scale.hpp:54
Gecode::Float::ScaleView::gq
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition:
scale.hpp:123