alpaqa 1.0.0a18
Nonconvex constrained optimization
Loading...
Searching...
No Matches
problem-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 EvalCounter &c) {
33 os << " proj_diff_g:" //
34 << CountResult{c.proj_diff_g, c.time.proj_diff_g};
35 os << " proj_multipliers:" //
36 << CountResult{c.proj_multipliers, c.time.proj_multipliers};
37 os << " prox_grad_step:" //
38 << CountResult{c.prox_grad_step, c.time.prox_grad_step};
39 os << " f:" //
40 << CountResult{c.f, c.time.f};
41 os << " grad_f:" //
42 << CountResult{c.grad_f, c.time.grad_f};
43 os << " f_grad_f:" //
44 << CountResult{c.f_grad_f, c.time.f_grad_f};
45 os << " f_g:" //
46 << CountResult{c.f_g, c.time.f_g};
47 os << " grad_f_grad_g_prod:" //
48 << CountResult{c.grad_f_grad_g_prod, c.time.grad_f_grad_g_prod};
49 os << " g:" //
50 << CountResult{c.g, c.time.g};
51 os << " grad_g_prod:" //
52 << CountResult{c.grad_g_prod, c.time.grad_g_prod};
53 os << " grad_gi:" //
54 << CountResult{c.grad_gi, c.time.grad_gi};
55 os << " jac_g:" //
56 << CountResult{c.jac_g, c.time.jac_g};
57 os << " grad_L:" //
58 << CountResult{c.grad_L, c.time.grad_L};
59 os << " hess_L_prod:" //
60 << CountResult{c.hess_L_prod, c.time.hess_L_prod};
61 os << " hess_L:" //
62 << CountResult{c.hess_L, c.time.hess_L};
63 os << " hess_ψ_prod:" //
64 << CountResult{c.hess_ψ_prod, c.time.hess_ψ_prod};
65 os << " hess_ψ:" //
66 << CountResult{c.hess_ψ, c.time.hess_ψ};
67 os << " ψ:" //
68 << CountResult{c.ψ, c.time.ψ};
69 os << " grad_ψ:" //
70 << CountResult{c.grad_ψ, c.time.grad_ψ};
71 os << " ψ_grad_ψ:" //
72 << CountResult{c.ψ_grad_ψ, c.time.ψ_grad_ψ};
73 return os;
74}
75
76} // namespace alpaqa
std::ostream & operator<<(std::ostream &os, PANOCStopCrit s)
constexpr const auto inf
Definition config.hpp:112
std::chrono::nanoseconds grad_gi
std::chrono::nanoseconds proj_diff_g
std::chrono::nanoseconds jac_g
std::chrono::nanoseconds ψ_grad_ψ
std::chrono::nanoseconds grad_f_grad_g_prod
struct alpaqa::EvalCounter::EvalTimer time
std::chrono::nanoseconds hess_L
std::chrono::nanoseconds f_grad_f
std::chrono::nanoseconds grad_f
std::chrono::nanoseconds hess_ψ
std::chrono::nanoseconds grad_ψ
std::chrono::nanoseconds hess_ψ_prod
std::chrono::nanoseconds prox_grad_step
std::chrono::nanoseconds ψ
std::chrono::nanoseconds f_g
std::chrono::nanoseconds grad_L
std::chrono::nanoseconds proj_multipliers
std::chrono::nanoseconds grad_g_prod
std::chrono::nanoseconds hess_L_prod