Generated on Sat Feb 7 2015 02:01:22 for Gecode by doxygen 1.8.9.1
set.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  * Christian Schulte <schulte@gecode.org>
6  * Gabor Szokoli <szokoli@gecode.org>
7  *
8  * Copyright:
9  * Guido Tack, 2004
10  * Christian Schulte, 2004
11  * Gabor Szokoli, 2004
12  *
13  * Last modified:
14  * $Date: 2010-08-31 16:19:34 +0200 (Tue, 31 Aug 2010) $ by $Author: schulte $
15  * $Revision: 11366 $
16  *
17  * This file is part of Gecode, the generic constraint
18  * development environment:
19  * http://www.gecode.org
20  *
21  * Permission is hereby granted, free of charge, to any person obtaining
22  * a copy of this software and associated documentation files (the
23  * "Software"), to deal in the Software without restriction, including
24  * without limitation the rights to use, copy, modify, merge, publish,
25  * distribute, sublicense, and/or sell copies of the Software, and to
26  * permit persons to whom the Software is furnished to do so, subject to
27  * the following conditions:
28  *
29  * The above copyright notice and this permission notice shall be
30  * included in all copies or substantial portions of the Software.
31  *
32  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39  *
40  */
41 
42 namespace Gecode {
43 
44  /*
45  * Constructors and access
46  *
47  */
48 
50  SetVar::SetVar(void) {}
51 
54  : VarImpVar<Set::SetVarImp>(y.varimp()) {}
55 
58  : VarImpVar<Set::SetVarImp>(y.varimp()) {}
59 
60 
61  /*
62  * Variable information
63  *
64  */
65 
66  forceinline unsigned int
67  SetVar::glbSize(void) const { return x->glbSize(); }
68 
69  forceinline unsigned int
70  SetVar::lubSize(void) const { return x->lubSize(); }
71 
72  forceinline unsigned int
73  SetVar::unknownSize(void) const { return x->lubSize()-x->glbSize(); }
74 
75  forceinline bool
76  SetVar::contains(int i) const { return x->knownIn(i); }
77 
78  forceinline bool
79  SetVar::notContains(int i) const { return x->knownOut(i); }
80 
81  forceinline unsigned int
82  SetVar::cardMin(void) const { return x->cardMin(); }
83 
84  forceinline unsigned int
85  SetVar::cardMax(void) const { return x->cardMax(); }
86 
87  forceinline int
88  SetVar::lubMin(void) const { return x->lubMin(); }
89 
90  forceinline int
91  SetVar::lubMax(void) const { return x->lubMax(); }
92 
93  forceinline int
94  SetVar::glbMin(void) const { return x->glbMin(); }
95 
96  forceinline int
97  SetVar::glbMax(void) const { return x->glbMax(); }
98 
99 
100 
101  /*
102  * Range and value iterators for set variables
103  *
104  */
105 
108 
111  : iter(s.varimp()) {}
112 
114  bool
115  SetVarGlbRanges::operator ()(void) const { return iter(); }
116 
118  void
120 
122  int
123  SetVarGlbRanges::min(void) const { return iter.min(); }
124 
126  int
127  SetVarGlbRanges::max(void) const { return iter.max(); }
128 
130  unsigned int
131  SetVarGlbRanges::width(void) const { return iter.width(); }
132 
135 
138  : iter(s.varimp()) {}
139 
141  bool
142  SetVarLubRanges::operator ()(void) const { return iter(); }
143 
145  void
147 
149  int
150  SetVarLubRanges::min(void) const { return iter.min(); }
151 
153  int
154  SetVarLubRanges::max(void) const { return iter.max(); }
155 
157  unsigned int
158  SetVarLubRanges::width(void) const { return iter.width(); }
159 
162 
165  iter.init(s.varimp());
166  }
167 
169  bool
170  SetVarUnknownRanges::operator ()(void) const { return iter(); }
171 
173  void
175 
177  int
178  SetVarUnknownRanges::min(void) const { return iter.min(); }
179 
181  int
182  SetVarUnknownRanges::max(void) const { return iter.max(); }
183 
185  unsigned int
186  SetVarUnknownRanges::width(void) const { return iter.width(); }
187 
190  SetVarGlbRanges ivr(x);
191  iter.init(ivr);
192  }
193 
194  forceinline bool
196  return iter();
197  }
198 
199  forceinline void
201  ++iter;
202  }
203 
204  forceinline int
205  SetVarGlbValues::val(void) const {
206  return iter.val();
207  }
208 
211  SetVarLubRanges ivr(x);
212  iter.init(ivr);
213  }
214 
215  forceinline bool
217  return iter();
218  }
219 
220  forceinline void
222  ++iter;
223  }
224 
225  forceinline int
226  SetVarLubValues::val(void) const {
227  return iter.val();
228  }
229 
232  SetVarUnknownRanges ivr(x);
233  iter.init(ivr);
234  }
235 
236  forceinline bool
238  return iter();
239  }
240 
241  forceinline void
243  ++iter;
244  }
245 
246  forceinline int
248  return iter.val();
249  }
250 
251 }
252 
253 // STATISTICS: set-var
254 
void operator++(void)
Move iterator to next value (if possible)
Definition: set.hpp:200
unsigned int cardMax(void) const
Return cardinality maximum.
Definition: set.hpp:85
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition: set.hpp:115
int val(void) const
Return current value.
Definition: set.hpp:247
Variables as interfaces to variable implementations.
Definition: var.hpp:51
int min(void) const
Return smallest value of range.
Definition: set.hpp:150
int min(void) const
Return smallest value of range.
Definition: set.hpp:123
int glbMin(void) const
Return minimum of the greatest lower bound.
Definition: set.hpp:124
int glbMax(void) const
Return maximum of greatest lower bound.
Definition: set.hpp:97
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition: set.hpp:186
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition: set.hpp:158
int max(void) const
Return largest value of range.
Definition: set.hpp:154
unsigned int lubSize(void) const
Return number of elements in the least upper bound.
Definition: set.hpp:70
Finite integer set variable implementation.
Definition: var-imp.hpp:434
bool contains(int i) const
Test whether i is in greatest lower bound.
Definition: set.hpp:76
unsigned int unknownSize(void) const
Return number of unknown elements (elements in lub but not in glb)
Definition: set.hpp:73
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition: set.hpp:195
unsigned int cardMin(void) const
Return cardinality minimum.
Definition: set.hpp:82
unsigned int glbSize(void) const
Return number of elements in the greatest lower bound.
Definition: set.hpp:67
int glbMax(void) const
Return maximum of the greatest lower bound.
Definition: set.hpp:127
Iterator for the unknown ranges of a set variable.
Definition: set.hh:336
int val(void) const
Return current value.
Definition: set.hpp:205
int lubMax(void) const
Return maximum of the least upper bound.
Definition: set.hpp:118
SetVarLubRanges(void)
Default constructor.
Definition: set.hpp:134
Gecode::IntArgs i(4, 1, 2, 3, 4)
int max(void) const
Return largest value of range.
Definition: set.hpp:127
unsigned int cardMax(void) const
Return current cardinality maximum.
Definition: set.hpp:106
unsigned int cardMin(void) const
Return current cardinality minimum.
Definition: set.hpp:103
int val(void) const
Return current value.
Definition: set.hpp:226
int lubMax(void) const
Return maximum element of least upper bound.
Definition: set.hpp:91
Set::SetVarImp * x
Pointer to variable implementation.
Definition: var.hpp:54
Iterator for the greatest lower bound ranges of a set variable.
Definition: set.hh:272
bool notContains(int i) const
Test whether i is not in the least upper bound.
Definition: set.hpp:79
bool knownOut(int) const
Test whether n is not contained in least upper bound.
Definition: set.hpp:112
Iterator for the least upper bound ranges of a set variable.
Definition: set.hh:304
void operator++(void)
Move iterator to next value (if possible)
Definition: set.hpp:242
bool knownIn(int n) const
Test whether n is contained in greatest lower bound.
Definition: set.hpp:109
SetVarLubValues(void)
Default constructor.
Set view for set variables
Definition: view.hpp:60
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition: set.hpp:216
void operator++(void)
Move iterator to next range (if possible)
Definition: set.hpp:119
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Set variables
Definition: set.hh:129
unsigned int lubSize(void) const
Return the size of the least upper bound.
Definition: set.hpp:133
SetVarUnknownValues(void)
Default constructor.
void operator++(void)
Move iterator to next range (if possible)
Definition: set.hpp:146
int lubMin(void) const
Return minimum element of least upper bound.
Definition: set.hpp:88
#define forceinline
Definition: config.hpp:132
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition: set.hpp:170
int lubMin(void) const
Return minimum of the least upper bound.
Definition: set.hpp:115
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition: set.hpp:142
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition: set.hpp:131
unsigned int glbSize(void) const
Return the size of the greatest lower bound.
Definition: set.hpp:130
SetVarUnknownRanges(void)
Default constructor.
Definition: set.hpp:161
int min(void) const
Return smallest value of range.
Definition: set.hpp:178
void operator++(void)
Move iterator to next range (if possible)
Definition: set.hpp:174
Gecode toplevel namespace
void operator++(void)
Move iterator to next value (if possible)
Definition: set.hpp:221
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition: set.hpp:237
SetVarGlbRanges(void)
Default constructor.
Definition: set.hpp:107
SetVar(void)
Default constructor.
Definition: set.hpp:50
VarImp * varimp(void) const
Return variable implementation of variable.
Definition: var.hpp:108
SetVarGlbValues(void)
Default constructor.
int glbMin(void) const
Return minimum element of greatest lower bound.
Definition: set.hpp:94
int max(void) const
Return largest value of range.
Definition: set.hpp:182