aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
history-callback.hpp
Go to the documentation of this file.
1
2#pragma once
3
7
9
10namespace aligator {
11
13template <typename Scalar> struct HistoryCallbackTpl : CallbackBaseTpl<Scalar> {
16 HistoryCallbackTpl(bool store_pd_vars = false, 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 std::vector<std::vector<VectorXs>> xs;
24 std::vector<std::vector<VectorXs>> us;
25 std::vector<std::vector<VectorXs>> lams;
26 std::vector<Scalar> values;
27 std::vector<Scalar> merit_values;
28 std::vector<Scalar> prim_infeas;
29 std::vector<Scalar> dual_infeas;
30 std::vector<Scalar> inner_crits;
31 std::vector<std::size_t> al_index;
32 std::vector<Scalar> prim_tols;
33 std::vector<Scalar> dual_tols;
34
35 void call(const Workspace & /*workspace*/, const Results &results) {
37 xs.push_back(results.xs);
38 us.push_back(results.us);
39 // lams.push_back(results.lams);
40 }
41 if (store_values_) {
42 values.push_back(results.traj_cost_);
43 merit_values.push_back(results.merit_value_);
44 }
45 if (store_residuals_) {
46 prim_infeas.push_back(results.prim_infeas);
47 dual_infeas.push_back(results.dual_infeas);
48 }
49 // if (auto w = dynamic_cast<const WorkspaceTpl<Scalar> *>(&workspace)) {
50 // inner_crits.push_back(w->inner_criterion);
51 // }
52 if (auto r = dynamic_cast<const ResultsTpl<Scalar> *>(&results)) {
53 al_index.push_back(r->al_iter);
54 }
55 }
56
60};
61
62} // namespace aligator
63
64#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
65#include "./history-callback.txx"
66#endif
Main package namespace.
Base callback class.
Definition fwd.hpp:99
Store the history of results.
std::vector< Scalar > prim_tols
std::vector< Scalar > dual_tols
std::vector< Scalar > prim_infeas
std::vector< std::size_t > al_index
HistoryCallbackTpl(bool store_pd_vars=false, bool store_values=true, bool store_residuals=true)
void call(const Workspace &, const Results &results)
std::vector< std::vector< VectorXs > > xs
std::vector< Scalar > dual_infeas
std::vector< Scalar > merit_values
std::vector< std::vector< VectorXs > > us
std::vector< Scalar > inner_crits
std::vector< std::vector< VectorXs > > lams
std::vector< VectorXs > xs
States.
Scalar dual_infeas
Overall dual infeasibility measure.
Scalar prim_infeas
Overall primal infeasibility measure/constraint violation.
std::vector< VectorXs > us
Controls.
Results holder struct.
Definition results.hpp:11
Base workspace struct for the algorithms.
Definition fwd.hpp:119