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

Method solution

test/set/dom.cpp:290–349  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

288 srt(srt0) {}
289 /// %Test whether \a x is solution
290 virtual bool solution(const SetAssignment& x) const {
291 IntSet is(-3,-3);
292 for (int i=x.size(); i--; ) {
293 CountableSetRanges xr(x.lub, x[i]);
294 IntSetRanges dr(is);
295 switch (srt) {
296 case SRT_EQ:
297 if (!Iter::Ranges::equal(xr, dr))
298 return false;
299 break;
300 case SRT_LQ:
301 if (!((!xr()) || in(minSymDiff(x,i,is),dr,true)))
302 return false;
303 break;
304 case SRT_LE:
305 if (!(xr() ? in(minSymDiff(x,i,is),dr) : dr()))
306 return false;
307 break;
308 case SRT_GQ:
309 if (!((!dr()) || in(minSymDiff(x,i,is),xr,true)))
310 return false;
311 break;
312 case SRT_GR:
313 if (!(dr() ? in(minSymDiff(x,i,is),xr) : xr()))
314 return false;
315 break;
316 case SRT_NQ:
317 if (Iter::Ranges::equal(xr, dr))
318 return false;
319 break;
320 case SRT_SUB:
321 if (!(Iter::Ranges::subset(xr, dr)))
322 return false;
323 break;
324 case SRT_SUP:
325 if (!(Iter::Ranges::subset(dr, xr)))
326 return false;
327 break;
328 case SRT_DISJ:
329 {
330 Gecode::Iter::Ranges::Inter<CountableSetRanges,IntSetRanges>
331 inter(xr, dr);
332
333 if (inter())
334 return false;
335 break;
336 }
337 case SRT_CMPL:
338 {
339 Gecode::Set::RangesCompl<IntSetRanges> drc(dr);
340
341 if (!Iter::Ranges::equal(xr,drc))
342 return false;
343 break;
344 }
345 default: GECODE_NEVER;
346 }
347 }

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