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
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
* Last modified:
12
* $Date: 2012-04-06 13:04:47 +0200 (Fri, 06 Apr 2012) $ by $Author: schulte $
13
* $Revision: 12711 $
14
*
15
* This file is part of Gecode, the generic constraint
16
* development environment:
17
* http://www.gecode.org
18
*
19
* Permission is hereby granted, free of charge, to any person obtaining
20
* a copy of this software and associated documentation files (the
21
* "Software"), to deal in the Software without restriction, including
22
* without limitation the rights to use, copy, modify, merge, publish,
23
* distribute, sublicense, and/or sell copies of the Software, and to
24
* permit persons to whom the Software is furnished to do so, subject to
25
* the following conditions:
26
*
27
* The above copyright notice and this permission notice shall be
28
* included in all copies or substantial portions of the Software.
29
*
30
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37
*
38
*/
39
40
namespace
Gecode
{
namespace
Float {
41
42
/*
43
* Constructors and initialization
44
*
45
*/
46
forceinline
47
ScaleView::ScaleView
(
void
) {}
48
forceinline
49
ScaleView::ScaleView
(
FloatVal
d
,
const
FloatView
&
y
)
50
:
DerivedView
<
FloatView
>(
y
),
a
(
d
) {}
51
52
53
/*
54
* Value access
55
*
56
*/
57
forceinline
FloatVal
58
ScaleView::scale
(
void
)
const
{
59
return
a
;
60
}
61
forceinline
FloatVal
62
ScaleView::domain
(
void
)
const
{
63
return
x
.domain()*
a
;
64
}
65
forceinline
FloatNum
66
ScaleView::min
(
void
)
const
{
67
FloatVal
c
=
x
.min();
c
*=
a
;
return
c
.
min
();
68
}
69
forceinline
FloatNum
70
ScaleView::max
(
void
)
const
{
71
FloatVal
c
=
x
.max();
c
*=
a
;
return
c
.
max
();
72
}
73
forceinline
FloatNum
74
ScaleView::med
(
void
)
const
{
75
FloatVal
c
=
x
.med();
c
*=
a
;
return
(
c
.
min
()+
c
.
max
())/2;
76
}
77
forceinline
FloatVal
78
ScaleView::val
(
void
)
const
{
79
FloatVal
c
=
x
.val();
c
*=
a
;
return
c
;
80
}
81
82
forceinline
FloatNum
83
ScaleView::size
(
void
)
const
{
84
FloatVal
c
=
x
.size();
c
*=
a
;
return
c
.
max
();
85
}
86
87
88
/*
89
* Domain tests
90
*
91
*/
92
forceinline
bool
93
ScaleView::zero_in
(
void
)
const
{
94
return
x
.zero_in();
95
}
96
forceinline
bool
97
ScaleView::in
(
FloatNum
n
)
const
{
98
return
x
.in(
n
/
a
);
99
}
100
forceinline
bool
101
ScaleView::in
(
const
FloatVal
&
n
)
const
{
102
return
x
.in(
n
/
a
);
103
}
104
105
106
/*
107
* Domain update by value
108
*
109
*/
110
forceinline
ModEvent
111
ScaleView::lq
(
Space
& home,
int
n
) {
112
FloatVal
c
=
n
;
c
/=
a
;
113
return
x
.lq(home,
c
.
max
());
114
}
115
forceinline
ModEvent
116
ScaleView::lq
(
Space
& home,
FloatNum
n
) {
117
FloatVal
c
=
n
;
c
/=
a
;
118
return
x
.lq(home,
c
.
max
());
119
}
120
forceinline
ModEvent
121
ScaleView::lq
(
Space
& home,
FloatVal
n
) {
122
FloatVal
c
=
n
;
c
/=
a
;
123
return
x
.lq(home,
c
.
max
());
124
}
125
126
forceinline
ModEvent
127
ScaleView::gq
(
Space
& home,
int
n
) {
128
FloatVal
c
=
n
;
c
/=
a
;
129
return
x
.gq(home,
c
.
min
());
130
}
131
forceinline
ModEvent
132
ScaleView::gq
(
Space
& home,
FloatNum
n
) {
133
FloatVal
c
=
n
;
c
/=
a
;
134
return
x
.gq(home,
c
.
min
());
135
}
136
forceinline
ModEvent
137
ScaleView::gq
(
Space
& home,
FloatVal
n
) {
138
FloatVal
c
=
n
;
c
/=
a
;
139
return
x
.gq(home,
c
.
min
());
140
}
141
142
forceinline
ModEvent
143
ScaleView::eq
(
Space
& home,
int
n
) {
144
FloatVal
c
=
n
;
c
/=
a
;
145
return
x
.eq(home,
c
);
146
}
147
forceinline
ModEvent
148
ScaleView::eq
(
Space
& home,
FloatNum
n
) {
149
FloatVal
c
=
n
;
c
/=
a
;
150
return
x
.eq(home,
c
);
151
}
152
forceinline
ModEvent
153
ScaleView::eq
(
Space
& home,
const
FloatVal
&
n
) {
154
FloatVal
c
=
n
;
c
/=
a
;
155
return
x
.eq(home,
c
);
156
}
157
158
159
/*
160
* Delta information for advisors
161
*
162
*/
163
forceinline
FloatNum
164
ScaleView::min
(
const
Delta
&
d
)
const
{
165
FloatVal
c
=
x
.min(
d
);
c
*=
a
;
return
c
.
min
();
166
}
167
forceinline
FloatNum
168
ScaleView::max
(
const
Delta
&
d
)
const
{
169
FloatVal
c
=
x
.max(
d
);
c
*=
a
;
return
c
.
max
();
170
}
171
172
forceinline
ModEventDelta
173
ScaleView::med
(
ModEvent
me) {
174
return
VarImpView<FloatVar>::med
(
me
);
175
}
176
177
178
/*
179
* Cloning
180
*
181
*/
182
forceinline
void
183
ScaleView::update
(
Space
& home,
bool
share,
ScaleView
&
y
) {
184
DerivedView<FloatView>::update
(home,share,
y
);
185
a
=
y
.a;
186
}
187
188
}}
189
190
// STATISTICS: float-var
191
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:784
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::FloatVal::max
friend FloatVal max(const FloatVal &x, const FloatVal &y)
Definition:
val.hpp:390
Gecode::FloatVal::min
friend FloatVal min(const FloatVal &x, const FloatVal &y)
Definition:
val.hpp:402
Gecode::Float::ScaleView::in
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition:
scale.hpp:97
Gecode::Float::ScaleView::ScaleView
ScaleView(void)
Default constructor.
Definition:
scale.hpp:47
Gecode::Float::ScaleView
Scale float view.
Definition:
view.hpp:373
Gecode::Float::ScaleView::a
FloatVal a
Scale factor.
Definition:
view.hpp:377
Gecode::Float::ScaleView::val
FloatVal val(void) const
Return assigned value.
Definition:
scale.hpp:78
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::DerivedView::update
void update(Space &home, bool share, DerivedView< View > &y)
Update this view to be a clone of view y.
Gecode::DerivedView
Base-class for derived views.
Definition:
view.hpp:222
Gecode
Gecode toplevel namespace
Gecode::DerivedView< FloatView >::me
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
Gecode::Float::ScaleView::update
void update(Space &home, bool share, ScaleView &y)
Definition:
scale.hpp:183
Gecode::Float::FloatView
Float view for float variables.
Definition:
view.hpp:56
Gecode::Delta
Generic domain change information to be supplied to advisors.
Definition:
core.hpp:281
Gecode::Float::ScaleView::domain
FloatVal domain(void) const
Return domain.
Definition:
scale.hpp:62
a
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Gecode::Float::ScaleView::min
FloatNum min(void) const
Return minimum of domain.
Definition:
scale.hpp:66
Gecode::Float::ScaleView::max
FloatNum max(void) const
Return maximum of domain.
Definition:
scale.hpp:70
Gecode::FloatNum
double FloatNum
Floating point number base type.
Definition:
float.hh:110
Gecode::Float::ScaleView::size
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition:
scale.hpp:83
Gecode::Float::ScaleView::eq
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition:
scale.hpp:143
Gecode::Float::ScaleView::zero_in
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition:
scale.hpp:93
Gecode::ModEvent
int ModEvent
Type for modification events.
Definition:
core.hpp:142
Gecode::DerivedView< FloatView >::x
FloatView x
View from which this view is derived.
Definition:
view.hpp:230
Gecode::FloatVal
Float value type.
Definition:
float.hh:338
Gecode::VarImpView::med
static ModEventDelta med(ModEvent me)
Translate modification event me to modification event delta for view.
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:111
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:74
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:238
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:169
Gecode::Float::ScaleView::scale
FloatVal scale(void) const
Return scale factor of scale view.
Definition:
scale.hpp:58
Gecode::Float::ScaleView::gq
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition:
scale.hpp:127