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

Method solution

test/int/cumulatives.cpp:203–225  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

201 }
202 /// %Test whether \a x is solution
203 virtual bool solution(const Assignment& x) const {
204 std::vector<Event> e;
205 for (int i = 0; i < ntasks; ++i) {
206 int p = i*4;
207 // Positive start, duration and end
208 if (x[p+0] < 0 || x[p+1] < 1 || x[p+2] < 1) return false;
209 // Start + Duration == End
210 if (x[p+0] + x[p+1] != x[p+2]) {
211 return false;
212 }
213 }
214 for (int i = 0; i < ntasks; ++i) {
215 int p = i*4;
216 // Up at start, down at end.
217 e.push_back(Event(x[p+0], +x[p+3], true));
218 e.push_back(Event(x[p+2], -x[p+3], false));
219 }
220 if (at_most) {
221 return valid(e, Below(limit));
222 } else {
223 return valid(e, Above(limit));
224 }
225 }
226 /// Post constraint on \a x
227 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
228 using namespace Gecode;

Callers

nothing calls this directly

Calls 4

validFunction · 0.85
BelowClass · 0.85
AboveClass · 0.85
EventClass · 0.70

Tested by

no test coverage detected