Generated on Sat Feb 7 2015 02:01:18 for Gecode by doxygen 1.8.9.1
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  */
50  : DerivedView<FloatView>(y), a(d) {}
51 
52 
53  /*
54  * Value access
55  *
56  */
58  ScaleView::scale(void) const {
59  return a;
60  }
62  ScaleView::domain(void) const {
63  return x.domain()*a;
64  }
66  ScaleView::min(void) const {
67  FloatVal c = x.min(); c *= a; return c.min();
68  }
70  ScaleView::max(void) const {
71  FloatVal c = x.max(); c *= a; return c.max();
72  }
74  ScaleView::med(void) const {
75  FloatVal c = x.med(); c *= a; return (c.min()+c.max())/2;
76  }
78  ScaleView::val(void) const {
79  FloatVal c = x.val(); c *= a; return c;
80  }
81 
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
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  */
111  ScaleView::lq(Space& home, int n) {
112  FloatVal c = n; c /= a;
113  return x.lq(home,c.max());
114  }
117  FloatVal c = n; c /= a;
118  return x.lq(home,c.max());
119  }
122  FloatVal c = n; c /= a;
123  return x.lq(home,c.max());
124  }
125 
127  ScaleView::gq(Space& home, int n) {
128  FloatVal c = n; c /= a;
129  return x.gq(home,c.min());
130  }
133  FloatVal c = n; c /= a;
134  return x.gq(home,c.min());
135  }
138  FloatVal c = n; c /= a;
139  return x.gq(home,c.min());
140  }
141 
143  ScaleView::eq(Space& home, int n) {
144  FloatVal c = n; c /= a;
145  return x.eq(home,c);
146  }
149  FloatVal c = n; c /= a;
150  return x.eq(home,c);
151  }
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  */
164  ScaleView::min(const Delta& d) const {
165  FloatVal c = x.min(d); c *= a; return c.min();
166  }
168  ScaleView::max(const Delta& d) const {
169  FloatVal c = x.max(d); c *= a; return c.max();
170  }
171 
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 
FloatVal scale(void) const
Return scale factor of scale view.
Definition: scale.hpp:58
static ModEventDelta med(ModEvent me)
Translate modification event me to modification event delta for view.
Definition: view.hpp:484
FloatNum med(void) const
Return median of domain (closest representation)
Definition: scale.hpp:74
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition: scale.hpp:111
FloatVal domain(void) const
Return domain.
Definition: scale.hpp:62
int ModEvent
Type for modification events.
Definition: core.hpp:146
Computation spaces.
Definition: core.hpp:1362
Base-class for derived views.
Definition: view.hpp:208
Gecode::IntSet d(v, 7)
Gecode::FloatVal c(-8, 8)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
void update(Space &home, bool share, DerivedView< View > &y)
Update this view to be a clone of view y.
Definition: view.hpp:590
ScaleView(void)
Default constructor.
Definition: scale.hpp:47
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: scale.hpp:127
FloatVal a
Scale factor.
Definition: view.hpp:377
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition: scale.hpp:83
Float view for float variables.
Definition: view.hpp:56
FloatVal val(void) const
Return assigned value.
Definition: scale.hpp:78
Float value type.
Definition: float.hh:321
FloatNum min(void) const
Return minimum of domain.
Definition: scale.hpp:66
Generic domain change information to be supplied to advisors.
Definition: core.hpp:275
void update(Space &home, bool share, ScaleView &y)
Definition: scale.hpp:183
#define forceinline
Definition: config.hpp:132
FloatNum max(void) const
Return maximum of domain.
Definition: scale.hpp:70
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition: scale.hpp:97
FloatView x
View from which this view is derived.
Definition: view.hpp:216
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition: scale.hpp:93
Gecode toplevel namespace
friend FloatVal max(const FloatVal &x, const FloatVal &y)
Definition: val.hpp:390
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
friend FloatVal min(const FloatVal &x, const FloatVal &y)
Definition: val.hpp:402
double FloatNum
Floating point number base type.
Definition: float.hh:108
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
Scale float view.
Definition: view.hpp:373
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition: scale.hpp:143