23template <
class Problem>
31 real_t eval_prox_grad_step(
real_t γ,
crvec x,
crvec grad_ψ,
rvec x̂,
rvec p)
const { ++
evaluations->prox_grad_step;
return timed(
evaluations->time.prox_grad_step, std::bind(&std::remove_cvref_t<Problem>::eval_prox_grad_step, &
problem, γ, x, grad_ψ, x̂, p)); }
38 void eval_jac_g(
crvec x,
rindexvec inner_idx,
rindexvec outer_ptr,
rvec J_values)
const requires requires { &std::remove_cvref_t<Problem>::eval_jac_g; } {
if (J_values.size() == 0)
return problem.eval_jac_g(x, inner_idx, outer_ptr, J_values); ++
evaluations->jac_g;
return timed(
evaluations->time.jac_g, std::bind(&std::remove_cvref_t<Problem>::eval_jac_g, &
problem, x, inner_idx, outer_ptr, J_values)); }
40 void eval_hess_L_prod(
crvec x,
crvec y,
real_t scale,
crvec v,
rvec Hv)
const requires requires { &std::remove_cvref_t<Problem>::eval_hess_L_prod; } { ++
evaluations->hess_L_prod;
return timed(
evaluations->time.hess_L_prod, std::bind(&std::remove_cvref_t<Problem>::eval_hess_L_prod, &
problem, x, y, scale, v, Hv)); }
41 void eval_hess_L(
crvec x,
crvec y,
real_t scale,
rindexvec inner_idx,
rindexvec outer_ptr,
rvec H_values)
const requires requires { &std::remove_cvref_t<Problem>::eval_hess_L; } {
if (H_values.size() == 0)
return problem.eval_hess_L(x, y, scale, inner_idx, outer_ptr, H_values); ++
evaluations->hess_L;
return timed(
evaluations->time.hess_L, std::bind(&std::remove_cvref_t<Problem>::eval_hess_L, &
problem, x, y, scale, inner_idx, outer_ptr, H_values)); }
43 void eval_hess_ψ_prod(
crvec x,
crvec y,
crvec Σ,
real_t scale,
crvec v,
rvec Hv)
const requires requires { &std::remove_cvref_t<Problem>::eval_hess_ψ_prod; } { ++
evaluations->hess_ψ_prod;
return timed(
evaluations->time.hess_ψ_prod, std::bind(&std::remove_cvref_t<Problem>::eval_hess_ψ_prod, &
problem, x, y, Σ, scale, v, Hv)); }
44 void eval_hess_ψ(
crvec x,
crvec y,
crvec Σ,
real_t scale,
rindexvec inner_idx,
rindexvec outer_ptr,
rvec H_values)
const requires requires { &std::remove_cvref_t<Problem>::eval_hess_ψ; } {
if (H_values.size() == 0)
return problem.eval_hess_ψ(x, y, Σ, scale, inner_idx, outer_ptr, H_values); ++
evaluations->hess_ψ;
return timed(
evaluations->time.hess_ψ, std::bind(&std::remove_cvref_t<Problem>::eval_hess_ψ, &
problem, x, y, Σ, scale, inner_idx, outer_ptr, H_values)); }
51 void eval_grad_ψ(
crvec x,
crvec y,
crvec Σ,
rvec grad_ψ,
rvec work_n,
rvec work_m)
const requires requires { &std::remove_cvref_t<Problem>::eval_grad_ψ; } { ++
evaluations->grad_ψ;
return timed(
evaluations->time.grad_ψ, std::bind(&std::remove_cvref_t<Problem>::eval_grad_ψ, &
problem, x, y, Σ, grad_ψ, work_n, work_m)); }
52 real_t eval_ψ_grad_ψ(
crvec x,
crvec y,
crvec Σ,
rvec grad_ψ,
rvec work_n,
rvec work_m)
const requires requires { &std::remove_cvref_t<Problem>::eval_ψ_grad_ψ; } { ++
evaluations->ψ_grad_ψ;
return timed(
evaluations->time.ψ_grad_ψ, std::bind(&std::remove_cvref_t<Problem>::eval_ψ_grad_ψ, &
problem, x, y, Σ, grad_ψ, work_n, work_m)); }
53 const Box &
get_box_C() const requires requires { &std::remove_cvref_t<Problem>::get_box_C; } {
return problem.get_box_C(); }
54 const Box &
get_box_D() const requires requires { &std::remove_cvref_t<Problem>::get_box_D; } {
return problem.get_box_D(); }
55 void check() const requires requires { &std::remove_cvref_t<Problem>::check; } {
return problem.check(); }
57 [[nodiscard]]
bool provides_eval_grad_gi() const requires requires (Problem p) { { p.provides_eval_grad_gi() } -> std::convertible_to<bool>; } {
return problem.provides_eval_grad_gi(); }
58 [[nodiscard]]
bool provides_eval_inactive_indices_res_lna() const requires requires (Problem p) { { p.provides_eval_inactive_indices_res_lna() } -> std::convertible_to<bool>; } {
return problem.provides_eval_inactive_indices_res_lna(); }
59 [[nodiscard]]
bool provides_eval_jac_g() const requires requires (Problem p) { { p.provides_eval_jac_g() } -> std::convertible_to<bool>; } {
return problem.provides_eval_jac_g(); }
60 [[nodiscard]]
bool provides_get_jac_g_num_nonzeros() const requires requires (Problem p) { { p.provides_get_jac_g_num_nonzeros() } -> std::convertible_to<bool>; } {
return problem.provides_get_jac_g_num_nonzeros(); }
61 [[nodiscard]]
bool provides_eval_hess_L_prod() const requires requires (Problem p) { { p.provides_eval_hess_L_prod() } -> std::convertible_to<bool>; } {
return problem.provides_eval_hess_L_prod(); }
62 [[nodiscard]]
bool provides_eval_hess_L() const requires requires (Problem p) { { p.provides_eval_hess_L() } -> std::convertible_to<bool>; } {
return problem.provides_eval_hess_L(); }
63 [[nodiscard]]
bool provides_get_hess_L_num_nonzeros() const requires requires (Problem p) { { p.provides_get_hess_L_num_nonzeros() } -> std::convertible_to<bool>; } {
return problem.provides_get_hess_L_num_nonzeros(); }
64 [[nodiscard]]
bool provides_eval_hess_ψ_prod() const requires requires (Problem p) { { p.provides_eval_hess_ψ() } -> std::convertible_to<bool>; } {
return problem.provides_eval_hess_ψ_prod(); }
65 [[nodiscard]]
bool provides_eval_hess_ψ() const requires requires (Problem p) { { p.provides_eval_hess_ψ() } -> std::convertible_to<bool>; } {
return problem.provides_eval_hess_ψ(); }
66 [[nodiscard]]
bool provides_get_hess_ψ_num_nonzeros() const requires requires (Problem p) { { p.provides_get_hess_ψ_num_nonzeros() } -> std::convertible_to<bool>; } {
return problem.provides_get_hess_ψ_num_nonzeros(); }
67 [[nodiscard]]
bool provides_eval_f_grad_f() const requires requires (Problem p) { { p.provides_eval_f_grad_f() } -> std::convertible_to<bool>; } {
return problem.provides_eval_f_grad_f(); }
68 [[nodiscard]]
bool provides_eval_f_g() const requires requires (Problem p) { { p.provides_eval_f_g() } -> std::convertible_to<bool>; } {
return problem.provides_eval_f_g(); }
69 [[nodiscard]]
bool provides_eval_grad_f_grad_g_prod() const requires requires (Problem p) { { p.provides_eval_grad_f_grad_g_prod() } -> std::convertible_to<bool>; } {
return problem.provides_eval_grad_f_grad_g_prod(); }
70 [[nodiscard]]
bool provides_eval_grad_L() const requires requires (Problem p) { { p.provides_eval_grad_L() } -> std::convertible_to<bool>; } {
return problem.provides_eval_grad_L(); }
71 [[nodiscard]]
bool provides_eval_ψ() const requires requires (Problem p) { { p.provides_eval_ψ() } -> std::convertible_to<bool>; } {
return problem.provides_eval_ψ(); }
72 [[nodiscard]]
bool provides_eval_grad_ψ() const requires requires (Problem p) { { p.provides_eval_grad_ψ() } -> std::convertible_to<bool>; } {
return problem.provides_eval_grad_ψ(); }
73 [[nodiscard]]
bool provides_eval_ψ_grad_ψ() const requires requires (Problem p) { { p.provides_eval_ψ_grad_ψ() } -> std::convertible_to<bool>; } {
return problem.provides_eval_ψ_grad_ψ(); }
74 [[nodiscard]]
bool provides_get_box_C() const requires requires (Problem p) { { p.provides_get_box_C() } -> std::convertible_to<bool>; } {
return problem.provides_get_box_C(); }
75 [[nodiscard]]
bool provides_get_box_D() const requires requires (Problem p) { { p.provides_get_box_D() } -> std::convertible_to<bool>; } {
return problem.provides_get_box_D(); }
76 [[nodiscard]]
bool provides_check() const requires requires (Problem p) { { p.provides_check() } -> std::convertible_to<bool>; } {
return problem.provides_check(); }
82 std::shared_ptr<EvalCounter>
evaluations = std::make_shared<EvalCounter>();
86 requires std::is_default_constructible_v<Problem>
90 requires std::is_same_v<std::remove_cvref_t<P>, std::remove_cvref_t<Problem>>
92 template <
class... Args>
94 requires(!std::is_lvalue_reference_v<Problem>)
95 :
problem{std::forward<Args>(args)...} {}
107 template <
class TimeT,
class FunT>
108 static decltype(
auto)
timed(TimeT &time, FunT &&f) {
110 return std::forward<FunT>(f)();
119template <
class Problem>
121 using Prob = std::remove_cvref_t<Problem>;
123 return ProbWithCnt{std::forward<Problem>(p)};
132template <
class Problem>
134 using Prob = std::remove_cvref_t<Problem>;
136 return ProbWithCnt{p};
#define USING_ALPAQA_CONFIG_TEMPLATE(Conf)
auto problem_with_counters(Problem &&p)
Wraps the given problem into a ProblemWithCounters and keeps track of how many times each function is...
auto problem_with_counters_ref(Problem &p)
Wraps the given problem into a ProblemWithCounters and keeps track of how many times each function is...
typename Conf::real_t real_t
typename Conf::rindexvec rindexvec
typename Conf::index_t index_t
typename Conf::length_t length_t
typename Conf::crvec crvec
Problem wrapper that keeps track of the number of evaluations and the run time of each function.
void eval_hess_ψ_prod(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
void decouple_evaluations()
Give this instance its own evaluation counters and timers, decoupling it from any other instances the...
real_t eval_ψ_grad_ψ(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
bool provides_eval_ψ() const
void eval_hess_L(crvec x, crvec y, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const
bool provides_get_hess_L_num_nonzeros() const
void eval_jac_g(crvec x, rindexvec inner_idx, rindexvec outer_ptr, rvec J_values) const
void eval_grad_ψ(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
const Box & get_box_C() const
bool provides_eval_grad_ψ() const
void eval_grad_L(crvec x, crvec y, rvec grad_L, rvec work_n) const
bool provides_eval_f_g() const
bool provides_get_hess_ψ_num_nonzeros() const
bool provides_eval_grad_gi() const
bool provides_eval_ψ_grad_ψ() const
const Box & get_box_D() const
std::shared_ptr< EvalCounter > evaluations
ProblemWithCounters()=default
bool provides_get_box_D() const
real_t eval_ψ(crvec x, crvec y, crvec Σ, rvec ŷ) const
length_t get_hess_L_num_nonzeros() const
void reset_evaluations()
Reset all evaluation counters and timers to zero.
typename TypeErasedProblem< config_t >::Box Box
void eval_hess_ψ(crvec x, crvec y, crvec Σ, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const
real_t eval_f_grad_f(crvec x, rvec grad_fx) const
bool provides_eval_hess_ψ() const
length_t get_hess_ψ_num_nonzeros() const
index_t eval_inactive_indices_res_lna(real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
void eval_grad_g_prod(crvec x, crvec y, rvec grad_gxy) const
void eval_hess_L_prod(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
bool provides_eval_grad_L() const
void eval_proj_multipliers(rvec y, real_t M) const
void eval_grad_f(crvec x, rvec grad_fx) const
void eval_grad_gi(crvec x, index_t i, rvec grad_gi) const
bool provides_check() const
real_t eval_f_g(crvec x, rvec g) const
bool provides_eval_hess_L_prod() const
real_t eval_prox_grad_step(real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
void eval_g(crvec x, rvec gx) const
bool provides_eval_grad_f_grad_g_prod() const
bool provides_eval_hess_ψ_prod() const
real_t eval_f(crvec x) const
ProblemWithCounters(std::in_place_t, Args &&...args)
bool provides_eval_hess_L() const
void eval_proj_diff_g(crvec z, rvec e) const
bool provides_eval_inactive_indices_res_lna() const
static decltype(auto) timed(TimeT &time, FunT &&f)
bool provides_get_box_C() const
length_t get_jac_g_num_nonzeros() const
bool provides_eval_f_grad_f() const
void eval_grad_f_grad_g_prod(crvec x, crvec y, rvec grad_f, rvec grad_gxy) const
bool provides_get_jac_g_num_nonzeros() const
bool provides_eval_jac_g() const