alpaqa 1.0.0a17
Nonconvex constrained optimization
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Private Member Functions | List of all members
ProblemWithCounters< Problem > Struct Template Reference

#include <alpaqa/problem/problem-with-counters.hpp>

Detailed Description

template<class Problem>
struct alpaqa::ProblemWithCounters< Problem >

Problem wrapper that keeps track of the number of evaluations and the run time of each function.

You probably want to use problem_with_counters or problem_with_counters_ref instead of instantiating this class directly.

Note
The evaluation counters are stored using a std::shared_pointers, which means that different copies of a ProblemWithCounters instance all share the same counters. To opt out of this behavior, you can use the decouple_evaluations function.

Definition at line 24 of file problem-with-counters.hpp.

+ Collaboration diagram for ProblemWithCounters< Problem >:

Public Types

using Box = typename TypeErasedProblem< config_t >::Box
 
using Sparsity = sparsity::Sparsity< config_t >
 

Public Member Functions

void eval_proj_diff_g (crvec z, rvec e) const
 
void eval_proj_multipliers (rvec y, real_t M) const
 
real_t eval_prox_grad_step (real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
 
index_t eval_inactive_indices_res_lna (real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
 
real_t eval_f (crvec x) const
 
void eval_grad_f (crvec x, rvec grad_fx) const
 
void eval_g (crvec x, rvec gx) const
 
void eval_grad_g_prod (crvec x, crvec y, rvec grad_gxy) const
 
void eval_grad_gi (crvec x, index_t i, rvec grad_gi) const
 
void eval_jac_g (crvec x, rvec J_values) const
 
Sparsity get_jac_g_sparsity () const
 
void eval_hess_L_prod (crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
 
void eval_hess_L (crvec x, crvec y, real_t scale, rvec H_values) const
 
Sparsity get_hess_L_sparsity () const
 
void eval_hess_ψ_prod (crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
 
void eval_hess_ψ (crvec x, crvec y, crvec Σ, real_t scale, rvec H_values) const
 
Sparsity get_hess_ψ_sparsity () const
 
real_t eval_f_grad_f (crvec x, rvec grad_fx) const
 
real_t eval_f_g (crvec x, rvec g) const
 
void eval_grad_f_grad_g_prod (crvec x, crvec y, rvec grad_f, rvec grad_gxy) const
 
void eval_grad_L (crvec x, crvec y, rvec grad_L, rvec work_n) const
 
real_t eval_ψ (crvec x, crvec y, crvec Σ, rvec ŷ) const
 
void eval_grad_ψ (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
 
real_t eval_ψ_grad_ψ (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
 
const Boxget_box_C () const
 
const Boxget_box_D () const
 
void check () const
 
std::string get_name () const
 
bool provides_eval_grad_gi () const
 
bool provides_eval_inactive_indices_res_lna () const
 
bool provides_eval_jac_g () const
 
bool provides_get_jac_g_sparsity () const
 
bool provides_eval_hess_L_prod () const
 
bool provides_eval_hess_L () const
 
bool provides_get_hess_L_sparsity () const
 
bool provides_eval_hess_ψ_prod () const
 
bool provides_eval_hess_ψ () const
 
bool provides_get_hess_ψ_sparsity () const
 
bool provides_eval_f_grad_f () const
 
bool provides_eval_f_g () const
 
bool provides_eval_grad_f_grad_g_prod () const
 
bool provides_eval_grad_L () const
 
bool provides_eval_ψ () const
 
bool provides_eval_grad_ψ () const
 
bool provides_eval_ψ_grad_ψ () const
 
bool provides_get_box_C () const
 
bool provides_get_box_D () const
 
bool provides_check () const
 
bool provides_get_name () const
 
length_t get_n () const
 
length_t get_m () const
 
 ProblemWithCounters ()=default
 
template<class P >
requires std::is_same_v<std::remove_cvref_t<P>, std::remove_cvref_t<Problem>>
 ProblemWithCounters (P &&problem)
 
template<class... Args>
requires (!std::is_lvalue_reference_v<Problem>)
 ProblemWithCounters (std::in_place_t, Args &&...args)
 
void reset_evaluations ()
 Reset all evaluation counters and timers to zero.
 
void decouple_evaluations ()
 Give this instance its own evaluation counters and timers, decoupling it from any other instances they might have previously been shared with.
 

Public Attributes

std::shared_ptr< EvalCounterevaluations = std::make_shared<EvalCounter>()
 
Problem problem
 

Static Private Member Functions

template<class TimeT , class FunT >
static decltype(autotimed (TimeT &time, FunT &&f)
 

Member Typedef Documentation

◆ Box

template<class Problem >
using Box = typename TypeErasedProblem<config_t>::Box

Definition at line 26 of file problem-with-counters.hpp.

◆ Sparsity

template<class Problem >
using Sparsity = sparsity::Sparsity<config_t>

Definition at line 27 of file problem-with-counters.hpp.

Constructor & Destructor Documentation

◆ ProblemWithCounters() [1/3]

template<class Problem >
ProblemWithCounters ( )
default

◆ ProblemWithCounters() [2/3]

template<class Problem >
template<class P >
requires std::is_same_v<std::remove_cvref_t<P>, std::remove_cvref_t<Problem>>
ProblemWithCounters ( P &&  problem)
inlineexplicit

Definition at line 92 of file problem-with-counters.hpp.

◆ ProblemWithCounters() [3/3]

template<class Problem >
template<class... Args>
requires (!std::is_lvalue_reference_v<Problem>)
ProblemWithCounters ( std::in_place_t  ,
Args &&...  args 
)
inlineexplicit

Definition at line 96 of file problem-with-counters.hpp.

Member Function Documentation

◆ eval_proj_diff_g()

template<class Problem >
void eval_proj_diff_g ( crvec  z,
rvec  e 
) const
inline

Definition at line 30 of file problem-with-counters.hpp.

+ Here is the call graph for this function:

◆ eval_proj_multipliers()

template<class Problem >
void eval_proj_multipliers ( rvec  y,
real_t  M 
) const
inline

Definition at line 31 of file problem-with-counters.hpp.

+ Here is the call graph for this function:

◆ eval_prox_grad_step()

template<class Problem >
real_t eval_prox_grad_step ( real_t  γ,
crvec  x,
crvec  grad_ψ,
rvec  ,
rvec  p 
) const
inline

Definition at line 32 of file problem-with-counters.hpp.

+ Here is the call graph for this function:

◆ eval_inactive_indices_res_lna()

template<class Problem >
index_t eval_inactive_indices_res_lna ( real_t  γ,
crvec  x,
crvec  grad_ψ,
rindexvec  J 
) const
inline

Definition at line 33 of file problem-with-counters.hpp.

◆ eval_f()

template<class Problem >
real_t eval_f ( crvec  x) const
inline

Definition at line 34 of file problem-with-counters.hpp.

+ Here is the call graph for this function:

◆ eval_grad_f()

template<class Problem >
void eval_grad_f ( crvec  x,
rvec  grad_fx 
) const
inline

Definition at line 35 of file problem-with-counters.hpp.

+ Here is the call graph for this function:

◆ eval_g()

template<class Problem >
void eval_g ( crvec  x,
rvec  gx 
) const
inline

Definition at line 36 of file problem-with-counters.hpp.

+ Here is the call graph for this function:

◆ eval_grad_g_prod()

template<class Problem >
void eval_grad_g_prod ( crvec  x,
crvec  y,
rvec  grad_gxy 
) const
inline

Definition at line 37 of file problem-with-counters.hpp.

+ Here is the call graph for this function:

◆ eval_grad_gi()

template<class Problem >
void eval_grad_gi ( crvec  x,
index_t  i,
rvec  grad_gi 
) const
inline

Definition at line 38 of file problem-with-counters.hpp.

◆ eval_jac_g()

template<class Problem >
void eval_jac_g ( crvec  x,
rvec  J_values 
) const
inline

Definition at line 39 of file problem-with-counters.hpp.

◆ get_jac_g_sparsity()

template<class Problem >
Sparsity get_jac_g_sparsity ( ) const
inline

Definition at line 40 of file problem-with-counters.hpp.

◆ eval_hess_L_prod()

template<class Problem >
void eval_hess_L_prod ( crvec  x,
crvec  y,
real_t  scale,
crvec  v,
rvec  Hv 
) const
inline

Definition at line 41 of file problem-with-counters.hpp.

◆ eval_hess_L()

template<class Problem >
void eval_hess_L ( crvec  x,
crvec  y,
real_t  scale,
rvec  H_values 
) const
inline

Definition at line 42 of file problem-with-counters.hpp.

◆ get_hess_L_sparsity()

template<class Problem >
Sparsity get_hess_L_sparsity ( ) const
inline

Definition at line 43 of file problem-with-counters.hpp.

◆ eval_hess_ψ_prod()

template<class Problem >
void eval_hess_ψ_prod ( crvec  x,
crvec  y,
crvec  Σ,
real_t  scale,
crvec  v,
rvec  Hv 
) const
inline

Definition at line 44 of file problem-with-counters.hpp.

◆ eval_hess_ψ()

template<class Problem >
void eval_hess_ψ ( crvec  x,
crvec  y,
crvec  Σ,
real_t  scale,
rvec  H_values 
) const
inline

Definition at line 45 of file problem-with-counters.hpp.

◆ get_hess_ψ_sparsity()

template<class Problem >
Sparsity get_hess_ψ_sparsity ( ) const
inline

Definition at line 46 of file problem-with-counters.hpp.

◆ eval_f_grad_f()

template<class Problem >
real_t eval_f_grad_f ( crvec  x,
rvec  grad_fx 
) const
inline

Definition at line 47 of file problem-with-counters.hpp.

◆ eval_f_g()

template<class Problem >
real_t eval_f_g ( crvec  x,
rvec  g 
) const
inline

Definition at line 48 of file problem-with-counters.hpp.

◆ eval_grad_f_grad_g_prod()

template<class Problem >
void eval_grad_f_grad_g_prod ( crvec  x,
crvec  y,
rvec  grad_f,
rvec  grad_gxy 
) const
inline

Definition at line 49 of file problem-with-counters.hpp.

◆ eval_grad_L()

template<class Problem >
void eval_grad_L ( crvec  x,
crvec  y,
rvec  grad_L,
rvec  work_n 
) const
inline

Definition at line 50 of file problem-with-counters.hpp.

◆ eval_ψ()

template<class Problem >
real_t eval_ψ ( crvec  x,
crvec  y,
crvec  Σ,
rvec  ŷ 
) const
inline

Definition at line 51 of file problem-with-counters.hpp.

◆ eval_grad_ψ()

template<class Problem >
void eval_grad_ψ ( crvec  x,
crvec  y,
crvec  Σ,
rvec  grad_ψ,
rvec  work_n,
rvec  work_m 
) const
inline

Definition at line 52 of file problem-with-counters.hpp.

◆ eval_ψ_grad_ψ()

template<class Problem >
real_t eval_ψ_grad_ψ ( crvec  x,
crvec  y,
crvec  Σ,
rvec  grad_ψ,
rvec  work_n,
rvec  work_m 
) const
inline

Definition at line 53 of file problem-with-counters.hpp.

◆ get_box_C()

template<class Problem >
const Box & get_box_C ( ) const
inline

Definition at line 54 of file problem-with-counters.hpp.

◆ get_box_D()

template<class Problem >
const Box & get_box_D ( ) const
inline

Definition at line 55 of file problem-with-counters.hpp.

◆ check()

template<class Problem >
void check ( ) const
inline

Definition at line 56 of file problem-with-counters.hpp.

◆ get_name()

template<class Problem >
std::string get_name ( ) const
inline

Definition at line 57 of file problem-with-counters.hpp.

◆ provides_eval_grad_gi()

template<class Problem >
bool provides_eval_grad_gi ( ) const
inline

Definition at line 59 of file problem-with-counters.hpp.

◆ provides_eval_inactive_indices_res_lna()

template<class Problem >
bool provides_eval_inactive_indices_res_lna ( ) const
inline

Definition at line 60 of file problem-with-counters.hpp.

◆ provides_eval_jac_g()

template<class Problem >
bool provides_eval_jac_g ( ) const
inline

Definition at line 61 of file problem-with-counters.hpp.

◆ provides_get_jac_g_sparsity()

template<class Problem >
bool provides_get_jac_g_sparsity ( ) const
inline

Definition at line 62 of file problem-with-counters.hpp.

◆ provides_eval_hess_L_prod()

template<class Problem >
bool provides_eval_hess_L_prod ( ) const
inline

Definition at line 63 of file problem-with-counters.hpp.

◆ provides_eval_hess_L()

template<class Problem >
bool provides_eval_hess_L ( ) const
inline

Definition at line 64 of file problem-with-counters.hpp.

◆ provides_get_hess_L_sparsity()

template<class Problem >
bool provides_get_hess_L_sparsity ( ) const
inline

Definition at line 65 of file problem-with-counters.hpp.

◆ provides_eval_hess_ψ_prod()

template<class Problem >
bool provides_eval_hess_ψ_prod ( ) const
inline

Definition at line 66 of file problem-with-counters.hpp.

◆ provides_eval_hess_ψ()

template<class Problem >
bool provides_eval_hess_ψ ( ) const
inline

Definition at line 67 of file problem-with-counters.hpp.

◆ provides_get_hess_ψ_sparsity()

template<class Problem >
bool provides_get_hess_ψ_sparsity ( ) const
inline

Definition at line 68 of file problem-with-counters.hpp.

◆ provides_eval_f_grad_f()

template<class Problem >
bool provides_eval_f_grad_f ( ) const
inline

Definition at line 69 of file problem-with-counters.hpp.

◆ provides_eval_f_g()

template<class Problem >
bool provides_eval_f_g ( ) const
inline

Definition at line 70 of file problem-with-counters.hpp.

◆ provides_eval_grad_f_grad_g_prod()

template<class Problem >
bool provides_eval_grad_f_grad_g_prod ( ) const
inline

Definition at line 71 of file problem-with-counters.hpp.

◆ provides_eval_grad_L()

template<class Problem >
bool provides_eval_grad_L ( ) const
inline

Definition at line 72 of file problem-with-counters.hpp.

◆ provides_eval_ψ()

template<class Problem >
bool provides_eval_ψ ( ) const
inline

Definition at line 73 of file problem-with-counters.hpp.

◆ provides_eval_grad_ψ()

template<class Problem >
bool provides_eval_grad_ψ ( ) const
inline

Definition at line 74 of file problem-with-counters.hpp.

◆ provides_eval_ψ_grad_ψ()

template<class Problem >
bool provides_eval_ψ_grad_ψ ( ) const
inline

Definition at line 75 of file problem-with-counters.hpp.

◆ provides_get_box_C()

template<class Problem >
bool provides_get_box_C ( ) const
inline

Definition at line 76 of file problem-with-counters.hpp.

◆ provides_get_box_D()

template<class Problem >
bool provides_get_box_D ( ) const
inline

Definition at line 77 of file problem-with-counters.hpp.

◆ provides_check()

template<class Problem >
bool provides_check ( ) const
inline

Definition at line 78 of file problem-with-counters.hpp.

◆ provides_get_name()

template<class Problem >
bool provides_get_name ( ) const
inline

Definition at line 79 of file problem-with-counters.hpp.

◆ get_n()

template<class Problem >
length_t get_n ( ) const
inline

Definition at line 82 of file problem-with-counters.hpp.

◆ get_m()

template<class Problem >
length_t get_m ( ) const
inline

Definition at line 83 of file problem-with-counters.hpp.

◆ reset_evaluations()

template<class Problem >
void reset_evaluations ( )
inline

Reset all evaluation counters and timers to zero.

Affects all instances that share the same evaluations. If you only want to reset the counters of this instance, use decouple_evaluations first.

Definition at line 103 of file problem-with-counters.hpp.

◆ decouple_evaluations()

template<class Problem >
void decouple_evaluations ( )
inline

Give this instance its own evaluation counters and timers, decoupling it from any other instances they might have previously been shared with.

The evaluation counters and timers are preserved (a copy is made).

Definition at line 107 of file problem-with-counters.hpp.

◆ timed()

template<class Problem >
template<class TimeT , class FunT >
static decltype(auto) timed ( TimeT time,
FunT &&  f 
)
inlinestaticprivate

Definition at line 111 of file problem-with-counters.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ evaluations

template<class Problem >
std::shared_ptr<EvalCounter> evaluations = std::make_shared<EvalCounter>()

Definition at line 85 of file problem-with-counters.hpp.

◆ problem

template<class Problem >
Problem problem

Definition at line 86 of file problem-with-counters.hpp.


The documentation for this struct was generated from the following file: