Generated on Sat Feb 7 2015 02:01:18 for Gecode by doxygen 1.8.9.1
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  * 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), c(d) {}
51 
52 
53  /*
54  * Value access
55  *
56  */
58  OffsetView::offset(void) const {
59  return c;
60  }
61  forceinline void
63  c = n;
64  }
66  OffsetView::domain(void) const {
67  return x.domain()+c;
68  }
70  OffsetView::min(void) const {
71  return x.min()+c;
72  }
74  OffsetView::max(void) const {
75  return x.max()+c;
76  }
78  OffsetView::med(void) const {
79  return x.med()+c;
80  }
82  OffsetView::val(void) const {
83  return x.val()+c;
84  }
85 
87  OffsetView::size(void) const {
88  return x.size();
89  }
90 
91 
92  /*
93  * Domain tests
94  *
95  */
96  forceinline bool
97  OffsetView::zero_in(void) const {
98  return x.in(-c);
99  }
100  forceinline bool
102  return x.in(n-c);
103  }
104  forceinline bool
105  OffsetView::in(const FloatVal& n) const {
106  return x.in(n-c);
107  }
108 
109 
110  /*
111  * Domain update by value
112  *
113  */
115  OffsetView::lq(Space& home, int n) {
116  return x.lq(home,n-c);
117  }
120  return x.lq(home,n-c);
121  }
124  return x.lq(home,n-c);
125  }
126 
128  OffsetView::gq(Space& home, int n) {
129  return x.gq(home,n-c);
130  }
133  return x.gq(home,n-c);
134  }
137  return x.gq(home,n-c);
138  }
139 
141  OffsetView::eq(Space& home, int n) {
142  return x.eq(home,n-c);
143  }
146  return x.eq(home,n-c);
147  }
149  OffsetView::eq(Space& home, const FloatVal& n) {
150  return x.eq(home,n-c);
151  }
152 
153 
154  /*
155  * Delta information for advisors
156  *
157  */
159  OffsetView::min(const Delta& d) const {
160  return x.min(d)+c;
161  }
163  OffsetView::max(const Delta& d) const {
164  return x.max(d)+c;
165  }
166 
169  return VarImpView<FloatVar>::med(me);
170  }
171 
172 
173  /*
174  * Cloning
175  *
176  */
177  forceinline void
178  OffsetView::update(Space& home, bool share, OffsetView& y) {
179  DerivedView<FloatView>::update(home,share,y);
180  c=y.c;
181  }
182 
183 }}
184 
185 // STATISTICS: float-var
186 
static ModEventDelta med(ModEvent me)
Translate modification event me to modification event delta for view.
Definition: view.hpp:484
FloatNum min(void) const
Return minimum of domain.
Definition: offset.hpp:70
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: offset.hpp:128
FloatNum med(void) const
Return median of domain (closest representation)
Definition: offset.hpp:78
FloatVal domain(void) const
Return domain.
Definition: offset.hpp:66
FloatNum offset(void) const
Return offset.
Definition: offset.hpp:58
OffsetView float view.
Definition: view.hpp:260
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition: offset.hpp:87
int ModEvent
Type for modification events.
Definition: core.hpp:146
void update(Space &home, bool share, OffsetView &y)
Definition: offset.hpp:178
Computation spaces.
Definition: core.hpp:1362
Base-class for derived views.
Definition: view.hpp:208
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition: offset.hpp:101
Gecode::IntSet d(v, 7)
Gecode::FloatVal c(-8, 8)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition: offset.hpp:141
OffsetView(void)
Default constructor.
Definition: offset.hpp:47
void update(Space &home, bool share, DerivedView< View > &y)
Update this view to be a clone of view y.
Definition: view.hpp:590
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition: offset.hpp:97
FloatVal val(void) const
Return assigned value.
Definition: offset.hpp:82
Float view for float variables.
Definition: view.hpp:56
Float value type.
Definition: float.hh:321
Generic domain change information to be supplied to advisors.
Definition: core.hpp:275
FloatNum max(void) const
Return maximum of domain.
Definition: offset.hpp:74
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition: offset.hpp:115
#define forceinline
Definition: config.hpp:132
FloatView x
View from which this view is derived.
Definition: view.hpp:216
Gecode toplevel namespace
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
double FloatNum
Floating point number base type.
Definition: float.hh:108
FloatNum c
Offset.
Definition: view.hpp:263