Public Member Functions | Private Attributes
ifopt::Composite Class Reference

A collection of components which is treated as another Component. More...

#include <composite.h>

Inheritance diagram for ifopt::Composite:
Inheritance graph
[legend]

List of all members.

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_

Detailed Description

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.


Constructor & Destructor Documentation

ifopt::Composite::Composite ( const std::string &  name,
bool  is_cost 
)

Creates a Composite holding either variables, costs or constraints.

Parameters:
is_costTrue 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]

Member Function Documentation

void ifopt::Composite::AddComponent ( const Component::Ptr &  c)

Adds a component to this composite.

Definition at line 66 of file composite.cc.

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.

  • For Variable these are the upper and lower variable bound.
  • For Constraint this represents the constraint bounds.
  • For Cost these done't exists (set to infinity).

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.

Parameters:
nameThe name given to the component.
Returns:
A generic pointer of that component.

Definition at line 87 of file composite.cc.

template<typename T >
std::shared_ptr< T > ifopt::Composite::GetComponent ( const std::string &  name) const

Access type-casted component with the specified name.

Parameters:
nameThe name given to the component.
Template Parameters:
TType of component.
Returns:
A type-casted pointer possibly providing addtional functionality.

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.

  • For Constraint this is a matrix with one row per constraint.
  • For a Cost this is a row vector (gradient transpose).
  • Not sensible for Variable.

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.

  • For Variable this represents the actual optimization values.
  • For Constraint this represents the constraint value g.
  • For Cost this represents the cost value.

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.


Member Data Documentation

ComponentVec ifopt::Composite::components_ [private]

Definition at line 223 of file composite.h.

Definition at line 224 of file composite.h.


The documentation for this class was generated from the following files:


ifopt_core
Author(s): Alexander W. Winkler
autogenerated on Sat Apr 21 2018 03:01:48