Generated on Sat Apr 10 2021 00:00:00 for Gecode by doxygen 1.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  *
6  * Contributing authors:
7  * Christian Schulte <schulte@gecode.org>
8  * Gabor Szokoli <szokoli@gecode.org>
9  *
10  * Copyright:
11  * Guido Tack, 2004
12  * Christian Schulte, 2004
13  * Gabor Szokoli, 2004
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 namespace Gecode { namespace Set {
41 
42  /*
43  * Constructors and access
44  *
45  */
46 
51  : VarImpView<SetVar>(y.varimp()) {}
54  : VarImpView<SetVar>(y) {}
55 
56  /*
57  * Variable information
58  *
59  */
60 
61  forceinline unsigned int
62  SetView::glbSize(void) const {
63  return x->glbSize();
64  }
65  forceinline unsigned int
66  SetView::lubSize(void) const {
67  return x->lubSize();
68  }
69  forceinline unsigned int
70  SetView::unknownSize(void) const {
71  return x->lubSize() - x->glbSize();
72  }
73  forceinline bool
74  SetView::contains(int i) const {
75  return x->knownIn(i);
76  }
77  forceinline bool
78  SetView::notContains(int i) const {
79  return x->knownOut(i);
80  }
81  forceinline unsigned int
82  SetView::cardMin(void) const {
83  return x->cardMin();
84  }
85  forceinline unsigned int
86  SetView::cardMax(void) const {
87  return x->cardMax();
88  }
89  forceinline int
90  SetView::lubMin(void) const {
91  return x->lubMin();
92  }
93  forceinline int
94  SetView::lubMax(void) const {
95  return x->lubMax();
96  }
97  forceinline int
98  SetView::lubMinN(unsigned int n) const {
99  return x->lubMinN(n);
100  }
101  forceinline int
102  SetView::glbMin(void) const {
103  return x->glbMin();
104  }
105  forceinline int
106  SetView::glbMax(void) const {
107  return x->glbMax();
108  }
109 
110  /*
111  * Tells
112  *
113  */
114 
116  SetView::cardMin(Space& home, unsigned int m) {
117  return x->cardMin(home, m);
118  }
119 
121  SetView::cardMax(Space& home, unsigned int m) {
122  return x->cardMax(home, m);
123  }
124 
126  SetView::include(Space& home, int from, int to) {
127  return x->include(home,from,to);
128  }
129 
131  SetView::include(Space& home, int n) {
132  return x->include(home,n);
133  }
134 
136  SetView::exclude(Space& home, int n) {
137  return x->exclude(home, n);
138  }
139 
141  SetView::intersect(Space& home, int from, int to) {
142  return x->intersect(home,from,to);
143  }
144 
146  SetView::intersect(Space& home, int n) {
147  return x->intersect(home,n);
148  }
149 
150  template<class I> ModEvent
151  SetView::includeI(Space& home, I& iter) {
152  return x->includeI(home, iter);
153  }
154 
156  SetView::exclude(Space& home, int from, int to) {
157  return x->exclude(home,from,to);
158  }
159  template<class I> ModEvent
160  SetView::excludeI(Space& home, I& iter) {
161  return x->excludeI(home, iter);
162  }
163  template<class I> ModEvent
164  SetView::intersectI(Space& home, I& iter) {
165  return x->intersectI(home, iter);
166  }
167 
168 
169  /*
170  * Delta information for advisors
171  *
172  */
173 
176  return SetVarImp::modevent(d);
177  }
178 
179  forceinline int
180  SetView::glbMin(const Delta& d) const {
181  return SetVarImp::glbMin(d);
182  }
183  forceinline int
184  SetView::glbMax(const Delta& d) const {
185  return SetVarImp::glbMax(d);
186  }
187  forceinline bool
188  SetView::glbAny(const Delta& d) const {
189  return SetVarImp::glbAny(d);
190  }
191 
192  forceinline int
193  SetView::lubMin(const Delta& d) const {
194  return SetVarImp::lubMin(d);
195  }
196  forceinline int
197  SetView::lubMax(const Delta& d) const {
198  return SetVarImp::lubMax(d);
199  }
200  forceinline bool
201  SetView::lubAny(const Delta& d) const {
202  return SetVarImp::lubAny(d);
203  }
204 
205 
210  template<>
211  class LubRanges<SetView> : public LubRanges<SetVarImp*> {
212  public:
214 
215  LubRanges(void);
218  LubRanges(const SetView& x);
220  void init(const SetView& x);
222  };
223 
226 
229  : LubRanges<SetVarImp*>(x.varimp()) {}
230 
231  forceinline void
233  LubRanges<SetVarImp*>::init(x.varimp());
234  }
235 
236 
241  template<>
242  class GlbRanges<SetView> : public GlbRanges<SetVarImp*> {
243  public:
245 
246  GlbRanges(void);
249  GlbRanges(const SetView& x);
251  void init(const SetView& x);
252  };
253 
256 
259  : GlbRanges<SetVarImp*>(x.varimp()) {}
260 
261  forceinline void
263  GlbRanges<SetVarImp*>::init(x.varimp());
264  }
265 
266 }}
267 
268 // STATISTICS: set-var
269 
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:249
Generic domain change information to be supplied to advisors.
Definition: core.hpp:204
Set variables
Definition: set.hh:127
Range iterator for the greatest lower bound.
Definition: var-imp.hpp:359
void init(const T &x)
Initialize with greatest lower bound ranges for set variable x.
GlbRanges(void)
Default constructor.
Range iterator for the least upper bound.
Definition: var-imp.hpp:317
LubRanges(void)
Default constructor.
void init(const T &x)
Initialize with least upper bound ranges for set variable x.
Finite integer set variable implementation.
Definition: var-imp.hpp:430
int glbMin(void) const
Return minimum of the greatest lower bound.
Definition: set.hpp:120
static bool lubAny(const Delta &d)
Test whether arbitrary values got pruned from lub.
Definition: set.hpp:156
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
static bool glbAny(const Delta &d)
Test whether arbitrary values got pruned from glb.
Definition: set.hpp:144
Set view for set variables
Definition: view.hpp:56
bool contains(int i) const
Test whether i is in the greatest lower bound.
Definition: set.hpp:74
bool lubAny(const Delta &d) const
Test whether arbitrary values got pruned from lub.
Definition: set.hpp:201
bool glbAny(const Delta &d) const
Test whether arbitrary values got pruned from glb.
Definition: set.hpp:188
unsigned int unknownSize(void) const
Return the number of unknown elements.
Definition: set.hpp:70
SetView(void)
Default constructor.
Definition: set.hpp:48
ModEvent intersectI(Space &home, I &iter)
Intersect least upper bound with range sequence described by i.
Definition: set.hpp:164
ModEvent include(Space &home, int i, int j)
Update greatest lower bound to include all elements between and including i and j.
Definition: set.hpp:126
int glbMax(void) const
Return maximum of the greatest lower bound.
Definition: set.hpp:106
unsigned int lubSize(void) const
Return the number of elements in the least upper bound.
Definition: set.hpp:66
int lubMax(void) const
Return maximum of the least upper bound.
Definition: set.hpp:94
int lubMin(void) const
Return minimum of the least upper bound.
Definition: set.hpp:90
int lubMinN(unsigned int n) const
Return n-th smallest element of the least upper bound.
Definition: set.hpp:98
int glbMin(void) const
Return minimum of the greatest lower bound.
Definition: set.hpp:102
static ModEvent modevent(const Delta &d)
Return modification event.
Definition: set.hpp:175
unsigned int cardMin(void) const
Return minimum cardinality.
Definition: set.hpp:82
unsigned int cardMax(void) const
Return maximum cardinality.
Definition: set.hpp:86
unsigned int glbSize(void) const
Return the number of elements in the greatest lower bound.
Definition: set.hpp:62
bool notContains(int i) const
Test whether i is not in the least upper bound.
Definition: set.hpp:78
ModEvent intersect(Space &home, int i, int j)
Update least upper bound to contain at most all elements between and including i and j.
Definition: set.hpp:141
ModEvent excludeI(Space &home, I &i)
Remove range sequence described by i from least upper bound.
Definition: set.hpp:160
ModEvent exclude(Space &home, int i, int j)
Restrict least upper bound to not contain all elements between and including i and j.
Definition: set.hpp:156
ModEvent includeI(Space &home, I &i)
Include range sequence described by i in greatest lower bound.
Definition: set.hpp:151
Computation spaces.
Definition: core.hpp:1742
Base-class for variable implementation views.
Definition: view.hpp:133
VarImpType * x
Pointer to variable implementation.
Definition: view.hpp:141
static ModEvent modevent(const Delta &d)
Return modification event.
Definition: core.hpp:4190
int ModEvent
Type for modification events.
Definition: core.hpp:62
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::IntSet d(v, 7)
#define forceinline
Definition: config.hpp:192