[GIT] ppl/ppl(pip): Implemented constraint negation, plus minor fixes.

Module: ppl/ppl Branch: pip Commit: 33905b7bf1a3383376e5186937f7505308a5c2c9 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=33905b7bf1a33...
Author: François Galea francois.galea@uvsq.fr Date: Fri Sep 11 13:08:53 2009 +0200
Implemented constraint negation, plus minor fixes.
---
src/PIP_Tree.cc | 22 ++++++++++------------ src/PIP_Tree.defs.hh | 2 +- src/PIP_Tree.inlines.hh | 5 +++++ 3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc index 041184e..2f1afe0 100644 --- a/src/PIP_Tree.cc +++ b/src/PIP_Tree.cc @@ -37,7 +37,7 @@ add_assign(Row& x, const Row& y, Coefficient_traits::const_reference c) { add_mul_assign(x[i], c, y[i]); }
-// Merge constraint systems such as x = x U z +// Merge constraint systems such as x = x U y void merge_assign(Constraint_System& x, const Constraint_System& y) { for (Constraint_System::const_iterator y_i = y.begin(), @@ -140,8 +140,12 @@ PIP_Decision_Node::solve(PIP_Tree_Node **parent_ref, // Decision nodes with false child must have exactly one constraint PPL_ASSERT(1 == std::distance(constraints_.begin(), constraints_.end())); Constraint_System context_false(context); - //FIXME: not implemented yet (constraint negation) - //context_false.insert(!constraints_[0]); + Constraint_System::const_iterator ci = constraints_.begin(); + PPL_ASSERT(ci->is_nonstrict_inequality()); + Linear_Expression expr = Linear_Expression(*ci); + expr += 1; + Constraint c(expr <= 0); + context_false.insert(c); stf = false_child->solve(&false_child, context_false); }
@@ -149,9 +153,9 @@ PIP_Decision_Node::solve(PIP_Tree_Node **parent_ref, return_status = UNFEASIBLE_PIP_PROBLEM; *parent_ref = 0; delete this; - return UNFEASIBLE_PIP_PROBLEM; - } - return OPTIMIZED_PIP_PROBLEM; + } else + return_status = OPTIMIZED_PIP_PROBLEM; + return return_status; }
void @@ -159,12 +163,6 @@ PIP_Solution_Node::Rational_Matrix::normalize() { //FIXME }
-//! Returns the allocated capacity of each Row of the Matrix. -dimension_type -PIP_Solution_Node::Rational_Matrix::capacity() { - return row_capacity; -} - void PIP_Solution_Node::Rational_Matrix::ascii_dump(std::ostream& s) const { s << "denominator " << denominator << "\n"; diff --git a/src/PIP_Tree.defs.hh b/src/PIP_Tree.defs.hh index c3c1b4b..13dc12b 100644 --- a/src/PIP_Tree.defs.hh +++ b/src/PIP_Tree.defs.hh @@ -185,7 +185,7 @@ private: void normalize();
//! Returns the allocated capacity of each Row of the Matrix. - dimension_type capacity(); + dimension_type capacity() const;
//! Tests whether the matrix is integer, \e ie. the denominator is 1. bool is_integer() const; diff --git a/src/PIP_Tree.inlines.hh b/src/PIP_Tree.inlines.hh index 87f2a22..c3b23bc 100644 --- a/src/PIP_Tree.inlines.hh +++ b/src/PIP_Tree.inlines.hh @@ -55,6 +55,11 @@ PIP_Solution_Node::Rational_Matrix::get_denominator() const { return denominator; }
+inline dimension_type +PIP_Solution_Node::Rational_Matrix::capacity() const { + return row_capacity; +} + inline PIP_Tree_Node::~PIP_Tree_Node() { }
participants (1)
-
François Galea