Generated on Sat Jun 2 2018 07:17:44 for Gecode by doxygen 1.8.13
bool.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<BoolVar>(y.varimp()) {}
51  : VarImpView<BoolVar>(y) {}
52 
53  /*
54  * Value access
55  *
56  */
58  BoolView::status(void) const {
59  return x->status();
60  }
61  forceinline int
62  BoolView::min(void) const {
63  return x->min();
64  }
65  forceinline int
66  BoolView::max(void) const {
67  return x->max();
68  }
69  forceinline int
70  BoolView::med(void) const {
71  return x->med();
72  }
73  forceinline int
74  BoolView::val(void) const {
75  return x->val();
76  }
77 #ifdef GECODE_HAS_CBS
78  forceinline int
79  BoolView::baseval(int val) const {
80  return val;
81  }
82 #endif
83 
84  forceinline unsigned int
85  BoolView::size(void) const {
86  return x->size();
87  }
88  forceinline unsigned int
89  BoolView::width(void) const {
90  return x->width();
91  }
92  forceinline unsigned int
93  BoolView::regret_min(void) const {
94  return x->regret_min();
95  }
96  forceinline unsigned int
97  BoolView::regret_max(void) const {
98  return x->regret_max();
99  }
100 
101 
102  /*
103  * Domain tests
104  *
105  */
106  forceinline bool
107  BoolView::range(void) const {
108  return x->range();
109  }
110  forceinline bool
111  BoolView::in(int n) const {
112  return x->in(n);
113  }
114  forceinline bool
115  BoolView::in(long long int n) const {
116  return x->in(n);
117  }
118 
119 
120  /*
121  * Domain update by value
122  *
123  */
125  BoolView::lq(Space& home, int n) {
126  return x->lq(home,n);
127  }
129  BoolView::lq(Space& home, long long int n) {
130  return x->lq(home,n);
131  }
132 
134  BoolView::le(Space& home, int n) {
135  return x->lq(home,n-1);
136  }
138  BoolView::le(Space& home, long long int n) {
139  return x->lq(home,n-1);
140  }
141 
143  BoolView::gq(Space& home, int n) {
144  return x->gq(home,n);
145  }
147  BoolView::gq(Space& home, long long int n) {
148  return x->gq(home,n);
149  }
150 
152  BoolView::gr(Space& home, int n) {
153  return x->gq(home,n+1);
154  }
156  BoolView::gr(Space& home, long long int n) {
157  return x->gq(home,n+1);
158  }
159 
161  BoolView::nq(Space& home, int n) {
162  return x->nq(home,n);
163  }
165  BoolView::nq(Space& home, long long int n) {
166  return x->nq(home,n);
167  }
168 
170  BoolView::eq(Space& home, int n) {
171  return x->eq(home,n);
172  }
174  BoolView::eq(Space& home, long long int n) {
175  return x->eq(home,n);
176  }
177 
178 
179  /*
180  * Iterator-based domain update
181  *
182  */
183  template<class I>
185  BoolView::narrow_r(Space& home, I& i, bool depend) {
186  return x->narrow_r(home,i,depend);
187  }
188  template<class I>
190  BoolView::inter_r(Space& home, I& i, bool depend) {
191  return x->inter_r(home,i,depend);
192  }
193  template<class I>
195  BoolView::minus_r(Space& home, I& i, bool depend) {
196  return x->minus_r(home,i,depend);
197  }
198  template<class I>
200  BoolView::narrow_v(Space& home, I& i, bool depend) {
201  return x->narrow_v(home,i,depend);
202  }
203  template<class I>
205  BoolView::inter_v(Space& home, I& i, bool depend) {
206  return x->inter_v(home,i,depend);
207  }
208  template<class I>
210  BoolView::minus_v(Space& home, I& i, bool depend) {
211  return x->minus_v(home,i,depend);
212  }
213 
214 
215  /*
216  * Boolean domain tests
217  *
218  */
219  forceinline bool
220  BoolView::zero(void) const {
221  return x->zero();
222  }
223  forceinline bool
224  BoolView::one(void) const {
225  return x->one();
226  }
227  forceinline bool
228  BoolView::none(void) const {
229  return x->none();
230  }
231 
232 
233  /*
234  * Boolean assignment operations
235  *
236  */
239  return x->zero_none(home);
240  }
243  return x->one_none(home);
244  }
245 
248  return x->zero(home);
249  }
252  return x->one(home);
253  }
254 
255 
256  /*
257  * Delta information for advisors
258  *
259  */
260  forceinline int
261  BoolView::min(const Delta& d) const {
262  return BoolVarImp::min(d);
263  }
264  forceinline int
265  BoolView::max(const Delta& d) const {
266  return BoolVarImp::max(d);
267  }
268  forceinline unsigned int
269  BoolView::width(const Delta& d) const {
270  return BoolVarImp::width(d);
271  }
272  forceinline bool
273  BoolView::any(const Delta& d) const {
274  return BoolVarImp::any(d);
275  }
276  forceinline bool
278  return BoolVarImp::zero(d);
279  }
280  forceinline bool
282  return BoolVarImp::one(d);
283  }
284 
285 
286 
289  return VarImpView<BoolVar>::med(me);
290  }
291 
296  template<>
298  public:
300 
301  ViewRanges(void);
304  ViewRanges(const BoolView& x);
306  void init(const BoolView& x);
308  };
309 
312 
315  : Iter::Ranges::Singleton(x.min(),x.max()) {}
316 
317  forceinline void
320  }
321 
322 }}
323 
324 // STATISTICS: int-var
static ModEventDelta med(ModEvent me)
Translate modification event me to modification event delta for view.
Definition: view.hpp:545
bool zero(void) const
Test whether view is assigned to be zero.
Definition: bool.hpp:220
Range iterator for singleton range.
bool range(void) const
Test whether domain is a range.
Definition: bool.hpp:107
ModEvent minus_r(Space &home, I &i, bool depends=true)
Remove from domain the ranges described by i.
Definition: bool.hpp:195
unsigned int size(void) const
Return size (cardinality) of domain.
Definition: bool.hpp:85
unsigned int BoolStatus
Type for status of a Boolean variable.
Definition: var-imp.hpp:484
ModEvent inter_v(Space &home, I &i, bool depends=true)
Intersect domain with values described by i.
Definition: bool.hpp:205
bool one(void) const
Test whether view is assigned to be one.
Definition: bool.hpp:224
ViewRanges(void)
Default constructor.
ModEvent gr(Space &home, int n)
Restrict domain values to be greater than n.
Definition: bool.hpp:152
int ModEvent
Type for modification events.
Definition: core.hpp:62
static bool any(const Delta &d)
Test whether arbitrary values got pruned.
Definition: bool.hpp:165
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition: bool.hpp:91
#define forceinline
Definition: config.hpp:185
Computation spaces.
Definition: core.hpp:1701
void init(const View &x)
Initialize with ranges for view x.
bool zero(void) const
Test whether variable is assigned to zero.
Definition: bool.hpp:131
BoolView(void)
Default constructor.
Definition: bool.hpp:45
Range iterator for integer views.
Definition: view.hpp:54
Boolean variable implementation.
Definition: var-imp.hpp:491
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition: bool.hpp:170
Gecode::IntSet d(v, 7)
int min(void) const
Return minimum of domain.
Definition: bool.hpp:62
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition: bool.hpp:125
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
ModEvent minus_v(Space &home, I &i, bool depends=true)
Remove from domain the values described by i.
Definition: bool.hpp:210
ModEvent zero_none(Space &home)
Assign not yet assigned view to zero.
Definition: bool.hpp:238
int max(void) const
Return maximum of domain.
Definition: bool.hpp:66
void init(int min, int max)
Initialize with range min to max.
BoolStatus status(void) const
Return current domain status.
Definition: bool.hpp:58
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: bool.hpp:143
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Definition: bool.hpp:97
Base-class for variable implementation views.
Definition: view.hpp:127
ModEvent narrow_v(Space &home, I &i, bool depends=true)
Replace domain by values described by i.
Definition: bool.hpp:200
ModEvent nq(Space &home, int n)
Restrict domain values to be different from n.
Definition: bool.hpp:161
int max(void) const
Return maximum of domain.
Definition: bool.hpp:66
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Definition: bool.hpp:93
int min(void) const
Return minimum of domain.
Definition: bool.hpp:62
Boolean integer variables.
Definition: int.hh:488
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:765
ModEvent inter_r(Space &home, I &i, bool depends=true)
Intersect domain with ranges described by i.
Definition: bool.hpp:190
Generic domain change information to be supplied to advisors.
Definition: core.hpp:203
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
Definition: view.hpp:540
Post propagator for SetVar x
Definition: set.hh:765
int med(void) const
Return median of domain (greatest element not greater than the median)
Definition: bool.hpp:70
bool in(int n) const
Test whether n is contained in domain.
Definition: bool.hpp:111
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition: bool.hpp:89
Gecode toplevel namespace
ModEvent one_none(Space &home)
Assign not yet assigned view to one.
Definition: bool.hpp:242
bool none(void) const
Test whether view is not yet assigned.
Definition: bool.hpp:228
VarImpType * varimp(void) const
Return variable implementation of view.
Definition: view.hpp:482
ModEvent le(Space &home, int n)
Restrict domain values to be less than n.
Definition: bool.hpp:134
VarImpType * x
Pointer to variable implementation.
Definition: view.hpp:135
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
int val(void) const
Return assigned value (only if assigned)
Definition: bool.hpp:74
bool one(void) const
Test whether variable is assigned to one.
Definition: bool.hpp:135
bool any(const Delta &d) const
Test whether arbitrary values got pruned.
Definition: bool.hpp:273
Boolean view for Boolean variables.
Definition: view.hpp:1349
ModEvent narrow_r(Space &home, I &i, bool depends=true)
Replace domain by ranges described by i.
Definition: bool.hpp:185