Generated on Sat Feb 7 2015 02:01:22 for Gecode by doxygen 1.8.9.1
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  * Copyright:
7  * Christian Schulte, 2002
8  *
9  * Last modified:
10  * $Date: 2013-02-14 16:29:11 +0100 (Thu, 14 Feb 2013) $ by $Author: schulte $
11  * $Revision: 13292 $
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 
74  forceinline unsigned int
75  IntView::size(void) const {
76  return x->size();
77  }
78  forceinline unsigned int
79  IntView::width(void) const {
80  return x->width();
81  }
82  forceinline unsigned int
83  IntView::regret_min(void) const {
84  return x->regret_min();
85  }
86  forceinline unsigned int
87  IntView::regret_max(void) const {
88  return x->regret_max();
89  }
90 
91 
92  /*
93  * Domain tests
94  *
95  */
96  forceinline bool
97  IntView::range(void) const {
98  return x->range();
99  }
100  forceinline bool
101  IntView::in(int n) const {
102  return x->in(n);
103  }
104  forceinline bool
105  IntView::in(long long int n) const {
106  return x->in(n);
107  }
108 
109 
110  /*
111  * Domain update by value
112  *
113  */
115  IntView::lq(Space& home, int n) {
116  return x->lq(home,n);
117  }
119  IntView::lq(Space& home, long long int n) {
120  return x->lq(home,n);
121  }
122 
124  IntView::le(Space& home, int n) {
125  return x->lq(home,n-1);
126  }
128  IntView::le(Space& home, long long int n) {
129  return x->lq(home,n-1);
130  }
131 
133  IntView::gq(Space& home, int n) {
134  return x->gq(home,n);
135  }
137  IntView::gq(Space& home, long long int n) {
138  return x->gq(home,n);
139  }
140 
142  IntView::gr(Space& home, int n) {
143  return x->gq(home,n+1);
144  }
146  IntView::gr(Space& home, long long int n) {
147  return x->gq(home,n+1);
148  }
149 
151  IntView::nq(Space& home, int n) {
152  return x->nq(home,n);
153  }
155  IntView::nq(Space& home, long long int n) {
156  return x->nq(home,n);
157  }
158 
160  IntView::eq(Space& home, int n) {
161  return x->eq(home,n);
162  }
164  IntView::eq(Space& home, long long int n) {
165  return x->eq(home,n);
166  }
167 
168 
169  /*
170  * Iterator-based domain update
171  *
172  */
173  template<class I>
175  IntView::narrow_r(Space& home, I& i, bool depend) {
176  return x->narrow_r(home,i,depend);
177  }
178  template<class I>
180  IntView::inter_r(Space& home, I& i, bool depend) {
181  return x->inter_r(home,i,depend);
182  }
183  template<class I>
185  IntView::minus_r(Space& home, I& i, bool depend) {
186  return x->minus_r(home,i,depend);
187  }
188  template<class I>
190  IntView::narrow_v(Space& home, I& i, bool depend) {
191  return x->narrow_v(home,i,depend);
192  }
193  template<class I>
195  IntView::inter_v(Space& home, I& i, bool depend) {
196  return x->inter_v(home,i,depend);
197  }
198  template<class I>
200  IntView::minus_v(Space& home, I& i, bool depend) {
201  return x->minus_v(home,i,depend);
202  }
203 
204 
205 
206 
207  /*
208  * Delta information for advisors
209  *
210  */
211  forceinline int
212  IntView::min(const Delta& d) const {
213  return IntVarImp::min(d);
214  }
215  forceinline int
216  IntView::max(const Delta& d) const {
217  return IntVarImp::max(d);
218  }
219  forceinline bool
220  IntView::any(const Delta& d) const {
221  return IntVarImp::any(d);
222  }
223 
224 
227  return VarImpView<IntVar>::med(me);
228  }
229 
230 
235  template<>
236  class ViewRanges<IntView> : public IntVarImpFwd {
237  public:
239 
240  ViewRanges(void);
243  ViewRanges(const IntView& x);
245  void init(const IntView& x);
247  };
248 
251 
254  : IntVarImpFwd(x.varimp()) {}
255 
256  forceinline void
259  }
260 
261 }}
262 
263 // STATISTICS: int-var
264 
ModEvent nq(Space &home, int n)
Restrict domain values to be different from n.
Definition: int.hpp:408
int val(void) const
Return assigned value (only if assigned)
Definition: int.hpp:70
ModEvent inter_r(Space &home, I &i, bool depends=true)
Intersect domain with ranges described by i.
Definition: int.hpp:180
ModEvent nq(Space &home, int n)
Restrict domain values to be different from n.
Definition: int.hpp:151
ModEvent gr(Space &home, int n)
Restrict domain values to be greater than n.
Definition: int.hpp:142
static ModEventDelta med(ModEvent me)
Translate modification event me to modification event delta for view.
Definition: view.hpp:484
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition: int.hpp:386
unsigned int size(void) const
Return size (cardinality) of domain.
Definition: int.hpp:257
VarImpType * varimp(void) const
Return variable implementation of view.
Definition: view.hpp:433
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition: int.hpp:160
IntView(void)
Default constructor.
Definition: int.hpp:45
ViewRanges(void)
Default constructor.
int ModEvent
Type for modification events.
Definition: core.hpp:146
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition: int.hpp:365
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Definition: int.hpp:87
ModEvent narrow_r(Space &home, I &i, bool depends=true)
Replace domain by ranges described by i.
Definition: int.hpp:175
ModEvent minus_r(Space &home, I &i, bool depends=true)
Remove from domain the ranges described by i.
Definition: int.hpp:185
Computation spaces.
Definition: core.hpp:1362
void init(const View &x)
Initialize with ranges for view x.
ModEvent minus_v(Space &home, I &i, bool depends=true)
Remove from domain the values described by i.
Definition: int.hpp:200
Range iterator for integer views.
Definition: view.hpp:54
Gecode::IntSet d(v, 7)
int val(void) const
Return assigned value (only if assigned)
Definition: int.hpp:236
int max(void) const
Return maximum of domain.
Definition: int.hpp:62
ModEvent le(Space &home, int n)
Restrict domain values to be less than n.
Definition: int.hpp:124
Gecode::IntArgs i(4, 1, 2, 3, 4)
bool in(int n) const
Test whether n is contained in domain.
Definition: int.hpp:101
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Definition: int.hpp:83
ModEvent narrow_v(Space &home, I &i, bool depends=true)
Replace domain by values described by i.
Definition: int.hpp:190
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition: int.hpp:115
bool range(void) const
Test whether domain is a range.
Definition: int.hpp:242
unsigned int size(void) const
Return size (cardinality) of domain.
Definition: int.hpp:75
Range iterator for ranges of integer variable implementation.
Definition: var-imp.hpp:387
int min(void) const
Return minimum of domain.
Definition: int.hpp:58
Base-class for variable implementation views.
Definition: view.hpp:117
bool any(const Delta &d) const
Test whether arbitrary values got pruned.
Definition: int.hpp:220
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Definition: int.hpp:272
ModEvent inter_r(Space &home, I &i, bool depends=true)
Intersect domain with ranges described by i.
Definition: int.hpp:670
ModEvent minus_v(Space &home, I &i, bool depends=true)
Remove from domain the values described by i.
Definition: int.hpp:849
ModEvent inter_v(Space &home, I &i, bool depends=true)
Intersect domain with values described by i.
Definition: int.hpp:195
ModEvent narrow_v(Space &home, I &i, bool depends=true)
Replace domain by values described by i.
Definition: int.hpp:835
Integer view for integer variables.
Definition: view.hpp:129
Integer variable implementation.
Definition: var-imp.hpp:91
ModEvent inter_v(Space &home, I &i, bool depends=true)
Intersect domain with values described by i.
Definition: int.hpp:842
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Generic domain change information to be supplied to advisors.
Definition: core.hpp:275
int max(void) const
Return maximum of domain.
Definition: int.hpp:232
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition: int.hpp:79
Integer variables.
Definition: int.hh:350
#define forceinline
Definition: config.hpp:132
ModEvent minus_r(Space &home, I &i, bool depends=true)
Remove from domain the ranges described by i.
Definition: int.hpp:678
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: int.hpp:133
int med(void) const
Return median of domain (greatest element not greater than the median)
Definition: int.hpp:66
bool in(int n) const
Test whether n is contained in domain.
Definition: int.hpp:290
bool range(void) const
Test whether domain is a range.
Definition: int.hpp:97
int med(void) const
Return median of domain (greatest element not greater than the median)
Definition: int.cpp:50
static bool any(const Delta &d)
Test whether arbitrary values got pruned.
Definition: int.hpp:333
Gecode toplevel namespace
void init(const IntVarImp *x)
Initialize with ranges from variable implementation x.
Definition: int.hpp:432
VarImpType * x
Pointer to variable implementation.
Definition: view.hpp:125
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
ModEvent narrow_r(Space &home, I &i, bool depends=true)
Replace domain by ranges described by i.
Definition: int.hpp:503
int min(void) const
Return minimum of domain.
Definition: int.hpp:228
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Definition: int.hpp:262
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition: int.hpp:252
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: int.hpp:344