|
Biorbd Release_1.13.0
|
The actual implementation of the Static Optimization problem. More...
#include <StaticOptimizationIpopt.h>
Public Member Functions | |
| 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 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. | |
| 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 | dispatch (const Ipopt::Number *x) |
| To dispatch the variables into biorbd format. | |
Protected Attributes | |
| 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. | |
Static Protected Attributes | |
| 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.
Definition at line 29 of file StaticOptimizationIpopt.h.
| 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.
| model | The musculoskeletal Model |
| Q | The generalized coordinates |
| Qdot | The generalized velocities |
| torqueTarget | The generalized torque target |
| activationInit | The initial activation |
| 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 24 of file StaticOptimizationIpopt.cpp.
|
virtual |
Destroy class properly.
Definition at line 79 of file StaticOptimizationIpopt.cpp.
|
protected |
To dispatch the variables into biorbd format.
| x | variables |
Definition at line 372 of file StaticOptimizationIpopt.cpp.
|
virtual |
Compute the objective value from a set of variables.
| n | The number of variables |
| x | The values of the variables |
| new_x | If the variables were modified by IPOPT |
| obj_value | The actual value of the objective function |
Definition at line 171 of file StaticOptimizationIpopt.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 in BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpoptLinearized.
Definition at line 213 of file StaticOptimizationIpopt.cpp.
|
virtual |
Return the gradient of the objective.
| n | The number of variables |
| x | The values of the variables |
| new_x | If the variables were modified by IPOPT |
| grad_f | The gradient vector of the objective function |
Definition at line 190 of file StaticOptimizationIpopt.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 in BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpoptLinearized.
Definition at line 242 of file StaticOptimizationIpopt.cpp.
|
virtual |
Finalize the optimization.
| status | The status of the optimization |
| n | Number of variables |
| x | Optimal solution |
| z_L | Optimal lower bound of z (ignored result) |
| z_U | Optimal upper bound of z (ignored result) |
| m | number of constraints |
| g | Residual at solution |
| lambda | Lagrange multipliers at solution |
| obj_value | Objective function value at solution |
| ip_data | Not used results |
| ip_cq | Not used results |
Definition at line 323 of file StaticOptimizationIpopt.cpp.
| utils::Vector internal_forces::muscles::StaticOptimizationIpopt::finalResidual | ( | ) | const |
Return the final residual.
Definition at line 367 of file StaticOptimizationIpopt.cpp.
| utils::Vector internal_forces::muscles::StaticOptimizationIpopt::finalSolution | ( | ) | const |
Return the final solution.
Definition at line 362 of file StaticOptimizationIpopt.cpp.
|
virtual |
Return the bounds for my problem.
| n | Number of variables |
| x_l | Lower bounds of the variables |
| x_u | Upper bounds of the variables |
| m | Number of constraints |
| g_l | Lower bounds of the constraints |
| g_u | Upper bounds of the constraints |
Definition at line 109 of file StaticOptimizationIpopt.cpp.
|
virtual |
Get info about the NLP.
| n | Number of variables |
| m | Number of constraints |
| nnz_jac_g | Dimension of the constraint jacobian |
| nnz_h_lag | Dimension of the constraint hessian |
| index_style | Formatting of the matrix (C-Style) |
Definition at line 81 of file StaticOptimizationIpopt.cpp.
|
virtual |
Return the starting point for the algorithm.
| n | Number of variables |
| init_x | If variables are initialized. That variable must be true |
| x | The initial values for the variables (output) |
| init_z | If z parameters are initialized. That variable must be false |
| z_L | Lower bound of z (ignored output) |
| z_U | Upper bound of z (ignored output) |
| m | Number of constraints |
| init_lambda | If lambda parameters are initialized. That variable must be false |
| lambda | Initial values of lagrange multipliers (ignored output) |
Definition at line 138 of file StaticOptimizationIpopt.cpp.
|
staticprotected |
Minimal muscle activation.
Definition at line 228 of file StaticOptimizationIpopt.h.
|
protected |
The activations.
Definition at line 242 of file StaticOptimizationIpopt.h.
|
staticprotected |
Maximal muscle activation.
Definition at line 229 of file StaticOptimizationIpopt.h.
|
protected |
Precision of the finite differentiate.
Definition at line 241 of file StaticOptimizationIpopt.h.
|
protected |
The final residual.
Definition at line 256 of file StaticOptimizationIpopt.h.
|
protected |
The final solution.
Definition at line 255 of file StaticOptimizationIpopt.h.
|
protected |
The model.
Definition at line 231 of file StaticOptimizationIpopt.h.
|
protected |
The number of degrees of freedom.
Definition at line 237 of file StaticOptimizationIpopt.h.
|
protected |
The number of muscles.
Definition at line 236 of file StaticOptimizationIpopt.h.
|
protected |
The number of generalized coordinates.
Definition at line 233 of file StaticOptimizationIpopt.h.
|
protected |
The number of generalized velocities.
Definition at line 235 of file StaticOptimizationIpopt.h.
|
protected |
The number of torques to match.
Definition at line 238 of file StaticOptimizationIpopt.h.
|
protected |
The number of torque residual.
Definition at line 240 of file StaticOptimizationIpopt.h.
|
protected |
The p-norm factor.
Definition at line 253 of file StaticOptimizationIpopt.h.
|
protected |
The generalized coordinates.
Definition at line 244 of file StaticOptimizationIpopt.h.
|
protected |
The generalized velocities.
Definition at line 246 of file StaticOptimizationIpopt.h.
|
protected |
The muscle states.
Definition at line 252 of file StaticOptimizationIpopt.h.
|
protected |
The torque ponderation.
Definition at line 250 of file StaticOptimizationIpopt.h.
|
protected |
The torque residual.
Definition at line 249 of file StaticOptimizationIpopt.h.
|
protected |
The torque to match.
Definition at line 248 of file StaticOptimizationIpopt.h.
|
protected |
Verbose level of IPOPT.
Definition at line 254 of file StaticOptimizationIpopt.h.