[PPL-devel] [GIT] ppl/ppl(master): In frequency(), deal properly with the case when a box is empty.

Patricia Hill p.m.hill at leeds.ac.uk
Wed Mar 24 13:15:01 CET 2010


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

Author: Patricia Hill <p.m.hill at leeds.ac.uk>
Date:   Wed Mar 24 12:12:44 2010 +0000

In frequency(), deal properly with the case when a box is empty.
Added tests for this case.
Re-enable frequency test in the Prolog interface.

---

 ...face_generator_prolog_generated_test_pl_code.m4 |    2 +-
 src/Box.templates.hh                               |    2 +-
 tests/BD_Shape/frequency1.cc                       |   20 ++++++++++++++++++++
 tests/Box/frequency1.cc                            |   20 ++++++++++++++++++++
 tests/Octagonal_Shape/frequency1.cc                |   20 ++++++++++++++++++++
 5 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/interfaces/Prolog/tests/ppl_interface_generator_prolog_generated_test_pl_code.m4 b/interfaces/Prolog/tests/ppl_interface_generator_prolog_generated_test_pl_code.m4
index 56eb533..4ed6891 100644
--- a/interfaces/Prolog/tests/ppl_interface_generator_prolog_generated_test_pl_code.m4
+++ b/interfaces/Prolog/tests/ppl_interface_generator_prolog_generated_test_pl_code.m4
@@ -905,7 +905,7 @@ ppl_ at CLASS@_ at MAXMIN@_with_point_6_test :-
   ).
 
 ')
-m4_define(`ppl_ at CLASS@_frequency_codeXXX',
+m4_define(`ppl_ at CLASS@_frequency_code',
 `
 ppl_ at CLASS@_frequency_6_test :-
   (
diff --git a/src/Box.templates.hh b/src/Box.templates.hh
index 5b08ea1..674fd44 100644
--- a/src/Box.templates.hh
+++ b/src/Box.templates.hh
@@ -1383,7 +1383,7 @@ Box<ITV>::frequency(const Linear_Expression& expr,
   }
 
   // For an empty Box, we simply return false.
-  if (marked_empty())
+  if (is_empty())
     return false;
 
   // The Box has at least 1 dimension and is not empty.
diff --git a/tests/BD_Shape/frequency1.cc b/tests/BD_Shape/frequency1.cc
index 7c420b6..f74e6fb 100644
--- a/tests/BD_Shape/frequency1.cc
+++ b/tests/BD_Shape/frequency1.cc
@@ -243,6 +243,25 @@ test09() {
   return ok;
 }
 
+// Non-relational test of an empty bd_shape in 1-dimension.
+bool
+test10() {
+  Variable A(0);
+
+  TBD_Shape bds(1);
+  bds.add_constraint(A <= 0);
+  bds.add_constraint(A >= 1);
+
+  Coefficient num;
+  Coefficient den;
+  Coefficient valn;
+  Coefficient vald;
+  bool ok = (!bds.frequency(Linear_Expression(A), num, den, valn, vald));
+  print_constraints(bds, "*** bds ***");
+
+  return ok;
+}
+
 } // namespace
 
 BEGIN_MAIN
@@ -255,4 +274,5 @@ BEGIN_MAIN
   DO_TEST(test07);
   DO_TEST(test08);
   DO_TEST(test09);
+  DO_TEST(test10);
 END_MAIN
diff --git a/tests/Box/frequency1.cc b/tests/Box/frequency1.cc
index b64be53..d6c53b1 100644
--- a/tests/Box/frequency1.cc
+++ b/tests/Box/frequency1.cc
@@ -196,6 +196,25 @@ test08() {
   return ok;
 }
 
+// Non-relational test of an empty box in 1-dimension.
+bool
+test09() {
+  Variable A(0);
+
+  TBox box(1);
+  box.add_constraint(A <= 0);
+  box.add_constraint(A >= 1);
+
+  Coefficient num;
+  Coefficient den;
+  Coefficient valn;
+  Coefficient vald;
+  bool ok = (!box.frequency(Linear_Expression(A), num, den, valn, vald));
+  print_constraints(box, "*** box ***");
+
+  return ok;
+}
+
 } // namespace
 
 BEGIN_MAIN
@@ -207,4 +226,5 @@ BEGIN_MAIN
   DO_TEST(test06);
   DO_TEST(test07);
   DO_TEST(test08);
+  DO_TEST(test09);
 END_MAIN
diff --git a/tests/Octagonal_Shape/frequency1.cc b/tests/Octagonal_Shape/frequency1.cc
index ad840a6..571dd5b 100644
--- a/tests/Octagonal_Shape/frequency1.cc
+++ b/tests/Octagonal_Shape/frequency1.cc
@@ -321,6 +321,25 @@ test13() {
   return ok;
 }
 
+// Test of an empty octagonal_shape in 1-dimension.
+bool
+test14() {
+  Variable A(0);
+
+  TOctagonal_Shape os(1);
+  os.add_constraint(A <= 0);
+  os.add_constraint(A >= 1);
+
+  Coefficient num;
+  Coefficient den;
+  Coefficient valn;
+  Coefficient vald;
+  bool ok = (!os.frequency(Linear_Expression(A), num, den, valn, vald));
+  print_constraints(os, "*** os ***");
+
+  return ok;
+}
+
 } // namespace
 
 BEGIN_MAIN
@@ -337,4 +356,5 @@ BEGIN_MAIN
   DO_TEST(test11);
   DO_TEST(test12);
   DO_TEST(test13);
+  DO_TEST(test14);
 END_MAIN




More information about the PPL-devel mailing list