alpaqa 1.0.0a13
Nonconvex constrained optimization
Loading...
Searching...
No Matches
ocproblem-counters.cpp
Go to the documentation of this file.
2
3#include <iomanip>
4#include <iostream>
5
6namespace alpaqa {
7
8namespace {
9struct CountResult {
10 unsigned count;
11 std::chrono::nanoseconds time;
12};
13std::ostream &operator<<(std::ostream &os, const CountResult &t) {
14 auto sec = [](auto t) { return std::chrono::duration<double>(t).count(); };
15 os << std::setw(8);
16 if (t.count > 0) {
17 os << t.count << " (";
18 auto old = os.flags();
19 auto prec = os.precision(3);
20 os << std::scientific << std::setw(9) << 1e6 * sec(t.time) << " µs, "
21 << std::setw(9) << 1e6 * sec(t.time) / static_cast<double>(t.count)
22 << " µs/call)\r\n";
23 os.precision(prec);
24 os.flags(old);
25 } else {
26 os << '-' << "\r\n";
27 }
28 return os;
29}
30} // namespace
31
32std::ostream &operator<<(std::ostream &os, const OCPEvalCounter &c) {
33 os << " f:" //
34 << CountResult{c.f, c.time.f};
35 os << " jac_f:" //
36 << CountResult{c.jac_f, c.time.jac_f};
37 os << " grad_f_prod:" //
38 << CountResult{c.grad_f_prod, c.time.grad_f_prod};
39 os << " h:" //
40 << CountResult{c.h, c.time.h};
41 os << " h_N:" //
42 << CountResult{c.h_N, c.time.h_N};
43 os << " l:" //
44 << CountResult{c.l, c.time.l};
45 os << " l_N:" //
46 << CountResult{c.l_N, c.time.l_N};
47 os << " qr:" //
48 << CountResult{c.qr, c.time.qr};
49 os << " q_N:" //
50 << CountResult{c.q_N, c.time.q_N};
51 os << " add_Q:" //
52 << CountResult{c.add_Q, c.time.add_Q};
53 os << " add_Q_N:" //
54 << CountResult{c.add_Q_N, c.time.add_Q_N};
55 os << " add_R_masked:" //
56 << CountResult{c.add_R_masked, c.time.add_R_masked};
57 os << " add_S_masked:" //
58 << CountResult{c.add_S_masked, c.time.add_S_masked};
59 os << " add_R_prod_masked:" //
60 << CountResult{c.add_R_prod_masked, c.time.add_R_prod_masked};
61 os << " add_S_prod_masked:" //
62 << CountResult{c.add_S_prod_masked, c.time.add_S_prod_masked};
63 os << " constr:" //
64 << CountResult{c.constr, c.time.constr};
65 os << " constr_N:" //
66 << CountResult{c.constr_N, c.time.constr_N};
67 os << " grad_constr_prod:" //
68 << CountResult{c.grad_constr_prod, c.time.grad_constr_prod};
69 os << " grad_constr_prod_N:" //
70 << CountResult{c.grad_constr_prod_N, c.time.grad_constr_prod_N};
71 os << " add_gn_hess_constr:" //
72 << CountResult{c.add_gn_hess_constr, c.time.add_gn_hess_constr};
73 os << "add_gn_hess_constr_N:" //
75 return os;
76}
77
78} // namespace alpaqa
std::ostream & operator<<(std::ostream &os, PANOCStopCrit s)
constexpr const auto inf
Definition config.hpp:85
std::chrono::nanoseconds grad_constr_prod_N
struct alpaqa::OCPEvalCounter::OCPEvalTimer time
std::chrono::nanoseconds add_gn_hess_constr
std::chrono::nanoseconds add_gn_hess_constr_N