[PPL-devel] [GIT] ppl/ppl(master): Added some missing C interface methods and enum values for the new PIP classes .

Patricia Hill p.m.hill at leeds.ac.uk
Thu Feb 18 21:24:47 CET 2010


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

Author: Patricia Hill <p.m.hill at leeds.ac.uk>
Date:   Thu Feb 18 20:22:54 2010 +0000

Added some missing C interface methods and enum values for the new PIP classes.

---

 interfaces/C/ppl_c_header.h                 |   44 +++++++++++++++++++++++
 interfaces/C/ppl_c_implementation_common.cc |   51 +++++++++++++++++++++++++++
 interfaces/C/tests/pip_test.c               |   17 ++++++++-
 3 files changed, 111 insertions(+), 1 deletions(-)

diff --git a/interfaces/C/ppl_c_header.h b/interfaces/C/ppl_c_header.h
index 7cce12c..d49703b 100644
--- a/interfaces/C/ppl_c_header.h
+++ b/interfaces/C/ppl_c_header.h
@@ -2388,6 +2388,16 @@ extern int PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_FIRST;
 */
 extern int PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_MAX_COLUMN;
 
+/*! \relates ppl_PIP_Problem_tag \brief
+  Code of PIP problem's "name size" control parameter name.
+*/
+extern int PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_SIZE;
+
+/*! \relates ppl_PIP_Problem_tag \brief
+  Code of PIP problem's "value size" control parameter name.
+*/
+extern int PPL_PIP_PROBLEM_CONTROL_PARAMETER_VALUE_SIZE;
+
 /*@}*/ /* Symbolic Constants */
 
 /*! \brief \name Constructors, Assignment and Destructor */
@@ -2702,6 +2712,21 @@ ppl_assign_PIP_Problem_from_PIP_Problem
 PPL_PROTO((ppl_PIP_Problem_t dst, ppl_const_PIP_Problem_t src));
 
 /*! \relates ppl_PIP_Problem_tag \brief
+  Builds a PIP problem having space dimension \p d from the sequence
+  of constraints in the range \f$[\mathrm{first}, \mathrm{last})\f$;
+  the \p n dimensions whose indices occur in \p ds are interpreted as
+  parameters.
+*/
+int
+ppl_new_PIP_Problem_from_constraints
+PPL_PROTO((ppl_PIP_Problem_t* ppip,
+           ppl_dimension_type d,
+           ppl_Constraint_System_const_iterator_t first,
+           ppl_Constraint_System_const_iterator_t last,
+           size_t n,
+           ppl_dimension_type ds[]));
+
+/*! \relates ppl_PIP_Problem_tag \brief
   Invalidates the handle \p pip: this makes sure the corresponding
   resources will eventually be released.
 */
@@ -3022,6 +3047,25 @@ PPL_PROTO((ppl_const_Artificial_Parameter_t ap,
            ppl_const_Linear_Expression_t* le));
 
 /*! \relates ppl_Artificial_Parameter_tag \brief
+  Copies into \p coef the coefficient of variable \p var in
+  the artificial parameter \p ap.
+*/
+int
+ppl_Artificial_Parameter_get_coefficient
+PPL_PROTO((ppl_const_Artificial_Parameter_t ap,
+           ppl_dimension_type var,
+           ppl_const_Coefficient_t* coef));
+
+/*! \relates ppl_Artificial_Parameter_tag \brief
+  Copies into \p coef the inhomogeneous term of the artificial
+  parameter \p ap.
+*/
+int
+ppl_Artificial_Parameter_get_inhomogeneous_term
+PPL_PROTO((ppl_const_Artificial_Parameter_t ap,
+           ppl_const_Coefficient_t* coef));
+
+/*! \relates ppl_Artificial_Parameter_tag \brief
   Writes to \p coeff the denominator in artificial parameter \p ap.
 */
 int
diff --git a/interfaces/C/ppl_c_implementation_common.cc b/interfaces/C/ppl_c_implementation_common.cc
index 2d0598e..47e5259 100644
--- a/interfaces/C/ppl_c_implementation_common.cc
+++ b/interfaces/C/ppl_c_implementation_common.cc
@@ -168,8 +168,11 @@ int PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_CUTTING_STRATEGY;
 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_FIRST;
 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_DEEPEST;
 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_ALL;
+int PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_PIVOT_ROW_STRATEGY;
 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_FIRST;
 int PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_MAX_COLUMN;
+int PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_SIZE;
+int PPL_PIP_PROBLEM_CONTROL_PARAMETER_VALUE_SIZE;
 
 int PPL_OPTIMIZATION_MODE_MINIMIZATION;
 int PPL_OPTIMIZATION_MODE_MAXIMIZATION;
@@ -224,10 +227,16 @@ ppl_initialize(void) try {
     = PIP_Problem::CUTTING_STRATEGY_DEEPEST;
   PPL_PIP_PROBLEM_CONTROL_PARAMETER_CUTTING_STRATEGY_ALL
     = PIP_Problem::CUTTING_STRATEGY_ALL;
+  PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_PIVOT_ROW_STRATEGY
+    = PIP_Problem::PIVOT_ROW_STRATEGY;
   PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_FIRST
     = PIP_Problem::PIVOT_ROW_STRATEGY_FIRST;
   PPL_PIP_PROBLEM_CONTROL_PARAMETER_PIVOT_ROW_STRATEGY_MAX_COLUMN
     = PIP_Problem::PIVOT_ROW_STRATEGY_MAX_COLUMN;
+  PPL_PIP_PROBLEM_CONTROL_PARAMETER_NAME_SIZE
+    = PIP_Problem::CONTROL_PARAMETER_NAME_SIZE;
+  PPL_PIP_PROBLEM_CONTROL_PARAMETER_VALUE_SIZE
+    = PIP_Problem::CONTROL_PARAMETER_VALUE_SIZE;
 
   PPL_OPTIMIZATION_MODE_MINIMIZATION = MINIMIZATION;
   PPL_OPTIMIZATION_MODE_MAXIMIZATION = MAXIMIZATION;
@@ -2148,6 +2157,23 @@ ppl_new_PIP_Problem_from_PIP_Problem(ppl_PIP_Problem_t* dpip,
 CATCH_ALL
 
 int
+ppl_new_PIP_Problem_from_constraints
+(ppl_PIP_Problem_t* ppip,
+ ppl_dimension_type d,
+ ppl_Constraint_System_const_iterator_t first,
+ ppl_Constraint_System_const_iterator_t last,
+ size_t n,
+ ppl_dimension_type ds[]) try {
+  Variables_Set p_vars;
+  for (ppl_dimension_type i = n; i-- > 0; )
+    p_vars.insert(ds[i]);
+  *ppip = to_nonconst(new PIP_Problem(d, *to_const(first),
+                                      *to_const(last), p_vars));
+  return 0;
+}
+CATCH_ALL
+
+int
 ppl_assign_PIP_Problem_from_PIP_Problem(ppl_PIP_Problem_t dst,
 					ppl_const_PIP_Problem_t src) try {
   const PIP_Problem& ssrc = *to_const(src);
@@ -2461,6 +2487,31 @@ ppl_Artificial_Parameter_get_Linear_Expression
 CATCH_ALL
 
 int
+ppl_Artificial_Parameter_get_coefficient(ppl_const_Artificial_Parameter_t ap,
+                                         ppl_dimension_type var,
+                                         ppl_const_Coefficient_t* coef) try {
+  const Artificial_Parameter& sap = *to_const(ap);
+  const Linear_Expression& lle = static_cast<const Linear_Expression&>(sap);
+  const Coefficient& ncoef = lle.coefficient(Variable(var));
+  *coef = to_const(&ncoef);
+  return 0;
+}
+CATCH_ALL
+
+int
+ppl_Artificial_Parameter_get_inhomogeneous_term
+(ppl_const_Artificial_Parameter_t ap,
+ ppl_const_Coefficient_t* coef) try {
+  const Artificial_Parameter& sap = *to_const(ap);
+  const Linear_Expression& lle = static_cast<const Linear_Expression&>(sap);
+  const Coefficient& icoef = lle.inhomogeneous_term();
+  *coef = to_const(&icoef);
+  return 0;
+}
+CATCH_ALL
+
+
+int
 ppl_Artificial_Parameter_get_denominator(ppl_const_Artificial_Parameter_t ap,
                                          ppl_const_Coefficient_t* coef) try {
   const Artificial_Parameter& sap = *to_const(ap);
diff --git a/interfaces/C/tests/pip_test.c b/interfaces/C/tests/pip_test.c
index ff0f533..71f0a68 100644
--- a/interfaces/C/tests/pip_test.c
+++ b/interfaces/C/tests/pip_test.c
@@ -232,7 +232,6 @@ main(int argc, char **argv) {
     ppl_Linear_Expression_add_to_inhomogeneous(le, c);
     ppl_new_Constraint(&ct, le, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
     ppl_PIP_Problem_add_constraint(pip, ct);
-    ppl_delete_Constraint(ct);
     ppl_delete_Linear_Expression(le);
   }
   ppl_delete_Coefficient(c);
@@ -240,13 +239,29 @@ main(int argc, char **argv) {
 
   ppl_PIP_Problem_total_memory_in_bytes(pip, &sz);
   ppl_PIP_Problem_external_memory_in_bytes(pip, &sz);
+
   ok = (ppl_PIP_Problem_solve(pip) == PPL_PIP_PROBLEM_STATUS_OPTIMIZED);
   if (ok) {
     ppl_dimension_type dim;
     ppl_const_PIP_Tree_Node_t solution;
+    ppl_PIP_Problem_t pip0;
+    ppl_Constraint_System_t constraints;
+    ppl_Constraint_System_const_iterator_t begin, end;
+
     ppl_PIP_Problem_space_dimension(pip, &dim);
     ppl_PIP_Problem_solution(pip, &solution);
     display_solution(solution, N_VARS, N_PARAMETERS, parameter_dim);
+    ppl_new_Constraint_System_const_iterator(&begin);
+    ppl_new_Constraint_System_const_iterator(&end);
+    ppl_new_Constraint_System_from_Constraint(&constraints, ct);
+    ppl_Constraint_System_begin(constraints, begin);
+    ppl_Constraint_System_end(constraints, end);
+    ppl_new_PIP_Problem_from_constraints(&pip0, N_VARS+N_PARAMETERS,
+                                         begin, end, N_PARAMETERS,
+                                         parameter_dim);
+    ok = ppl_PIP_Problem_OK(pip0);
+    ppl_delete_Constraint(ct);
+    ppl_delete_Constraint_System(constraints);
   }
 
   ppl_delete_PIP_Problem(pip);




More information about the PPL-devel mailing list