Helios++
Helios software for LiDAR simulations
fluxionum::IterativeMethodHandler< IT, ET > Class Template Reference

Base implementation of an iterative method. More...

#include <IterativeMethodHandler.h>

Collaboration diagram for fluxionum::IterativeMethodHandler< IT, ET >:

Public Types

enum  IterativeMethodStatus { PATIENCE_EARLY_STOPPING , MAX_ITERATIONS , CONVERGENCE , CONTINUE }
 Enumeration with different iterative method status. More...
 

Public Member Functions

 IterativeMethodHandler (size_t maxIters, bool enableConvergenceCriterion=false, ET convergenceEps=0.000000001, size_t patience=0, ET patienceEps=0.000000001, bool patiencePreserveBest=true)
 Iterative method constructor. More...
 
virtual IterativeMethodStatus handleEndOfIteration (IT const &input, ET const &error)
 Handle end of iteration. More...
 
virtual size_t getMaxIters () const
 Obtain the maximum number of iterations. More...
 
virtual void setMaxIters (size_t const maxIters)
 Set the maximum number of iterations. More...
 
virtual size_t getCurrentIter () const
 Obtain the number of current iteration. More...
 
virtual void setCurrentIter (size_t const iter)
 Set the number of current iteration. More...
 
virtual size_t getPatience () const
 Obtain the patience of the iterative method. More...
 
virtual void setPatience (size_t const patience)
 Set the patience of the iterative method. More...
 
virtual size_t getPatienceCount () const
 Obtain number of consecutive iterations without improvement. More...
 
virtual void setPatienceCount (size_t const count)
 Set the number of consecutive iterations without improvement. More...
 
virtual ET getPatienceEps () const
 Obtain the tolerance criterion for patience based early stopping. More...
 
virtual void setPatienceEps (ET const eps)
 Set the tolerance criterion for patience based early stopping. More...
 
virtual bool isPatiencePreservingBest () const
 Check whether the patience based early stopping mechanism is preserving best (true) or not (false) More...
 
virtual void setPatiencePreserveBest (bool const preserveBest)
 Set the patience based early stopping mechanism preserve best mode. More...
 
virtual ET getPatienceBestError () const
 Get the patience based early stopping mechanism best known error. More...
 
virtual void setPatienceBestError (ET bestError)
 Set the patience based early stopping mechanism best known error. More...
 
virtual IT getPatienceBestInput () const
 Obtain the input of best known case for patience based early stopping mechanism. More...
 
virtual void setPatienceBestInput (IT bestInput)
 Set the input of best known case for patience based early stopping mechanism. More...
 

Protected Attributes

size_t maxIters
 Maximum number of iterations for the iterative method. More...
 
size_t currentIter
 The current iteration of the iterative method.
 
bool enableConvergenceCriterion
 True to enable the usage of convergence criterion.
 
ET convergenceEps
 The convergence threshold \(\epsilon\). More...
 
size_t patience
 How many consecutive iterations with no improvement will be tolerated until aborting. More...
 
size_t patienceCount
 Count of how many consecutive iterations without improvement have elapsed.
 
ET patienceEps
 The tolerance criterion \(\epsilon\) to determine whether there have been an improvement or not. More...
 
bool patiencePreserveBest
 True to enable preserving best known input when early stopping because of patience, false to disable it.
 
ET patienceBestError
 Error of best known case for patience based early stopping mechanism.
 
IT patienceBestInput
 Input of best known case for patience based early stopping mechanism.
 

Private Member Functions

template<typename Archive >
void serialize (Archive &ar, unsigned int const version)
 Serialize the iterative method handler to a stream of bytes. More...
 

Friends

class boost::serialization::access
 

Detailed Description

template<typename IT, typename ET>
class fluxionum::IterativeMethodHandler< IT, ET >

Base implementation of an iterative method.

Author
Alberto M. Esmoris Pena
Version
1.0

It supports control by maximum number of iterations, a good enough convergence criterion and a patience based early stopping mechanism.

Template Parameters
ITInput type
ETError type

Member Enumeration Documentation

◆ IterativeMethodStatus

template<typename IT , typename ET >
enum fluxionum::IterativeMethodHandler::IterativeMethodStatus

Enumeration with different iterative method status.

  • PATIENCE_EARLY_STOPPING : Iterative method must stop because of patience early stopping mechanism
  • MAX_ITERATIONS : Iterative method must stop because max iterations have been reached
  • CONVERGENCE : Iterative method must stop because convergence have been reached
  • CONTINUE : Iterative method must continue
See also
fluxionum::IterativeMethodHandler::handleEndOfIteration

Constructor & Destructor Documentation

◆ IterativeMethodHandler()

template<typename IT , typename ET >
fluxionum::IterativeMethodHandler< IT, ET >::IterativeMethodHandler ( size_t  maxIters,
bool  enableConvergenceCriterion = false,
ET  convergenceEps = 0.000000001,
size_t  patience = 0,
ET  patienceEps = 0.000000001,
bool  patiencePreserveBest = true 
)
inline

Member Function Documentation

◆ getCurrentIter()

template<typename IT , typename ET >
virtual size_t fluxionum::IterativeMethodHandler< IT, ET >::getCurrentIter ( ) const
inlinevirtual

Obtain the number of current iteration.

Returns
Number of current iteration
See also
fluxionum::IterativeMethodHandler::currentIter

◆ getMaxIters()

template<typename IT , typename ET >
virtual size_t fluxionum::IterativeMethodHandler< IT, ET >::getMaxIters ( ) const
inlinevirtual

Obtain the maximum number of iterations.

Returns
Maximum number of iterations
See also
fluxionum::IterativeMethodHandler::maxIters

◆ getPatience()

template<typename IT , typename ET >
virtual size_t fluxionum::IterativeMethodHandler< IT, ET >::getPatience ( ) const
inlinevirtual

Obtain the patience of the iterative method.

Returns
Patience of the iterative method
See also
fluxionum::IterativeMethodHandler::patience

◆ getPatienceBestError()

template<typename IT , typename ET >
virtual ET fluxionum::IterativeMethodHandler< IT, ET >::getPatienceBestError ( ) const
inlinevirtual

Get the patience based early stopping mechanism best known error.

Returns
Patience based early stopping mechanism best known error
See also
fluxionum::IterativeMethodHandler::patienceBestError

◆ getPatienceBestInput()

template<typename IT , typename ET >
virtual IT fluxionum::IterativeMethodHandler< IT, ET >::getPatienceBestInput ( ) const
inlinevirtual

Obtain the input of best known case for patience based early stopping mechanism.

Returns
Input of best known case for patience based early stopping mechanism
See also
fluxionum::IterativeMethodHandler::patienceBestInput

◆ getPatienceCount()

template<typename IT , typename ET >
virtual size_t fluxionum::IterativeMethodHandler< IT, ET >::getPatienceCount ( ) const
inlinevirtual

Obtain number of consecutive iterations without improvement.

Returns
Number of consecutive iterations without improvement
See also
fluxionum::IterativeMethodHandler::patienceCount

◆ getPatienceEps()

template<typename IT , typename ET >
virtual ET fluxionum::IterativeMethodHandler< IT, ET >::getPatienceEps ( ) const
inlinevirtual

Obtain the tolerance criterion for patience based early stopping.

Returns
Tolerance criterion for patience based early stopping
See also
fluxionum::IterativeMethodHandler::patienceEps

◆ handleEndOfIteration()

template<typename IT , typename ET >
virtual IterativeMethodStatus fluxionum::IterativeMethodHandler< IT, ET >::handleEndOfIteration ( IT const &  input,
ET const &  error 
)
virtual

Handle end of iteration.

Parameters
errorError at given iteration
Returns
True if the iterative method is considered to have finished, thus no more iterations are needed. False otherwise.
See also
IterativeMethodHandler::IterativeMethodStatus

◆ isPatiencePreservingBest()

template<typename IT , typename ET >
virtual bool fluxionum::IterativeMethodHandler< IT, ET >::isPatiencePreservingBest ( ) const
inlinevirtual

Check whether the patience based early stopping mechanism is preserving best (true) or not (false)

Returns
True if patience based early stopping mechanism is preserving best, false otherwise
See also
fluxionum::IterativeMethodHandler::patiencePreserveBest

◆ serialize()

template<typename IT , typename ET >
template<typename Archive >
void fluxionum::IterativeMethodHandler< IT, ET >::serialize ( Archive &  ar,
unsigned int const  version 
)
inlineprivate

Serialize the iterative method handler to a stream of bytes.

Template Parameters
ArchiveType of rendering
Parameters
arSpecific rendering for the stream of bytes
versionVersion number for the iterative method handler

◆ setCurrentIter()

template<typename IT , typename ET >
virtual void fluxionum::IterativeMethodHandler< IT, ET >::setCurrentIter ( size_t const  iter)
inlinevirtual

Set the number of current iteration.

Parameters
iterNew number of current iteration
See also
fluxionum::IterativeMethodHandler::currentIter

◆ setMaxIters()

template<typename IT , typename ET >
virtual void fluxionum::IterativeMethodHandler< IT, ET >::setMaxIters ( size_t const  maxIters)
inlinevirtual

Set the maximum number of iterations.

Parameters
maxItersNew maximum number of iterations
See also
fluxionum::IterativeMethodHandler::maxIters

◆ setPatience()

template<typename IT , typename ET >
virtual void fluxionum::IterativeMethodHandler< IT, ET >::setPatience ( size_t const  patience)
inlinevirtual

Set the patience of the iterative method.

Parameters
patienceNew patience of the iterative method
See also
fluxionum::IterativeMethodHandler::patience

◆ setPatienceBestError()

template<typename IT , typename ET >
virtual void fluxionum::IterativeMethodHandler< IT, ET >::setPatienceBestError ( ET  bestError)
inlinevirtual

Set the patience based early stopping mechanism best known error.

Parameters
bestErrorNew best known error
See also
fluxionum::IterativeMethodHandler::patienceBestError

◆ setPatienceBestInput()

template<typename IT , typename ET >
virtual void fluxionum::IterativeMethodHandler< IT, ET >::setPatienceBestInput ( IT  bestInput)
inlinevirtual

Set the input of best known case for patience based early stopping mechanism.

Parameters
bestInputNew best input for patience based early stopping mechanism
See also
fluxionum::IterativeMethodHandler::patienceBestInput

◆ setPatienceCount()

template<typename IT , typename ET >
virtual void fluxionum::IterativeMethodHandler< IT, ET >::setPatienceCount ( size_t const  count)
inlinevirtual

Set the number of consecutive iterations without improvement.

Parameters
countNew number of consecutive iterations without improvement
See also
fluxionum::IterativeMethodHandler::patienceCount

◆ setPatienceEps()

template<typename IT , typename ET >
virtual void fluxionum::IterativeMethodHandler< IT, ET >::setPatienceEps ( ET const  eps)
inlinevirtual

Set the tolerance criterion for patience based early stopping.

Parameters
epsNew tolerance criterion for patience based early stopping
See also
fluxionum::IterativeMethodHandler::patienceEps

◆ setPatiencePreserveBest()

template<typename IT , typename ET >
virtual void fluxionum::IterativeMethodHandler< IT, ET >::setPatiencePreserveBest ( bool const  preserveBest)
inlinevirtual

Set the patience based early stopping mechanism preserve best mode.

Parameters
preserveBestTrue to enabled preserve best mode, false to disable it
See also
fluxionum::IterativeMethodHandler::patiencePreserveBest

Member Data Documentation

◆ convergenceEps

template<typename IT , typename ET >
ET fluxionum::IterativeMethodHandler< IT, ET >::convergenceEps
protected

The convergence threshold \(\epsilon\).

The iterative method will stop, even if the maximum number of iterations has not been reached, when \(\xi \leq \epsilon \) where \(\xi\) is the convergence error.

◆ maxIters

template<typename IT , typename ET >
size_t fluxionum::IterativeMethodHandler< IT, ET >::maxIters
protected

Maximum number of iterations for the iterative method.

While usage of this attribute may vary depending on the class which extends the implementation, the default behavior expects that \(0\) means no maximum number of iterations while \(>0\) sets a concrete maximum number of iterations for the iterative method

◆ patience

template<typename IT , typename ET >
size_t fluxionum::IterativeMethodHandler< IT, ET >::patience
protected

How many consecutive iterations with no improvement will be tolerated until aborting.

While usage of this attribute may vary depending on the class which extends the implementation, the default behavior expects that \(0\) means no patience mechanism will be used while \(>0\) sets a concrete maximum number of iterations without improvement for the patience based early stopping mechanism

◆ patienceEps

template<typename IT , typename ET >
ET fluxionum::IterativeMethodHandler< IT, ET >::patienceEps
protected

The tolerance criterion \(\epsilon\) to determine whether there have been an improvement or not.

Let \(\xi_*\) be the lowest (best) patience error and \(\xi\) the error at current iteration. Thus, there is an improvement if and only if \(\xi - \xi_* \leq \epsilon\).


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