proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
expose-function.cpp
Go to the documentation of this file.
4
5namespace proxsuite {
6namespace nlp {
7namespace python {
10using context::ConstVectorRef;
13using context::Scalar;
14
16
18
19 bp::class_<FunctionWrap, boost::noncopyable>(
20 "BaseFunction", "Base class for functions.", bp::no_init)
21 .def(bp::init<const Manifold &, const int>(
22 bp::args("self", "manifold", "nr")))
23 .def(bp::init<int, int, int>(bp::args("self", "nx", "ndx", "nr")))
24 .def("__call__", bp::pure_virtual(&Function::operator()),
25 bp::args("self", "x"), "Call the function.")
26 .add_property("nx", &Function::nx, "Input dimension")
27 .add_property("ndx", &Function::ndx, "Input tangent space dimension.")
28 .add_property("nr", &Function::nr, "Function codimension.");
29
30 context::MatFuncType C1Function::*compJac1 = &C1Function::computeJacobian;
31 context::MatFuncRetType C1Function::*compJac2 = &C1Function::computeJacobian;
32
33 bp::class_<C1FunctionWrap, bp::bases<Function>, boost::noncopyable>(
34 "C1Function", "Base class for differentiable functions", bp::no_init)
35 .def(bp::init<const Manifold &, const int>(
36 bp::args("self", "manifold", "nr")))
37 .def(bp::init<int, int, int>(bp::args("self", "nx", "ndx", "nr")))
38 .def("computeJacobian", bp::pure_virtual(compJac1),
39 bp::args("self", "x", "Jout"))
40 .def("getJacobian", compJac2, bp::args("self", "x"),
41 "Compute and return Jacobian.");
42
43 bp::register_ptr_to_python<shared_ptr<C2Function>>();
44 bp::class_<C2FunctionWrap, bp::bases<C1Function>, boost::noncopyable>(
45 "C2Function", "Base class for twice-differentiable functions.",
46 bp::no_init)
47 .def(bp::init<const Manifold &, const int>(
48 bp::args("self", "manifold", "nr")))
49 .def(bp::init<int, int, int>(bp::args("self", "nx", "ndx", "nr")))
50 .def("vectorHessianProduct", &C2Function::vectorHessianProduct,
51 &C2FunctionWrap::default_vhp, bp::args("self", "x", "v", "Hout"))
52 .def("getVHP", &C2FunctionWrap::getVHP, bp::args("self", "x", "v"),
53 "Compute and return the vector-Hessian product.")
54 .def(
55 "__matmul__",
56 +[](shared_ptr<C2Function> const &left,
57 shared_ptr<C2Function> const &right) {
58 return ::proxsuite::nlp::compose<Scalar>(left, right);
59 },
60 "Composition operator. This composes the first argument over the "
61 "second one.");
62
64}
65
67 using ComposeFunction = ComposeFunctionTpl<Scalar>;
68
69 const char *compose_doc = "Composition of two functions. This returns the "
70 "composition of `f` over `g`.";
71 bp::register_ptr_to_python<shared_ptr<ComposeFunction>>();
72 bp::class_<ComposeFunction, bp::bases<C2Function>>("ComposeFunction",
73 compose_doc, bp::no_init)
74 .def(bp::init<const shared_ptr<C2Function> &,
75 const shared_ptr<C2Function> &>(bp::args("self", "f", "g")))
76 .add_property("left",
77 bp::make_function(&ComposeFunction::left,
78 bp::return_internal_reference<>()),
79 "The left-hand side of the composition.")
80 .add_property("right",
81 bp::make_function(&ComposeFunction::right,
82 bp::return_internal_reference<>()),
83 "The right-hand side of the composition.");
84
86 bp::args("f", "g"), compose_doc);
87}
88
89} // namespace python
90} // namespace nlp
91} // namespace proxsuite
void(const ConstVectorRef &, MatrixRef) const MatFuncType
Definition context.hpp:31
MatrixXs(const ConstVectorRef &) const MatFuncRetType
Definition context.hpp:37
auto compose(const shared_ptr< C2FunctionTpl< Scalar > > &left, const shared_ptr< C2FunctionTpl< Scalar > > &right)
Compose two function objects.
Main package namespace.
Definition bcl-params.hpp:5
Base function type.
Definition fwd.hpp:70
Differentiable function, with method for the Jacobian.
Definition fwd.hpp:73
Twice-differentiable function, with method Jacobian and vector-hessian product evaluation.
Definition fwd.hpp:76
Composition of two functions .
Definition fwd.hpp:82
void default_vhp(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Hout) const
Definition function.hpp:69
MatrixXs getVHP(const ConstVectorRef &x, const ConstVectorRef &v) const
Definition function.hpp:62