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

Method solution

test/set/dom.cpp:387–443  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

385 srt(srt0), is(srt == Gecode::SRT_CMPL ? d1c: d1) {}
386 /// %Test whether \a x is solution
387 virtual bool solution(const SetAssignment& x) const {
388 for (int i=x.size(); i--; ) {
389 CountableSetRanges xr(x.lub, x[i]);
390 IntSetRanges dr(is);
391 switch (srt) {
392 case SRT_EQ:
393 if (!Iter::Ranges::equal(xr, dr))
394 return false;
395 break;
396 case SRT_LQ:
397 if (!((!xr()) || in(minSymDiff(x,i,is),dr,true)))
398 return false;
399 break;
400 case SRT_LE:
401 if (!(xr() ? in(minSymDiff(x,i,is),dr) : dr()))
402 return false;
403 break;
404 case SRT_GQ:
405 if (!((!dr()) || in(minSymDiff(x,i,is),xr,true)))
406 return false;
407 break;
408 case SRT_GR:
409 if (!(dr() ? in(minSymDiff(x,i,is),xr) : xr()))
410 return false;
411 break;
412 case SRT_NQ:
413 if (Iter::Ranges::equal(xr, dr))
414 return false;
415 break;
416 case SRT_SUB:
417 if (!Iter::Ranges::subset(xr, dr))
418 return false;
419 break;
420 case SRT_SUP:
421 if (!Iter::Ranges::subset(dr, xr))
422 return false;
423 break;
424 case SRT_DISJ:
425 {
426 Gecode::Iter::Ranges::Inter<CountableSetRanges,IntSetRanges>
427 inter(xr, dr);
428 if (inter())
429 return false;
430 }
431 break;
432 case SRT_CMPL:
433 {
434 Gecode::Set::RangesCompl<IntSetRanges> drc(dr);
435 if (!Iter::Ranges::equal(xr,drc))
436 return false;
437 }
438 break;
439 default: GECODE_NEVER;
440 }
441 }
442 return true;
443 }
444 /// Post constraint on \a x

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