alpaqa dll
Nonconvex constrained optimization
Loading...
Searching...
No Matches
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_projecting_difference_constraints (crvec z, rvec e) const
void eval_projection_multipliers (rvec y, real_t M) const
real_t eval_proximal_gradient_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_objective (crvec x) const
void eval_objective_gradient (crvec x, rvec grad_fx) const
void eval_constraints (crvec x, rvec gx) const
void eval_constraints_gradient_product (crvec x, crvec y, rvec grad_gxy) const
void eval_grad_gi (crvec x, index_t i, rvec grad_gi) const
void eval_constraints_jacobian (crvec x, rvec J_values) const
Sparsity get_constraints_jacobian_sparsity () const
void eval_lagrangian_hessian_product (crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
void eval_lagrangian_hessian (crvec x, crvec y, real_t scale, rvec H_values) const
Sparsity get_lagrangian_hessian_sparsity () const
void eval_augmented_lagrangian_hessian_product (crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
void eval_augmented_lagrangian_hessian (crvec x, crvec y, crvec Σ, real_t scale, rvec H_values) const
Sparsity get_augmented_lagrangian_hessian_sparsity () const
real_t eval_objective_and_gradient (crvec x, rvec grad_fx) const
real_t eval_objective_and_constraints (crvec x, rvec g) const
void eval_objective_gradient_and_constraints_gradient_product (crvec x, crvec y, rvec grad_f, rvec grad_gxy) const
void eval_lagrangian_gradient (crvec x, crvec y, rvec grad_L, rvec work_n) const
real_t eval_augmented_lagrangian (crvec x, crvec y, crvec Σ, rvec ŷ) const
void eval_augmented_lagrangian_gradient (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
real_t eval_augmented_lagrangian_and_gradient (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
const Boxget_variable_bounds () const
const Boxget_general_bounds () 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_constraints_jacobian () const
bool provides_get_constraints_jacobian_sparsity () const
bool provides_eval_lagrangian_hessian_product () const
bool provides_eval_lagrangian_hessian () const
bool provides_get_lagrangian_hessian_sparsity () const
bool provides_eval_augmented_lagrangian_hessian_product () const
bool provides_eval_augmented_lagrangian_hessian () const
bool provides_get_augmented_lagrangian_hessian_sparsity () const
bool provides_eval_objective_and_gradient () const
bool provides_eval_objective_and_constraints () const
bool provides_eval_objective_gradient_and_constraints_gradient_product () const
bool provides_eval_lagrangian_gradient () const
bool provides_eval_augmented_lagrangian () const
bool provides_eval_augmented_lagrangian_gradient () const
bool provides_eval_augmented_lagrangian_and_gradient () const
bool provides_get_variable_bounds () const
bool provides_get_general_bounds () const
bool provides_check () const
bool provides_get_name () const
length_t get_num_variables () const
length_t get_num_constraints () 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

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

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

Constructor & Destructor Documentation

◆ ProblemWithCounters() [1/3]

template<class Problem>
ProblemWithCounters ( )
default
Here is the caller graph for this function:

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

Here is the call graph for this function:

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

Member Function Documentation

◆ eval_projecting_difference_constraints()

template<class Problem>
void eval_projecting_difference_constraints ( 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_projection_multipliers()

template<class Problem>
void eval_projection_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_proximal_gradient_step()

template<class Problem>
real_t eval_proximal_gradient_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()

template<class Problem>
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_objective()

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

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

Here is the call graph for this function:

◆ eval_objective_gradient()

template<class Problem>
void eval_objective_gradient ( 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_constraints()

template<class Problem>
void eval_constraints ( 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_constraints_gradient_product()

template<class Problem>
void eval_constraints_gradient_product ( 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()

template<class Problem>
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_constraints_jacobian()

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

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

◆ get_constraints_jacobian_sparsity()

template<class Problem>
Sparsity get_constraints_jacobian_sparsity ( ) const
inline

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

◆ eval_lagrangian_hessian_product()

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

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

◆ eval_lagrangian_hessian()

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

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

◆ get_lagrangian_hessian_sparsity()

template<class Problem>
Sparsity get_lagrangian_hessian_sparsity ( ) const
inline

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

◆ eval_augmented_lagrangian_hessian_product()

template<class Problem>
void eval_augmented_lagrangian_hessian_product ( 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_augmented_lagrangian_hessian()

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

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

◆ get_augmented_lagrangian_hessian_sparsity()

template<class Problem>
Sparsity get_augmented_lagrangian_hessian_sparsity ( ) const
inline

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

◆ eval_objective_and_gradient()

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

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

◆ eval_objective_and_constraints()

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

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

◆ eval_objective_gradient_and_constraints_gradient_product()

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

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

◆ eval_lagrangian_gradient()

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

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

◆ eval_augmented_lagrangian()

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

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

◆ eval_augmented_lagrangian_gradient()

template<class Problem>
void eval_augmented_lagrangian_gradient ( 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_augmented_lagrangian_and_gradient()

template<class Problem>
real_t eval_augmented_lagrangian_and_gradient ( 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_variable_bounds()

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

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

◆ get_general_bounds()

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

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

◆ check()

template<class Problem>
void check ( ) const
inline

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

◆ get_name()

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

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

◆ provides_eval_grad_gi()

template<class Problem>
bool provides_eval_grad_gi ( ) const
inlinenodiscard

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

◆ provides_eval_inactive_indices_res_lna()

template<class Problem>
bool provides_eval_inactive_indices_res_lna ( ) const
inlinenodiscard

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

◆ provides_eval_constraints_jacobian()

template<class Problem>
bool provides_eval_constraints_jacobian ( ) const
inlinenodiscard

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

◆ provides_get_constraints_jacobian_sparsity()

template<class Problem>
bool provides_get_constraints_jacobian_sparsity ( ) const
inlinenodiscard

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

◆ provides_eval_lagrangian_hessian_product()

template<class Problem>
bool provides_eval_lagrangian_hessian_product ( ) const
inlinenodiscard

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

◆ provides_eval_lagrangian_hessian()

template<class Problem>
bool provides_eval_lagrangian_hessian ( ) const
inlinenodiscard

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

◆ provides_get_lagrangian_hessian_sparsity()

template<class Problem>
bool provides_get_lagrangian_hessian_sparsity ( ) const
inlinenodiscard

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

◆ provides_eval_augmented_lagrangian_hessian_product()

template<class Problem>
bool provides_eval_augmented_lagrangian_hessian_product ( ) const
inlinenodiscard

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

◆ provides_eval_augmented_lagrangian_hessian()

template<class Problem>
bool provides_eval_augmented_lagrangian_hessian ( ) const
inlinenodiscard

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

◆ provides_get_augmented_lagrangian_hessian_sparsity()

template<class Problem>
bool provides_get_augmented_lagrangian_hessian_sparsity ( ) const
inlinenodiscard

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

◆ provides_eval_objective_and_gradient()

template<class Problem>
bool provides_eval_objective_and_gradient ( ) const
inlinenodiscard

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

◆ provides_eval_objective_and_constraints()

template<class Problem>
bool provides_eval_objective_and_constraints ( ) const
inlinenodiscard

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

◆ provides_eval_objective_gradient_and_constraints_gradient_product()

template<class Problem>
bool provides_eval_objective_gradient_and_constraints_gradient_product ( ) const
inlinenodiscard

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

◆ provides_eval_lagrangian_gradient()

template<class Problem>
bool provides_eval_lagrangian_gradient ( ) const
inlinenodiscard

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

◆ provides_eval_augmented_lagrangian()

template<class Problem>
bool provides_eval_augmented_lagrangian ( ) const
inlinenodiscard

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

◆ provides_eval_augmented_lagrangian_gradient()

template<class Problem>
bool provides_eval_augmented_lagrangian_gradient ( ) const
inlinenodiscard

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

◆ provides_eval_augmented_lagrangian_and_gradient()

template<class Problem>
bool provides_eval_augmented_lagrangian_and_gradient ( ) const
inlinenodiscard

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

◆ provides_get_variable_bounds()

template<class Problem>
bool provides_get_variable_bounds ( ) const
inlinenodiscard

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

◆ provides_get_general_bounds()

template<class Problem>
bool provides_get_general_bounds ( ) const
inlinenodiscard

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

◆ provides_check()

template<class Problem>
bool provides_check ( ) const
inlinenodiscard

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

◆ provides_get_name()

template<class Problem>
bool provides_get_name ( ) const
inlinenodiscard

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

◆ get_num_variables()

template<class Problem>
length_t get_num_variables ( ) const
inlinenodiscard

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

◆ get_num_constraints()

template<class Problem>
length_t get_num_constraints ( ) const
inlinenodiscard

Definition at line 82 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 102 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 106 of file problem-with-counters.hpp.

◆ timed()

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

Definition at line 110 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 84 of file problem-with-counters.hpp.

◆ problem

template<class Problem>
Problem problem

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


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