Generated on Fri Jan 10 2020 11:38:25 for Gecode by doxygen 1.8.16
int.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  *
6  * Contributing authors:
7  * Samuel Gagnon <samuel.gagnon92@gmail.com>
8  *
9  * Copyright:
10  * Christian Schulte, 2002
11  * Samuel Gagnon, 2018
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 namespace Gecode { namespace Int {
39 
40  /*
41  * Constructors and initialization
42  *
43  */
48  : VarImpView<IntVar>(y.varimp()) {}
51  : VarImpView<IntVar>(y) {}
52 
53  /*
54  * Value access
55  *
56  */
57  forceinline int
58  IntView::min(void) const {
59  return x->min();
60  }
61  forceinline int
62  IntView::max(void) const {
63  return x->max();
64  }
65  forceinline int
66  IntView::med(void) const {
67  return x->med();
68  }
69  forceinline int
70  IntView::val(void) const {
71  return x->val();
72  }
73 #ifdef GECODE_HAS_CBS
74  forceinline int
75  IntView::baseval(int val) const {
76  return val;
77  }
78 #endif
79 
80  forceinline unsigned int
81  IntView::size(void) const {
82  return x->size();
83  }
84  forceinline unsigned int
85  IntView::width(void) const {
86  return x->width();
87  }
88  forceinline unsigned int
89  IntView::regret_min(void) const {
90  return x->regret_min();
91  }
92  forceinline unsigned int
93  IntView::regret_max(void) const {
94  return x->regret_max();
95  }
96 
97 
98  /*
99  * Domain tests
100  *
101  */
102  forceinline bool
103  IntView::range(void) const {
104  return x->range();
105  }
106  forceinline bool
107  IntView::in(int n) const {
108  return x->in(n);
109  }
110  forceinline bool
111  IntView::in(long long int n) const {
112  return x->in(n);
113  }
114 
115 
116  /*
117  * Domain update by value
118  *
119  */
121  IntView::lq(Space& home, int n) {
122  return x->lq(home,n);
123  }
125  IntView::lq(Space& home, long long int n) {
126  return x->lq(home,n);
127  }
128 
130  IntView::le(Space& home, int n) {
131  return x->lq(home,n-1);
132  }
134  IntView::le(Space& home, long long int n) {
135  return x->lq(home,n-1);
136  }
137 
139  IntView::gq(Space& home, int n) {
140  return x->gq(home,n);
141  }
143  IntView::gq(Space& home, long long int n) {
144  return x->gq(home,n);
145  }
146 
148  IntView::gr(Space& home, int n) {
149  return x->gq(home,n+1);
150  }
152  IntView::gr(Space& home, long long int n) {
153  return x->gq(home,n+1);
154  }
155 
157  IntView::nq(Space& home, int n) {
158  return x->nq(home,n);
159  }
161  IntView::nq(Space& home, long long int n) {
162  return x->nq(home,n);
163  }
164 
166  IntView::eq(Space& home, int n) {
167  return x->eq(home,n);
168  }
170  IntView::eq(Space& home, long long int n) {
171  return x->eq(home,n);
172  }
173 
174 
175  /*
176  * Iterator-based domain update
177  *
178  */
179  template<class I>
181  IntView::narrow_r(Space& home, I& i, bool depend) {
182  return x->narrow_r(home,i,depend);
183  }
184  template<class I>
186  IntView::inter_r(Space& home, I& i, bool depend) {
187  return x->inter_r(home,i,depend);
188  }
189  template<class I>
191  IntView::minus_r(Space& home, I& i, bool depend) {
192  return x->minus_r(home,i,depend);
193  }
194  template<class I>
196  IntView::narrow_v(Space& home, I& i, bool depend) {
197  return x->narrow_v(home,i,depend);
198  }
199  template<class I>
201  IntView::inter_v(Space& home, I& i, bool depend) {
202  return x->inter_v(home,i,depend);
203  }
204  template<class I>
206  IntView::minus_v(Space& home, I& i, bool depend) {
207  return x->minus_v(home,i,depend);
208  }
209 
210 
211 
212 
213  /*
214  * Delta information for advisors
215  *
216  */
217  forceinline int
218  IntView::min(const Delta& d) const {
219  return IntVarImp::min(d);
220  }
221  forceinline int
222  IntView::max(const Delta& d) const {
223  return IntVarImp::max(d);
224  }
225  forceinline unsigned int
226  IntView::width(const Delta& d) const {
227  return IntVarImp::width(d);
228  }
229  forceinline bool
230  IntView::any(const Delta& d) const {
231  return IntVarImp::any(d);
232  }
233 
234 
237  return VarImpView<IntVar>::med(me);
238  }
239 
240 
245  template<>
246  class ViewRanges<IntView> : public IntVarImpFwd {
247  public:
249 
250  ViewRanges(void);
253  ViewRanges(const IntView& x);
255  void init(const IntView& x);
257  };
258 
261 
264  : IntVarImpFwd(x.varimp()) {}
265 
266  forceinline void
269  }
270 
271 }}
272 
273 // STATISTICS: int-var
274 
VarImpType * x
Pointer to variable implementation.
Definition: view.hpp:141
Post propagator for SetVar x
Definition: set.hh:767
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
int min(void) const
Return minimum of domain.
Definition: int.hpp:224
void init(const View &x)
Initialize with ranges for view x.
int min(void) const
Return minimum of domain.
Definition: int.hpp:58
Range iterator for ranges of integer variable implementation.
Definition: var-imp.hpp:392
ModEvent minus_v(Space &home, I &i, bool depends=true)
Remove from domain the values described by i.
Definition: int.hpp:206
Computation spaces.
Definition: core.hpp:1742
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition: int.hpp:248
Integer variable implementation.
Definition: var-imp.hpp:89
Gecode toplevel namespace
int max(void) const
Return maximum of domain.
Definition: int.hpp:62
Range iterator for integer views.
Definition: view.hpp:54
ModEvent inter_r(Space &home, I &i, bool depends=true)
Intersect domain with ranges described by i.
Definition: int.hpp:186
int val(void) const
Return assigned value (only if assigned)
Definition: int.hpp:70
Generic domain change information to be supplied to advisors.
Definition: core.hpp:204
VarImp * varimp(void) const
Return variable implementation of variable.
Definition: var.hpp:96
unsigned int size(void) const
Return size (cardinality) of domain.
Definition: int.hpp:81
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
Definition: view.hpp:552
ModEvent inter_v(Space &home, I &i, bool depends=true)
Intersect domain with values described by i.
Definition: int.hpp:201
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Definition: int.hpp:89
ViewRanges(void)
Default constructor.
ModEvent nq(Space &home, int n)
Restrict domain values to be different from n.
Definition: int.hpp:157
Integer variables.
Definition: int.hh:371
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Definition: int.hpp:93
bool in(int n) const
Test whether n is contained in domain.
Definition: int.hpp:107
int ModEvent
Type for modification events.
Definition: core.hpp:62
ModEvent narrow_r(Space &home, I &i, bool depends=true)
Replace domain by ranges described by i.
Definition: int.hpp:181
static bool any(const Delta &d)
Test whether arbitrary values got pruned.
Definition: int.hpp:333
Gecode::IntSet d(v, 7)
ModEvent gr(Space &home, int n)
Restrict domain values to be greater than n.
Definition: int.hpp:148
Integer view for integer variables.
Definition: view.hpp:129
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition: int.hpp:85
#define forceinline
Definition: config.hpp:185
void init(const IntVarImp *x)
Initialize with ranges from variable implementation x.
Definition: int.hpp:432
static ModEventDelta med(ModEvent me)
Translate modification event me to modification event delta for view.
Definition: view.hpp:557
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition: int.hpp:121
ModEvent narrow_v(Space &home, I &i, bool depends=true)
Replace domain by values described by i.
Definition: int.hpp:196
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: int.hpp:139
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
int med(void) const
Return median of domain (greatest element not greater than the median)
Definition: int.hpp:66
ModEvent minus_r(Space &home, I &i, bool depends=true)
Remove from domain the ranges described by i.
Definition: int.hpp:191
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
bool any(const Delta &d) const
Test whether arbitrary values got pruned.
Definition: int.hpp:230
Gecode::IntArgs i({1, 2, 3, 4})
bool range(void) const
Test whether domain is a range.
Definition: int.hpp:103
int max(void) const
Return maximum of domain.
Definition: int.hpp:228
ModEvent le(Space &home, int n)
Restrict domain values to be less than n.
Definition: int.hpp:130
Base-class for variable implementation views.
Definition: view.hpp:133
IntView(void)
Default constructor.
Definition: int.hpp:45
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition: int.hpp:166