[GIT] ppl/ppl(master): Corrected a few expected results in Powerset/maxmin1 .cc.

Module: ppl/ppl Branch: master Commit: dfff7e13e8817970647c38289b1f4e8d94999ea2 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=dfff7e13e8817...
Author: Enea Zaffanella zaffanella@cs.unipr.it Date: Sat Aug 15 08:10:19 2009 +0200
Corrected a few expected results in Powerset/maxmin1.cc. This uncovered a bug in Pointset_Powerset methods maximize() and minimize(), whereby we are returning true even for empty powersets.
---
tests/Octagonal_Shape/max_min1.cc | 1 - tests/Polyhedron/max_min1.cc | 25 ++++++++++- tests/Powerset/maxmin1.cc | 93 +++++++++++++++++++------------------ 3 files changed, 72 insertions(+), 47 deletions(-)
diff --git a/tests/Octagonal_Shape/max_min1.cc b/tests/Octagonal_Shape/max_min1.cc index c0915ac..4d87172 100644 --- a/tests/Octagonal_Shape/max_min1.cc +++ b/tests/Octagonal_Shape/max_min1.cc @@ -326,7 +326,6 @@ test09() {
bool test10() { - TOctagonal_Shape oct(0);
print_constraints(oct, "*** oct ***"); diff --git a/tests/Polyhedron/max_min1.cc b/tests/Polyhedron/max_min1.cc index c8da74b..8a73b99 100644 --- a/tests/Polyhedron/max_min1.cc +++ b/tests/Polyhedron/max_min1.cc @@ -132,7 +132,6 @@ test02() {
bool test03() { - C_Polyhedron ph(0);
print_constraints(ph, "*** ph ***"); @@ -172,10 +171,34 @@ test03() { return ok; }
+bool +test04() { + C_Polyhedron ph(2, EMPTY); + + print_constraints(ph, "*** ph ***"); + + Coefficient num = 0; + Coefficient den = 0; + bool included = false; + Generator g(point()); + Linear_Expression LE; + bool ok = !ph.maximize(LE, num, den, included, g) + && num == 0 && den == 0 && !included + && g.is_point() + && g.divisor() == 1; + ok = ok && !ph.minimize(LE, num, den, included, g) + && num == 0 && den == 0 && !included + && g.is_point() + && g.divisor() == 1; + + return ok; +} + } // namespace
BEGIN_MAIN DO_TEST(test01); DO_TEST_F8(test02); DO_TEST(test03); + DO_TEST(test04); END_MAIN diff --git a/tests/Powerset/maxmin1.cc b/tests/Powerset/maxmin1.cc index b1a351f..0973762 100644 --- a/tests/Powerset/maxmin1.cc +++ b/tests/Powerset/maxmin1.cc @@ -29,15 +29,15 @@ namespace { bool test01() { Pointset_Powerset<C_Polyhedron> ps(0, EMPTY); - Coefficient num; - Coefficient den; - bool included; + Coefficient num = 0; + Coefficient den = 0; + bool included = false; Generator g(point()); Linear_Expression LE; - bool ok = ps.maximize(LE, num, den, included) - && num == 0 && den == 1 && !included; - ok = ok && ps.maximize(LE, num, den, included, g) - && num == 0 && den == 1 && !included + bool ok = !ps.maximize(LE, num, den, included) + && num == 0 && den == 0 && !included; + ok = ok && !ps.maximize(LE, num, den, included, g) + && num == 0 && den == 0 && !included && g.is_point() && g.divisor() == 1;
@@ -69,9 +69,9 @@ test02() { Constraint_System cs; Linear_Expression LE = x;
- Coefficient max_n; - Coefficient max_d; - bool max_included; + Coefficient max_n = 0; + Coefficient max_d = 0; + bool max_included = false; Generator max_g(point()); Pointset_Powerset<NNC_Polyhedron> ps(1, EMPTY);
@@ -123,9 +123,9 @@ test03() { Constraint_System cs; Linear_Expression LE = 9*x + y;
- Coefficient num; - Coefficient den; - bool included; + Coefficient num = 0; + Coefficient den = 0; + bool included = false; Generator g(point()); Pointset_Powerset<C_Polyhedron> ps(2, EMPTY);
@@ -148,7 +148,6 @@ test03() { print_generator(g); nout << endl;
- if (!ok) return false;
@@ -180,16 +179,16 @@ test04() { Variable x(0); Linear_Expression LE = x;
- Coefficient num; - Coefficient den; - bool included; + Coefficient num = 0; + Coefficient den = 0; + bool included = false; Generator g(point()); Pointset_Powerset<C_Polyhedron> ps(1, EMPTY);
- bool ok = ps.maximize(LE, num, den, included) - && num == 0 && den == 1 && !included; - ok = ok && ps.maximize(LE, num, den, included, g) - && num == 0 && den == 1 && !included + bool ok = !ps.maximize(LE, num, den, included) + && num == 0 && den == 0 && !included; + ok = ok && !ps.maximize(LE, num, den, included, g) + && num == 0 && den == 0 && !included && g.is_point() && g.divisor() == 1;
@@ -197,7 +196,10 @@ test04() { return false;
ps.add_disjunct(C_Polyhedron(1)); - ok = !ps.maximize(LE, num, den, included, g); + ok = !ps.maximize(LE, num, den, included, g) + && num == 0 && den == 0 && !included + && g.is_point() + && g.divisor() == 1;
return ok; } @@ -206,16 +208,16 @@ test04() { bool test05() { Linear_Expression LE; - Coefficient num; - Coefficient den; - bool included; + Coefficient num = 0; + Coefficient den = 0; + bool included = false; Generator g(point()); Pointset_Powerset<C_Polyhedron> ps(0, EMPTY);
- bool ok = ps.minimize(LE, num, den, included) - && num == 0 && den == 1 && !included; - ok = ok && ps.minimize(LE, num, den, included, g) - && num == 0 && den == 1 && !included + bool ok = !ps.minimize(LE, num, den, included) + && num == 0 && den == 0 && !included; + ok = ok && !ps.minimize(LE, num, den, included, g) + && num == 0 && den == 0 && !included && g.is_point() && g.divisor() == 1;
@@ -247,9 +249,9 @@ test06() { Constraint_System cs; Linear_Expression LE = x;
- Coefficient min_n; - Coefficient min_d; - bool min_included; + Coefficient min_n = 0; + Coefficient min_d = 0; + bool min_included = false; Generator min_g(point());
Pointset_Powerset<NNC_Polyhedron> ps(1, EMPTY); @@ -302,9 +304,9 @@ test07() { Constraint_System cs; Linear_Expression LE = x + y;
- Coefficient num; - Coefficient den; - bool included; + Coefficient num = 0; + Coefficient den = 0; + bool included = false; Generator g(point()); Pointset_Powerset<C_Polyhedron> ps(2, EMPTY);
@@ -327,7 +329,6 @@ test07() { print_generator(g); nout << endl;
- if (!ok) return false;
@@ -359,25 +360,27 @@ test08() { Variable x(0); Linear_Expression LE = x;
- Coefficient num; - Coefficient den; - bool included; + Coefficient num = 0; + Coefficient den = 0; + bool included = false; Generator g(point()); Pointset_Powerset<C_Polyhedron> ps(1, EMPTY);
- bool ok = ps.minimize(LE, num, den, included) - && num == 0 && den == 1 && !included; - ok = ok && ps.minimize(LE, num, den, included, g) - && num == 0 && den == 1 && !included + bool ok = !ps.minimize(LE, num, den, included) + && num == 0 && den == 0 && !included; + ok = ok && !ps.minimize(LE, num, den, included, g) + && num == 0 && den == 0 && !included && g.is_point() && g.divisor() == 1;
- if (!ok) return false;
ps.add_disjunct(C_Polyhedron(1)); - ok = !ps.minimize(LE, num, den, included, g); + ok = !ps.minimize(LE, num, den, included, g) + && num == 0 && den == 0 && !included + && g.is_point() + && g.divisor() == 1;
return ok; }
participants (1)
-
Enea Zaffanella