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

Method solution

test/set/element.cpp:110–138  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

108 : SetTest(t,2,ds_13,false), i0(-3,-3), i1(-1,1), i2(0,2) {}
109 /// %Test whether \a x is solution
110 virtual bool solution(const SetAssignment& x) const {
111 int selected = 0;
112 for (CountableSetValues sel2(x.lub, x[0]); sel2();
113 ++sel2, selected++) {}
114 CountableSetValues x4v(x.lub, x[1]);
115 if (selected==0)
116 return !x4v();
117 IntSet iss[] = {i0, i1, i2};
118 IntSetRanges* sel = new IntSetRanges[selected];
119 CountableSetValues selector(x.lub, x[0]);
120 for (int i=selected; i--;++selector) {
121 if (selector.val()>=3 || selector.val()<0) {
122 delete[] sel;
123 return false;
124 }
125 sel[i].init(iss[selector.val()]);
126 }
127
128 bool ret;
129 {
130 Region r;
131 Iter::Ranges::NaryUnion u(r, sel, selected);
132
133 CountableSetRanges z(x.lub, x[1]);
134 ret = Iter::Ranges::equal(u, z);
135 }
136 delete[] sel;
137 return ret;
138 }
139 /// Post constraint on \a x
140 virtual void post(Space& home, SetVarArray& x, IntVarArray&) {
141 IntSetArgs xs(3);

Callers

nothing calls this directly

Calls 3

equalFunction · 0.50
valMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected