OpenSim Moco  0.4.0
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
OpenSim::MocoProblem Class Reference

Description

A description of an optimal control problem, backed by OpenSim Models.

A MocoProblem is a series of phases, each of which contains the following:

Currently, only single-phase problems are supported. This class has convenience methods to configure the first (0-th) phase.

This class allows you to define your problem, but does not let you do anything with your problem (this class only contains user input). Use createRep() to create an instance of MocoProblemRep, which provides additional functionality.

Examples:
example2DWalking.cpp, exampleMarkerTracking.cpp, exampleMocoCustomEffortGoal.cpp, exampleMocoInverse.cpp, exampleMocoTrack.cpp, exampleSlidingMass.cpp, exampleSlidingMassAdvanced.cpp, and exampleTracking.cpp.
Inheritance diagram for OpenSim::MocoProblem:

#include <Moco/Moco/MocoProblem.h>

Public Member Functions

MocoPhaseupdPhase (int index=0)
 Get a modifiable phase of the problem by index (starting index of 0). More...
 
const MocoPhasegetPhase (int index=0) const
 Get a modifiable phase of the problem by index (starting index of 0). More...
 
MocoProblemRep createRep () const
 Create an instance of MocoProblemRep, which fills in additional state and control bounds, and allows you to apply parameter values and evaluate the goals. More...
 
Convenience methods for phase 0.

These methods allow you to conveniently edit phase 0 of the problem.

See MocoPhase's documentation for more information.

Model * setModel (std::unique_ptr< Model > model)
 Set the model to use for phase 0. More...
 
Model * setModelCopy (Model model)
 Set the model to use for phase 0. More...
 
Model & updModel ()
 Update the model in phase 0.
 
void setModelProcessor (ModelProcessor model)
 Set a model processor for phase 0. More...
 
void setTimeBounds (const MocoInitialBounds &, const MocoFinalBounds &)
 Set time bounds for phase 0.
 
void printStateNamesWithSubstring (const std::string &name)
 Find and print the names of all state variables containing a substring.
 
void setStateInfo (const std::string &name, const MocoBounds &, const MocoInitialBounds &={}, const MocoFinalBounds &={})
 Set bounds for a state variable for phase 0.
 
void setStateInfoPattern (const std::string &pattern, const MocoBounds &bounds, const MocoInitialBounds &init={}, const MocoFinalBounds &final={})
 Set bounds for all state variables for phase 0 whose path matches the provided pattern. More...
 
void printControlNamesWithSubstring (const std::string &name)
 Find and print the names of all state variables containing a substring.
 
void setControlInfo (const std::string &name, const MocoBounds &, const MocoInitialBounds &={}, const MocoFinalBounds &={})
 Set bounds for a control variable for phase 0.
 
void setControlInfoPattern (const std::string &pattern, const MocoBounds &, const MocoInitialBounds &={}, const MocoFinalBounds &={})
 Set bounds for a control variable using a regular expression.
 
void setKinematicConstraintBounds (const MocoBounds &bounds)
 Set bounds for the kinematic constraints in phase 0.
 
void setMultiplierBounds (const MocoBounds &bounds)
 Set bounds for the Lagrange multipliers in phase 0.
 
template<typename MocoParamType = MocoParameter, typename... Args>
MocoParamType * addParameter (Args &&... args)
 Add a parameter variable for phase 0. More...
 
template<typename MocoParamType = MocoParameter>
MocoParamType * addParameter (std::unique_ptr< MocoParamType > param)
 Add a parameter variable for phase 0.
 
template<typename MocoGoalType , typename... Args>
MocoGoalType * addGoal (Args &&... args)
 Add a goal for phase 0. More...
 
template<typename MocoGoalType >
MocoGoalType * addGoal (std::unique_ptr< MocoGoalType > goal)
 Add a goal for phase 0.
 
MocoGoalupdGoal (const std::string &name)
 Returns a reference to the goal with name "name" in phase 0.
 
template<typename MocoPCType , typename... Args>
MocoPCType * addPathConstraint (Args &&... args)
 Add a constraint for phase 0. More...
 
template<typename MocoPCType >
MocoPCType * addPathConstraint (std::unique_ptr< MocoPCType > pc)
 Add a constraint for phase 0.
 

Public Attributes

friend MocoProblemRep
 

Protected Member Functions

 OpenSim_DECLARE_LIST_PROPERTY_SIZE (phases, MocoPhase, 1, "List of 1 or more MocoPhases.")
 

Member Function Documentation

◆ addGoal()

template<typename MocoGoalType , typename... Args>
MocoGoalType* OpenSim::MocoProblem::addGoal ( Args &&...  args)
inline

◆ addParameter()

template<typename MocoParamType = MocoParameter, typename... Args>
MocoParamType* OpenSim::MocoProblem::addParameter ( Args &&...  args)
inline

Add a parameter variable for phase 0.

See also
MocoPhase::addParameter()

◆ addPathConstraint()

template<typename MocoPCType , typename... Args>
MocoPCType* OpenSim::MocoProblem::addPathConstraint ( Args &&...  args)
inline

Add a constraint for phase 0.

See also
MocoPhase::addPathConstraint()

◆ createRep()

MocoProblemRep OpenSim::MocoProblem::createRep ( ) const
inline

Create an instance of MocoProblemRep, which fills in additional state and control bounds, and allows you to apply parameter values and evaluate the goals.

This function will check your problem for various errors.

◆ getPhase()

const MocoPhase& OpenSim::MocoProblem::getPhase ( int  index = 0) const
inline

Get a modifiable phase of the problem by index (starting index of 0).

This accesses the internal phases property.

◆ setModel()

Model* OpenSim::MocoProblem::setModel ( std::unique_ptr< Model >  model)

◆ setModelCopy()

Model* OpenSim::MocoProblem::setModelCopy ( Model  model)

Set the model to use for phase 0.

See also
MocoPhase::setModelCopy().

◆ setModelProcessor()

void OpenSim::MocoProblem::setModelProcessor ( ModelProcessor  model)

Set a model processor for phase 0.

See also
MocoPhase::setModelProcessor().
Examples:
example2DWalking.cpp.

◆ setStateInfoPattern()

void OpenSim::MocoProblem::setStateInfoPattern ( const std::string &  pattern,
const MocoBounds bounds,
const MocoInitialBounds init = {},
const MocoFinalBounds final = {} 
)

Set bounds for all state variables for phase 0 whose path matches the provided pattern.

◆ updPhase()

MocoPhase& OpenSim::MocoProblem::updPhase ( int  index = 0)
inline

Get a modifiable phase of the problem by index (starting index of 0).

This accesses the internal phases property.


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