Hi, It's not a truncating error, you get different solutions but very very close ones (only one float between two solutions), printing is not precise enough to distinguish them. Are you sure about your constraints ? It seems odd that you post only one constraint about your expression with NodeConfValues.
I modified a little your script, maybe it's what you expected ? Best regards, Vincent 2013/6/4 Mailing List Email <mailingli...@gmail.com> > I have a simple model which I am trying to use to find one, two or > possible three floating variables that satisfies certain solutions to a > formula. The problem I face is that Gecode keeps giving thousands of the > SAME solution, probably because of truncation errors. > I've looked in the MPG, but can't find any information regarding how to do > this, so if anyone has any suggestions or hints, I'd be grateful. > I'm using Gist to find and print the solutions. > I'm attaching the code. > > _______________________________________________ > Gecode users mailing list > users@gecode.org > https://www.gecode.org/mailman/listinfo/gecode-users > > -- Vincent Barichard Université d'Angers (LERIA) Tel: 02 41 73 52 06 Département Informatique Fax: 02 41 73 50 73 H203
// FindConfidenceFormula.cpp : Defines the entry point for the console application. // #include <gecode/gist.hh> #include <gecode/driver.hh> #include <gecode/int.hh> #include <gecode/float.hh> #include <gecode/minimodel.hh> class XFindConfidenceFormula: public Gecode::Space { private: static const int NumLevels = 2; Gecode::FloatVarArray R, r; Gecode::BoolVarArray RightSubtree; public: XFindConfidenceFormula(): R(*this, NumLevels, 0, 1), r(*this, NumLevels, 0, 1), RightSubtree(*this, NumLevels, false, true) { static const double NodeConfValues[NumLevels] = { 0, 0.44 }; for (int i = 0; i < NumLevels; i++) { Gecode::rel(*this, R[i], Gecode::FRT_EQ, Gecode::expr(*this, 1 - r[i]), RightSubtree[i]); Gecode::rel(*this, R[i], Gecode::FRT_EQ, r[i], Gecode::expr(*this, !RightSubtree[i])); } Gecode::LinFloatExpr Product = R[0]; for (int i = 1; i < NumLevels; i++) Product = Product * R[i]; for (int i = 0; i < NumLevels; i++) Gecode::rel(*this, Gecode::expr(*this, Gecode::abs((R[i] - Product)/(1 - Product) - NodeConfValues[i])), Gecode::FRT_EQ, 0); //for (int i = 1; i < NumLevels; i++) // Gecode::rel(*this, Gecode::abs(r[i - 1] - r[i]) >= 0.01); Gecode::rel(*this, r[0] == 0); //Gecode::rel(*this, r[1] == 0.8); //Gecode::rel(*this, RightSubtree[0] == false); //Gecode::rel(*this, RightSubtree[1] == false); Gecode::branch(*this, RightSubtree, Gecode::INT_VAR_NONE(), Gecode::INT_VAL_MIN()); Gecode::branch(*this, R, Gecode::FLOAT_VAR_NONE(), Gecode::FLOAT_VAL_SPLIT_MIN()); Gecode::branch(*this, r, Gecode::FLOAT_VAR_NONE(), Gecode::FLOAT_VAL_SPLIT_MIN()); } virtual Gecode::Space* copy(bool share) { return new XFindConfidenceFormula(share, *this); } XFindConfidenceFormula(bool share, XFindConfidenceFormula& that): Gecode::Space(share, that) { R.update(*this, share, that.R); r.update(*this, share, that.r); RightSubtree.update(*this, share, that.RightSubtree); } virtual void print(std::ostream& out) const { out << "Right subtree: " << RightSubtree << "\nR: " << R << "\n" << "r: " << r << "\n"; } }; int main() { typedef XFindConfidenceFormula Model_t; Model_t Model; Gecode::Gist::Options options; Gecode::Gist::Print<Model_t> printer("Print solution"); options.inspect.click(&printer); Gecode::Gist::dfs(&Model, options); return 0; }
_______________________________________________ Gecode users mailing list users@gecode.org https://www.gecode.org/mailman/listinfo/gecode-users