[PPL-devel] [GIT] ppl/ppl(pip): Test test07() in pipproblem2. cc shows a bug in PIP_Problem.
Enea Zaffanella
zaffanella at cs.unipr.it
Tue Nov 24 13:09:45 CET 2009
Module: ppl/ppl
Branch: pip
Commit: 9cc933834e49973804e0865ff034f5663b5c2648
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=9cc933834e49973804e0865ff034f5663b5c2648
Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date: Tue Nov 24 13:06:50 2009 +0100
Test test07() in pipproblem2.cc shows a bug in PIP_Problem.
Apparently, we cannot incrementally add new constraints to a PIP_Problem
taht was already solved.
---
tests/PIP_Problem/pipproblem2.cc | 45 ++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/tests/PIP_Problem/pipproblem2.cc b/tests/PIP_Problem/pipproblem2.cc
index a6b5b8c..cbadbbb 100644
--- a/tests/PIP_Problem/pipproblem2.cc
+++ b/tests/PIP_Problem/pipproblem2.cc
@@ -109,6 +109,48 @@ test04() {
return ok;
}
+bool
+test05() {
+ Variable X(0);
+ PIP_Problem pip(1);
+ pip.add_constraint(X == -X);
+
+ bool ok = (pip.solve() == OPTIMIZED_PIP_PROBLEM);
+ // Solving again a problem already optimized.
+ ok &= (pip.solve() == OPTIMIZED_PIP_PROBLEM);
+
+ return ok;
+}
+
+bool
+test06() {
+ Variable X(0);
+ PIP_Problem pip(1);
+ pip.add_constraint(X == -X);
+ pip.add_constraint(X >= 1);
+
+ bool ok = (pip.solve() == UNFEASIBLE_PIP_PROBLEM);
+ // Solving again a problem already detected to be unfeasible.
+ ok &= (pip.solve() == UNFEASIBLE_PIP_PROBLEM);
+
+ return ok;
+}
+
+bool
+test07() {
+ Variable X(0);
+ PIP_Problem pip(1);
+ pip.add_constraint(X == -X);
+ bool ok = (pip.solve() == OPTIMIZED_PIP_PROBLEM);
+
+ // Incrementally adding a constraint.
+ pip.add_constraint(X >= 1);
+ // Solving a problem that was optimized and now is unfeasible.
+ ok &= (pip.solve() == UNFEASIBLE_PIP_PROBLEM);
+
+ return ok;
+}
+
} // namespace
BEGIN_MAIN
@@ -116,4 +158,7 @@ BEGIN_MAIN
DO_TEST(test02);
DO_TEST(test03);
DO_TEST(test04);
+ DO_TEST(test05);
+ DO_TEST(test06);
+ DO_TEST_F(test07);
END_MAIN
More information about the PPL-devel
mailing list