OpenSim Moco
0.4.0
|
A MocoParameter allows you to optimize property values in an OpenSim Model.
To describe this parameter, you must provide the name of the property you want to optimize and the path to the component in the model where the property exists. If the property is not a scalar, then you must also provide the element index of the property you want to optimize. To optimize multiple elements of a non-scalar property, use multiple MocoParameters. By specifying multiple component paths, you can optimize the same property in multiple components (each property will have the same value, as determined by this parameter). The following property types are currently supported:
List properties are not currently supported.
The name you give to a MocoParameter does not need to match the name of its model property.
Create a MocoParameter from a property in the model:
Using the convenience constructor:
Here is a Matlab example of optimizing the optimal fiber length of a muscle:
The generic constructor can be used for more complex MocoParameter assignments. Here, we create a MocoParameter for the y-position of the mass center of three different rigid bodies in the model:
#include <Moco/Moco/MocoParameter.h>
Public Member Functions | |
MocoParameter (const std::string &name, const std::vector< std::string > &componentPaths, const std::string &propertyName, const MocoBounds &, const int &propertyElt) | |
This is a generic constructor that supports applying this parameter to multiple components and to non-scalar properties. More... | |
MocoParameter (const std::string &name, const std::string &componentPath, const std::string &propertyName, const MocoBounds &) | |
MocoParameter (const std::string &name, const std::string &componentPath, const std::string &propertyName, const MocoBounds &, const int &propertyElt) | |
MocoParameter (const std::string &name, const std::vector< std::string > &componentPaths, const std::string &propertyName, const MocoBounds &) | |
MocoBounds | getBounds () const |
std::string | getPropertyName () const |
std::vector< std::string > | getComponentPaths () const |
void | setBounds (const MocoBounds &bounds) |
void | setPropertyName (const std::string &propertyName) |
void | appendComponentPath (const std::string &componentPath) |
void | initializeOnModel (Model &model) const |
For use by solvers. More... | |
void | applyParameterToModelProperties (const double &value) const |
Set the value of the stored model properties, which may include properties from multiple models. More... | |
void | printDescription (std::ostream &stream=std::cout) const |
Print the name, property name, component paths, property element (if it exists), and bounds for this parameter. More... | |
OpenSim::MocoParameter::MocoParameter | ( | const std::string & | name, |
const std::vector< std::string > & | componentPaths, | ||
const std::string & | propertyName, | ||
const MocoBounds & | , | ||
const int & | propertyElt | ||
) |
This is a generic constructor that supports applying this parameter to multiple components and to non-scalar properties.
Specifying propertyElt as -1 is treated as not specifying a property element.
void OpenSim::MocoParameter::applyParameterToModelProperties | ( | const double & | value | ) | const |
Set the value of the stored model properties, which may include properties from multiple models.
|
inline |
Note: the return value is constructed fresh on every call from the internal property. Avoid repeated calls to this function.
void OpenSim::MocoParameter::initializeOnModel | ( | Model & | model | ) | const |
For use by solvers.
This performs error checks and caches information about the model that is useful during the optimization. This method takes a non-const reference to the model because parameters need to be able to alter the model. If it is desired to apply this MocoParameter to multiple models, this should be called on all models of interest. The property references from each model will be append to this MocoParameter's internal property reference list.
void OpenSim::MocoParameter::printDescription | ( | std::ostream & | stream = std::cout | ) | const |
Print the name, property name, component paths, property element (if it exists), and bounds for this parameter.