SOPT
Sparse OPTimisation
Public Types | Public Member Functions | List of all members
sopt::proximal::L1< SCALAR >::Breaker Class Reference

#include <l1_proximal.h>

Public Types

using Real = typename real_type< SCALAR >::type
 

Public Member Functions

 Breaker (Real objective, Real tolerance=1e-8, bool do_two_cycle=true)
 
bool operator() (Real objective)
 True if we should break out of loop. More...
 
Real current () const
 Current objective. More...
 
Real previous () const
 Current objective. More...
 
Real relative_variation () const
 Variation in the objective function. More...
 
bool two_cycle () const
 Whether we have a cycle of period two. More...
 
bool converged () const
 True if relative variation smaller than tolerance. More...
 
Real tolerance () const
 Tolerance criteria. More...
 
L1< SCALAR >::Breakertolerance (Real tol) const
 Tolerance criteria. More...
 

Detailed Description

template<typename SCALAR>
class sopt::proximal::L1< SCALAR >::Breaker

Definition at line 425 of file l1_proximal.h.

Member Typedef Documentation

◆ Real

template<typename SCALAR >
using sopt::proximal::L1< SCALAR >::Breaker::Real = typename real_type<SCALAR>::type

Definition at line 427 of file l1_proximal.h.

Constructor & Destructor Documentation

◆ Breaker()

template<typename SCALAR >
sopt::proximal::L1< SCALAR >::Breaker::Breaker ( Real  objective,
Real  tolerance = 1e-8,
bool  do_two_cycle = true 
)
inline

Constructs a breaker object

Parameters
[in]objectivethe first objective function
[in]toleranceConvergence criteria for convergence
[in]do_two_cycleWhether to enable two cycle detections. Only necessary when mixing is not enabled.

Definition at line 433 of file l1_proximal.h.

434  : tolerance_(tolerance),
435  iter(0),
436  objectives({{objective, 0, 0, 0}}),
437  do_two_cycle(do_two_cycle) {}
std::enable_if< is_complex< Scalar >::value==is_complex< typename T0::Scalar >::value and is_complex< Scalar >::value==is_complex< typename T1::Scalar >::value, Real >::type objective(Eigen::MatrixBase< T0 > const &x, Eigen::MatrixBase< T1 > const &z, Real const &gamma) const
Definition: l1_proximal.h:149
Real tolerance() const
Tolerance criteria.
Definition: l1_proximal.h:465

References sopt::proximal::L1TightFrame< SCALAR >::objective().

Member Function Documentation

◆ converged()

template<typename SCALAR >
bool sopt::proximal::L1< SCALAR >::Breaker::converged ( ) const
inline

True if relative variation smaller than tolerance.

Definition at line 458 of file l1_proximal.h.

458  {
459  // If current ~ 0, then defaults to absolute convergence
460  // This is mainly to avoid a division by zero
461  if (std::abs(current() * 1000) < tolerance()) return std::abs(previous() * 1000) < tolerance();
462  return relative_variation() < tolerance();
463  }
Real previous() const
Current objective.
Definition: l1_proximal.h:447
Real current() const
Current objective.
Definition: l1_proximal.h:445
Real relative_variation() const
Variation in the objective function.
Definition: l1_proximal.h:449

Referenced by TEST_CASE().

◆ current()

template<typename SCALAR >
Real sopt::proximal::L1< SCALAR >::Breaker::current ( ) const
inline

Current objective.

Definition at line 445 of file l1_proximal.h.

445 { return objectives[0]; }

Referenced by TEST_CASE().

◆ operator()()

template<typename SCALAR >
bool sopt::proximal::L1< SCALAR >::Breaker::operator() ( Real  objective)
inline

True if we should break out of loop.

Definition at line 439 of file l1_proximal.h.

439  {
440  ++iter;
441  objectives = {{objective, objectives[0], objectives[1], objectives[2]}};
442  return converged() or two_cycle();
443  }
bool converged() const
True if relative variation smaller than tolerance.
Definition: l1_proximal.h:458
bool two_cycle() const
Whether we have a cycle of period two.
Definition: l1_proximal.h:452

References sopt::proximal::L1TightFrame< SCALAR >::objective().

◆ previous()

template<typename SCALAR >
Real sopt::proximal::L1< SCALAR >::Breaker::previous ( ) const
inline

Current objective.

Definition at line 447 of file l1_proximal.h.

447 { return objectives[1]; }

◆ relative_variation()

template<typename SCALAR >
Real sopt::proximal::L1< SCALAR >::Breaker::relative_variation ( ) const
inline

Variation in the objective function.

Definition at line 449 of file l1_proximal.h.

449 { return std::abs((current() - previous()) / current()); }

◆ tolerance() [1/2]

template<typename SCALAR >
Real sopt::proximal::L1< SCALAR >::Breaker::tolerance ( ) const
inline

Tolerance criteria.

Definition at line 465 of file l1_proximal.h.

465 { return tolerance_; }

◆ tolerance() [2/2]

template<typename SCALAR >
L1<SCALAR>::Breaker& sopt::proximal::L1< SCALAR >::Breaker::tolerance ( Real  tol) const
inline

Tolerance criteria.

Definition at line 467 of file l1_proximal.h.

467  {
468  tolerance_ = tol;
469  return *this;
470  }
constexpr Scalar tol

References tol.

◆ two_cycle()

template<typename SCALAR >
bool sopt::proximal::L1< SCALAR >::Breaker::two_cycle ( ) const
inline

Whether we have a cycle of period two.

Cycling is prone to happen without mixing, it seems.

Definition at line 452 of file l1_proximal.h.

452  {
453  return do_two_cycle and iter > 3 and std::abs(objectives[0] - objectives[2]) < tolerance() and
454  std::abs(objectives[1] - objectives[3]) < tolerance();
455  }

Referenced by TEST_CASE().


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