Biorbd Release_1.13.0
Loading...
Searching...
No Matches
BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpoptLinearized Class Reference

The actual implementation of the Static Optimization problem using a linearized approach. More...

#include <StaticOptimizationIpoptLinearized.h>

Inheritance diagram for BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpoptLinearized:
BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpopt

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ StaticOptimizationIpoptLinearized()

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.

Parameters
modelThe musculoskeletal Model
QThe generalized coordinates
QdotThe generalized velocities
torqueTargetThe generalized torque target
activationInitThe initial activation, also used as the reference activation of the linearization
useResidualIf use residual torque, if set to false, the optimization will fail if the model is not strong enough
pNormFactorThe p-norm to perform
verboseLevel of IPOPT verbose you want
epsThe precision to perform the finite diffentiation

Definition at line 14 of file StaticOptimizationIpoptLinearized.cpp.

◆ ~StaticOptimizationIpoptLinearized()

internal_forces::muscles::StaticOptimizationIpoptLinearized::~StaticOptimizationIpoptLinearized ( )
virtual

Destroy class properly.

Definition at line 76 of file StaticOptimizationIpoptLinearized.cpp.

Member Function Documentation

◆ eval_g()

bool internal_forces::muscles::StaticOptimizationIpoptLinearized::eval_g ( Ipopt::Index n,
const Ipopt::Number * x,
bool new_x,
Ipopt::Index m,
Ipopt::Number * g )
virtual

Method to return the constraint residuals.

Parameters
nThe number of variables
xThe values of the variables
new_xIf the variables were modified by IPOPT
mThe number of constraints
gThe actual contraints residual
Returns
Return the presence of that function

Reimplemented from BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpopt.

Definition at line 79 of file StaticOptimizationIpoptLinearized.cpp.

◆ eval_jac_g()

bool internal_forces::muscles::StaticOptimizationIpoptLinearized::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 )
virtual

Return the jacobian of contraints.

Parameters
nThe number of variables
xThe values of the variables
new_xIf the variables were modified by IPOPT
mThe number of constraints
nele_jacNumber of elements in the jacobian matrix
iRowiterator on the rows of the jacobian
jColiterator on the columns of the jacobian
valuesThe actual constraint jacobian
Returns
Return the presence of that function

Reimplemented from BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpopt.

Definition at line 110 of file StaticOptimizationIpoptLinearized.cpp.

◆ prepareJacobian()

void internal_forces::muscles::StaticOptimizationIpoptLinearized::prepareJacobian ( )
protected

Setup the constant constraints jacobian.

Definition at line 40 of file StaticOptimizationIpoptLinearized.cpp.

Member Data Documentation

◆ m_jacobian

std::shared_ptr<utils::Matrix> BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpoptLinearized::m_jacobian
protected

The constraints jacobian.

Definition at line 100 of file StaticOptimizationIpoptLinearized.h.

◆ m_torquePassive

std::shared_ptr<utils::Vector> BIORBD_NAMESPACE::internal_forces::muscles::StaticOptimizationIpoptLinearized::m_torquePassive
protected

The muscle torque when not activated.

Definition at line 102 of file StaticOptimizationIpoptLinearized.h.


The documentation for this class was generated from the following files: