A collection of components which is treated as another Component. More...
#include <composite.h>
Public Member Functions | |
void | AddComponent (const Component::Ptr &) |
Adds a component to this composite. | |
void | ClearComponents () |
Removes all component from this composite. | |
Composite (const std::string &name, bool is_cost) | |
Creates a Composite holding either variables, costs or constraints. | |
VecBound | GetBounds () const override |
Returns the "bounds" of this component. | |
const Component::Ptr | GetComponent (std::string name) const |
Access generic component with the specified name. | |
template<typename T > | |
std::shared_ptr< T > | GetComponent (const std::string &name) const |
Access type-casted component with the specified name. | |
const ComponentVec | GetComponents () const |
Returns read access to the components. | |
Jacobian | GetJacobian () const override |
Returns derivatives of each row w.r.t. the variables. | |
VectorXd | GetValues () const override |
Returns the "values" of whatever this component represents. | |
void | PrintAll () const |
void | SetVariables (const VectorXd &x) override |
Sets the optimization variables from an Eigen vector. | |
virtual | ~Composite () |
Private Attributes | |
ComponentVec | components_ |
bool | is_cost_ |
A collection of components which is treated as another Component.
This class follows the Component interface as well, but doesn't actually do any evaluation, but only stitches together the results of the components it is holding. This is where multiple sets of variables, constraints or costs are ordered and combined.
See Component and Composite Pattern for more information.
Definition at line 162 of file composite.h.
ifopt::Composite::Composite | ( | const std::string & | name, |
bool | is_cost | ||
) |
Creates a Composite holding either variables, costs or constraints.
is_cost | True if this class holds cost terms, false for all others. |
Constraints and variables append individual constraint sets and Jacobian rows below one another, whereas costs terms are all accumulated to a scalar value/a single Jacobian row.
Definition at line 98 of file composite.cc.
virtual ifopt::Composite::~Composite | ( | ) | [virtual] |
void ifopt::Composite::AddComponent | ( | const Component::Ptr & | c | ) |
Adds a component to this composite.
Definition at line 104 of file composite.cc.
void ifopt::Composite::ClearComponents | ( | ) |
Removes all component from this composite.
Definition at line 118 of file composite.cc.
Composite::VecBound ifopt::Composite::GetBounds | ( | ) | const [override, virtual] |
Returns the "bounds" of this component.
Implements ifopt::Component.
Definition at line 191 of file composite.cc.
const Component::Ptr ifopt::Composite::GetComponent | ( | std::string | name | ) | const |
Access generic component with the specified name.
name | The name given to the component. |
Definition at line 125 of file composite.cc.
std::shared_ptr< T > ifopt::Composite::GetComponent | ( | const std::string & | name | ) | const |
Access type-casted component with the specified name.
name | The name given to the component. |
T | Type of component. |
Definition at line 224 of file composite.h.
const Composite::ComponentVec ifopt::Composite::GetComponents | ( | ) | const |
Returns read access to the components.
Definition at line 203 of file composite.cc.
Composite::Jacobian ifopt::Composite::GetJacobian | ( | ) | const [override, virtual] |
Returns derivatives of each row w.r.t. the variables.
Implements ifopt::Component.
Definition at line 164 of file composite.cc.
Composite::VectorXd ifopt::Composite::GetValues | ( | ) | const [override, virtual] |
Returns the "values" of whatever this component represents.
Implements ifopt::Component.
Definition at line 136 of file composite.cc.
void ifopt::Composite::PrintAll | ( | ) | const |
< tolerance when printing out constraint/bound violation.
Definition at line 209 of file composite.cc.
void ifopt::Composite::SetVariables | ( | const VectorXd & | x | ) | [override, virtual] |
Sets the optimization variables from an Eigen vector.
This is only done for Variable, where these are set from the current values of the solvers.
Implements ifopt::Component.
Definition at line 153 of file composite.cc.
ComponentVec ifopt::Composite::components_ [private] |
Definition at line 217 of file composite.h.
bool ifopt::Composite::is_cost_ [private] |
Definition at line 218 of file composite.h.