MCPcopy Create free account
hub / github.com/Gecode/gecode / solution

Method solution

test/set/element.cpp:155–181  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

153 : SetTest(t,5,ds_12,false) {}
154 /// %Test whether \a x is solution
155 virtual bool solution(const SetAssignment& x) const {
156 int selected = 0;
157 for (CountableSetValues sel2(x.lub, x[3]); sel2();
158 ++sel2, selected++) {}
159 CountableSetRanges x4r(x.lub, x[4]);
160 if (selected==0)
161 return Iter::Ranges::size(x4r)==Gecode::Set::Limits::card;
162 CountableSetRanges* sel = new CountableSetRanges[selected];
163 CountableSetValues selector(x.lub, x[3]);
164 for (int i=selected; i--;++selector) {
165 if (selector.val()>=3 || selector.val()<0) {
166 delete[] sel;
167 return false;
168 }
169 sel[i].init(x.lub, x[selector.val()]);
170 }
171 bool ret;
172 {
173 Region r;
174 Iter::Ranges::NaryInter u(r, sel, selected);
175
176 CountableSetRanges z(x.lub, x[4]);
177 ret = Iter::Ranges::equal(u, z);
178 }
179 delete [] sel;
180 return ret;
181 }
182 /// Post constraint on \a x
183 virtual void post(Space& home, SetVarArray& x, IntVarArray&) {
184 SetVarArgs xs(x.size()-2);

Callers

nothing calls this directly

Calls 4

sizeFunction · 0.50
equalFunction · 0.50
valMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected