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 | Print () const override |
Prints the relevant information (name, rows, values) of this component. | |
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 168 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 60 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 66 of file composite.cc.
void ifopt::Composite::ClearComponents | ( | ) |
Removes all component from this composite.
Definition at line 80 of file composite.cc.
Composite::VecBound ifopt::Composite::GetBounds | ( | ) | const [override, virtual] |
Returns the "bounds" of this component.
Implements ifopt::Component.
Definition at line 149 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 87 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 230 of file composite.h.
const Composite::ComponentVec ifopt::Composite::GetComponents | ( | ) | const |
Returns read access to the components.
Definition at line 161 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 128 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 98 of file composite.cc.
void ifopt::Composite::Print | ( | ) | const [override, virtual] |
Prints the relevant information (name, rows, values) of this component.
Reimplemented from ifopt::Component.
Definition at line 169 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 NLP solvers.
Implements ifopt::Component.
Definition at line 116 of file composite.cc.
ComponentVec ifopt::Composite::components_ [private] |
Definition at line 223 of file composite.h.
bool ifopt::Composite::is_cost_ [private] |
Definition at line 224 of file composite.h.