#include <edge_interface.h>
Public Types | |
using | Ptr = std::shared_ptr< BaseEdge > |
using | UPtr = std::unique_ptr< BaseEdge > |
![]() | |
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... | |
EdgeCache & | getCache () |
Retreive values computed previously via computeValuesCached() More... | |
const EdgeCache & | getCache () const |
![]() | |
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 VertexInterface * | getVertex (int idx) const =0 |
virtual VertexInterface * | getVertexRaw (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 |
Definition at line 107 of file edge_interface.h.
using corbo::BaseEdge::Ptr = std::shared_ptr<BaseEdge> |
Definition at line 112 of file edge_interface.h.
using corbo::BaseEdge::UPtr = std::unique_ptr<BaseEdge> |
Definition at line 113 of file edge_interface.h.
|
virtual |
Definition at line 205 of file edge_interface.cpp.
|
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.
[in] | vtx_idx_i | First vertex number |
[in] | vtx_idx_j | Second vertex number |
[in] | block_jacobian_i | Block jacobian for vertex i which might be taken into account: [dimension() x VertexInterface::dimensionUnfixed()] (must be preallocated) |
[out] | block_hessian_ij | Resulting block hessian for vertex pair i and j: [VertexInterface::dimensionUnfixed() x VertexInterface::dimensionUnfixed()] |
[in] | multipliers | Scale each value component by an optional multiplier if argument is not null |
Definition at line 151 of file edge_interface.cpp.
|
virtual |
Definition at line 98 of file edge_interface.cpp.
|
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().
[in] | vtx_idx | Vertex number for which the block jacobian should be computed |
[out] | block_jacobian | Resulting block jacobian [dimension() x VertexInterface::dimensionUnfixed()] (must be preallocated) |
[in] | multipliers | Scale 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.
|
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.
|
overridepure virtual |
Compute function values.
Here, the actual cost/constraint function values are computed:
[in] | values | values 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.
|
inline |
Call computeValues() and store result to previously allocated internal cache (call allocateInteralValuesCache() first once)
Definition at line 198 of file edge_interface.h.
|
inline |
Retreive values computed previously via computeValuesCached()
Definition at line 204 of file edge_interface.h.
|
inline |
Definition at line 205 of file edge_interface.h.
|
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.
|
inline |
Retrieve current edge index (warning, this value is determined within the related HyperGraph)
Definition at line 210 of file edge_interface.h.
|
inlinevirtual |
Defines if the edge is formulated as Least-Squares form.
Least-squares cost terms are defined as and the function values and Jacobian are computed for
rather than for
. 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).
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.
|
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.
|
inlinevirtual |
Return true if a custom Hessian is provided (e.g. computeHessian() is overwritten)
Definition at line 141 of file edge_interface.h.
|
inlinevirtual |
Return true if a custom Jacobian is provided (e.g. computeJacobian() is overwritten)
Reimplemented in corbo::TernaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::BinaryVectorScalarVertexEdge< T, ComputeMethod >, corbo::BinaryVectorVertexEdge< T, ComputeMethod >, corbo::UnaryScalarVertexEdge< T, ComputeMethod >, corbo::UnaryVectorVertexEdge< T, ComputeMethod >, 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::EdgeGenericVectorFun< D, VerticesT >, and corbo::EdgeGenericScalarFun< VerticesT >.
Definition at line 139 of file edge_interface.h.
Definition at line 189 of file edge_interface.h.
|
inline |
Definition at line 195 of file edge_interface.h.
|
inline |
Definition at line 194 of file edge_interface.h.
|
friend |
Definition at line 109 of file edge_interface.h.
|
protected |
Definition at line 214 of file edge_interface.h.
|
protected |
Definition at line 213 of file edge_interface.h.