Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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
36namespace Gecode { namespace Float {
37
38 /*
39 * Constructors and initialization
40 *
41 */
47
48
49 /*
50 * Value access
51 *
52 */
54 ScaleView::scale(void) const {
55 return a;
56 }
58 ScaleView::domain(void) const {
59 return x.domain()*a;
60 }
62 ScaleView::min(void) const {
63 FloatVal c = x.min(); c *= a; return c.min();
64 }
66 ScaleView::max(void) const {
67 FloatVal c = x.max(); c *= a; return c.max();
68 }
70 ScaleView::med(void) const {
71 FloatVal c = x.med(); c *= a; return (c.min()+c.max())/2;
72 }
74 ScaleView::val(void) const {
75 FloatVal c = x.val(); c *= a; return c;
76 }
77
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
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 */
107 ScaleView::lq(Space& home, int n) {
108 FloatVal c = n; c /= a;
109 return x.lq(home,c.max());
110 }
113 FloatVal c = n; c /= a;
114 return x.lq(home,c.max());
115 }
118 FloatVal c = n; c /= a;
119 return x.lq(home,c.max());
120 }
121
123 ScaleView::gq(Space& home, int n) {
124 FloatVal c = n; c /= a;
125 return x.gq(home,c.min());
126 }
129 FloatVal c = n; c /= a;
130 return x.gq(home,c.min());
131 }
134 FloatVal c = n; c /= a;
135 return x.gq(home,c.min());
136 }
137
139 ScaleView::eq(Space& home, int n) {
140 FloatVal c = n; c /= a;
141 return x.eq(home,c);
142 }
145 FloatVal c = n; c /= a;
146 return x.eq(home,c);
147 }
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 */
160 ScaleView::min(const Delta& d) const {
161 FloatVal c = x.min(d); c *= a; return c.min();
162 }
164 ScaleView::max(const Delta& d) const {
165 FloatVal c = x.max(d); c *= a; return c.max();
166 }
167
172
173
174 /*
175 * Cloning
176 *
177 */
178 forceinline void
183
184 /*
185 * Ordering
186 *
187 */
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
201 return (x.base() == y.base()) && (x.scale() == y.scale());
202 }
203 forceinline bool
205 return !(x == y);
206 }
207
208}}
209
210// STATISTICS: float-var
211
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Generic domain change information to be supplied to advisors.
Definition core.hpp:204
Base-class for derived views.
Definition view.hpp:230
FloatView base(void) const
Definition view.hpp:605
static ModEvent me(const ModEventDelta &med)
Definition view.hpp:639
void update(Space &home, DerivedView< View > &y)
Update this view to be a clone of view y.
Definition view.hpp:681
Float value type.
Definition float.hh:334
bool zero_in(void) const
Test whether zero is included.
Definition val.hpp:100
FloatNum med(void) const
Return median of float value.
Definition val.hpp:82
friend FloatVal max(const FloatVal &x, const FloatVal &y)
Definition val.hpp:386
friend FloatVal min(const FloatVal &x, const FloatVal &y)
Definition val.hpp:398
FloatNum size(void) const
Return size of float value (distance between maximum and minimum)
Definition val.hpp:78
Float view for float variables.
Definition view.hpp:52
Scale float view.
Definition view.hpp:395
FloatVal scale(void) const
Return scale factor of scale view.
Definition scale.hpp:54
void update(Space &home, ScaleView &y)
Definition scale.hpp:179
FloatVal a
Scale factor.
Definition view.hpp:399
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition scale.hpp:89
FloatNum min(void) const
Return minimum of domain.
Definition scale.hpp:62
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition scale.hpp:107
bool operator<(const ScaleView &y) const
Whether this view comes before view y (arbitray order)
Definition scale.hpp:189
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition scale.hpp:79
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition scale.hpp:123
FloatNum med(void) const
Return median of domain (closest representation)
Definition scale.hpp:70
ScaleView(void)
Default constructor.
Definition scale.hpp:43
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition scale.hpp:93
FloatVal val(void) const
Return assigned value.
Definition scale.hpp:74
FloatVal domain(void) const
Return domain.
Definition scale.hpp:58
FloatNum max(void) const
Return maximum of domain.
Definition scale.hpp:66
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition scale.hpp:139
Computation spaces.
Definition core.hpp:1742
static ModEventDelta med(ModEvent me)
Translate modification event me to modification event delta for view.
Definition view.hpp:557
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
double FloatNum
Floating point number base type.
Definition float.hh:106
bool operator!=(const MinusView &x, const MinusView &y)
Definition minus.hpp:169
bool operator==(const MinusView &x, const MinusView &y)
Definition minus.hpp:165
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:767
Post propagator for SetVar x
Definition set.hh:767
int ModEvent
Type for modification events.
Definition core.hpp:62
#define forceinline
Definition config.hpp:187