Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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 * 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
38namespace Gecode {
39
40 /*
41 * Constructors and access
42 *
43 */
44
47
50 : VarImpVar<Set::SetVarImp>(y.varimp()) {}
51
54 : VarImpVar<Set::SetVarImp>(y.varimp()) {}
55
56
57 /*
58 * Variable information
59 *
60 */
61
62 forceinline unsigned int
63 SetVar::glbSize(void) const { return x->glbSize(); }
64
65 forceinline unsigned int
66 SetVar::lubSize(void) const { return x->lubSize(); }
67
68 forceinline unsigned int
69 SetVar::unknownSize(void) const { return x->lubSize()-x->glbSize(); }
70
71 forceinline bool
72 SetVar::contains(int i) const { return x->knownIn(i); }
73
74 forceinline bool
75 SetVar::notContains(int i) const { return x->knownOut(i); }
76
77 forceinline unsigned int
78 SetVar::cardMin(void) const { return x->cardMin(); }
79
80 forceinline unsigned int
81 SetVar::cardMax(void) const { return x->cardMax(); }
82
83 forceinline int
84 SetVar::lubMin(void) const { return x->lubMin(); }
85
86 forceinline int
87 SetVar::lubMax(void) const { return x->lubMax(); }
88
89 forceinline int
90 SetVar::glbMin(void) const { return x->glbMin(); }
91
92 forceinline int
93 SetVar::glbMax(void) const { return x->glbMax(); }
94
95
96
97 /*
98 * Range and value iterators for set variables
99 *
100 */
101
104
107 : iter(s.varimp()) {}
108
110 bool
111 SetVarGlbRanges::operator ()(void) const { return iter(); }
112
114 void
116
118 int
119 SetVarGlbRanges::min(void) const { return iter.min(); }
120
122 int
123 SetVarGlbRanges::max(void) const { return iter.max(); }
124
126 unsigned int
127 SetVarGlbRanges::width(void) const { return iter.width(); }
128
131
134 : iter(s.varimp()) {}
135
137 bool
138 SetVarLubRanges::operator ()(void) const { return iter(); }
139
141 void
143
145 int
146 SetVarLubRanges::min(void) const { return iter.min(); }
147
149 int
150 SetVarLubRanges::max(void) const { return iter.max(); }
151
153 unsigned int
154 SetVarLubRanges::width(void) const { return iter.width(); }
155
158
161 iter.init(s.varimp());
162 }
163
165 bool
166 SetVarUnknownRanges::operator ()(void) const { return iter(); }
167
169 void
171
173 int
174 SetVarUnknownRanges::min(void) const { return iter.min(); }
175
177 int
178 SetVarUnknownRanges::max(void) const { return iter.max(); }
179
181 unsigned int
182 SetVarUnknownRanges::width(void) const { return iter.width(); }
183
186 SetVarGlbRanges ivr(x);
187 iter.init(ivr);
188 }
189
190 forceinline bool
192 return iter();
193 }
194
195 forceinline void
197 ++iter;
198 }
199
200 forceinline int
202 return iter.val();
203 }
204
207 SetVarLubRanges ivr(x);
208 iter.init(ivr);
209 }
210
211 forceinline bool
213 return iter();
214 }
215
216 forceinline void
218 ++iter;
219 }
220
221 forceinline int
223 return iter.val();
224 }
225
229 iter.init(ivr);
230 }
231
232 forceinline bool
234 return iter();
235 }
236
237 forceinline void
239 ++iter;
240 }
241
242 forceinline int
244 return iter.val();
245 }
246
247}
248
249// STATISTICS: set-var
250
Iterator for the greatest lower bound ranges of a set variable.
Definition set.hh:270
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition set.hpp:111
int max(void) const
Return largest value of range.
Definition set.hpp:123
void operator++(void)
Move iterator to next range (if possible)
Definition set.hpp:115
int min(void) const
Return smallest value of range.
Definition set.hpp:119
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition set.hpp:127
SetVarGlbRanges(void)
Default constructor.
Definition set.hpp:103
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition set.hpp:191
int val(void) const
Return current value.
Definition set.hpp:201
void operator++(void)
Move iterator to next value (if possible)
Definition set.hpp:196
SetVarGlbValues(void)
Default constructor.
Iterator for the least upper bound ranges of a set variable.
Definition set.hh:302
void operator++(void)
Move iterator to next range (if possible)
Definition set.hpp:142
SetVarLubRanges(void)
Default constructor.
Definition set.hpp:130
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition set.hpp:154
int max(void) const
Return largest value of range.
Definition set.hpp:150
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition set.hpp:138
int min(void) const
Return smallest value of range.
Definition set.hpp:146
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition set.hpp:212
int val(void) const
Return current value.
Definition set.hpp:222
SetVarLubValues(void)
Default constructor.
void operator++(void)
Move iterator to next value (if possible)
Definition set.hpp:217
Iterator for the unknown ranges of a set variable.
Definition set.hh:334
int max(void) const
Return largest value of range.
Definition set.hpp:178
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition set.hpp:166
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition set.hpp:182
void operator++(void)
Move iterator to next range (if possible)
Definition set.hpp:170
int min(void) const
Return smallest value of range.
Definition set.hpp:174
SetVarUnknownRanges(void)
Default constructor.
Definition set.hpp:157
int val(void) const
Return current value.
Definition set.hpp:243
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition set.hpp:233
SetVarUnknownValues(void)
Default constructor.
void operator++(void)
Move iterator to next value (if possible)
Definition set.hpp:238
Set variables
Definition set.hh:127
unsigned int cardMax(void) const
Return cardinality maximum.
Definition set.hpp:81
SetVar(void)
Default constructor.
Definition set.hpp:46
bool notContains(int i) const
Test whether i is not in the least upper bound.
Definition set.hpp:75
int lubMin(void) const
Return minimum element of least upper bound.
Definition set.hpp:84
unsigned int lubSize(void) const
Return number of elements in the least upper bound.
Definition set.hpp:66
int lubMax(void) const
Return maximum element of least upper bound.
Definition set.hpp:87
unsigned int glbSize(void) const
Return number of elements in the greatest lower bound.
Definition set.hpp:63
int glbMin(void) const
Return minimum element of greatest lower bound.
Definition set.hpp:90
unsigned int unknownSize(void) const
Return number of unknown elements (elements in lub but not in glb)
Definition set.hpp:69
int glbMax(void) const
Return maximum of greatest lower bound.
Definition set.hpp:93
bool contains(int i) const
Test whether i is in greatest lower bound.
Definition set.hpp:72
unsigned int cardMin(void) const
Return cardinality minimum.
Definition set.hpp:78
Finite integer set variable implementation.
Definition var-imp.hpp:430
bool knownIn(int n) const
Test whether n is contained in greatest lower bound.
Definition set.hpp:105
int glbMin(void) const
Return minimum of the greatest lower bound.
Definition set.hpp:120
unsigned int cardMax(void) const
Return current cardinality maximum.
Definition set.hpp:102
unsigned int lubSize(void) const
Return the size of the least upper bound.
Definition set.hpp:129
int lubMin(void) const
Return minimum of the least upper bound.
Definition set.hpp:111
int lubMax(void) const
Return maximum of the least upper bound.
Definition set.hpp:114
int glbMax(void) const
Return maximum of the greatest lower bound.
Definition set.hpp:123
bool knownOut(int) const
Test whether n is not contained in least upper bound.
Definition set.hpp:108
unsigned int glbSize(void) const
Return the size of the greatest lower bound.
Definition set.hpp:126
unsigned int cardMin(void) const
Return current cardinality minimum.
Definition set.hpp:99
Set view for set variables
Definition view.hpp:56
Variables as interfaces to variable implementations.
Definition var.hpp:47
VarImp * varimp(void) const
Return variable implementation of variable.
Definition var.hpp:96
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:767
Post propagator for SetVar x
Definition set.hh:767
#define forceinline
Definition config.hpp:187