Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
corbo::BaseEdge Class Referenceabstract

#include <edge_interface.h>

Inheritance diagram for corbo::BaseEdge:
Inheritance graph
[legend]

Public Types

using Ptr = std::shared_ptr< BaseEdge >
 
using UPtr = std::unique_ptr< BaseEdge >
 
- Public Types inherited from corbo::EdgeInterface
using Ptr = std::shared_ptr< EdgeInterface >
 
using UPtr = std::unique_ptr< EdgeInterface >
 

Public Member Functions

virtual void computeHessian (int vtx_idx_i, int vtx_idx_j, const Eigen::Ref< const Eigen::MatrixXd > &block_jacobian_i, Eigen::Ref< Eigen::MatrixXd > block_hessian_ij, const double *multipliers=nullptr, double weight=1.0)
 
virtual void computeHessianInc (int vtx_idx_i, int vtx_idx_j, const Eigen::Ref< const Eigen::MatrixXd > &block_jacobian_i, Eigen::Ref< Eigen::MatrixXd > block_hessian_ij, const double *multipliers=nullptr, double weight=1.0)
 Compute edge block Hessian for a given vertex pair. More...
 
virtual void computeHessianInc (int vtx_idx_i, int vtx_idx_j, Eigen::Ref< Eigen::MatrixXd > block_hessian_ij, const double *multipliers=nullptr, double weight=1.0)
 
virtual void computeJacobian (int vtx_idx, Eigen::Ref< Eigen::MatrixXd > block_jacobian, const double *multipliers=nullptr)
 Compute edge block jacobian for a given vertex. More...
 
void computeValues (Eigen::Ref< Eigen::VectorXd > values) override=0
 Compute function values. More...
 
int getDimension () const override=0
 Get dimension of the edge (dimension of the cost-function/constraint value vector) More...
 
int getEdgeIdx () const
 Retrieve current edge index (warning, this value is determined within the related HyperGraph) More...
 
virtual bool isLeastSquaresForm () const
 Defines if the edge is formulated as Least-Squares form. More...
 
virtual bool isLinear () const
 Return true if the edge is linear (and hence its Hessian is always zero) More...
 
virtual bool providesHessian () const
 Return true if a custom Hessian is provided (e.g. computeHessian() is overwritten) More...
 
virtual bool providesJacobian () const
 Return true if a custom Jacobian is provided (e.g. computeJacobian() is overwritten) More...
 
Caching of edge values and block jacobians
void reserveCacheMemory (int num_value_vectors, int num_jacobians)
 
void reserveValuesCacheMemory (int num_value_vectors)
 
void reserveJacobiansCacheMemory (int num_jacobians)
 
void computeValuesCached ()
 Call computeValues() and store result to previously allocated internal cache (call allocateInteralValuesCache() first once) More...
 
void computeSquaredNormOfValuesCached ()
 compute the specialied squared-norm method for computing the values (note only the first element in the values cache is used) More...
 
EdgeCachegetCache ()
 Retreive values computed previously via computeValuesCached() More...
 
const EdgeCachegetCache () const
 
- Public Member Functions inherited from corbo::EdgeInterface
virtual double computeSquaredNormOfValues ()
 
virtual double computeSumOfValues ()
 
int getNumFiniteVerticesLowerBounds () const
 
int getNumFiniteVerticesUpperBounds () const
 
virtual int getNumVertices () const =0
 Return number of attached vertices. More...
 
virtual const VertexInterfacegetVertex (int idx) const =0
 
virtual VertexInterfacegetVertexRaw (int idx)=0
 Get access to vertex with index idx (0 <= idx < numVertices) More...
 
virtual int verticesDimension () const =0
 Return the combined dimension of all attached vertices (excluding fixed vertex components) More...
 
virtual ~EdgeInterface ()
 Virtual destructor. More...
 

Protected Attributes

EdgeCache _cache
 
int _edge_idx = 0
 

Friends

class EdgeSetInterface
 

Detailed Description

Definition at line 107 of file edge_interface.h.

Member Typedef Documentation

◆ Ptr

using corbo::BaseEdge::Ptr = std::shared_ptr<BaseEdge>

Definition at line 112 of file edge_interface.h.

◆ UPtr

using corbo::BaseEdge::UPtr = std::unique_ptr<BaseEdge>

Definition at line 113 of file edge_interface.h.

Member Function Documentation

◆ computeHessian()

void corbo::BaseEdge::computeHessian ( int  vtx_idx_i,
int  vtx_idx_j,
const Eigen::Ref< const Eigen::MatrixXd > &  block_jacobian_i,
Eigen::Ref< Eigen::MatrixXd >  block_hessian_ij,
const double *  multipliers = nullptr,
double  weight = 1.0 
)
virtual

Definition at line 205 of file edge_interface.cpp.

◆ computeHessianInc() [1/2]

void corbo::BaseEdge::computeHessianInc ( int  vtx_idx_i,
int  vtx_idx_j,
const Eigen::Ref< const Eigen::MatrixXd > &  block_jacobian_i,
Eigen::Ref< Eigen::MatrixXd >  block_hessian_ij,
const double *  multipliers = nullptr,
double  weight = 1.0 
)
virtual

Compute edge block Hessian for a given vertex pair.

This interface class provides a numerical computation of the Hessian using finite differences. However, a user-defined implementation might be specified by overwriting this method. In that case do not forget to also overwrite providesHessian().

Given two vertices i and j, four matrices can be computed: Hii, Hij, Hji, Hjj. However, usually it is Hij = Hji.

Parameters
[in]vtx_idx_iFirst vertex number
[in]vtx_idx_jSecond vertex number
[in]block_jacobian_iBlock jacobian for vertex i which might be taken into account: [dimension() x VertexInterface::dimensionUnfixed()] (must be preallocated)
[out]block_hessian_ijResulting block hessian for vertex pair i and j: [VertexInterface::dimensionUnfixed() x VertexInterface::dimensionUnfixed()]
[in]multipliersScale each value component by an optional multiplier if argument is not null

Definition at line 151 of file edge_interface.cpp.

◆ computeHessianInc() [2/2]

void corbo::BaseEdge::computeHessianInc ( int  vtx_idx_i,
int  vtx_idx_j,
Eigen::Ref< Eigen::MatrixXd >  block_hessian_ij,
const double *  multipliers = nullptr,
double  weight = 1.0 
)
virtual

Definition at line 98 of file edge_interface.cpp.

◆ computeJacobian()

void corbo::BaseEdge::computeJacobian ( int  vtx_idx,
Eigen::Ref< Eigen::MatrixXd >  block_jacobian,
const double *  multipliers = nullptr 
)
virtual

Compute edge block jacobian for a given vertex.

This interface class provides a numerical computation of the Jacobian using finite differences. However, a user-defined implementation might be specified by overwriting this method. In that case do not forget to also overwrite providesJacobian().

Parameters
[in]vtx_idxVertex number for which the block jacobian should be computed
[out]block_jacobianResulting block jacobian [dimension() x VertexInterface::dimensionUnfixed()] (must be preallocated)
[in]multipliersScale each value component by an optional multiplier if argument is not null null.

Reimplemented in corbo::EdgeGenericVectorFun< D, VerticesT >, and corbo::EdgeGenericScalarFun< VerticesT >.

Definition at line 55 of file edge_interface.cpp.

◆ computeSquaredNormOfValuesCached()

void corbo::BaseEdge::computeSquaredNormOfValuesCached ( )
inline

compute the specialied squared-norm method for computing the values (note only the first element in the values cache is used)

Definition at line 201 of file edge_interface.h.

◆ computeValues()

void corbo::BaseEdge::computeValues ( Eigen::Ref< Eigen::VectorXd >  values)
overridepure virtual

Compute function values.

Here, the actual cost/constraint function values are computed:

  • objective in non-least-squares form: e(x) (hereby, the actual cost is f(x) = e(x)^T e(x))
  • objective in least-squares form: f(x)
  • equality constraints: ceq(x) (in case constraints are satisfied: ceq(x) = 0)
  • inequality constraints: c(x) (in case constraints are satisfied: c(x) < 0)
    Parameters
    [in]valuesvalues should be stored here according to getDimension().

Implements corbo::EdgeInterface.

Implemented in corbo::UncompressedCollocationEdge, corbo::MSDynamicsOnlyMultiControlsMultiDtsEdge, corbo::MSDynamicsOnlyMultiControlsEdge, corbo::CompressedCollocationMultipleControlsEdge, corbo::TernaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::LeftSumInequalityEdge, corbo::BinaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::CompressedCollocationEdge, corbo::BinaryVectorVertexEdge< T, ComputeMethod >, corbo::LeftSumEqualityEdge, corbo::UnaryScalarVertexEdge< T, ComputeMethod >, corbo::LeftSumCostEdge, corbo::UnaryVectorVertexEdge< T, ComputeMethod >, corbo::TrapezoidalCollocationIntegralInequalityEdge, corbo::TrapezoidalIntegralInequalityEdge, corbo::Edge<>, corbo::TrapezoidalCollocationIntegralEqualityEdge, corbo::TrapezoidalIntegralEqualityEdge, corbo::Edge< Vertices >, corbo::Edge< VectorVertex, VectorVertex >, corbo::Edge< VerticesT... >, corbo::Edge< VectorVertex >, corbo::Edge< VectorVertex, VectorVertex, VectorVertex >, corbo::Edge< ScalarVertex >, corbo::Edge< VectorVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, ScalarVertex >, corbo::Edge< ScalarVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, VectorVertex, VectorVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, VectorVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, ScalarVertex, VectorVertex, VectorVertex >, corbo::EdgeGenericVectorFun< D, VerticesT >, corbo::TrapezoidalCollocationIntegralEqualityDynamicsEdge, corbo::TrapezoidalIntegralEqualityDynamicsEdge, corbo::TrapezoidalIntegralCostEdge, corbo::MSVariableDynamicsOnlyEdge, corbo::TrapezoidalCollocationIntegralCostEdge, corbo::L1StabInequalityEdge, corbo::EdgeGenericScalarFun< VerticesT >, corbo::QuadratureCollocationDynamicsOnly, corbo::FDCollocationEdge, corbo::MSDynamicsOnlyEdge, corbo::TrapezoidalCollocationDynamicsOnlyEdge, corbo::L1StabCostEdge, and corbo::TwoScalarEqualEdge.

◆ computeValuesCached()

void corbo::BaseEdge::computeValuesCached ( )
inline

Call computeValues() and store result to previously allocated internal cache (call allocateInteralValuesCache() first once)

Definition at line 198 of file edge_interface.h.

◆ getCache() [1/2]

EdgeCache& corbo::BaseEdge::getCache ( )
inline

Retreive values computed previously via computeValuesCached()

Definition at line 204 of file edge_interface.h.

◆ getCache() [2/2]

const EdgeCache& corbo::BaseEdge::getCache ( ) const
inline

Definition at line 205 of file edge_interface.h.

◆ getDimension()

int corbo::BaseEdge::getDimension ( ) const
overridepure virtual

Get dimension of the edge (dimension of the cost-function/constraint value vector)

Implements corbo::EdgeInterface.

Implemented in corbo::UncompressedCollocationEdge, corbo::MSDynamicsOnlyMultiControlsMultiDtsEdge, corbo::MSDynamicsOnlyMultiControlsEdge, corbo::CompressedCollocationMultipleControlsEdge, corbo::TernaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::LeftSumInequalityEdge, corbo::BinaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::CompressedCollocationEdge, corbo::LeftSumEqualityEdge, corbo::BinaryVectorVertexEdge< T, ComputeMethod >, corbo::UnaryScalarVertexEdge< T, ComputeMethod >, corbo::LeftSumCostEdge, corbo::UnaryVectorVertexEdge< T, ComputeMethod >, corbo::TrapezoidalCollocationIntegralInequalityEdge, corbo::TrapezoidalIntegralInequalityEdge, corbo::Edge<>, corbo::TrapezoidalCollocationIntegralEqualityEdge, corbo::TrapezoidalIntegralEqualityEdge, corbo::Edge< Vertices >, corbo::Edge< VectorVertex, VectorVertex >, corbo::Edge< VerticesT... >, corbo::Edge< VectorVertex >, corbo::Edge< VectorVertex, VectorVertex, VectorVertex >, corbo::Edge< ScalarVertex >, corbo::Edge< VectorVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, ScalarVertex >, corbo::Edge< ScalarVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, VectorVertex, VectorVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, VectorVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, ScalarVertex, VectorVertex, VectorVertex >, corbo::EdgeGenericVectorFun< D, VerticesT >, corbo::TrapezoidalCollocationIntegralEqualityDynamicsEdge, corbo::TrapezoidalIntegralEqualityDynamicsEdge, corbo::TrapezoidalIntegralCostEdge, corbo::TrapezoidalCollocationIntegralCostEdge, corbo::MSVariableDynamicsOnlyEdge, corbo::L1StabInequalityEdge, corbo::EdgeGenericScalarFun< VerticesT >, corbo::QuadratureCollocationDynamicsOnly, corbo::FDCollocationEdge, corbo::MSDynamicsOnlyEdge, corbo::TrapezoidalCollocationDynamicsOnlyEdge, corbo::L1StabCostEdge, and corbo::TwoScalarEqualEdge.

◆ getEdgeIdx()

int corbo::BaseEdge::getEdgeIdx ( ) const
inline

Retrieve current edge index (warning, this value is determined within the related HyperGraph)

Definition at line 210 of file edge_interface.h.

◆ isLeastSquaresForm()

virtual bool corbo::BaseEdge::isLeastSquaresForm ( ) const
inlinevirtual

Defines if the edge is formulated as Least-Squares form.

Least-squares cost terms are defined as $ f(x) = e(x)^T e(x) $ and the function values and Jacobian are computed for $ e(x) $ rather than for $ f(x) $. Specialiezed least-squares solvers require the optimization problem to be defined in this particular form. Other solvers can automatically compute the square of least-squares edges if required. However, the other way round is more restrictive: general solvers might not cope with non-least-squares forms.

Note, in the LS-form case computeValues() computes e(x) and otherwise f(x).

Returns
true if the edge is given in LS-form

Reimplemented in corbo::UncompressedCollocationEdge, corbo::MSDynamicsOnlyMultiControlsMultiDtsEdge, corbo::MSDynamicsOnlyMultiControlsEdge, corbo::CompressedCollocationMultipleControlsEdge, corbo::TernaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::LeftSumInequalityEdge, corbo::BinaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::CompressedCollocationEdge, corbo::LeftSumEqualityEdge, corbo::BinaryVectorVertexEdge< T, ComputeMethod >, corbo::UnaryScalarVertexEdge< T, ComputeMethod >, corbo::LeftSumCostEdge, corbo::UnaryVectorVertexEdge< T, ComputeMethod >, corbo::TrapezoidalCollocationIntegralInequalityEdge, corbo::TrapezoidalIntegralInequalityEdge, corbo::TrapezoidalCollocationIntegralEqualityEdge, corbo::TrapezoidalIntegralEqualityEdge, corbo::TrapezoidalCollocationIntegralEqualityDynamicsEdge, corbo::EdgeGenericVectorFun< D, VerticesT >, corbo::TrapezoidalIntegralEqualityDynamicsEdge, corbo::TrapezoidalIntegralCostEdge, corbo::MSVariableDynamicsOnlyEdge, corbo::TrapezoidalCollocationIntegralCostEdge, corbo::L1StabInequalityEdge, corbo::EdgeGenericScalarFun< VerticesT >, corbo::QuadratureCollocationDynamicsOnly, corbo::FDCollocationEdge, corbo::MSDynamicsOnlyEdge, corbo::TrapezoidalCollocationDynamicsOnlyEdge, corbo::L1StabCostEdge, and corbo::TwoScalarEqualEdge.

Definition at line 134 of file edge_interface.h.

◆ isLinear()

virtual bool corbo::BaseEdge::isLinear ( ) const
inlinevirtual

Return true if the edge is linear (and hence its Hessian is always zero)

Reimplemented in corbo::UncompressedCollocationEdge, corbo::MSDynamicsOnlyMultiControlsMultiDtsEdge, corbo::MSDynamicsOnlyMultiControlsEdge, corbo::CompressedCollocationMultipleControlsEdge, corbo::TernaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::LeftSumInequalityEdge, corbo::BinaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::CompressedCollocationEdge, corbo::LeftSumEqualityEdge, corbo::BinaryVectorVertexEdge< T, ComputeMethod >, corbo::UnaryScalarVertexEdge< T, ComputeMethod >, corbo::LeftSumCostEdge, corbo::UnaryVectorVertexEdge< T, ComputeMethod >, corbo::TrapezoidalCollocationIntegralInequalityEdge, corbo::TrapezoidalIntegralInequalityEdge, corbo::Edge<>, corbo::TrapezoidalCollocationIntegralEqualityEdge, corbo::TrapezoidalIntegralEqualityEdge, corbo::Edge< Vertices >, corbo::Edge< VectorVertex, VectorVertex >, corbo::Edge< VerticesT... >, corbo::Edge< VectorVertex >, corbo::Edge< VectorVertex, VectorVertex, VectorVertex >, corbo::Edge< ScalarVertex >, corbo::Edge< VectorVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, ScalarVertex >, corbo::Edge< ScalarVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, VectorVertex, VectorVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, VectorVertex, ScalarVertex >, corbo::Edge< VectorVertex, VectorVertex, ScalarVertex, VectorVertex, VectorVertex >, corbo::EdgeGenericVectorFun< D, VerticesT >, corbo::TrapezoidalCollocationIntegralEqualityDynamicsEdge, corbo::TrapezoidalIntegralEqualityDynamicsEdge, corbo::TrapezoidalIntegralCostEdge, corbo::MSVariableDynamicsOnlyEdge, corbo::TrapezoidalCollocationIntegralCostEdge, corbo::L1StabInequalityEdge, corbo::EdgeGenericScalarFun< VerticesT >, corbo::QuadratureCollocationDynamicsOnly, corbo::FDCollocationEdge, corbo::MSDynamicsOnlyEdge, corbo::TrapezoidalCollocationDynamicsOnlyEdge, corbo::L1StabCostEdge, and corbo::TwoScalarEqualEdge.

Definition at line 137 of file edge_interface.h.

◆ providesHessian()

virtual bool corbo::BaseEdge::providesHessian ( ) const
inlinevirtual

Return true if a custom Hessian is provided (e.g. computeHessian() is overwritten)

Definition at line 141 of file edge_interface.h.

◆ providesJacobian()

virtual bool corbo::BaseEdge::providesJacobian ( ) const
inlinevirtual

◆ reserveCacheMemory()

void corbo::BaseEdge::reserveCacheMemory ( int  num_value_vectors,
int  num_jacobians 
)
inline

Definition at line 189 of file edge_interface.h.

◆ reserveJacobiansCacheMemory()

void corbo::BaseEdge::reserveJacobiansCacheMemory ( int  num_jacobians)
inline

Definition at line 195 of file edge_interface.h.

◆ reserveValuesCacheMemory()

void corbo::BaseEdge::reserveValuesCacheMemory ( int  num_value_vectors)
inline

Definition at line 194 of file edge_interface.h.

Friends And Related Function Documentation

◆ EdgeSetInterface

friend class EdgeSetInterface
friend

Definition at line 109 of file edge_interface.h.

Member Data Documentation

◆ _cache

EdgeCache corbo::BaseEdge::_cache
protected

Definition at line 214 of file edge_interface.h.

◆ _edge_idx

int corbo::BaseEdge::_edge_idx = 0
protected

Definition at line 213 of file edge_interface.h.


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


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:08:02