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  *
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  * Last modified:
16  * $Date: 2010-08-31 17:19:33 +0200 (Tue, 31 Aug 2010) $ by $Author: schulte $
17  * $Revision: 11368 $
18  *
19  * This file is part of Gecode, the generic constraint
20  * development environment:
21  * http://www.gecode.org
22  *
23  * Permission is hereby granted, free of charge, to any person obtaining
24  * a copy of this software and associated documentation files (the
25  * "Software"), to deal in the Software without restriction, including
26  * without limitation the rights to use, copy, modify, merge, publish,
27  * distribute, sublicense, and/or sell copies of the Software, and to
28  * permit persons to whom the Software is furnished to do so, subject to
29  * the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be
32  * included in all copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
38  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
39  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41  *
42  */
43 
44 namespace Gecode { namespace Set {
45 
46  /*
47  * Constructors and access
48  *
49  */
50 
55  : VarImpView<SetVar>(y.varimp()) {}
58  : VarImpView<SetVar>(y) {}
59 
60  /*
61  * Variable information
62  *
63  */
64 
65  forceinline unsigned int
66  SetView::glbSize(void) const {
67  return x->glbSize();
68  }
69  forceinline unsigned int
70  SetView::lubSize(void) const {
71  return x->lubSize();
72  }
73  forceinline unsigned int
74  SetView::unknownSize(void) const {
75  return x->lubSize() - x->glbSize();
76  }
77  forceinline bool
78  SetView::contains(int i) const {
79  return x->knownIn(i);
80  }
81  forceinline bool
82  SetView::notContains(int i) const {
83  return x->knownOut(i);
84  }
85  forceinline unsigned int
86  SetView::cardMin(void) const {
87  return x->cardMin();
88  }
89  forceinline unsigned int
90  SetView::cardMax(void) const {
91  return x->cardMax();
92  }
93  forceinline int
94  SetView::lubMin(void) const {
95  return x->lubMin();
96  }
97  forceinline int
98  SetView::lubMax(void) const {
99  return x->lubMax();
100  }
101  forceinline int
102  SetView::lubMinN(unsigned int n) const {
103  return x->lubMinN(n);
104  }
105  forceinline int
106  SetView::glbMin(void) const {
107  return x->glbMin();
108  }
109  forceinline int
110  SetView::glbMax(void) const {
111  return x->glbMax();
112  }
113 
114  /*
115  * Tells
116  *
117  */
118 
120  SetView::cardMin(Space& home, unsigned int m) {
121  return x->cardMin(home, m);
122  }
123 
125  SetView::cardMax(Space& home, unsigned int m) {
126  return x->cardMax(home, m);
127  }
128 
130  SetView::include (Space& home, int from, int to) {
131  return x->include(home,from,to);
132  }
133 
135  SetView::include (Space& home, int n) {
136  return x->include(home,n);
137  }
138 
140  SetView::exclude (Space& home, int n) {
141  return x->exclude(home, n);
142  }
143 
145  SetView::intersect (Space& home, int from, int to) {
146  return x->intersect(home,from,to);
147  }
148 
150  SetView::intersect (Space& home, int n) {
151  return x->intersect(home,n);
152  }
153 
154  template<class I> ModEvent
155  SetView::includeI (Space& home, I& iter) {
156  return x->includeI(home, iter);
157  }
158 
160  SetView::exclude (Space& home, int from, int to) {
161  return x->exclude(home,from,to);
162  }
163  template<class I> ModEvent
164  SetView::excludeI(Space& home, I& iter) {
165  return x->excludeI(home, iter);
166  }
167  template<class I> ModEvent
168  SetView::intersectI(Space& home, I& iter) {
169  return x->intersectI(home, iter);
170  }
171 
172 
173  /*
174  * Delta information for advisors
175  *
176  */
177 
180 
181  forceinline int
182  SetView::glbMin(const Delta& d) const { return SetVarImp::glbMin(d); }
183 
184  forceinline int
185  SetView::glbMax(const Delta& d) const { return SetVarImp::glbMax(d); }
186 
187  forceinline bool
188  SetView::glbAny(const Delta& d) const { return SetVarImp::glbAny(d); }
189 
190  forceinline int
191  SetView::lubMin(const Delta& d) const { return SetVarImp::lubMin(d); }
192 
193  forceinline int
194  SetView::lubMax(const Delta& d) const { return SetVarImp::lubMax(d); }
195 
196  forceinline bool
197  SetView::lubAny(const Delta& d) const { return SetVarImp::lubAny(d); }
198 
199 
204  template<>
205  class LubRanges<SetView> : public LubRanges<SetVarImp*> {
206  public:
208 
209  LubRanges(void);
212  LubRanges(const SetView& x);
214  void init(const SetView& x);
216  };
217 
220 
223  : LubRanges<SetVarImp*>(x.varimp()) {}
224 
225  forceinline void
228  }
229 
230 
235  template<>
236  class GlbRanges<SetView> : public GlbRanges<SetVarImp*> {
237  public:
239 
240  GlbRanges(void);
243  GlbRanges(const SetView& x);
245  void init(const SetView& x);
246  };
247 
250 
253  : GlbRanges<SetVarImp*>(x.varimp()) {}
254 
255  forceinline void
258  }
259 
260 }}
261 
262 // STATISTICS: set-var
263 
static bool lubAny(const Delta &d)
Test whether arbitrary values got pruned from lub.
Definition: set.hpp:160
unsigned int cardMin(void) const
Return minimum cardinality.
Definition: set.hpp:86
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:130
ModEvent exclude(Space &home, int n)
Exclude n from the least upper bound.
Definition: set.hpp:365
VarImpType * varimp(void) const
Return variable implementation of view.
Definition: view.hpp:433
unsigned int glbSize(void) const
Return the number of elements in the greatest lower bound.
Definition: set.hpp:66
int glbMin(void) const
Return minimum of the greatest lower bound.
Definition: set.hpp:124
unsigned int unknownSize(void) const
Return the number of unknown elements.
Definition: set.hpp:74
int glbMin(void) const
Return minimum of the greatest lower bound.
Definition: set.hpp:106
int lubMinN(unsigned int n) const
Return n -th smallest element in the least upper bound.
Definition: set.hpp:121
ModEvent excludeI(Space &home, I &i)
Exclude set described by i from the least upper bound.
Definition: set.hpp:371
int ModEvent
Type for modification events.
Definition: core.hpp:146
unsigned int cardMax(void) const
Return maximum cardinality.
Definition: set.hpp:90
static ModEvent modevent(const Delta &d)
Return modification event.
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:145
Range iterator for the greatest lower bound.
Definition: var-imp.hpp:363
Finite integer set variable implementation.
Definition: var-imp.hpp:434
ModEvent excludeI(Space &home, I &i)
Remove range sequence described by i from least upper bound.
Definition: set.hpp:164
ModEvent intersect(Space &home, int n)
Exclude everything but n from the least upper bound.
Definition: set.hpp:210
Computation spaces.
Definition: core.hpp:1362
static ModEvent modevent(const Delta &d)
Return modification event.
Definition: set.hpp:179
Range iterator for the least upper bound.
Definition: var-imp.hpp:321
int glbMax(void) const
Return maximum of the greatest lower bound.
Definition: set.hpp:127
Gecode::IntSet d(v, 7)
int lubMax(void) const
Return maximum of the least upper bound.
Definition: set.hpp:118
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
unsigned int cardMax(void) const
Return current cardinality maximum.
Definition: set.hpp:106
static bool glbAny(const Delta &d)
Test whether arbitrary values got pruned from glb.
Definition: set.hpp:148
unsigned int cardMin(void) const
Return current cardinality minimum.
Definition: set.hpp:103
int lubMin(void) const
Return minimum of the least upper bound.
Definition: set.hpp:94
ModEvent includeI(Space &home, I &i)
Include set described by i in the greatest lower bound.
Definition: set.hpp:296
int glbMax(void) const
Return maximum of the greatest lower bound.
Definition: set.hpp:110
SetView(void)
Default constructor.
Definition: set.hpp:52
int lubMinN(unsigned int n) const
Return n-th smallest element of the least upper bound.
Definition: set.hpp:102
Base-class for variable implementation views.
Definition: view.hpp:117
bool contains(int i) const
Test whether i is in the greatest lower bound.
Definition: set.hpp:78
bool knownOut(int) const
Test whether n is not contained in least upper bound.
Definition: set.hpp:112
ModEvent includeI(Space &home, I &i)
Include range sequence described by i in greatest lower bound.
Definition: set.hpp:155
bool notContains(int i) const
Test whether i is not in the least upper bound.
Definition: set.hpp:82
ModEvent include(Space &home, int n)
Include n in the greatest lower bound.
Definition: set.hpp:291
int lubMax(void) const
Return maximum of the least upper bound.
Definition: set.hpp:98
bool knownIn(int n) const
Test whether n is contained in greatest lower bound.
Definition: set.hpp:109
ModEvent intersectI(Space &home, I &iter)
Intersect least upper bound with range sequence described by i.
Definition: set.hpp:168
Set view for set variables
Definition: view.hpp:60
ModEvent intersectI(Space &home, I &i)
Exclude everything but set described by i from the least upper bound.
Definition: set.hpp:216
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
Set variables
Definition: set.hh:129
unsigned int lubSize(void) const
Return the size of the least upper bound.
Definition: set.hpp:133
GlbRanges(void)
Default constructor.
#define forceinline
Definition: config.hpp:132
void init(const T &x)
Initialize with least upper bound ranges for set variable x.
int lubMin(void) const
Return minimum of the least upper bound.
Definition: set.hpp:115
unsigned int glbSize(void) const
Return the size of the greatest lower bound.
Definition: set.hpp:130
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:160
Gecode toplevel namespace
bool glbAny(const Delta &d) const
Test whether arbitrary values got pruned from glb.
Definition: set.hpp:188
LubRanges(void)
Default constructor.
VarImpType * x
Pointer to variable implementation.
Definition: view.hpp:125
unsigned int lubSize(void) const
Return the number of elements in the least upper bound.
Definition: set.hpp:70
bool lubAny(const Delta &d) const
Test whether arbitrary values got pruned from lub.
Definition: set.hpp:197
void init(const T &x)
Initialize with greatest lower bound ranges for set variable x.