proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
expose-callbacks.cpp
Go to the documentation of this file.
4
5namespace proxsuite {
6namespace nlp {
7namespace python {
8
9struct CallbackWrapper : helpers::base_callback<context::Scalar>,
10 bp::wrapper<helpers::base_callback<context::Scalar>> {
11 CallbackWrapper() = default;
12 void call(const context::Workspace &w, const context::Results &r) {
13 this->get_override("call")(w, r);
14 }
15};
16
18 using context::Scalar;
19 using callback_t = helpers::base_callback<Scalar>;
20
21 bp::register_ptr_to_python<shared_ptr<callback_t>>();
22
23 bp::class_<CallbackWrapper, shared_ptr<CallbackWrapper>, boost::noncopyable>(
24 "BaseCallback", "Base callback for solvers.", bp::init<>())
25 .def("call", bp::pure_virtual(&CallbackWrapper::call),
26 bp::args("self", "workspace", "results"));
27
28 {
29 using history_storage_t =
31
32 bp::scope in_history =
33 bp::class_<helpers::history_callback<Scalar>, bp::bases<callback_t>>(
34 "HistoryCallback", "Store the history of solver's variables.",
35 bp::init<bool, bool, bool>((bp::arg("store_pd_vars") = true,
36 bp::arg("store_values") = true,
37 bp::arg("store_residuals") = true)))
38 .def_readonly("storage",
40
41 bp::class_<history_storage_t, shared_ptr<history_storage_t>>(
42 "history_storage")
43 .def_readonly("xs", &history_storage_t::xs)
44 .def_readonly("lams", &history_storage_t::lams)
45 .def_readonly("values", &history_storage_t::values)
46 .def_readonly("prim_infeas", &history_storage_t::prim_infeas)
47 .def_readonly("dual_infeas", &history_storage_t::dual_infeas)
48 .def_readonly("ls_alphas", &history_storage_t::ls_alphas)
49 .def_readonly("ls_values", &history_storage_t::ls_values)
50 .def_readonly("alphas", &history_storage_t::alphas)
51 .def_readonly("dmerit_dir", &history_storage_t::dmerit_dir);
52 }
53}
54} // namespace python
55} // namespace nlp
56} // namespace proxsuite
Main package namespace.
Definition bcl-params.hpp:5
Results struct, holding the returned data from the solver.
Definition results.hpp:20
void call(const context::Workspace &w, const context::Results &r)