SOPT
Sparse OPTimisation
Classes | Public Member Functions | List of all members
sopt::algorithm::JointMAP< ALGORITHM > Class Template Reference

#include <joint_map.h>

Classes

struct  DiagnosticAndResultReg
 Holds results and reg parameter. More...
 

Public Member Functions

 JointMAP (const std::shared_ptr< ALGORITHM > &algo_ptr, const t_Reg_Term &reg_term, const t_uint number_of_wavelet_coeffs)
 
 SOPT_MACRO (itermax, t_uint)
 Maximum number of iterations. More...
 
 SOPT_MACRO (alpha, t_real)
 Alpha parameter. More...
 
 SOPT_MACRO (beta, t_real)
 Beta parameter. More...
 
 SOPT_MACRO (k, t_real)
 k More...
 
 SOPT_MACRO (number_of_wavelet_coeffs, t_uint)
 number of wavelet coeffs More...
 
 SOPT_MACRO (algo_ptr, std::shared_ptr< ALGORITHM >)
 Shared ptr with algorithm. More...
 
 SOPT_MACRO (reg_term, t_Reg_Term)
 Regularsation Term. More...
 
 SOPT_MACRO (relative_variation, t_real)
 relative variation of reg parameter More...
 
 SOPT_MACRO (objective_variation, t_real)
 relative variation of objective_function More...
 
 SOPT_MACRO (is_converged, t_IsConverged)
 A function verifying convergence. More...
 
template<typename... ARGS>
DiagnosticAndResultReg operator() (ARGS &&... args) const
 Calls Joint MAP estimation. More...
 

Detailed Description

template<typename ALGORITHM>
class sopt::algorithm::JointMAP< ALGORITHM >

Definition at line 19 of file joint_map.h.

Constructor & Destructor Documentation

◆ JointMAP()

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::JointMAP ( const std::shared_ptr< ALGORITHM > &  algo_ptr,
const t_Reg_Term &  reg_term,
const t_uint  number_of_wavelet_coeffs 
)
inline

Definition at line 36 of file joint_map.h.

38  : algo_ptr_(algo_ptr),
39  reg_term_(reg_term),
40  alpha_(1),
41  beta_(1),
42  k_(1),
43  number_of_wavelet_coeffs_(number_of_wavelet_coeffs),
44  is_converged_([](t_Vector const &, t_Vector const &, t_real const) { return true; }),
45  relative_variation_(1e-3),
46  objective_variation_(1e-3),
47  itermax_(std::numeric_limits<t_uint>::max()){}
sopt::Vector< Scalar > t_Vector
sopt::t_real t_real

Member Function Documentation

◆ operator()()

template<typename ALGORITHM >
template<typename... ARGS>
DiagnosticAndResultReg sopt::algorithm::JointMAP< ALGORITHM >::operator() ( ARGS &&...  args) const
inline

Calls Joint MAP estimation.

Parameters
[out]outDiagnostic and Solution

Definition at line 95 of file joint_map.h.

95  {
96  SOPT_HIGH_LOG("Performing Joint MAP estimation");
97 
98  ScalarRelativeVariation<t_real> scalvar(relative_variation(), relative_variation(),
99  "Regularisation Parameter");
100  ScalarRelativeVariation<t_real> objvar(objective_variation(), objective_variation(),
101  "Joint Objective Function");
102  sanity_check(this->algo_ptr_->regulariser_strength(), beta(), alpha());
103  t_uint niters(0);
104  bool converged = false;
105  using ResultType = typename ALGORITHM::DiagnosticAndResult;
106  ResultType result = (*(this->algo_ptr_))(std::forward<ARGS>(args)...);
107  t_real regulariser_strength = 0;
108  niters++;
109  t_uint algo_iters(result.niters);
110  for (; (not converged) && (niters < itermax()); ++niters) {
111  SOPT_LOW_LOG(" - [JMAP] Iteration {}/{}", niters, itermax());
112  regulariser_strength = (static_cast<t_real>(number_of_wavelet_coeffs()) / k() + alpha()) /
113  (this->reg_term()(result.x) + beta());
114  SOPT_LOW_LOG(" - [JMAP] Regularisation Parameter Value {}", regulariser_strength);
115  algo_ptr_->regulariser_strength(regulariser_strength);
116  result = (*algo_ptr_)(result);
117  converged = result.good and scalvar(regulariser_strength) and objvar(algo_ptr_->objmin()) and
118  this->is_converged()(result.x, result.residual, regulariser_strength);
119  algo_iters += result.niters;
120  }
121 
122  if (converged) {
123  SOPT_MEDIUM_LOG(" - [JMAP] converged in {} of {} iterations", niters, itermax());
124  } else {
125  // not meaningful if not convergence function
126  SOPT_ERROR(" - [JMAP] did not converge within {} iterations", itermax());
127  }
128  SOPT_MEDIUM_LOG(" - Total Algorithm iterations {} ", algo_iters);
129  DiagnosticAndResultReg diagnostic;
130  static_cast<ResultType &>(diagnostic) = result;
131  diagnostic.niters = algo_iters;
132  diagnostic.reg_good = converged;
133  diagnostic.reg_niters = niters;
134  diagnostic.reg_term = regulariser_strength;
135  return diagnostic;
136  }
#define SOPT_LOW_LOG(...)
Low priority message.
Definition: logging.h:227
#define SOPT_HIGH_LOG(...)
High priority message.
Definition: logging.h:223
#define SOPT_ERROR(...)
\macro Something is definitely wrong, algorithm exits
Definition: logging.h:211
#define SOPT_MEDIUM_LOG(...)
Medium priority message.
Definition: logging.h:225
size_t t_uint
Root of the type hierarchy for unsigned integers.
Definition: types.h:15

References sopt::algorithm::JointMAP< ALGORITHM >::DiagnosticAndResultReg::reg_good, sopt::algorithm::JointMAP< ALGORITHM >::DiagnosticAndResultReg::reg_niters, sopt::algorithm::JointMAP< ALGORITHM >::DiagnosticAndResultReg::reg_term, SOPT_ERROR, SOPT_HIGH_LOG, SOPT_LOW_LOG, and SOPT_MEDIUM_LOG.

◆ SOPT_MACRO() [1/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( algo_ptr  ,
std::shared_ptr< ALGORITHM >   
)

Shared ptr with algorithm.

◆ SOPT_MACRO() [2/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( alpha  ,
t_real   
)

Alpha parameter.

◆ SOPT_MACRO() [3/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( beta  ,
t_real   
)

Beta parameter.

◆ SOPT_MACRO() [4/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( is_converged  ,
t_IsConverged   
)

A function verifying convergence.

It takes as input two arguments: the current solution x and the current residual.

◆ SOPT_MACRO() [5/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( itermax  ,
t_uint   
)

Maximum number of iterations.

◆ SOPT_MACRO() [6/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( ,
t_real   
)

k

◆ SOPT_MACRO() [7/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( number_of_wavelet_coeffs  ,
t_uint   
)

number of wavelet coeffs

◆ SOPT_MACRO() [8/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( objective_variation  ,
t_real   
)

relative variation of objective_function

◆ SOPT_MACRO() [9/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( reg_term  ,
t_Reg_Term   
)

Regularsation Term.

◆ SOPT_MACRO() [10/10]

template<typename ALGORITHM >
sopt::algorithm::JointMAP< ALGORITHM >::SOPT_MACRO ( relative_variation  ,
t_real   
)

relative variation of reg parameter


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