main page
modules
namespaces
classes
files
Gecode home
Generated on Sat May 25 2013 18:00:35 for Gecode by
doxygen
1.8.3.1
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