Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
offset.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 OffsetView::offset(void) const {
55 return c;
56 }
57 forceinline void
62 OffsetView::domain(void) const {
63 return x.domain()+c;
64 }
66 OffsetView::min(void) const {
67 return x.min()+c;
68 }
70 OffsetView::max(void) const {
71 return x.max()+c;
72 }
74 OffsetView::med(void) const {
75 return x.med()+c;
76 }
78 OffsetView::val(void) const {
79 return x.val()+c;
80 }
81
83 OffsetView::size(void) const {
84 return x.size();
85 }
86
87
88 /*
89 * Domain tests
90 *
91 */
92 forceinline bool
93 OffsetView::zero_in(void) const {
94 return x.in(-c);
95 }
96 forceinline bool
98 return x.in(n-c);
99 }
100 forceinline bool
101 OffsetView::in(const FloatVal& n) const {
102 return x.in(n-c);
103 }
104
105
106 /*
107 * Domain update by value
108 *
109 */
111 OffsetView::lq(Space& home, int n) {
112 return x.lq(home,n-c);
113 }
116 return x.lq(home,n-c);
117 }
120 return x.lq(home,n-c);
121 }
122
124 OffsetView::gq(Space& home, int n) {
125 return x.gq(home,n-c);
126 }
129 return x.gq(home,n-c);
130 }
133 return x.gq(home,n-c);
134 }
135
137 OffsetView::eq(Space& home, int n) {
138 return x.eq(home,n-c);
139 }
142 return x.eq(home,n-c);
143 }
146 return x.eq(home,n-c);
147 }
148
149
150 /*
151 * Delta information for advisors
152 *
153 */
155 OffsetView::min(const Delta& d) const {
156 return x.min(d)+c;
157 }
159 OffsetView::max(const Delta& d) const {
160 return x.max(d)+c;
161 }
162
167
168
169 /*
170 * Cloning
171 *
172 */
173 forceinline void
178
179 /*
180 * Ordering
181 *
182 */
184 OffsetView::operator <(const OffsetView& y) const {
185 return ((base() < y.base())
186 || ((base() == y.base()) && (offset() < y.offset())));
187 }
188
189
190 /*
191 * View comparison
192 *
193 */
194 forceinline bool
196 return (x.base() == y.base()) && (x.offset() == y.offset());
197 }
198 forceinline bool
200 return !(x == y);
201 }
202
203}}
204
205// STATISTICS: float-var
206
int n
Number of negative literals for node type.
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
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
OffsetView float view.
Definition view.hpp:266
bool operator<(const OffsetView &y) const
Whether this view comes before view y (arbitray order)
Definition offset.hpp:184
FloatVal domain(void) const
Return domain.
Definition offset.hpp:62
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition offset.hpp:97
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition offset.hpp:83
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition offset.hpp:137
FloatVal val(void) const
Return assigned value.
Definition offset.hpp:78
void update(Space &home, OffsetView &y)
Definition offset.hpp:174
OffsetView(void)
Default constructor.
Definition offset.hpp:43
FloatNum c
Offset.
Definition view.hpp:269
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition offset.hpp:124
FloatNum med(void) const
Return median of domain (closest representation)
Definition offset.hpp:74
FloatNum max(void) const
Return maximum of domain.
Definition offset.hpp:70
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition offset.hpp:111
FloatNum min(void) const
Return minimum of domain.
Definition offset.hpp:66
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition offset.hpp:93
FloatNum offset(void) const
Return offset.
Definition offset.hpp:54
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