alpaqa 1.0.0a9
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
 

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, rindexvec inner_idx, rindexvec outer_ptr, rvec J_values) const
 
length_t get_jac_g_num_nonzeros () 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, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const
 
length_t get_hess_L_num_nonzeros () 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, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const
 
length_t get_hess_ψ_num_nonzeros () 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
 
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_num_nonzeros () const
 
bool provides_eval_hess_L_prod () const
 
bool provides_eval_hess_L () const
 
bool provides_get_hess_L_num_nonzeros () const
 
bool provides_eval_hess_ψ_prod () const
 
bool provides_eval_hess_ψ () const
 
bool provides_get_hess_ψ_num_nonzeros () 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
 
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(auto) timed (TimeT &time, FunT &&f)
 

Member Typedef Documentation

◆ Box

using Box = typename TypeErasedProblem<config_t>::Box

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

Constructor & Destructor Documentation

◆ ProblemWithCounters() [1/3]

ProblemWithCounters ( )
default

◆ ProblemWithCounters() [2/3]

ProblemWithCounters ( P &&  problem)
inlineexplicit

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

◆ ProblemWithCounters() [3/3]

ProblemWithCounters ( std::in_place_t  ,
Args &&...  args 
)
inlineexplicit

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

Member Function Documentation

◆ eval_proj_diff_g()

void eval_proj_diff_g ( crvec  z,
rvec  e 
) const
inline

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

+ Here is the call graph for this function:

◆ eval_proj_multipliers()

void eval_proj_multipliers ( rvec  y,
real_t  M 
) const
inline

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

+ Here is the call graph for this function:

◆ eval_prox_grad_step()

real_t eval_prox_grad_step ( real_t  γ,
crvec  x,
crvec  grad_ψ,
rvec  ,
rvec  p 
) const
inline

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

+ Here is the call graph for this function:

◆ eval_inactive_indices_res_lna()

index_t eval_inactive_indices_res_lna ( real_t  γ,
crvec  x,
crvec  grad_ψ,
rindexvec  J 
) const
inline

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

◆ eval_f()

real_t eval_f ( crvec  x) const
inline

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

+ Here is the call graph for this function:

◆ eval_grad_f()

void eval_grad_f ( crvec  x,
rvec  grad_fx 
) const
inline

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

+ Here is the call graph for this function:

◆ eval_g()

void eval_g ( crvec  x,
rvec  gx 
) const
inline

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

+ Here is the call graph for this function:

◆ eval_grad_g_prod()

void eval_grad_g_prod ( crvec  x,
crvec  y,
rvec  grad_gxy 
) const
inline

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

+ Here is the call graph for this function:

◆ eval_grad_gi()

void eval_grad_gi ( crvec  x,
index_t  i,
rvec  grad_gi 
) const
inline

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

◆ eval_jac_g()

void eval_jac_g ( crvec  x,
rindexvec  inner_idx,
rindexvec  outer_ptr,
rvec  J_values 
) const
inline

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

◆ get_jac_g_num_nonzeros()

length_t get_jac_g_num_nonzeros ( ) const
inline

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

◆ eval_hess_L_prod()

void eval_hess_L_prod ( crvec  x,
crvec  y,
real_t  scale,
crvec  v,
rvec  Hv 
) const
inline

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

◆ eval_hess_L()

void eval_hess_L ( crvec  x,
crvec  y,
real_t  scale,
rindexvec  inner_idx,
rindexvec  outer_ptr,
rvec  H_values 
) const
inline

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

◆ get_hess_L_num_nonzeros()

length_t get_hess_L_num_nonzeros ( ) const
inline

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

◆ eval_hess_ψ_prod()

void eval_hess_ψ_prod ( crvec  x,
crvec  y,
crvec  Σ,
real_t  scale,
crvec  v,
rvec  Hv 
) const
inline

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

◆ eval_hess_ψ()

void eval_hess_ψ ( crvec  x,
crvec  y,
crvec  Σ,
real_t  scale,
rindexvec  inner_idx,
rindexvec  outer_ptr,
rvec  H_values 
) const
inline

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

◆ get_hess_ψ_num_nonzeros()

length_t get_hess_ψ_num_nonzeros ( ) const
inline

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

◆ eval_f_grad_f()

real_t eval_f_grad_f ( crvec  x,
rvec  grad_fx 
) const
inline

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

◆ eval_f_g()

real_t eval_f_g ( crvec  x,
rvec  g 
) const
inline

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

◆ eval_grad_f_grad_g_prod()

void eval_grad_f_grad_g_prod ( crvec  x,
crvec  y,
rvec  grad_f,
rvec  grad_gxy 
) const
inline

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

◆ eval_grad_L()

void eval_grad_L ( crvec  x,
crvec  y,
rvec  grad_L,
rvec  work_n 
) const
inline

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

◆ eval_ψ()

real_t eval_ψ ( crvec  x,
crvec  y,
crvec  Σ,
rvec  ŷ 
) const
inline

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

◆ eval_grad_ψ()

void eval_grad_ψ ( crvec  x,
crvec  y,
crvec  Σ,
rvec  grad_ψ,
rvec  work_n,
rvec  work_m 
) const
inline

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

◆ eval_ψ_grad_ψ()

real_t 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.

◆ get_box_C()

const Box & get_box_C ( ) const
inline

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

◆ get_box_D()

const Box & get_box_D ( ) const
inline

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

◆ check()

void check ( ) const
inline

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

◆ provides_eval_grad_gi()

bool provides_eval_grad_gi ( ) const
inline

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

◆ provides_eval_inactive_indices_res_lna()

bool provides_eval_inactive_indices_res_lna ( ) const
inline

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

◆ provides_eval_jac_g()

bool provides_eval_jac_g ( ) const
inline

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

◆ provides_get_jac_g_num_nonzeros()

bool provides_get_jac_g_num_nonzeros ( ) const
inline

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

◆ provides_eval_hess_L_prod()

bool provides_eval_hess_L_prod ( ) const
inline

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

◆ provides_eval_hess_L()

bool provides_eval_hess_L ( ) const
inline

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

◆ provides_get_hess_L_num_nonzeros()

bool provides_get_hess_L_num_nonzeros ( ) const
inline

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

◆ provides_eval_hess_ψ_prod()

bool provides_eval_hess_ψ_prod ( ) const
inline

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

◆ provides_eval_hess_ψ()

bool provides_eval_hess_ψ ( ) const
inline

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

◆ provides_get_hess_ψ_num_nonzeros()

bool provides_get_hess_ψ_num_nonzeros ( ) const
inline

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

◆ provides_eval_f_grad_f()

bool provides_eval_f_grad_f ( ) const
inline

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

◆ provides_eval_f_g()

bool provides_eval_f_g ( ) const
inline

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

◆ provides_eval_grad_f_grad_g_prod()

bool provides_eval_grad_f_grad_g_prod ( ) const
inline

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

◆ provides_eval_grad_L()

bool provides_eval_grad_L ( ) const
inline

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

◆ provides_eval_ψ()

bool provides_eval_ψ ( ) const
inline

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

◆ provides_eval_grad_ψ()

bool provides_eval_grad_ψ ( ) const
inline

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

◆ provides_eval_ψ_grad_ψ()

bool provides_eval_ψ_grad_ψ ( ) const
inline

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

◆ provides_get_box_C()

bool provides_get_box_C ( ) const
inline

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

◆ provides_get_box_D()

bool provides_get_box_D ( ) const
inline

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

◆ provides_check()

bool provides_check ( ) const
inline

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

◆ get_n()

length_t get_n ( ) const
inline

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

◆ get_m()

length_t get_m ( ) const
inline

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

◆ reset_evaluations()

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 100 of file problem-with-counters.hpp.

◆ decouple_evaluations()

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 104 of file problem-with-counters.hpp.

◆ timed()

static decltype(auto) timed ( TimeT &  time,
FunT &&  f 
)
inlinestaticprivate

Definition at line 108 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

std::shared_ptr<EvalCounter> evaluations = std::make_shared<EvalCounter>()

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

◆ problem

Problem problem

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


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