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

Method solution

test/set/dom.cpp:196–253  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

194 srt(srt0) {}
195 /// %Test whether \a x is solution
196 virtual bool solution(const SetAssignment& x) const {
197 for (int i=x.size(); i--; ) {
198 CountableSetRanges xr(x.lub, x[i]);
199 IntSet is(-3,-1);
200 IntSetRanges dr(is);
201 switch (srt) {
202 case SRT_EQ:
203 if (!Iter::Ranges::equal(xr, dr))
204 return false;
205 break;
206 case SRT_LQ:
207 if (!((!xr()) || in(minSymDiff(x,i,is),dr,true)))
208 return false;
209 break;
210 case SRT_LE:
211 if (!(xr() ? in(minSymDiff(x,i,is),dr) : dr()))
212 return false;
213 break;
214 case SRT_GQ:
215 if (!((!dr()) || in(minSymDiff(x,i,is),xr,true)))
216 return false;
217 break;
218 case SRT_GR:
219 if (!(dr() ? in(minSymDiff(x,i,is),xr) : xr()))
220 return false;
221 break;
222 case SRT_NQ:
223 if (!(!Iter::Ranges::equal(xr, dr)))
224 return false;
225 break;
226 case SRT_SUB:
227 if (!(Iter::Ranges::subset(xr, dr)))
228 return false;
229 break;
230 case SRT_SUP:
231 if (!(Iter::Ranges::subset(dr, xr)))
232 return false;
233 break;
234 case SRT_DISJ:
235 {
236 Gecode::Iter::Ranges::Inter<CountableSetRanges,IntSetRanges>
237 inter(xr, dr);
238 if (inter())
239 return false;
240 }
241 break;
242 case SRT_CMPL:
243 {
244 Gecode::Set::RangesCompl<IntSetRanges> drc(dr);
245 if (!Iter::Ranges::equal(xr,drc))
246 return false;
247 }
248 break;
249 default: GECODE_NEVER;
250 }
251 }
252 return true;
253 }

Callers

nothing calls this directly

Calls 6

minSymDiffFunction · 0.85
interFunction · 0.85
inFunction · 0.70
equalFunction · 0.50
subsetFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected