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

Method solution

test/float/linear.cpp:83–104  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

81 }
82 /// %Test whether \a x is solution
83 virtual MaybeType solution(const Assignment& x) const {
84 Gecode::FloatVal e = 0.0;
85 for (int i=x.size(); i--; )
86 e += a[i]*x[i];
87 switch (cmp(e, frt, Gecode::FloatVal(c))) {
88 case MT_FALSE: {
89 Gecode::FloatVal eError = e;
90 for (int i=x.size(); i--; )
91 eError -= a[i]*x[i];
92 if (cmp(e+eError, frt, Gecode::FloatVal(c)) == MT_FALSE)
93 return MT_FALSE;
94 else
95 return MT_MAYBE;
96 }
97 case MT_TRUE:
98 return MT_TRUE;
99 case MT_MAYBE:
100 return MT_MAYBE;
101 }
102 GECODE_NEVER;
103 return MT_FALSE;
104 }
105 /// Post constraint on \a x
106 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
107 if (one(a))

Callers

nothing calls this directly

Calls 2

FloatValClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected