A collection of components which is treated as another Component. More...
#include <composite.h>
Public Types | |
using | ComponentVec = std::vector< Component::Ptr > |
using | Ptr = std::shared_ptr< Composite > |
Public Types inherited from ifopt::Component | |
using | Jacobian = Eigen::SparseMatrix< double, Eigen::RowMajor > |
using | Ptr = std::shared_ptr< Component > |
using | VecBound = std::vector< Bounds > |
using | VectorXd = Eigen::VectorXd |
Public Member Functions | |
void | AddComponent (const Component::Ptr &) |
Adds a component to this composite. More... | |
void | ClearComponents () |
Removes all component from this composite. More... | |
Composite (const std::string &name, bool is_cost) | |
Creates a Composite holding either variables, costs or constraints. More... | |
VecBound | GetBounds () const override |
Returns the "bounds" of this component. More... | |
const Component::Ptr | GetComponent (std::string name) const |
Access generic component with the specified name. More... | |
template<typename T > | |
std::shared_ptr< T > | GetComponent (const std::string &name) const |
Access type-casted component with the specified name. More... | |
const ComponentVec | GetComponents () const |
Returns read access to the components. More... | |
Jacobian | GetJacobian () const override |
Returns derivatives of each row w.r.t. the variables. More... | |
VectorXd | GetValues () const override |
Returns the "values" of whatever this component represents. More... | |
void | PrintAll () const |
void | SetVariables (const VectorXd &x) override |
Sets the optimization variables from an Eigen vector. More... | |
virtual | ~Composite ()=default |
Public Member Functions inherited from ifopt::Component | |
Component (int num_rows, const std::string &name) | |
Creates a component. More... | |
std::string | GetName () const |
Returns the name (id) of this component. More... | |
int | GetRows () const |
Returns the number of rows of this component. More... | |
virtual void | Print (double tolerance, int &index_start) const |
Prints the relevant information (name, rows, values) of this component. More... | |
void | SetRows (int num_rows) |
Sets the number of rows of this component. More... | |
virtual | ~Component ()=default |
Private Attributes | |
ComponentVec | components_ |
bool | is_cost_ |
Additional Inherited Members | |
Static Public Attributes inherited from ifopt::Component | |
static const int | kSpecifyLater = -1 |
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.
using ifopt::Composite::ComponentVec = std::vector<Component::Ptr> |
Definition at line 165 of file composite.h.
using ifopt::Composite::Ptr = std::shared_ptr<Composite> |
Definition at line 164 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.
|
virtualdefault |
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.
|
overridevirtual |
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.
|
overridevirtual |
Returns derivatives of each row w.r.t. the variables.
Implements ifopt::Component.
Definition at line 164 of file composite.cc.
|
overridevirtual |
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.
|
overridevirtual |
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.
|
private |
Definition at line 217 of file composite.h.
|
private |
Definition at line 218 of file composite.h.