[PPL-devel] [GIT] ppl/ppl(pip): Implemented methods querying/ adding space dimensions and parameters.

Enea Zaffanella zaffanella at cs.unipr.it
Fri Sep 4 16:58:06 CEST 2009


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Fri Sep  4 16:56:54 2009 +0200

Implemented methods querying/adding space dimensions and parameters.

---

 src/PIP_Problem.cc         |   31 ++++++++++++++++++++++++++++++-
 src/PIP_Problem.inlines.hh |   10 ++++++++++
 2 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/src/PIP_Problem.cc b/src/PIP_Problem.cc
index dece4ef..fa290d2 100644
--- a/src/PIP_Problem.cc
+++ b/src/PIP_Problem.cc
@@ -321,4 +321,33 @@ PPL::PIP_Problem::Rational_Matrix::ascii_load(std::istream& s) {
   return Matrix::ascii_load(s);
 }
 
-
+void
+PPL::PIP_Problem
+::add_space_dimensions_and_embed(const dimension_type m_pip_vars,
+                                 const dimension_type m_pip_params) {
+  // The space dimension of the resulting PIP problem should not
+  // overflow the maximum allowed space dimension.
+  dimension_type available = max_space_dimension() - space_dimension();
+  bool should_throw = (m_pip_vars > available);
+  if (!should_throw) {
+    available -= m_pip_vars;
+    should_throw = (m_pip_params > available);
+  }
+  if (should_throw)
+    throw std::length_error("PPL::PIP_Problem::"
+			    "add_space_dimensions_and_embed(m_v, m_p):\n"
+			    "adding m_v+m_p new space dimensions exceeds "
+			    "the maximum allowed space dimension.");
+  // First add PIP variables ...
+  external_space_dim += m_pip_vars;
+  // ... then add PIP parameters.
+  if (m_pip_vars > 0) {
+    parameters.insert(Variable(external_space_dim),
+                      Variable(external_space_dim - 1 + m_pip_vars));
+    external_space_dim += m_pip_vars;
+  }
+  // Update problem status.
+  if (status != UNSATISFIABLE)
+    status = PARTIALLY_SATISFIABLE;
+  PPL_ASSERT(OK());
+}
diff --git a/src/PIP_Problem.inlines.hh b/src/PIP_Problem.inlines.hh
index c064ae9..2d9a726 100644
--- a/src/PIP_Problem.inlines.hh
+++ b/src/PIP_Problem.inlines.hh
@@ -60,6 +60,11 @@ PIP_Problem::~PIP_Problem() {
 }
 
 inline dimension_type
+PIP_Problem::space_dimension() const {
+  return external_space_dim;
+}
+
+inline dimension_type
 PIP_Problem::max_space_dimension() {
   return Constraint::max_space_dimension();
 }
@@ -74,6 +79,11 @@ PIP_Problem::constraints_end() const {
   return input_cs.end();
 }
 
+inline const Variables_Set&
+PIP_Problem::parameter_space_dimensions() const {
+  return parameters;
+}
+
 } // namespace Parma_Polyhedra_Library
 
 namespace std {




More information about the PPL-devel mailing list