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

Method solution

test/set/sequence.cpp:88–112  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

86 : SetTest("Sequence::SeqU"+str(n0),n0+1,ds_33,false), n(n0) {}
87 /// %Test whether \a x is solution
88 virtual bool solution(const SetAssignment& x) const {
89 int max = Gecode::Set::Limits::min - 1;
90 for (int i=0; i<n; i++) {
91 CountableSetRanges xir(x.lub, x[i]);
92 IntSet xi(xir);
93 if (xi.ranges() > 0) {
94 int oldMax = max;
95 max = xi.max();
96 if (xi.min() <= oldMax)
97 return false;
98 }
99 }
100 CountableSetRanges* isrs = new CountableSetRanges[n];
101 for (int i=n; i--; )
102 isrs[i].init(x.lub, x[i]);
103 bool ret;
104 {
105 Region r;
106 Iter::Ranges::NaryUnion u(r, isrs, n);
107 CountableSetRanges xnr(x.lub, x[n]);
108 ret = Iter::Ranges::equal(u, xnr);
109 }
110 delete[] isrs;
111 return ret;
112 }
113 /// Post constraint on \a x
114 virtual void post(Space& home, SetVarArray& x, IntVarArray&) {
115 SetVarArgs xs(x.size()-1);

Callers

nothing calls this directly

Calls 5

equalFunction · 0.50
rangesMethod · 0.45
maxMethod · 0.45
minMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected