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

Method solution

test/set/mm-set.cpp:133–150  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

131 bis(bis0), c(c0), srt(srt0) {}
132 /// %Test whether \a x is solution
133 virtual bool solution(const Assignment& x) const {
134 int reg[4] = {(x[0] != x[2]), x[1],
135 (x[2] > 0), x[3]};
136 bool failed;
137 int ret = eval(bis, reg, failed);
138 if (failed)
139 return false;
140 switch (srt) {
141 case Gecode::SRT_EQ: return ret == c;
142 case Gecode::SRT_NQ: return ret != c;
143 case Gecode::SRT_SUB: return ret <= c;
144 case Gecode::SRT_SUP: return ret >= c;
145 case Gecode::SRT_DISJ: return ret+c != 2;
146 case Gecode::SRT_CMPL: return ret != c;
147 default: GECODE_NEVER;
148 }
149 return false;
150 }
151 /// Post constraint on \a x
152 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
153 using namespace Gecode;

Callers

nothing calls this directly

Calls 1

evalFunction · 0.70

Tested by

no test coverage detected