Generated on Tue Mar 24 2020 14:04:04 for Gecode by doxygen 1.8.17
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 
36 namespace Gecode { namespace Float {
37 
38  /*
39  * Constructors and initialization
40  *
41  */
46  : DerivedView<FloatView>(y), c(d) {}
47 
48 
49  /*
50  * Value access
51  *
52  */
54  OffsetView::offset(void) const {
55  return c;
56  }
57  forceinline void
59  c = n;
60  }
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  }
145  OffsetView::eq(Space& home, const FloatVal& n) {
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 
166  }
167 
168 
169  /*
170  * Cloning
171  *
172  */
173  forceinline void
176  c=y.c;
177  }
178 
179  /*
180  * Ordering
181  *
182  */
183  forceinline bool
185  return ((base() < y.base())
186  || ((base() == y.base()) && (offset() < y.offset())));
187  }
188 
189 
190  /*
191  * View comparison
192  *
193  */
194  forceinline bool
195  operator ==(const OffsetView& x, const OffsetView& y) {
196  return (x.base() == y.base()) && (x.offset() == y.offset());
197  }
198  forceinline bool
199  operator !=(const OffsetView& x, const OffsetView& y) {
200  return !(x == y);
201  }
202 
203 }}
204 
205 // STATISTICS: float-var
206 
Post propagator for SetVar x
Definition: set.hh:767
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
void update(Space &home, OffsetView &y)
Definition: offset.hpp:174
void update(Space &home, DerivedView< View > &y)
Update this view to be a clone of view y.
Definition: view.hpp:681
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: offset.hpp:124
FloatNum min(void) const
Return minimum of domain.
Definition: offset.hpp:66
FloatVal val(void) const
Return assigned value.
Definition: offset.hpp:78
Computation spaces.
Definition: core.hpp:1742
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition: offset.hpp:83
bool operator<(const OffsetView &y) const
Whether this view comes before view y (arbitray order)
Definition: offset.hpp:184
OffsetView float view.
Definition: view.hpp:266
FloatVal domain(void) const
Return domain.
Definition: offset.hpp:62
Base-class for derived views.
Definition: view.hpp:230
Gecode toplevel namespace
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition: offset.hpp:137
bool operator!=(const MinusView &x, const MinusView &y)
Definition: minus.hpp:169
OffsetView(void)
Default constructor.
Definition: offset.hpp:43
Float view for float variables.
Definition: view.hpp:52
Generic domain change information to be supplied to advisors.
Definition: core.hpp:204
double FloatNum
Floating point number base type.
Definition: float.hh:106
FloatNum offset(void) const
Return offset.
Definition: offset.hpp:54
bool operator==(const MinusView &x, const MinusView &y)
Definition: minus.hpp:165
FloatNum med(void) const
Return median of domain (closest representation)
Definition: offset.hpp:74
int ModEvent
Type for modification events.
Definition: core.hpp:62
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
Definition: view.hpp:639
FloatNum max(void) const
Return maximum of domain.
Definition: offset.hpp:70
FloatView x
View from which this view is derived.
Definition: view.hpp:238
Float value type.
Definition: float.hh:334
FloatView base(void) const
Return view from which this view is derived.
Definition: view.hpp:605
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition: offset.hpp:93
Gecode::IntSet d(v, 7)
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition: offset.hpp:97
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition: offset.hpp:111
#define forceinline
Definition: config.hpp:185
static ModEventDelta med(ModEvent me)
Translate modification event me to modification event delta for view.
Definition: view.hpp:557
Gecode::FloatVal c(-8, 8)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
FloatNum c
Offset.
Definition: view.hpp:269
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89