[PPL-devel] [GIT] ppl/ppl(pip): New parameter choice method. Updated the C interface.
François Galea
francois.galea at uvsq.fr
Fri Oct 23 18:57:10 CEST 2009
Module: ppl/ppl
Branch: pip
Commit: 4c95e73449a6e069596deac0a5780cd6d0e4cb23
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=4c95e73449a6e069596deac0a5780cd6d0e4cb23
Author: François Galea <francois.galea at uvsq.fr>
Date: Fri Oct 23 17:00:25 2009 +0200
New parameter choice method. Updated the C interface.
---
interfaces/C/ppl_c_header.h | 4 ++--
interfaces/C/ppl_c_implementation_common.cc | 12 ++++++++++++
src/PIP_Problem.cc | 27 +++++++++++++++++++++++++++
src/PIP_Problem.defs.hh | 15 +++++++++++++--
4 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/interfaces/C/ppl_c_header.h b/interfaces/C/ppl_c_header.h
index 8d48fbe..8dc92be 100644
--- a/interfaces/C/ppl_c_header.h
+++ b/interfaces/C/ppl_c_header.h
@@ -2720,11 +2720,11 @@ PPL_PROTO((ppl_PIP_Problem_t pip,
/*! \relates ppl_PIP_Problem_tag \brief
Sets the space dimensions that are specified in first \p n positions
- of the array \p ds to be integer dimensions of problem \p pip.
+ of the array \p ds to be parameter dimensions of problem \p pip.
The presence of duplicates in \p ds is a waste but an innocuous one.
*/
int
-ppl_PIP_Problem_add_to_integer_space_dimensions
+ppl_PIP_Problem_add_to_parameter_space_dimensions
PPL_PROTO((ppl_PIP_Problem_t pip, ppl_dimension_type ds[], size_t n));
/*! \relates ppl_PIP_Problem_tag \brief
diff --git a/interfaces/C/ppl_c_implementation_common.cc b/interfaces/C/ppl_c_implementation_common.cc
index 2d5f45d..1ef11f1 100644
--- a/interfaces/C/ppl_c_implementation_common.cc
+++ b/interfaces/C/ppl_c_implementation_common.cc
@@ -2196,6 +2196,18 @@ ppl_PIP_Problem_add_space_dimensions_and_embed(ppl_PIP_Problem_t pip,
}
CATCH_ALL
int
+ppl_PIP_Problem_add_to_parameter_space_dimensions(ppl_PIP_Problem_t pip,
+ ppl_dimension_type ds[],
+ size_t n) try {
+ PIP_Problem& ppip = *to_nonconst(pip);
+ Variables_Set vars;
+ for (ppl_dimension_type i = n; i-- > 0; )
+ vars.insert(ds[i]);
+ ppip.add_to_parameter_space_dimensions(vars);
+ return 0;
+}
+CATCH_ALL
+int
ppl_PIP_Problem_add_constraint(ppl_PIP_Problem_t pip,
ppl_const_Constraint_t c) try {
const Constraint& cc = *to_const(c);
diff --git a/src/PIP_Problem.cc b/src/PIP_Problem.cc
index f2fb1c3..b228911 100644
--- a/src/PIP_Problem.cc
+++ b/src/PIP_Problem.cc
@@ -390,6 +390,33 @@ PPL::PIP_Problem
}
void
+PPL::PIP_Problem
+::add_to_parameter_space_dimensions(const Variables_Set& p_vars) {
+ if (p_vars.space_dimension() > external_space_dim)
+ throw std::invalid_argument("PPL::PIP_Problem::"
+ "add_to_parameter_space_dimension(p_vars):\n"
+ "*this and p_vars are dimension"
+ "incompatible.");
+ const dimension_type original_size = parameters.size();
+ parameters.insert(p_vars.begin(), p_vars.end());
+ // Do not allow to turn variables into parameters
+ Variables_Set::const_iterator p;
+ Variables_Set::const_iterator end = p_vars.end();
+ for (p=p_vars.begin(); p!=end; ++p) {
+ if (*p < internal_space_dim) {
+ throw std::invalid_argument("PPL::PIP_Problem::"
+ "add_to_parameter_space_dimension(p_vars):"
+ "p_vars contain variable indices.");
+ }
+ }
+
+ // If a new parameter was inserted, set the internal status to
+ // PARTIALLY_SATISFIABLE.
+ if (parameters.size() != original_size && status != UNSATISFIABLE)
+ status = PARTIALLY_SATISFIABLE;
+}
+
+void
PPL::PIP_Problem::add_constraint(const Constraint& c) {
if (c.space_dimension() > external_space_dim) {
std::ostringstream s;
diff --git a/src/PIP_Problem.defs.hh b/src/PIP_Problem.defs.hh
index 0096879..64fe7e9 100644
--- a/src/PIP_Problem.defs.hh
+++ b/src/PIP_Problem.defs.hh
@@ -87,7 +87,7 @@ class Parma_Polyhedra_Library::PIP_Problem {
public:
//! Builds a trivial PIP problem.
/*!
- A trivial PIP problem requires to maximize the objective function
+ A trivial PIP problem requires to minimize the objective function
\f$0\f$ on a vector space under no constraints and with no parameters:
the origin of the vector space is an optimal solution.
@@ -108,7 +108,8 @@ public:
interpreted as parameters.
\param dim
- The dimension of the vector space enclosing \p *this.
+ The dimension of the vector space (variables and parameters) enclosing
+ \p *this.
\param first
An input iterator to the start of the sequence of constraints.
@@ -208,6 +209,16 @@ public:
dimension_type m_pip_params);
/*! \brief
+ Sets the space dimensions whose indexes which are in set \p p_vars to be
+ parameter space dimensions.
+
+ \exception std::invalid_argument
+ Thrown if some index in \p p_vars does not correspond to
+ a space dimension in \p *this.
+ */
+ void add_to_parameter_space_dimensions(const Variables_Set& p_vars);
+
+ /*! \brief
Adds a copy of constraint \p c to the PIP problem.
\exception std::invalid_argument
More information about the PPL-devel
mailing list