|
Biorbd Release_1.13.0
|
The actual implementation of the Static Optimization problem using a linearized approach. More...
#include <StaticOptimizationIpoptLinearized.h>
Public Member Functions | |
| StaticOptimizationIpoptLinearized (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 | ~StaticOptimizationIpoptLinearized () |
| Destroy class properly. | |
| 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. | |
| 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. | |
| Public Member Functions inherited from BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpopt | |
| 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 | ~StaticOptimizationIpopt () |
| Destroy class properly. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| utils::Vector | finalSolution () const |
| Return the final solution. | |
| utils::Vector | finalResidual () const |
| Return the final residual. | |
Protected Member Functions | |
| void | prepareJacobian () |
| Setup the constant constraints jacobian. | |
| Protected Member Functions inherited from BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpopt | |
| void | dispatch (const Ipopt::Number *x) |
| To dispatch the variables into biorbd format. | |
Protected Attributes | |
| std::shared_ptr< utils::Matrix > | m_jacobian |
| The constraints jacobian. | |
| std::shared_ptr< utils::Vector > | m_torquePassive |
| The muscle torque when not activated. | |
| Protected Attributes inherited from BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpopt | |
| Model & | m_model |
| The model. | |
| std::shared_ptr< unsigned int > | m_nbQ |
| The number of generalized coordinates. | |
| std::shared_ptr< unsigned int > | m_nbQdot |
| The number of generalized velocities. | |
| std::shared_ptr< unsigned int > | m_nbMus |
| The number of muscles. | |
| std::shared_ptr< unsigned int > | m_nbDof |
| The number of degrees of freedom. | |
| std::shared_ptr< unsigned int > | m_nbTorque |
| The number of torques to match. | |
| std::shared_ptr< unsigned int > | m_nbTorqueResidual |
| The number of torque residual. | |
| std::shared_ptr< double > | m_eps |
| Precision of the finite differentiate. | |
| std::shared_ptr< utils::Vector > | m_activations |
| The activations. | |
| std::shared_ptr< rigidbody::GeneralizedCoordinates > | m_Q |
| The generalized coordinates. | |
| std::shared_ptr< rigidbody::GeneralizedVelocity > | m_Qdot |
| The generalized velocities. | |
| std::shared_ptr< rigidbody::GeneralizedTorque > | m_torqueTarget |
| The torque to match. | |
| std::shared_ptr< utils::Vector > | m_torqueResidual |
| The torque residual. | |
| std::shared_ptr< double > | m_torquePonderation |
| The torque ponderation. | |
| std::shared_ptr< std::vector< std::shared_ptr< State > > > | m_states |
| The muscle states. | |
| std::shared_ptr< unsigned int > | m_pNormFactor |
| The p-norm factor. | |
| std::shared_ptr< int > | m_verbose |
| Verbose level of IPOPT. | |
| std::shared_ptr< utils::Vector > | m_finalSolution |
| The final solution. | |
| std::shared_ptr< utils::Vector > | m_finalResidual |
| The final residual. | |
Additional Inherited Members | |
| Static Protected Attributes inherited from BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpopt | |
| static const double | m_activationLowerBound = 0.0001 |
| Minimal muscle activation. | |
| static const double | m_activationUpperBound = 0.9999 |
| Maximal muscle activation. | |
The actual implementation of the Static Optimization problem using a linearized approach.
This algo should be much faster than tradition but less precise. The torque of each muscle is linearized between no activation and its initial activation (the solution of the previous frame), so the approximation is exact at that reference activation (Michaud, "Two efficient static optimization algorithms that account for muscle-tendon equilibrium: approaching the constraint Jacobian via a constant or a cubic spline function")
Definition at line 28 of file StaticOptimizationIpoptLinearized.h.
| internal_forces::muscles::StaticOptimizationIpoptLinearized::StaticOptimizationIpoptLinearized | ( | 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.
| model | The musculoskeletal Model |
| Q | The generalized coordinates |
| Qdot | The generalized velocities |
| torqueTarget | The generalized torque target |
| activationInit | The initial activation, also used as the reference activation of the linearization |
| useResidual | If use residual torque, if set to false, the optimization will fail if the model is not strong enough |
| pNormFactor | The p-norm to perform |
| verbose | Level of IPOPT verbose you want |
| eps | The precision to perform the finite diffentiation |
Definition at line 14 of file StaticOptimizationIpoptLinearized.cpp.
|
virtual |
Destroy class properly.
Definition at line 76 of file StaticOptimizationIpoptLinearized.cpp.
|
virtual |
Method to return the constraint residuals.
| n | The number of variables |
| x | The values of the variables |
| new_x | If the variables were modified by IPOPT |
| m | The number of constraints |
| g | The actual contraints residual |
Reimplemented from BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpopt.
Definition at line 79 of file StaticOptimizationIpoptLinearized.cpp.
|
virtual |
Return the jacobian of contraints.
| n | The number of variables |
| x | The values of the variables |
| new_x | If the variables were modified by IPOPT |
| m | The number of constraints |
| nele_jac | Number of elements in the jacobian matrix |
| iRow | iterator on the rows of the jacobian |
| jCol | iterator on the columns of the jacobian |
| values | The actual constraint jacobian |
Reimplemented from BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpopt.
Definition at line 110 of file StaticOptimizationIpoptLinearized.cpp.
|
protected |
Setup the constant constraints jacobian.
Definition at line 40 of file StaticOptimizationIpoptLinearized.cpp.
|
protected |
The constraints jacobian.
Definition at line 100 of file StaticOptimizationIpoptLinearized.h.
|
protected |
The muscle torque when not activated.
Definition at line 102 of file StaticOptimizationIpoptLinearized.h.