3
* Guido Tack <tack@gecode.org>
4
* Christian Schulte <schulte@gecode.org>
8
* Christian Schulte, 2004
11
* $Date: 2005-10-31 11:02:00 +0100 (Mon, 31 Oct 2005) $ by $Author: schulte $
14
* This file is part of Gecode, the generic constraint
15
* development environment:
16
* http://www.gecode.org
18
* See the file "LICENSE" for information on usage and
19
* redistribution of this file, and for a
20
* DISCLAIMER OF ALL WARRANTIES.
26
namespace Gecode { namespace Set {
29
* "Standard" tell operations
33
SetVarImp::cardMin_full(Space* home,unsigned int newMin) {
34
ModEvent me = ME_SET_CARD;
35
if (_cardMin == _cardMax)
36
me = checkLubCardAssigned(home,ME_SET_CARD);
43
SetVarImp::cardMax_full(Space* home,unsigned int newMax) {
44
ModEvent me = ME_SET_CARD;
45
if (_cardMin == _cardMax)
46
me = checkGlbCardAssigned(home,ME_SET_CARD);
53
SetVarImp::processLubChange(Space* home) {
54
if (!boundsConsistent()) {
58
if (_cardMax > lub.size()) {
59
_cardMax = lub.size();
60
if (cardMin() > cardMax())
63
lub.linkTo(home, glb);
66
me = checkLubCardAssigned(home, ME_SET_CLUB);
69
me = checkLubCardAssigned(home, ME_SET_LUB);
77
SetVarImp::processGlbChange(Space* home) {
78
if (!boundsConsistent())
81
if (_cardMin < glb.size()) {
82
_cardMin = glb.size();
83
if (cardMin() > cardMax())
86
lub.linkTo(home, glb);
89
me = checkGlbCardAssigned(home, ME_SET_CGLB);
92
me = checkGlbCardAssigned(home, ME_SET_GLB);
94
if (me!=ME_SET_FAILED)
105
SetVarImp::SetVarImp(Space* home, bool share, SetVarImp& x)
106
: Variable<VTI_SET,PC_SET_ANY>(home,share,x),
107
_cardMin(x._cardMin), _cardMax(x._cardMax) {
108
lub.update(home, x.lub);
110
glb.linkTo(home,lub);
112
glb.update(home,x.glb);
118
SetVarImp::perform_copy(Space* home, bool share) {
119
return new (home) SetVarImp(home,share,*this);
124
* Finite Integer Set variable processor
129
SetVarImp::Processor::Processor(void) {
130
// Combination of modification events
131
mec(ME_SET_CARD, ME_SET_LUB, ME_SET_CLUB);
132
mec(ME_SET_CARD, ME_SET_GLB, ME_SET_CGLB);
133
mec(ME_SET_CARD, ME_SET_BB, ME_SET_CBB);
134
mec(ME_SET_CARD, ME_SET_CLUB, ME_SET_CLUB);
135
mec(ME_SET_CARD, ME_SET_CGLB, ME_SET_CGLB);
136
mec(ME_SET_CARD, ME_SET_CBB, ME_SET_CBB);
138
mec(ME_SET_LUB, ME_SET_GLB, ME_SET_BB);
139
mec(ME_SET_LUB, ME_SET_BB, ME_SET_BB);
140
mec(ME_SET_LUB, ME_SET_CLUB, ME_SET_CLUB);
141
mec(ME_SET_LUB, ME_SET_CGLB, ME_SET_CBB);
142
mec(ME_SET_LUB, ME_SET_CBB, ME_SET_CBB);
144
mec(ME_SET_GLB, ME_SET_BB, ME_SET_BB);
145
mec(ME_SET_GLB, ME_SET_CLUB, ME_SET_CBB);
146
mec(ME_SET_GLB, ME_SET_CGLB, ME_SET_CGLB);
147
mec(ME_SET_GLB, ME_SET_CBB, ME_SET_CBB);
149
mec(ME_SET_BB, ME_SET_CLUB, ME_SET_CBB);
150
mec(ME_SET_BB, ME_SET_CGLB, ME_SET_CBB);
151
mec(ME_SET_BB, ME_SET_CBB, ME_SET_CBB);
153
mec(ME_SET_CLUB, ME_SET_CGLB, ME_SET_CBB);
154
mec(ME_SET_CLUB, ME_SET_CBB, ME_SET_CBB);
156
mec(ME_SET_CGLB, ME_SET_CBB, ME_SET_CBB);
158
// Mapping between modification events and propagation conditions
159
mepc(ME_SET_CARD, PC_SET_CARD); mepc(ME_SET_CARD, PC_SET_CGLB);
160
mepc(ME_SET_CARD, PC_SET_CLUB); mepc(ME_SET_CARD, PC_SET_ANY);
162
mepc(ME_SET_LUB, PC_SET_CLUB); mepc(ME_SET_LUB, PC_SET_ANY);
164
mepc(ME_SET_GLB, PC_SET_CGLB); mepc(ME_SET_GLB, PC_SET_ANY);
166
mepc(ME_SET_BB, PC_SET_CGLB); mepc(ME_SET_BB, PC_SET_CLUB);
167
mepc(ME_SET_BB, PC_SET_ANY);
169
mepc(ME_SET_CLUB, PC_SET_CARD); mepc(ME_SET_CLUB, PC_SET_CGLB);
170
mepc(ME_SET_CLUB, PC_SET_CLUB); mepc(ME_SET_CLUB, PC_SET_ANY);
172
mepc(ME_SET_CGLB, PC_SET_CARD); mepc(ME_SET_CGLB, PC_SET_CGLB);
173
mepc(ME_SET_CGLB, PC_SET_CLUB); mepc(ME_SET_CGLB, PC_SET_ANY);
175
mepc(ME_SET_CBB, PC_SET_CARD); mepc(ME_SET_CBB, PC_SET_CGLB);
176
mepc(ME_SET_CBB, PC_SET_CLUB); mepc(ME_SET_CBB, PC_SET_ANY);
177
// Transfer to kernel
181
SetVarImp::Processor SetVarImp::svp;
185
* Subscribing to variables
190
SetVarImp::subscribe(Space* home, Propagator* p, PropCond pc) {
191
Variable<VTI_SET,PC_SET_ANY>::subscribe(home,p,pc,
192
assigned(), ME_SET_CBB);
197
// STATISTICS: set-var