| Directory: | ./ |
|---|---|
| File: | bindings/python/algorithm/admm-solver.cpp |
| Date: | 2025-02-12 21:03:38 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 97 | 116 | 83.6% |
| Branches: | 160 | 336 | 47.6% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2024 INRIA | ||
| 3 | // | ||
| 4 | |||
| 5 | #include <eigenpy/memory.hpp> | ||
| 6 | #include <eigenpy/eigen-from-python.hpp> | ||
| 7 | #include <eigenpy/eigen-to-python.hpp> | ||
| 8 | |||
| 9 | #include "pinocchio/bindings/python/fwd.hpp" | ||
| 10 | |||
| 11 | #include "pinocchio/algorithm/admm-solver.hpp" | ||
| 12 | #include "pinocchio/algorithm/contact-cholesky.hpp" | ||
| 13 | #include "pinocchio/algorithm/delassus-operator-dense.hpp" | ||
| 14 | #include "pinocchio/algorithm/delassus-operator-sparse.hpp" | ||
| 15 | |||
| 16 | #include "pinocchio/bindings/python/algorithm/contact-solver-base.hpp" | ||
| 17 | #include "pinocchio/bindings/python/utils/std-vector.hpp" | ||
| 18 | #include "pinocchio/bindings/python/utils/macros.hpp" | ||
| 19 | |||
| 20 | namespace pinocchio | ||
| 21 | { | ||
| 22 | namespace python | ||
| 23 | { | ||
| 24 | namespace bp = boost::python; | ||
| 25 | |||
| 26 | typedef ADMMContactSolverTpl<context::Scalar> Solver; | ||
| 27 | typedef Solver::PowerIterationAlgo PowerIterationAlgo; | ||
| 28 | typedef Solver::SolverStats SolverStats; | ||
| 29 | typedef context::Scalar Scalar; | ||
| 30 | typedef context::VectorXs VectorXs; | ||
| 31 | typedef const Eigen::Ref<const VectorXs> ConstRefVectorXs; | ||
| 32 | typedef ContactCholeskyDecompositionTpl<context::Scalar, context::Options> | ||
| 33 | ContactCholeskyDecomposition; | ||
| 34 | |||
| 35 | #ifdef PINOCCHIO_PYTHON_PLAIN_SCALAR_TYPE | ||
| 36 | |||
| 37 | template<typename DelassusDerived> | ||
| 38 | ✗ | static bool solve_wrapper( | |
| 39 | Solver & solver, | ||
| 40 | DelassusDerived & delassus, | ||
| 41 | const context::VectorXs & g, | ||
| 42 | const context::CoulombFrictionConeVector & cones, | ||
| 43 | const context::VectorXs & R, | ||
| 44 | const boost::optional<ConstRefVectorXs> primal_solution = boost::none, | ||
| 45 | const boost::optional<ConstRefVectorXs> dual_solution = boost::none, | ||
| 46 | bool compute_largest_eigen_values = true, | ||
| 47 | bool stat_record = false) | ||
| 48 | { | ||
| 49 | ✗ | return solver.solve( | |
| 50 | delassus, g, cones, R, primal_solution, dual_solution, compute_largest_eigen_values, | ||
| 51 | ✗ | stat_record); | |
| 52 | } | ||
| 53 | |||
| 54 | template<typename DelassusDerived> | ||
| 55 | static bool solve_wrapper2( | ||
| 56 | Solver & solver, | ||
| 57 | DelassusDerived & delassus, | ||
| 58 | const context::VectorXs & g, | ||
| 59 | const context::CoulombFrictionConeVector & cones, | ||
| 60 | Eigen::Ref<context::VectorXs> x) | ||
| 61 | { | ||
| 62 | return solver.solve(delassus, g, cones, x); | ||
| 63 | } | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #ifndef PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED | ||
| 67 | |||
| 68 | ✗ | static context::VectorXs computeConeProjection_wrapper( | |
| 69 | const context::CoulombFrictionConeVector & cones, const context::VectorXs & forces) | ||
| 70 | { | ||
| 71 | ✗ | context::VectorXs res(forces.size()); | |
| 72 | ✗ | ::pinocchio::internal::computeConeProjection(cones, forces, res); | |
| 73 | ✗ | return res; | |
| 74 | } | ||
| 75 | |||
| 76 | ✗ | static context::VectorXs computeDualConeProjection_wrapper( | |
| 77 | const context::CoulombFrictionConeVector & cones, const context::VectorXs & velocities) | ||
| 78 | { | ||
| 79 | ✗ | context::VectorXs res(velocities.size()); | |
| 80 | ✗ | ::pinocchio::internal::computeDualConeProjection(cones, velocities, res); | |
| 81 | ✗ | return res; | |
| 82 | } | ||
| 83 | |||
| 84 | ✗ | static context::Scalar computePrimalFeasibility_wrapper( | |
| 85 | const context::CoulombFrictionConeVector & cones, const context::VectorXs & forces) | ||
| 86 | { | ||
| 87 | ✗ | return ::pinocchio::internal::computePrimalFeasibility(cones, forces); | |
| 88 | } | ||
| 89 | |||
| 90 | ✗ | static context::Scalar computeReprojectionError_wrapper( | |
| 91 | const context::CoulombFrictionConeVector & cones, | ||
| 92 | const context::VectorXs & forces, | ||
| 93 | const context::VectorXs & velocities) | ||
| 94 | { | ||
| 95 | ✗ | return ::pinocchio::internal::computeReprojectionError(cones, forces, velocities); | |
| 96 | } | ||
| 97 | |||
| 98 | ✗ | static context::VectorXs computeComplementarityShift_wrapper( | |
| 99 | const context::CoulombFrictionConeVector & cones, const context::VectorXs & velocities) | ||
| 100 | { | ||
| 101 | ✗ | context::VectorXs res(velocities.size()); | |
| 102 | ✗ | ::pinocchio::internal::computeComplementarityShift(cones, velocities, res); | |
| 103 | ✗ | return res; | |
| 104 | } | ||
| 105 | #endif // PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED | ||
| 106 | |||
| 107 | 69 | void exposeADMMContactSolver() | |
| 108 | { | ||
| 109 | #ifdef PINOCCHIO_PYTHON_PLAIN_SCALAR_TYPE | ||
| 110 | bp::class_<Solver> cl( | ||
| 111 | "ADMMContactSolver", | ||
| 112 | "Alternating Direction Method of Multi-pliers solver for contact dynamics.", | ||
| 113 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::init<int, Scalar, Scalar, Scalar, Scalar, Scalar, int>( |
| 114 |
6/12✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
|
195 | (bp::arg("self"), bp::arg("problem_dim"), bp::arg("mu_prox") = Scalar(1e-6), |
| 115 |
6/12✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
|
260 | bp::arg("tau") = Scalar(0.5), bp::arg("rho_power") = Scalar(0.2), |
| 116 |
6/12✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
|
260 | bp::arg("rho_power_factor") = Scalar(0.05), bp::arg("ratio_primal_dual") = Scalar(10), |
| 117 |
3/6✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
|
130 | bp::arg("max_it_largest_eigen_value_solver") = 20), |
| 118 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | "Default constructor.")); |
| 119 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | cl.def(ContactSolverBasePythonVisitor<Solver>()) |
| 120 | |||
| 121 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 122 | "solve", solve_wrapper<ContactCholeskyDecomposition::DelassusCholeskyExpression>, | ||
| 123 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | (bp::args("self", "delassus", "g", "cones", "R"), |
| 124 |
6/12✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
|
130 | bp::arg("primal_solution") = boost::none, bp::arg("dual_solution") = boost::none, |
| 125 |
6/12✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
|
130 | bp::arg("compute_largest_eigen_values") = true, bp::arg("stat_record") = false), |
| 126 | "Solve the constrained conic problem, starting from the optional initial guess.") | ||
| 127 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 128 | "solve", solve_wrapper<context::DelassusOperatorDense>, | ||
| 129 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | (bp::args("self", "delassus", "g", "cones", "R"), |
| 130 |
6/12✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
|
130 | bp::arg("primal_solution") = boost::none, bp::arg("dual_solution") = boost::none, |
| 131 |
6/12✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
|
130 | bp::arg("compute_largest_eigen_values") = true, bp::arg("stat_record") = false), |
| 132 | "Solve the constrained conic problem, starting from the optional initial guess.") | ||
| 133 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 134 | "solve", solve_wrapper<context::DelassusOperatorSparse>, | ||
| 135 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | (bp::args("self", "delassus", "g", "cones", "R"), |
| 136 |
6/12✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
|
130 | bp::arg("primal_solution") = boost::none, bp::arg("dual_solution") = boost::none, |
| 137 |
6/12✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
|
130 | bp::arg("compute_largest_eigen_values") = true, bp::arg("stat_record") = false), |
| 138 | "Solve the constrained conic problem, starting from the optional initial guess.") | ||
| 139 | |||
| 140 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .def("setRho", &Solver::setRho, bp::args("self", "rho"), "Set the ADMM penalty value.") |
| 141 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .def("getRho", &Solver::getRho, bp::arg("self"), "Get the ADMM penalty value.") |
| 142 | |||
| 143 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 144 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "setRhoPower", &Solver::setRhoPower, bp::args("self", "rho_power"), |
| 145 | "Set the power associated to the problem conditionning.") | ||
| 146 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 147 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "getRhoPower", &Solver::getRhoPower, bp::arg("self"), |
| 148 | "Get the power associated to the problem conditionning.") | ||
| 149 | |||
| 150 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 151 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "setRhoPowerFactor", &Solver::setRhoPowerFactor, bp::args("self", "rho_power_factor"), |
| 152 | "Set the power factor associated to the problem conditionning.") | ||
| 153 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 154 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "getRhoPowerFactor", &Solver::getRhoPowerFactor, bp::arg("self"), |
| 155 | "Get the power factor associated to the problem conditionning.") | ||
| 156 | |||
| 157 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 158 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "setTau", &Solver::setTau, bp::args("self", "tau"), "Set the tau linear scaling factor.") |
| 159 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .def("getTau", &Solver::getTau, bp::arg("self"), "Get the tau linear scaling factor.") |
| 160 | |||
| 161 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 162 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "setProximalValue", &Solver::setProximalValue, bp::args("self", "mu"), |
| 163 | "Set the proximal value.") | ||
| 164 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 165 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "getProximalValue", &Solver::getProximalValue, bp::arg("self"), "Get the proximal value.") |
| 166 | |||
| 167 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 168 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "setRatioPrimalDual", &Solver::setRatioPrimalDual, bp::args("self", "ratio_primal_dual"), |
| 169 | "Set the primal/dual ratio.") | ||
| 170 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 171 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "getRatioPrimalDual", &Solver::getRatioPrimalDual, bp::arg("self"), |
| 172 | "Get the primal/dual ratio.") | ||
| 173 | |||
| 174 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 175 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | "getPrimalSolution", &Solver::getPrimalSolution, bp::arg("self"), |
| 176 | 65 | "Returns the primal solution of the problem.", bp::return_internal_reference<>()) | |
| 177 | |||
| 178 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 179 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | "getDualSolution", &Solver::getDualSolution, bp::arg("self"), |
| 180 | 65 | "Returns the dual solution of the problem.", bp::return_internal_reference<>()) | |
| 181 | |||
| 182 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 183 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "getCholeskyUpdateCount", &Solver::getCholeskyUpdateCount, bp::arg("self"), |
| 184 | "Returns the number of updates of the Cholesky factorization due to rho updates.") | ||
| 185 | |||
| 186 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 187 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "computeRho", &Solver::computeRho, bp::args("L", "m", "rho_power"), |
| 188 | "Compute the penalty ADMM value from the current largest and lowest eigenvalues and " | ||
| 189 | "the scaling spectral factor.") | ||
| 190 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .staticmethod("computeRho") |
| 191 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 192 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "computeRhoPower", &Solver::computeRhoPower, bp::args("L", "m", "rho"), |
| 193 | "Compute the scaling spectral factor of the ADMM penalty term from the current " | ||
| 194 | "largest and lowest eigenvalues and the ADMM penalty term.") | ||
| 195 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .staticmethod("computeRhoPower") |
| 196 | |||
| 197 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 198 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | "getPowerIterationAlgo", &Solver::getPowerIterationAlgo, bp::arg("self"), |
| 199 | 65 | bp::return_internal_reference<>()) | |
| 200 | |||
| 201 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
65 | .def("getStats", &Solver::getStats, bp::arg("self"), bp::return_internal_reference<>()); |
| 202 | |||
| 203 | #ifdef PINOCCHIO_WITH_ACCELERATE_SUPPORT | ||
| 204 | { | ||
| 205 | typedef Eigen::AccelerateLLT<context::SparseMatrix> AccelerateLLT; | ||
| 206 | typedef DelassusOperatorSparseTpl<context::Scalar, context::Options, AccelerateLLT> | ||
| 207 | DelassusOperatorSparseAccelerate; | ||
| 208 | cl.def( | ||
| 209 | "solve", solve_wrapper<DelassusOperatorSparseAccelerate>, | ||
| 210 | (bp::args("self", "delassus", "g", "cones", "R"), | ||
| 211 | bp::arg("primal_solution") = boost::none, bp::arg("dual_solution") = boost::none, | ||
| 212 | bp::arg("compute_largest_eigen_values") = true, bp::arg("stat_record") = false), | ||
| 213 | "Solve the constrained conic problem, starting from the optional initial guess."); | ||
| 214 | } | ||
| 215 | #endif | ||
| 216 | |||
| 217 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
| 218 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "computeConeProjection", computeConeProjection_wrapper, bp::args("cones", "forces"), |
| 219 | "Project a vector on the cartesian product of cones."); | ||
| 220 | |||
| 221 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
| 222 | "computeDualConeProjection", computeDualConeProjection_wrapper, | ||
| 223 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::args("cones", "velocities"), |
| 224 | "Project a vector on the cartesian product of dual cones."); | ||
| 225 | |||
| 226 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
| 227 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "computePrimalFeasibility", computePrimalFeasibility_wrapper, bp::args("cones", "forces"), |
| 228 | "Compute the primal feasibility."); | ||
| 229 | |||
| 230 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
| 231 | "computeReprojectionError", computeReprojectionError_wrapper, | ||
| 232 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::args("cones", "forces", "velocities"), "Compute the reprojection error."); |
| 233 | |||
| 234 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::def( |
| 235 | "computeComplementarityShift", computeComplementarityShift_wrapper, | ||
| 236 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | bp::args("cones", "velocities"), |
| 237 | "Compute the complementarity shift associated to the De Saxé function."); | ||
| 238 | |||
| 239 | { | ||
| 240 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::class_<SolverStats>( |
| 241 | "SolverStats", "", | ||
| 242 |
4/8✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
|
130 | bp::init<int>((bp::arg("self"), bp::arg("max_it")), "Default constructor")) |
| 243 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .def("reset", &SolverStats::reset, bp::arg("self"), "Reset the stasts.") |
| 244 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 245 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | "size", &SolverStats::size, bp::arg("self"), |
| 246 | "Size of the vectors stored in the structure.") | ||
| 247 | |||
| 248 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY(SolverStats, primal_feasibility, "") |
| 249 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY(SolverStats, dual_feasibility, "") |
| 250 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY(SolverStats, dual_feasibility_ncp, "") |
| 251 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY(SolverStats, complementarity, "") |
| 252 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY(SolverStats, rho, "") |
| 253 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY( |
| 254 | SolverStats, it, "Number of iterations performed by the algorithm.") | ||
| 255 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY( |
| 256 | SolverStats, cholesky_update_count, | ||
| 257 | "Number of Cholesky updates performed by the algorithm."); | ||
| 258 | } | ||
| 259 | |||
| 260 | { | ||
| 261 | typedef PowerIterationAlgoTpl<context::VectorXs> PowerIterationAlgo; | ||
| 262 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::class_<PowerIterationAlgo>( |
| 263 | "PowerIterationAlgo", "", | ||
| 264 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | bp::init<Eigen::DenseIndex, int, Scalar>( |
| 265 |
9/18✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 65 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 65 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 65 times.
✗ Branch 26 not taken.
|
130 | (bp::arg("self"), bp::arg("size"), bp::arg("max_it") = 10, bp::arg("rel_tol") = 1e-8), |
| 266 | "Default constructor")) | ||
| 267 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | .def("run", &PowerIterationAlgo::run<context::MatrixXs>, bp::arg("self"), "") |
| 268 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def( |
| 269 | "lowest", &PowerIterationAlgo::lowest<context::MatrixXs>, | ||
| 270 |
4/8✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
|
130 | (bp::arg("self"), bp::arg("compute_largest") = true), "") |
| 271 |
3/6✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
|
130 | .def("reset", &PowerIterationAlgo::reset, bp::arg("self")) |
| 272 | |||
| 273 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY(PowerIterationAlgo, principal_eigen_vector, "") |
| 274 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY(PowerIterationAlgo, lowest_eigen_vector, "") |
| 275 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY(PowerIterationAlgo, max_it, "") |
| 276 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY(PowerIterationAlgo, rel_tol, "") |
| 277 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY(PowerIterationAlgo, largest_eigen_value, "") |
| 278 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY(PowerIterationAlgo, lowest_eigen_value, "") |
| 279 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY(PowerIterationAlgo, it, "") |
| 280 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .PINOCCHIO_ADD_PROPERTY_READONLY(PowerIterationAlgo, convergence_criteria, ""); |
| 281 | } | ||
| 282 | #endif | ||
| 283 | 69 | } | |
| 284 | |||
| 285 | } // namespace python | ||
| 286 | } // namespace pinocchio | ||
| 287 |