1#ifndef BIORBD_MUSCLES_STATIC_OPTIMIZATION_IPOPT_H
2#define BIORBD_MUSCLES_STATIC_OPTIMIZATION_IPOPT_H
4#include "biorbdConfig.h"
6#include <IpIpoptApplication.hpp>
10namespace BIORBD_NAMESPACE {
23namespace internal_forces {
50 bool useResidual =
true,
51 unsigned int pNormFactor = 2,
72 Ipopt::Index& nnz_jac_g,
73 Ipopt::Index& nnz_h_lag,
74 IndexStyleEnum& index_style);
117 Ipopt::Number* lambda);
130 const Ipopt::Number* x,
132 Ipopt::Number& obj_value);
144 const Ipopt::Number* x,
146 Ipopt::Number* grad_f);
159 const Ipopt::Number* x,
178 const Ipopt::Number* x,
181 Ipopt::Index nele_jac,
184 Ipopt::Number* values);
201 Ipopt::SolverReturn status,
203 const Ipopt::Number* x,
204 const Ipopt::Number* z_L,
205 const Ipopt::Number* z_U,
207 const Ipopt::Number* g,
208 const Ipopt::Number* lambda,
209 Ipopt::Number obj_value,
210 const Ipopt::IpoptData* ip_data,
211 Ipopt::IpoptCalculatedQuantities* ip_cq);
232 std::shared_ptr<unsigned int>
234 std::shared_ptr<unsigned int>
239 std::shared_ptr<unsigned int>
243 std::shared_ptr<rigidbody::GeneralizedCoordinates>
245 std::shared_ptr<rigidbody::GeneralizedVelocity>
247 std::shared_ptr<rigidbody::GeneralizedTorque>
251 std::shared_ptr<std::vector<std::shared_ptr<State>>>
262 void dispatch(
const Ipopt::Number* x);
The actual musculoskeletal model that holds everything in biorbd.
EMG holder to interact with the muscle.
virtual bool eval_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
Compute the objective value from a set of variables.
std::shared_ptr< unsigned int > m_nbQdot
The number of generalized velocities.
Model & m_model
The model.
std::shared_ptr< utils::Vector > m_torqueResidual
The torque residual.
std::shared_ptr< std::vector< std::shared_ptr< State > > > m_states
The muscle states.
static const double m_activationUpperBound
Maximal muscle activation.
utils::Vector finalResidual() const
Return the final residual.
void dispatch(const Ipopt::Number *x)
To dispatch the variables into biorbd format.
std::shared_ptr< unsigned int > m_nbTorque
The number of torques to match.
virtual bool eval_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
Method to return the constraint residuals.
std::shared_ptr< unsigned int > m_nbMus
The number of muscles.
std::shared_ptr< utils::Vector > m_activations
The activations.
std::shared_ptr< double > m_eps
Precision of the finite differentiate.
virtual bool get_nlp_info(Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, IndexStyleEnum &index_style)
Get info about the NLP.
std::shared_ptr< unsigned int > m_pNormFactor
The p-norm factor.
std::shared_ptr< unsigned int > m_nbTorqueResidual
The number of torque residual.
StaticOptimizationIpopt(Model &model, const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, const rigidbody::GeneralizedTorque &torqueTarget, const utils::Vector &activationInit, bool useResidual=true, unsigned int pNormFactor=2, int verbose=0, double eps=1e-8)
Construct an Ipopt static optimization problem.
virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number *x, bool init_z, Ipopt::Number *z_L, Ipopt::Number *z_U, Ipopt::Index m, bool init_lambda, Ipopt::Number *lambda)
Return the starting point for the algorithm.
std::shared_ptr< rigidbody::GeneralizedVelocity > m_Qdot
The generalized velocities.
virtual void finalize_solution(Ipopt::SolverReturn status, Ipopt::Index n, const Ipopt::Number *x, const Ipopt::Number *z_L, const Ipopt::Number *z_U, Ipopt::Index m, const Ipopt::Number *g, const Ipopt::Number *lambda, Ipopt::Number obj_value, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq)
Finalize the optimization.
std::shared_ptr< unsigned int > m_nbQ
The number of generalized coordinates.
utils::Vector finalSolution() const
Return the final solution.
static const double m_activationLowerBound
Minimal muscle activation.
std::shared_ptr< rigidbody::GeneralizedCoordinates > m_Q
The generalized coordinates.
std::shared_ptr< utils::Vector > m_finalResidual
The final residual.
virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u)
Return the bounds for my problem.
std::shared_ptr< rigidbody::GeneralizedTorque > m_torqueTarget
The torque to match.
std::shared_ptr< int > m_verbose
Verbose level of IPOPT.
virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Return the jacobian of contraints.
virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
Return the gradient of the objective.
std::shared_ptr< double > m_torquePonderation
The torque ponderation.
std::shared_ptr< unsigned int > m_nbDof
The number of degrees of freedom.
std::shared_ptr< utils::Vector > m_finalSolution
The final solution.
Class GeneralizedCoordinates.
Class GeneralizedVelocity.
Wrapper of the Eigen VectorXd.