5 #ifndef __pinocchio_algorithm_admm_solver_hpp__
6 #define __pinocchio_algorithm_admm_solver_hpp__
16 #include <boost/optional.hpp>
20 template<
typename _Scalar>
22 ADMMContactSolverTpl : ContactSolverBaseTpl<_Scalar>
25 typedef ContactSolverBaseTpl<_Scalar>
Base;
26 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1>
VectorXs;
28 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
MatrixXs;
31 using Base::problem_size;
62 , cholesky_update_count(0)
64 primal_feasibility.reserve(
size_t(max_it));
65 dual_feasibility.reserve(
size_t(max_it));
66 dual_feasibility_ncp.reserve(
size_t(max_it));
67 complementarity.reserve(
size_t(max_it));
68 rho.reserve(
size_t(max_it));
73 primal_feasibility.clear();
74 dual_feasibility.clear();
75 complementarity.clear();
76 dual_feasibility_ncp.clear();
79 cholesky_update_count = 0;
84 return primal_feasibility.size();
91 int cholesky_update_count;
94 std::vector<Scalar> primal_feasibility;
97 std::vector<Scalar> dual_feasibility;
98 std::vector<Scalar> dual_feasibility_ncp;
101 std::vector<Scalar> complementarity;
104 std::vector<Scalar>
rho;
120 explicit ADMMContactSolverTpl(
127 int max_it_largest_eigen_value_solver = 20)
129 , is_initialized(false)
133 , rho_power(rho_power)
134 , rho_power_factor(rho_power_factor)
135 , ratio_primal_dual(ratio_primal_dual)
136 , max_it_largest_eigen_value_solver(max_it_largest_eigen_value_solver)
137 , power_iteration_algo(problem_dim)
140 , x_previous(
VectorXs::Zero(problem_dim))
141 , y_previous(
VectorXs::Zero(problem_dim))
142 , z_previous(
VectorXs::Zero(problem_dim))
146 , primal_feasibility_vector(
VectorXs::Zero(problem_dim))
147 , dual_feasibility_vector(
VectorXs::Zero(problem_dim))
148 , stats(
Base::max_it)
150 power_iteration_algo.max_it = max_it_largest_eigen_value_solver;
165 void setRhoPower(
const Scalar rho_power)
167 this->rho_power = rho_power;
170 Scalar getRhoPower()
const
176 void setRhoPowerFactor(
const Scalar rho_power_factor)
178 this->rho_power_factor = rho_power_factor;
181 Scalar getRhoPowerFactor()
const
183 return rho_power_factor;
198 void setProximalValue(
const Scalar mu)
203 Scalar getProximalValue()
const
209 void setRatioPrimalDual(
const Scalar ratio_primal_dual)
212 ratio_primal_dual > 0.,
"The ratio primal/dual should be positive strictly");
213 this->ratio_primal_dual = ratio_primal_dual;
216 Scalar getRatioPrimalDual()
const
218 return ratio_primal_dual;
222 int getCholeskyUpdateCount()
const
224 return cholesky_update_count;
241 typename DelassusDerived,
243 typename ConstraintAllocator,
244 typename VectorLikeR>
246 DelassusOperatorBase<DelassusDerived> & delassus,
247 const Eigen::MatrixBase<VectorLike> & g,
248 const std::vector<CoulombFrictionConeTpl<Scalar>, ConstraintAllocator> & cones,
249 const Eigen::MatrixBase<VectorLikeR> & R,
250 const boost::optional<ConstRefVectorXs> primal_guess = boost::none,
251 const boost::optional<ConstRefVectorXs> dual_guess = boost::none,
252 bool compute_largest_eigen_values =
true,
253 bool stat_record =
false);
268 typename DelassusDerived,
270 typename ConstraintAllocator,
271 typename VectorLikeOut>
273 DelassusOperatorBase<DelassusDerived> & delassus,
274 const Eigen::MatrixBase<VectorLike> & g,
275 const std::vector<CoulombFrictionConeTpl<Scalar>, ConstraintAllocator> & cones,
276 const Eigen::DenseBase<VectorLikeOut> & x)
279 delassus.derived(), g.derived(), cones,
x.const_cast_derived(),
280 VectorXs::Zero(problem_size));
284 const VectorXs & getPrimalSolution()
const
289 const VectorXs & getDualSolution()
const
294 const VectorXs & getComplementarityShift()
const
304 const Scalar rho = math::sqrt(L *
m) * math::pow(cond, rho_power);
313 const Scalar sqtr_L_m = math::sqrt(L *
m);
320 return power_iteration_algo;
347 int max_it_largest_eigen_value_solver;
355 VectorXs x_previous, y_previous, z_previous;
361 VectorXs rhs, primal_feasibility_vector, dual_feasibility_vector;
363 int cholesky_update_count;
368 #ifdef PINOCCHIO_WITH_HPP_FCL
370 #endif // PINOCCHIO_WITH_HPP_FCL
374 #include "pinocchio/algorithm/admm-solver.hxx"
376 #endif // ifndef __pinocchio_algorithm_admm_solver_hpp__