proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
history-callback.hpp
Go to the documentation of this file.
1
3#pragma once
4
9
10namespace proxsuite {
11namespace nlp {
12namespace helpers {
15template <typename Scalar> struct history_callback : base_callback<Scalar> {
16 history_callback(bool store_pd_vars = true, bool store_values = true,
17 bool store_residuals = true)
18 : store_primal_dual_vars_(store_pd_vars), store_values_(store_values),
19 store_residuals_(store_residuals) {}
20
22
23 struct {
24 std::vector<VectorXs> xs;
25 std::vector<VectorXs> lams;
26 std::vector<VectorOfRef> lams_view;
27 std::vector<Scalar> values;
28 std::vector<Scalar> prim_infeas;
29 std::vector<Scalar> dual_infeas;
30 std::vector<VectorXs> ls_alphas;
31 std::vector<VectorXs> ls_values;
33 std::vector<Scalar> alphas;
34 std::vector<Scalar> dmerit_dir;
36
37 void call(const WorkspaceTpl<Scalar> &workspace,
38 const ResultsTpl<Scalar> &results) {
40 storage.xs.push_back(results.x_opt);
41 storage.lams.push_back(results.data_lams_opt);
42 storage.lams_view.push_back(results.lams_opt);
43 }
44 if (store_values_)
45 storage.values.push_back(results.value);
46 if (store_residuals_) {
47 storage.prim_infeas.push_back(results.prim_infeas);
48 storage.dual_infeas.push_back(results.dual_infeas);
49 }
50 const std::size_t asize = workspace.ls_alphas.size();
51 storage.ls_alphas.emplace_back(
52 Eigen::Map<const VectorXs>(&workspace.ls_alphas[0], asize));
53 storage.ls_values.emplace_back(
54 Eigen::Map<const VectorXs>(&workspace.ls_values[0], asize));
55 storage.alphas.push_back(workspace.alpha_opt);
56 storage.dmerit_dir.push_back(workspace.dmerit_dir);
57 }
58
59protected:
61 const bool store_values_;
62 const bool store_residuals_;
63};
64
65} // namespace helpers
66} // namespace nlp
67} // namespace proxsuite
Forward declarations and configuration macros.
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:26
Main package namespace.
Definition bcl-params.hpp:5
Results struct, holding the returned data from the solver.
Definition results.hpp:20
Scalar dual_infeas
Dual infeasibility error.
Definition results.hpp:36
Scalar prim_infeas
Primal infeasibility error.
Definition results.hpp:38
std::vector< Scalar > ls_values
std::vector< Scalar > ls_alphas
Scalar dmerit_dir
Merit function derivative in descent direction.
Scalar alpha_opt
Optimal linesearch .
std::vector< Scalar > alphas
Linesearch step-lengths.
history_callback(bool store_pd_vars=true, bool store_values=true, bool store_residuals=true)
struct proxsuite::nlp::helpers::history_callback::@0 storage
void call(const WorkspaceTpl< Scalar > &workspace, const ResultsTpl< Scalar > &results)