Interface representing either Variable, Cost or Constraint. More...
#include <composite.h>
Public Types | |
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 | |
Component (int num_rows, const std::string &name) | |
Creates a component. More... | |
virtual VecBound | GetBounds () const =0 |
Returns the "bounds" of this component. More... | |
virtual Jacobian | GetJacobian () const =0 |
Returns derivatives of each row w.r.t. the variables. 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 VectorXd | GetValues () const =0 |
Returns the "values" of whatever this component represents. 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 void | SetVariables (const VectorXd &x)=0 |
Sets the optimization variables from an Eigen vector. More... | |
virtual | ~Component ()=default |
Static Public Attributes | |
static const int | kSpecifyLater = -1 |
Private Attributes | |
std::string | name_ |
int | num_rows_ = kSpecifyLater |
Interface representing either Variable, Cost or Constraint.
Variables, costs and constraints can all be fit into the same interface (Component). For example, each has a "value", which is either the actual value of the variables, the constraint value g or the cost. This representation provides one common interface ("smallest common denominator") that can be contain either individual variables/costs/constraints or a Composite of these. This pattern takes care of stacking variables, ordering Jacobians and providing bounds for the complete problem without duplicating code. For more information on the composite pattern visit https://sourcemaking.com/design_patterns/composite
Definition at line 63 of file composite.h.
using ifopt::Component::Jacobian = Eigen::SparseMatrix<double, Eigen::RowMajor> |
Definition at line 67 of file composite.h.
using ifopt::Component::Ptr = std::shared_ptr<Component> |
Definition at line 65 of file composite.h.
using ifopt::Component::VecBound = std::vector<Bounds> |
Definition at line 69 of file composite.h.
using ifopt::Component::VectorXd = Eigen::VectorXd |
Definition at line 68 of file composite.h.
ifopt::Component::Component | ( | int | num_rows, |
const std::string & | name | ||
) |
Creates a component.
num_rows | The number of rows of this components. |
name | The identifier for this component. |
The number of rows num_rows
can represent either
Definition at line 64 of file composite.cc.
|
virtualdefault |
|
pure virtual |
Returns the "bounds" of this component.
Implemented in ifopt::Composite, ifopt::ExConstraint, ifopt::ExVariables, ifopt::CostTerm, and ifopt::ExComponent.
|
pure virtual |
Returns derivatives of each row w.r.t. the variables.
Implemented in ifopt::Composite, ifopt::ConstraintSet, ifopt::VariableSet, and ifopt::ExComponent.
std::string ifopt::Component::GetName | ( | ) | const |
Returns the name (id) of this component.
Definition at line 80 of file composite.cc.
int ifopt::Component::GetRows | ( | ) | const |
Returns the number of rows of this component.
Definition at line 70 of file composite.cc.
|
pure virtual |
Returns the "values" of whatever this component represents.
Implemented in ifopt::Composite, ifopt::ExConstraint, ifopt::ExVariables, ifopt::CostTerm, and ifopt::ExComponent.
|
virtual |
Prints the relevant information (name, rows, values) of this component.
tolerance | When to flag constraint/bound violation. |
index_start | Of this specific variables-, constraint- or cost set. |
Reimplemented in ifopt::CostTerm.
Definition at line 85 of file composite.cc.
void ifopt::Component::SetRows | ( | int | num_rows | ) |
Sets the number of rows of this component.
kSpecifyLater
if you have good reason. Definition at line 75 of file composite.cc.
|
pure 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.
Implemented in ifopt::Composite, ifopt::ExVariables, ifopt::ExComponent, and ifopt::ConstraintSet.
|
static |
Definition at line 143 of file composite.h.
|
private |
Definition at line 147 of file composite.h.
|
private |
Definition at line 146 of file composite.h.