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

Method solution

test/set/element.cpp:61–88  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

59 : SetTest(t,5,ds_12,false) {}
60 /// %Test whether \a x is solution
61 virtual bool solution(const SetAssignment& x) const {
62 int selected = 0;
63 for (CountableSetValues sel2(x.lub, x[3]); sel2();
64 ++sel2, selected++) {}
65 CountableSetValues x4v(x.lub, x[4]);
66 if (selected==0)
67 return !x4v();
68 CountableSetRanges* sel = new CountableSetRanges[selected];
69 CountableSetValues selector(x.lub, x[3]);
70 for (int i=selected; i--;++selector) {
71 if (selector.val()>=3 || selector.val()<0) {
72 delete[] sel;
73 return false;
74 }
75 sel[i].init(x.lub, x[selector.val()]);
76 }
77
78 bool ret;
79 {
80 Region r;
81 Iter::Ranges::NaryUnion u(r, sel, selected);
82
83 CountableSetRanges z(x.lub, x[4]);
84 ret = Iter::Ranges::equal(u, z);
85 }
86 delete[] sel;
87 return ret;
88 }
89 /// Post constraint on \a x
90 virtual void post(Space& home, SetVarArray& x, IntVarArray&) {
91 SetVarArgs xs(x.size()-2);

Callers

nothing calls this directly

Calls 3

equalFunction · 0.50
valMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected