Public Types | Public Member Functions | 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...
 
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...
 
- 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...
 

Friends

class EdgeSetInterface
 

Caching of edge values and block jacobians

int _edge_idx = 0
 
EdgeCache _cache
 
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
 
int getEdgeIdx () const
 Retrieve current edge index (warning, this value is determined within the related HyperGraph) More...
 

Detailed Description

Definition at line 129 of file edge_interface.h.

Member Typedef Documentation

◆ Ptr

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

Definition at line 134 of file edge_interface.h.

◆ UPtr

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

Definition at line 135 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 227 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 173 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 120 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::EdgeGenericScalarFun< VerticesT >, and corbo::EdgeGenericVectorFun< D, VerticesT >.

Definition at line 77 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 223 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::Edge<>, 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::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::TrapezoidalCollocationIntegralEqualityEdge, corbo::TrapezoidalIntegralEqualityEdge, corbo::EdgeGenericVectorFun< D, VerticesT >, corbo::TrapezoidalCollocationIntegralEqualityDynamicsEdge, corbo::TrapezoidalIntegralEqualityDynamicsEdge, corbo::TrapezoidalIntegralCostEdge, corbo::MSVariableDynamicsOnlyEdge, corbo::EdgeGenericScalarFun< VerticesT >, corbo::TrapezoidalCollocationIntegralCostEdge, corbo::QuadratureCollocationDynamicsOnly, corbo::L1StabInequalityEdge, 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 220 of file edge_interface.h.

◆ getCache() [1/2]

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

Retreive values computed previously via computeValuesCached()

Definition at line 226 of file edge_interface.h.

◆ getCache() [2/2]

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

Definition at line 227 of file edge_interface.h.

◆ getDimension()

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

◆ getEdgeIdx()

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

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

Definition at line 232 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::EdgeGenericScalarFun< VerticesT >, corbo::QuadratureCollocationDynamicsOnly, corbo::L1StabInequalityEdge, corbo::FDCollocationEdge, corbo::MSDynamicsOnlyEdge, corbo::TrapezoidalCollocationDynamicsOnlyEdge, corbo::L1StabCostEdge, and corbo::TwoScalarEqualEdge.

Definition at line 156 of file edge_interface.h.

◆ isLinear()

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

◆ providesHessian()

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

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

Definition at line 163 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 211 of file edge_interface.h.

◆ reserveJacobiansCacheMemory()

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

Definition at line 217 of file edge_interface.h.

◆ reserveValuesCacheMemory()

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

Definition at line 216 of file edge_interface.h.

Friends And Related Function Documentation

◆ EdgeSetInterface

friend class EdgeSetInterface
friend

Definition at line 131 of file edge_interface.h.

Member Data Documentation

◆ _cache

EdgeCache corbo::BaseEdge::_cache
protected

Definition at line 236 of file edge_interface.h.

◆ _edge_idx

int corbo::BaseEdge::_edge_idx = 0
protected

Definition at line 235 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 Wed Mar 2 2022 00:07:20