proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
expose-quadratic-costs.cpp
Go to the documentation of this file.
2
5
6namespace proxsuite {
7namespace nlp {
8namespace python {
9
10using context::ConstMatrixRef;
11using context::ConstVectorRef;
12using context::Cost;
13using context::MatrixXs;
14using context::Scalar;
15using context::VectorXs;
16
18 using FunctionPtr = shared_ptr<context::C2Function>;
20
21 using QuadraticResidualCost = QuadraticResidualCostTpl<Scalar>;
22 bp::class_<QuadraticResidualCost, bp::bases<Cost>>(
23 "QuadraticResidualCost",
24 "A cost which is a quadratic form :math:`\\frac 12 r(x)^\\top Wr(x) + "
25 "b^\\top r(x) + c` of a residual function",
26 bp::no_init)
27 .def(bp::init<FunctionPtr, const ConstMatrixRef &, const ConstVectorRef &,
28 Scalar>((bp::arg("self"), bp::arg("residual"),
29 bp::arg("weights"), bp::arg("slope"),
30 bp::arg("constant") = 0.)))
31 .def(bp::init<const shared_ptr<context::C2Function> &,
32 const ConstMatrixRef &, Scalar>(
33 (bp::arg("self"), bp::arg("residual"), bp::arg("weights"),
34 bp::arg("constant") = 0.)))
35 .def_readonly("residual", &QuadraticResidualCost::residual_,
36 "The underlying function residual.")
37 .def_readwrite(
38 "gauss_newton", &QuadraticResidualCost::gauss_newton_,
39 "Whether to use a Gauss-Newton approximation of the Hessian.");
40
41 using QuadraticDistanceCost = QuadraticDistanceCostTpl<Scalar>;
42 bp::class_<QuadraticDistanceCost, bp::bases<QuadraticResidualCost>>(
43 "QuadraticDistanceCost",
44 "Quadratic distance cost `(1/2)r.T * Q * r + b.T * r + c` on the "
45 "manifold.",
46 bp::init<PolyManifold, const VectorXs &, const MatrixXs &>(
47 bp::args("self", "space", "target", "weights")))
48 .def(bp::init<PolyManifold, const VectorXs &>(
49 bp::args("self", "space", "target")))
50 .def(bp::init<PolyManifold>(
51 "Constructor which uses the neutral element of the space.",
52 bp::args("self", "space")))
53 .add_property("target", &QuadraticDistanceCost::getTarget,
54 &QuadraticDistanceCost::updateTarget);
55}
56} // namespace python
57} // namespace nlp
58} // namespace proxsuite
void exposeQuadraticCosts()
Expose specific cost functions.
Main package namespace.
Definition bcl-params.hpp:5
Base class for differentiable cost functions.
Definition fwd.hpp:89
Weighted quadratic distance on a space.
Quadratic function of a residual.