Commit 62079ad8 authored by Ballabriga Clément's avatar Ballabriga Clément
Browse files

Marche pour tout sauf edn (probleme avec le memcpy)

parent 08c122ff
......@@ -39,6 +39,9 @@ WLinExpr operator-(const WLinExpr &a, const WLinExpr &b);
WLinExpr operator+=(WLinExpr &a, const WLinExpr &b);
WLinExpr operator-=(WLinExpr &a, const WLinExpr &b);
class TranslationFailed : public std::exception {
};
class WVar {
public:
inline WVar() {
......@@ -248,6 +251,8 @@ class WPoly {
inline PPL::Variable translate(const guid_t g) const {
if (adapter.find(g) == adapter.end())
throw TranslationFailed();
return PPL::Variable(adapter.at(g));
}
......@@ -327,21 +332,28 @@ class WPoly {
inline const PPL::C_Polyhedron& getPoly() { return poly; }
inline bool maximize(const WLinExpr&expr, coef_t &sup_n, coef_t &sup_d, bool &maximum) const {
return poly.maximize(translate(expr), sup_n, sup_d, maximum);
try {
return poly.maximize(translate(expr), sup_n, sup_d, maximum);
} catch(TranslationFailed&) {
return false;
}
}
inline bool minimize(const WLinExpr&expr, coef_t &sup_n, coef_t &sup_d, bool &maximum) const {
return poly.minimize(translate(expr), sup_n, sup_d, maximum);
try {
return poly.minimize(translate(expr), sup_n, sup_d, maximum);
} catch(TranslationFailed&) {
return false;
}
}
inline void unconstrain(const WVar &var) {
assert(adapter.size() == poly.space_dimension());
// std::cout << adapter.size() << " == " << poly.space_dimension() << std::endl;
if (adapter.find(var.guid()) == adapter.end()) {
std::cout << "Attempted to unconstrain constraint-less variable v" << var.guid() << " (no biggie)" << std::endl;
try {
eliminate(const_cast<const WPoly*>(this)->translate(var.guid()).id());
} catch (TranslationFailed&) {
return;
}
eliminate(const_cast<const WPoly*>(this)->translate(var.guid()).id());
}
......
......@@ -2405,11 +2405,11 @@ void PPLDomain::_identifyPolyVars(const PPLDomain &d, const std::set<guid_t> &va
WPoly::ConsIterator it2(temp);
for (; it2 && !((*it2).is_equality() && (*it2).has_var(v)); it2++);
#ifdef POLY_DEBUG
cout << "Found equality: " << (*it2) << endl;
#endif
if (it2) {
#ifdef POLY_DEBUG
cout << "Found equality: " << (*it2) << endl;
#endif
WCons c = *it2;
Vector<PPL::Coefficient> vect;
vect.setLength(indep.size() + 2); /* vector format: [Indep. vars coefs, Current var (v) coef, Constant] */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment