alpaqa
conan-profiles
Nonconvex constrained optimization
Loading...
Searching...
No Matches
src
alpaqa
src
problem
problem-counters.cpp
Go to the documentation of this file.
1
#include <
alpaqa/problem/problem-counters.hpp
>
2
3
#include <iomanip>
4
#include <iostream>
5
6
namespace
alpaqa
{
7
8
namespace
{
9
struct
CountResult
{
10
unsigned
count
;
11
std::chrono::nanoseconds
time
;
12
};
13
std::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
32
#define ALPAQA_STRINGIFY(a) ALPAQA_STRINGIFY_IMPL(a)
33
#define ALPAQA_STRINGIFY_IMPL(a) #a
34
#define ALPAQA_PRINT_EVAL(x) \
35
do { \
36
total.count += c.x; \
37
total.time += c.time.x; \
38
os << std::setw(53) << ALPAQA_STRINGIFY(x) ":" \
39
<< CountResult{c.x, c.time.x}; \
40
} while (false)
41
42
std::ostream &
operator<<
(std::ostream &os,
const
EvalCounter
&c) {
43
CountResult total{{}, {}};
44
ALPAQA_PRINT_EVAL
(projecting_difference_constraints);
45
ALPAQA_PRINT_EVAL
(projection_multipliers);
46
ALPAQA_PRINT_EVAL
(proximal_gradient_step);
47
ALPAQA_PRINT_EVAL
(inactive_indices_res_lna);
48
ALPAQA_PRINT_EVAL
(prox_jacobian_diag);
49
ALPAQA_PRINT_EVAL
(objective);
50
ALPAQA_PRINT_EVAL
(objective_gradient);
51
ALPAQA_PRINT_EVAL
(objective_and_gradient);
52
ALPAQA_PRINT_EVAL
(objective_and_constraints);
53
ALPAQA_PRINT_EVAL
(objective_gradient_and_constraints_gradient_product);
54
ALPAQA_PRINT_EVAL
(constraints);
55
ALPAQA_PRINT_EVAL
(constraints_gradient_product);
56
ALPAQA_PRINT_EVAL
(grad_gi);
57
ALPAQA_PRINT_EVAL
(constraints_jacobian);
58
ALPAQA_PRINT_EVAL
(lagrangian_gradient);
59
ALPAQA_PRINT_EVAL
(lagrangian_hessian_product);
60
ALPAQA_PRINT_EVAL
(lagrangian_hessian);
61
ALPAQA_PRINT_EVAL
(augmented_lagrangian_hessian_product);
62
ALPAQA_PRINT_EVAL
(augmented_lagrangian_hessian);
63
ALPAQA_PRINT_EVAL
(augmented_lagrangian);
64
ALPAQA_PRINT_EVAL
(augmented_lagrangian_gradient);
65
ALPAQA_PRINT_EVAL
(augmented_lagrangian_and_gradient);
66
os <<
"+ --------------------------------------------------:\n"
67
<< std::setw(53) <<
"total:"
<< total;
68
return
os;
69
}
70
71
}
// namespace alpaqa
alpaqa::anonymous_namespace{problem-counters.cpp}::CountResult::time
std::chrono::nanoseconds time
Definition
problem-counters.cpp:11
alpaqa::anonymous_namespace{problem-counters.cpp}::CountResult::count
unsigned count
Definition
problem-counters.cpp:10
alpaqa::anonymous_namespace{problem-counters.cpp}::CountResult
Definition
problem-counters.cpp:9
alpaqa
Definition
anderson.hpp:10
alpaqa::operator<<
std::ostream & operator<<(std::ostream &os, PANOCStopCrit s)
Definition
panoc-stop-crit.cpp:7
ALPAQA_PRINT_EVAL
#define ALPAQA_PRINT_EVAL(x)
Definition
problem-counters.cpp:34
problem-counters.hpp
alpaqa::EvalCounter
Definition
problem-counters.hpp:10
Generated on
for alpaqa by
1.14.0