proxsuite-nlp  0.11.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
 
Loading...
Searching...
No Matches
squared-distance.hpp
1#pragma once
2
4#include "proxsuite-nlp/modelling/residuals/state-residual.hpp"
5
6namespace proxsuite {
7namespace nlp {
8
17template <typename _Scalar>
18struct QuadraticDistanceCostTpl : QuadraticResidualCostTpl<_Scalar> {
19 using Scalar = _Scalar;
21 using StateResidual = ManifoldDifferenceToPoint<Scalar>;
22 using Manifold = ManifoldAbstractTpl<Scalar>;
23 using Base = QuadraticResidualCostTpl<Scalar>;
24 using Base::residual_;
25 using Base::weights_;
26
27 QuadraticDistanceCostTpl(const polymorphic<Manifold> &space,
28 const ConstVectorRef &target,
29 const ConstMatrixRef &weights)
30 : Base(std::make_shared<StateResidual>(space, target), weights) {}
31
32 QuadraticDistanceCostTpl(const polymorphic<Manifold> &space,
33 const ConstVectorRef &target)
34 : QuadraticDistanceCostTpl(
35 space, target, MatrixXs::Identity(space->ndx(), space->ndx())) {}
36
37 QuadraticDistanceCostTpl(const polymorphic<Manifold> &space)
38 : QuadraticDistanceCostTpl(space, space->neutral()) {}
39
40 ConstVectorRef getTarget() const {
41 return static_cast<StateResidual *>(residual_.get())->target_;
42 }
43
44 void updateTarget(const ConstVectorRef &x) {
45 static_cast<StateResidual *>(residual_.get())->target_ = x;
46 }
47};
48
49} // namespace nlp
50} // namespace proxsuite
51
52#ifdef PROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION
53#include "proxsuite-nlp/modelling/costs/squared-distance.txx"
54#endif
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:26
Main package namespace.
Definition bcl-params.hpp:5
FunctionPtr residual_
Residual function the composite cost is constructed over.