[PPL-devel] [GIT] ppl/ppl(master): Do set the `solution_valid' flag on exit from update_solution().

Enea Zaffanella zaffanella at cs.unipr.it
Mon Feb 22 15:50:46 CET 2010


Module: ppl/ppl
Branch: master
Commit: af2621d1726b8eae41b4ebb46f929681bf4938a0
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=af2621d1726b8eae41b4ebb46f929681bf4938a0

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Mon Feb 22 15:48:20 2010 +0100

Do set the `solution_valid' flag on exit from update_solution().

---

 src/PIP_Tree.cc                  |    3 ++
 tests/PIP_Problem/exceptions1.cc |   71 ++++++++++++++++++++++++++++++++++++++
 tests/PIP_Problem/pipproblem2.cc |   29 +++++++++++++++
 3 files changed, 103 insertions(+), 0 deletions(-)

diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index d404db7..4c6de77 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -2649,6 +2649,9 @@ PIP_Solution_Node
     norm_coeff = row[0] / den;
     sol_i += norm_coeff;
   }
+
+  // Mark solution as valid.
+  x.solution_valid = true;
 }
 
 } // namespace Parma_Polyhedra_Library
diff --git a/tests/PIP_Problem/exceptions1.cc b/tests/PIP_Problem/exceptions1.cc
index d9c5966..16b8e3e 100644
--- a/tests/PIP_Problem/exceptions1.cc
+++ b/tests/PIP_Problem/exceptions1.cc
@@ -292,6 +292,75 @@ test13() {
   return false;
 }
 
+bool
+test14() {
+  Variable i(0);
+  Variable j(1);
+  Variable n(2);
+  Variable m(3);
+  Variables_Set params(n, m);
+
+  Constraint_System cs;
+  cs.insert(3*j >= -2*i+8);
+  cs.insert(j <= 4*i - 4);
+  cs.insert(j <= m);
+  cs.insert(i <= n);
+
+  PIP_Problem pip(cs.space_dimension(), cs.begin(), cs.end(), params);
+  (void) pip.solve();
+
+  const PIP_Decision_Node* root = pip.solution()->as_decision();
+  const PIP_Decision_Node* t_child = root->child_node(true)->as_decision();
+  const PIP_Solution_Node* t_t_child = t_child->child_node(true)->as_solution();
+
+  try {
+    // It is illegal to ask for the parametric value of a parameter.
+    (void) t_t_child->parametric_values(n);
+  }
+  catch (std::invalid_argument& e) {
+    nout << "invalid_argument: " << e.what() << endl << endl;
+    return true;
+  }
+  catch (...) {
+  }
+  return false;
+}
+
+bool
+test15() {
+  Variable i(0);
+  Variable j(1);
+  Variable n(2);
+  Variable m(3);
+  Variables_Set params(n, m);
+
+  Constraint_System cs;
+  cs.insert(3*j >= -2*i+8);
+  cs.insert(j <= 4*i - 4);
+  cs.insert(j <= m);
+  cs.insert(i <= n);
+
+  PIP_Problem pip(cs.space_dimension(), cs.begin(), cs.end(), params);
+  (void) pip.solve();
+
+  const PIP_Decision_Node* root = pip.solution()->as_decision();
+  const PIP_Decision_Node* t_child = root->child_node(true)->as_decision();
+  const PIP_Solution_Node* t_t_child = t_child->child_node(true)->as_solution();
+
+  try {
+    // It is illegal to ask for the parametric value of a variable
+    // having space dimension greater than that o fthe problem.
+    (void) t_t_child->parametric_values(Variable(4));
+  }
+  catch (std::invalid_argument& e) {
+    nout << "invalid_argument: " << e.what() << endl << endl;
+    return true;
+  }
+  catch (...) {
+  }
+  return false;
+}
+
 } // namespace
 
 BEGIN_MAIN
@@ -308,4 +377,6 @@ BEGIN_MAIN
   DO_TEST(test11);
   DO_TEST(test12);
   DO_TEST(test13);
+  DO_TEST(test14);
+  DO_TEST(test15);
 END_MAIN
diff --git a/tests/PIP_Problem/pipproblem2.cc b/tests/PIP_Problem/pipproblem2.cc
index 777c3bc..9f65993 100644
--- a/tests/PIP_Problem/pipproblem2.cc
+++ b/tests/PIP_Problem/pipproblem2.cc
@@ -298,6 +298,34 @@ test15() {
   return ok;
 }
 
+bool
+test16() {
+  // NOTE: adopting a strange dimension ordering to increase code coverage.
+  Variable i(2);
+  Variable j(3);
+  Variable n(0);
+  Variable m(1);
+  Variables_Set params(n, m);
+
+  Constraint_System cs;
+  cs.insert(3*j >= -2*i+8);
+  cs.insert(j <= 4*i - 4);
+  cs.insert(j <= m);
+  cs.insert(i <= n);
+
+  PIP_Problem pip(cs.space_dimension(), cs.begin(), cs.end(), params);
+  (void) pip.solve();
+
+  const PIP_Decision_Node* root = pip.solution()->as_decision();
+  const PIP_Decision_Node* t_child = root->child_node(true)->as_decision();
+  const PIP_Solution_Node* t_t_child = t_child->child_node(true)->as_solution();
+  const Linear_Expression& v_i = t_t_child->parametric_values(i);
+  bool ok = v_i.coefficient(n) == 0
+    && v_i.coefficient(m) == 0
+    && v_i.inhomogeneous_term() == 2;
+  return ok;
+}
+
 } // namespace
 
 BEGIN_MAIN
@@ -316,4 +344,5 @@ BEGIN_MAIN
   DO_TEST(test13);
   DO_TEST(test14);
   DO_TEST(test15);
+  DO_TEST_F8(test16);
 END_MAIN




More information about the PPL-devel mailing list