[PPL-devel] [GIT] ppl/ppl(master): Put under git control.

Enea Zaffanella zaffanella at cs.unipr.it
Sat Feb 20 08:53:58 CET 2010


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Sat Feb 20 08:52:24 2010 +0100

Put under git control.
These test exercise the incremental PIP solver (still buggy).

---

 tests/PIP_Problem/pipproblem3.cc |  158 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 158 insertions(+), 0 deletions(-)

diff --git a/tests/PIP_Problem/pipproblem3.cc b/tests/PIP_Problem/pipproblem3.cc
new file mode 100644
index 0000000..03bf580
--- /dev/null
+++ b/tests/PIP_Problem/pipproblem3.cc
@@ -0,0 +1,158 @@
+/* Test the PIP_Problem class.
+   Copyright (C) 2001-2010 Roberto Bagnara <bagnara at cs.unipr.it>
+
+This file is part of the Parma Polyhedra Library (PPL).
+
+The PPL is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The PPL is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
+
+For the most up-to-date information see the Parma Polyhedra Library
+site: http://www.cs.unipr.it/ppl/ . */
+
+#include "ppl_test.hh"
+
+namespace {
+
+bool
+test01() {
+  Variable i(0);
+  Variable j(1);
+  Variable n(2);
+  Variable m(3);
+
+  PIP_Problem pip;
+  pip.add_space_dimensions_and_embed(2, 0);
+
+  Constraint_System cs;
+  cs.insert(3*j >= -2*i+8);
+  cs.insert(j <= 4*i - 4);
+
+  pip.add_constraints(cs);
+
+  bool ok = (pip.solve() == OPTIMIZED_PIP_PROBLEM);
+  if (!ok)
+    return ok;
+
+  {
+    const PIP_Tree solution = pip.solution();
+    ok &= solution->OK();
+    pip.print_solution(nout);
+    nout << endl;
+  }
+
+  pip.add_space_dimensions_and_embed(0, 2);
+  pip.add_constraint(j <= m);
+  pip.add_constraint(i <= n);
+
+  ok &= (pip.solve() == OPTIMIZED_PIP_PROBLEM);
+  if (ok) {
+    const PIP_Tree solution = pip.solution();
+    ok &= solution->OK();
+    pip.print_solution(nout);
+  }
+  return ok;
+}
+
+bool
+test02() {
+  // NOTE_ changing the order of insertion of variables.
+  Variable i(0);
+  Variable n(1);
+  Variable j(2);
+  Variable m(3);
+
+  PIP_Problem pip;
+  pip.add_space_dimensions_and_embed(1, 1);
+
+  Constraint_System cs;
+  pip.add_constraint(i <= n);
+
+  pip.add_constraints(cs);
+
+  bool ok = (pip.solve() == OPTIMIZED_PIP_PROBLEM);
+  if (!ok)
+    return ok;
+
+  {
+    const PIP_Tree solution = pip.solution();
+    ok &= solution->OK();
+    pip.print_solution(nout);
+    nout << endl;
+  }
+
+  pip.add_space_dimensions_and_embed(1, 1);
+  pip.add_constraint(3*j >= -2*i+8);
+  pip.add_constraint(j <= 4*i - 4);
+  pip.add_constraint(j <= m);
+
+  ok &= (pip.solve() == OPTIMIZED_PIP_PROBLEM);
+  if (ok) {
+    const PIP_Tree solution = pip.solution();
+    ok &= solution->OK();
+    pip.print_solution(nout);
+  }
+  return ok;
+}
+
+bool
+test03() {
+  Variable i(0);
+  Variable j(1);
+  Variable n(2);
+  Variable m(3);
+
+  PIP_Problem pip;
+  pip.add_space_dimensions_and_embed(2, 2);
+
+  Constraint_System cs;
+  cs.insert(3*j >= -2*i+8);
+  cs.insert(j <= 4*i - 4);
+  pip.add_constraint(j <= m);
+  pip.add_constraint(i <= n);
+
+  pip.add_constraints(cs);
+
+  bool ok = (pip.solve() == OPTIMIZED_PIP_PROBLEM);
+  if (!ok)
+    return ok;
+
+  {
+    const PIP_Tree solution = pip.solution();
+    ok &= solution->OK();
+    pip.print_solution(nout);
+    nout << endl;
+  }
+
+  Variable k(4);
+  Variable p(5);
+  pip.add_space_dimensions_and_embed(1, 1);
+  pip.add_constraint(k <= i + p);
+  pip.add_constraint(p <= n + 2);
+
+  ok &= (pip.solve() == OPTIMIZED_PIP_PROBLEM);
+  if (ok) {
+    const PIP_Tree solution = pip.solution();
+    ok &= solution->OK();
+    pip.print_solution(nout);
+  }
+  return ok;
+}
+
+} // namespace
+
+BEGIN_MAIN
+  DO_TEST_F8(test01);
+  DO_TEST_F8(test02);
+  // DO_TEST_F8(test03);
+END_MAIN




More information about the PPL-devel mailing list