[PPL-devel] [GIT] ppl/ppl(pip): Fixed the C interface and the documentation for PIP_Tree_Node methods.

François Galea francois.galea at uvsq.fr
Tue Oct 27 16:43:40 CET 2009


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

Author: François Galea <francois.galea at uvsq.fr>
Date:   Tue Oct 27 16:31:42 2009 +0100

Fixed the C interface and the documentation for PIP_Tree_Node methods.

The concerned methods are insert_artificials and get_parametric_values.

---

 interfaces/C/ppl_c_header.h                 |   55 ++++++++++++++++++++-------
 interfaces/C/ppl_c_implementation_common.cc |   15 +++++--
 src/PIP_Tree.defs.hh                        |   18 +++++++--
 3 files changed, 65 insertions(+), 23 deletions(-)

diff --git a/interfaces/C/ppl_c_header.h b/interfaces/C/ppl_c_header.h
index af77a18..6913c87 100644
--- a/interfaces/C/ppl_c_header.h
+++ b/interfaces/C/ppl_c_header.h
@@ -2854,14 +2854,31 @@ PPL_PROTO((ppl_const_PIP_Tree_Node_t pip_tree,
            ppl_Artificial_Parameter_Sequence_const_iterator_t pit));
 
 /*! \relates ppl_PIP_Tree_Node_tag \brief
-  Insert in parameter set the parameter indices corresponding to local
+  Inserts in parameter set the parameter indices corresponding to local
   artificials.
 
-  \param params
-  the Variables_Set to be updated
+  This utility method can typically be used by user programs when spanning a
+  solution tree. As new parameters may be defined in tree nodes by the solver,
+  local solutions are likely to be expressed in terms of both the upper level
+  parameters and the local ones.
 
-  \param space_dimension
-  the space dimension for \p *this
+  The resulting space dimension is the sum of \p space_dim and the
+  returned number of inserts indices.
+
+  \param pip_tree
+  the pip tree node whose artificial parameter indices are queried about
+
+  \param ds
+  an array containing the current parameter indices, which will be updated
+  with the local indices, and must be properly dimensioned in order the new
+  indices to be inserted
+
+  \param n
+  number of current valid parameter indices in \p ds (excluding the values to
+  be inserted)
+
+  \param space_dim
+  the space dimension for \p pip_tree (excluding the local parameters)
 
   \return
   the number of inserted indices
@@ -2871,23 +2888,33 @@ ppl_PIP_Tree_Node_insert_artificials
 PPL_PROTO((ppl_const_PIP_Tree_Node_t pip_tree,
            ppl_dimension_type ds[],
            size_t n,
-           ppl_dimension_type space_dim,
-           ppl_dimension_type inserted));
+           ppl_dimension_type space_dim));
 
 /*! \relates ppl_PIP_Tree_Node_tag \brief
-  Writes to \p le a parametric expression of the values of variable \p v.
+  Writes to \p le a const pointer to the parametric expression of the values
+  of variable \p v in solution node \p pip_sol.
 
   The linear expression assigned to \p le only involves parameters.
 
-  \return PPL_ERROR_INVALID_ARGUMENT
-  Returned if \p v is dimension-incompatible with \p *this
-  or if \p v is a parameter.
+  \param pip_sol
+  the solution tree node
 
   \param v
-  The variable which is queried about
+  the variable which is queried about
 
   \param pars
-  A set of indices of the parameters in the constraints
+  a set of indices of the parameters in the constraints, including those for
+  all artificials from the solution tree root to this node (included)
+
+  \param n
+  number of valid elements in \p pars
+
+  \param le
+  the returned expression of variable \p v
+
+  \return PPL_ERROR_INVALID_ARGUMENT
+  Returned if \p v is dimension-incompatible with \p *this
+  or if \p v is a parameter.
 */
 int
 ppl_PIP_Solution_Node_get_parametric_values
@@ -2895,7 +2922,7 @@ PPL_PROTO((ppl_const_PIP_Solution_Node_t pip_sol,
            ppl_dimension_type v,
            ppl_dimension_type pars[],
            size_t n,
-           ppl_Linear_Expression_t le));
+           ppl_const_Linear_Expression_t* le));
 
 /*! \relates ppl_PIP_Tree_Node_tag \brief
   Writes to \p pip_tree a const pointer to the \p b (true or false) branch
diff --git a/interfaces/C/ppl_c_implementation_common.cc b/interfaces/C/ppl_c_implementation_common.cc
index 68cf73a..810f291 100644
--- a/interfaces/C/ppl_c_implementation_common.cc
+++ b/interfaces/C/ppl_c_implementation_common.cc
@@ -2324,14 +2324,19 @@ int
 ppl_PIP_Tree_Node_insert_artificials(ppl_const_PIP_Tree_Node_t pip_tree,
                                      ppl_dimension_type ds[],
                                      size_t n,
-                                     ppl_dimension_type space_dim,
-                                     ppl_dimension_type inserted) try {
+                                     ppl_dimension_type space_dim) try {
   const PIP_Tree_Node& spip_tree = *to_const(pip_tree);
   Variables_Set vars;
-  for (ppl_dimension_type i = n; i-- > 0; )
-    vars.insert(ds[i]);
+  ppl_dimension_type inserted;
+  ppl_dimension_type i;
   inserted = spip_tree.insert_artificials(vars, space_dim);
-  return 0;
+  if (inserted > 0) {
+    Variables_Set::const_iterator end = vars.end();
+    Variables_Set::const_iterator v;
+    for (i = n, v = vars.begin(); v != end; ++i, ++v)
+      ds[i] = *v;
+  }
+  return inserted;
 }
 CATCH_ALL
 
diff --git a/src/PIP_Tree.defs.hh b/src/PIP_Tree.defs.hh
index 8c3704f..40400ac 100644
--- a/src/PIP_Tree.defs.hh
+++ b/src/PIP_Tree.defs.hh
@@ -102,14 +102,22 @@ public:
   Artificial_Parameter_Sequence::const_iterator art_parameter_end() const;
 
   /*! \brief
-    Insert in parameter set the parameter indices corresponding to local
-    artificials.
+    Inserts in parameter set \p params the parameter indices corresponding to
+    local artificials.
+
+    This utility method can typically be used by user programs when spanning a
+    solution tree. As new parameters may be defined in tree nodes by the
+    solver, local solutions are likely to be expressed in terms of both the
+    upper level parameters and the local ones.
+
+    The resulting space dimension is the sum of \p space_dimension and the
+    returned number of inserts indices.
 
     \param params
     the Variables_Set to be updated
 
     \param space_dimension
-    the space dimension for \p *this
+    the space dimension for \p *this (excluding the local parameters)
 
     \return
     the number of inserted indices
@@ -218,7 +226,9 @@ public:
     the variable which is queried about
 
     \param parameters
-    a \c std::set of indices of the parameters in the constraints
+    a \c std::set of indices of the parameters in the constraints, including
+    those for all artificials from the solution tree root to this node
+    (included)
 
     \exception std::invalid_argument
     Thrown if \p v is dimension-incompatible with \p *this




More information about the PPL-devel mailing list