MCKL
Monte Carlo Kernel Library
Public Types | Public Member Functions | Static Public Member Functions | List of all members
mckl::SMCSampler< T, U > Class Template Reference

SMC sampler. More...

#include <mckl/algorithm/smc.hpp>

Inherits mckl::Sampler< SMCSampler< T, U > >.

Public Types

using estimator_type = typename Sampler< SMCSampler< T, U > >::estimator_type
 
using eval_type = typename Sampler< SMCSampler< T, U > >::eval_type
 
using size_type = typename Particle< T >::size_type
 
using state_type = T
 
- Public Types inherited from mckl::Sampler< SMCSampler< T, U > >
using estimator_type = typename SamplerTrait< SMCSampler< T, U > >::estimator_type
 
using eval_type = typename SamplerTrait< SMCSampler< T, U > >::eval_type
 

Public Member Functions

 SMCSampler ()
 
template<typename... Args>
 SMCSampler (size_type N, Args &&... args)
 Construct a SMC sampler. More...
 
void clear ()
 Clear all history. More...
 
SMCSampler< T, U > clone () const
 Clone the SMC sampler except the RNG engines. More...
 
void iterate (std::size_t n=1)
 Iterate the sampler. More...
 
template<typename Eval >
std::size_t mutation (Eval &&eval, std::enable_if_t<!std::is_integral< Eval >::value > *=nullptr)
 Add a new evaluation object for the mutation step. More...
 
eval_typemutation (std::size_t k)
 
const eval_typemutation (std::size_t k) const
 
template<typename Estimator >
std::size_t mutation_estimator (Estimator &&estimator, std::enable_if_t<!std::is_integral< Estimator >::value > *=nullptr)
 
estimator_typemutation_estimator (std::size_t k)
 
const estimator_typemutation_estimator (std::size_t k) const
 
std::size_t num_iter () const
 The number of iterations already performed. More...
 
Particle< T > & particle ()
 Read and write access to the Particle<T> object. More...
 
const Particle< T > & particle () const
 Read only access to the Particle<T> object. More...
 
template<typename OutputIter >
OutputIter read_ess_history (OutputIter first) const
 Read the history of the values of ESS. More...
 
template<typename OutputIter >
OutputIter read_size_history (OutputIter first) const
 Read history the sampler sizes. More...
 
template<typename Eval >
std::size_t resample (Eval &&eval, std::enable_if_t<!std::is_integral< Eval >::value > *=nullptr)
 Add a new evaluation object for the selection step. More...
 
std::size_t resample (ResampleScheme scheme)
 Add a new evaluation object for the resample step by a built-in resample scheme. More...
 
eval_typeresample (std::size_t k)
 
const eval_typeresample (std::size_t k) const
 
template<typename Estimator >
std::size_t resample_estimator (Estimator &&estimator, std::enable_if_t<!std::is_integral< Estimator >::value > *=nullptr)
 
estimator_typeresample_estimator (std::size_t k)
 
const estimator_typeresample_estimator (std::size_t k) const
 
double resample_threshold () const
 Get resampling threshold. More...
 
void resample_threshold (double threshold)
 Set resampling threshold. More...
 
void reserve (std::size_t n)
 Reserve space for a specified number of iterations. More...
 
void reset ()
 Reset the sampler by clear all history, evaluation objects, and estimators. More...
 
template<typename Eval >
std::size_t selection (Eval &&eval, std::enable_if_t<!std::is_integral< Eval >::value > *=nullptr)
 Add a new evaluation object for the selection step. More...
 
eval_typeselection (std::size_t k)
 
const eval_typeselection (std::size_t k) const
 
template<typename Estimator >
std::size_t selection_estimator (Estimator &&estimator, std::enable_if_t<!std::is_integral< Estimator >::value > *=nullptr)
 
estimator_typeselection_estimator (std::size_t k)
 
const estimator_typeselection_estimator (std::size_t k) const
 
size_type size () const
 this->particle().size() More...
 
- Public Member Functions inherited from mckl::Sampler< SMCSampler< T, U > >
void clear ()
 Clear all estimator histories. More...
 
std::basic_ostream< CharT, Traits > & print (std::basic_ostream< CharT, Traits > &os, char sepchar=' ') const
 Print the summary matrix in textual form. More...
 
void reserve (std::size_t n)
 Reserve space for additional iterations. More...
 
void reset ()
 Remove all evaluation and estimation methods. More...
 
Matrix< T, Layout > summary () const
 Return a combined matrix of all estimates. More...
 

Static Public Member Functions

static double resample_threshold_always ()
 Special value of resampling threshold that indicates resampling will always be performed. More...
 
static double resample_threshold_never ()
 Special value of resampling threshold that indicates no resampling will be ever performed. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mckl::Sampler< SMCSampler< T, U > >
 Sampler (std::size_t steps)
 
Vector< estimator_type > & estimator (std::size_t step)
 
const Vector< estimator_type > & estimator (std::size_t step) const
 
std::size_t estimator (std::size_t step, Estimator &&estimator, std::enable_if_t<!std::is_integral< Estimator >::value > *=nullptr)
 
estimator_typeestimator (std::size_t step, std::size_t k)
 
const estimator_typeestimator (std::size_t step, std::size_t k) const
 
Vector< eval_type > & eval (std::size_t step)
 
const Vector< eval_type > & eval (std::size_t step) const
 
std::size_t eval (std::size_t step, Eval &&eval, std::enable_if_t<!std::is_integral< Eval >::value > *=nullptr)
 
eval_typeeval (std::size_t step, std::size_t k)
 
const eval_typeeval (std::size_t step, std::size_t k) const
 

Detailed Description

template<typename T, typename U>
class mckl::SMCSampler< T, U >

SMC sampler.

Definition at line 139 of file smc.hpp.

Member Typedef Documentation

◆ estimator_type

template<typename T, typename U>
using mckl::SMCSampler< T, U >::estimator_type = typename Sampler<SMCSampler<T, U> >::estimator_type

Definition at line 158 of file smc.hpp.

◆ eval_type

template<typename T, typename U>
using mckl::SMCSampler< T, U >::eval_type = typename Sampler<SMCSampler<T, U> >::eval_type

Definition at line 157 of file smc.hpp.

◆ size_type

template<typename T, typename U>
using mckl::SMCSampler< T, U >::size_type = typename Particle<T>::size_type

Definition at line 156 of file smc.hpp.

◆ state_type

template<typename T, typename U>
using mckl::SMCSampler< T, U >::state_type = T

Definition at line 155 of file smc.hpp.

Constructor & Destructor Documentation

◆ SMCSampler() [1/2]

template<typename T, typename U>
mckl::SMCSampler< T, U >::SMCSampler ( )
inline

Definition at line 160 of file smc.hpp.

◆ SMCSampler() [2/2]

template<typename T, typename U>
template<typename... Args>
mckl::SMCSampler< T, U >::SMCSampler ( size_type  N,
Args &&...  args 
)
inlineexplicit

Construct a SMC sampler.

All arguments are passed to the constructor of Particle

Definition at line 167 of file smc.hpp.

Member Function Documentation

◆ clear()

template<typename T, typename U>
void mckl::SMCSampler< T, U >::clear ( )
inline

Clear all history.

Definition at line 210 of file smc.hpp.

◆ clone()

template<typename T, typename U>
SMCSampler<T, U> mckl::SMCSampler< T, U >::clone ( ) const
inline

Clone the SMC sampler except the RNG engines.

Definition at line 176 of file smc.hpp.

◆ iterate()

template<typename T, typename U>
void mckl::SMCSampler< T, U >::iterate ( std::size_t  n = 1)
inline

Iterate the sampler.

Definition at line 352 of file smc.hpp.

◆ mutation() [1/3]

template<typename T, typename U>
template<typename Eval >
std::size_t mckl::SMCSampler< T, U >::mutation ( Eval &&  eval,
std::enable_if_t<!std::is_integral< Eval >::value > *  = nullptr 
)
inline

Add a new evaluation object for the mutation step.

Definition at line 290 of file smc.hpp.

◆ mutation() [2/3]

template<typename T, typename U>
eval_type& mckl::SMCSampler< T, U >::mutation ( std::size_t  k)
inline

Definition at line 296 of file smc.hpp.

◆ mutation() [3/3]

template<typename T, typename U>
const eval_type& mckl::SMCSampler< T, U >::mutation ( std::size_t  k) const
inline

Definition at line 298 of file smc.hpp.

◆ mutation_estimator() [1/3]

template<typename T, typename U>
template<typename Estimator >
std::size_t mckl::SMCSampler< T, U >::mutation_estimator ( Estimator &&  estimator,
std::enable_if_t<!std::is_integral< Estimator >::value > *  = nullptr 
)
inline

Definition at line 335 of file smc.hpp.

◆ mutation_estimator() [2/3]

template<typename T, typename U>
estimator_type& mckl::SMCSampler< T, U >::mutation_estimator ( std::size_t  k)
inline

Definition at line 341 of file smc.hpp.

◆ mutation_estimator() [3/3]

template<typename T, typename U>
const estimator_type& mckl::SMCSampler< T, U >::mutation_estimator ( std::size_t  k) const
inline

Definition at line 346 of file smc.hpp.

◆ num_iter()

template<typename T, typename U>
std::size_t mckl::SMCSampler< T, U >::num_iter ( ) const
inline

The number of iterations already performed.

Definition at line 190 of file smc.hpp.

◆ particle() [1/2]

template<typename T, typename U>
Particle<T>& mckl::SMCSampler< T, U >::particle ( )
inline

Read and write access to the Particle<T> object.

Definition at line 363 of file smc.hpp.

◆ particle() [2/2]

template<typename T, typename U>
const Particle<T>& mckl::SMCSampler< T, U >::particle ( ) const
inline

Read only access to the Particle<T> object.

Definition at line 366 of file smc.hpp.

◆ read_ess_history()

template<typename T, typename U>
template<typename OutputIter >
OutputIter mckl::SMCSampler< T, U >::read_ess_history ( OutputIter  first) const
inline

Read the history of the values of ESS.

Definition at line 377 of file smc.hpp.

◆ read_size_history()

template<typename T, typename U>
template<typename OutputIter >
OutputIter mckl::SMCSampler< T, U >::read_size_history ( OutputIter  first) const
inline

Read history the sampler sizes.

Definition at line 370 of file smc.hpp.

◆ resample() [1/4]

template<typename T, typename U>
template<typename Eval >
std::size_t mckl::SMCSampler< T, U >::resample ( Eval &&  eval,
std::enable_if_t<!std::is_integral< Eval >::value > *  = nullptr 
)
inline

Add a new evaluation object for the selection step.

Definition at line 252 of file smc.hpp.

◆ resample() [2/4]

template<typename T, typename U>
std::size_t mckl::SMCSampler< T, U >::resample ( ResampleScheme  scheme)
inline

Add a new evaluation object for the resample step by a built-in resample scheme.

Definition at line 260 of file smc.hpp.

◆ resample() [3/4]

template<typename T, typename U>
eval_type& mckl::SMCSampler< T, U >::resample ( std::size_t  k)
inline

Definition at line 284 of file smc.hpp.

◆ resample() [4/4]

template<typename T, typename U>
const eval_type& mckl::SMCSampler< T, U >::resample ( std::size_t  k) const
inline

Definition at line 286 of file smc.hpp.

◆ resample_estimator() [1/3]

template<typename T, typename U>
template<typename Estimator >
std::size_t mckl::SMCSampler< T, U >::resample_estimator ( Estimator &&  estimator,
std::enable_if_t<!std::is_integral< Estimator >::value > *  = nullptr 
)
inline

Definition at line 318 of file smc.hpp.

◆ resample_estimator() [2/3]

template<typename T, typename U>
estimator_type& mckl::SMCSampler< T, U >::resample_estimator ( std::size_t  k)
inline

Definition at line 324 of file smc.hpp.

◆ resample_estimator() [3/3]

template<typename T, typename U>
const estimator_type& mckl::SMCSampler< T, U >::resample_estimator ( std::size_t  k) const
inline

Definition at line 329 of file smc.hpp.

◆ resample_threshold() [1/2]

template<typename T, typename U>
double mckl::SMCSampler< T, U >::resample_threshold ( ) const
inline

Get resampling threshold.

Definition at line 219 of file smc.hpp.

◆ resample_threshold() [2/2]

template<typename T, typename U>
void mckl::SMCSampler< T, U >::resample_threshold ( double  threshold)
inline

Set resampling threshold.

Definition at line 222 of file smc.hpp.

◆ resample_threshold_always()

template<typename T, typename U>
static double mckl::SMCSampler< T, U >::resample_threshold_always ( )
inlinestatic

Special value of resampling threshold that indicates resampling will always be performed.

Definition at line 233 of file smc.hpp.

◆ resample_threshold_never()

template<typename T, typename U>
static double mckl::SMCSampler< T, U >::resample_threshold_never ( )
inlinestatic

Special value of resampling threshold that indicates no resampling will be ever performed.

Definition at line 229 of file smc.hpp.

◆ reserve()

template<typename T, typename U>
void mckl::SMCSampler< T, U >::reserve ( std::size_t  n)
inline

Reserve space for a specified number of iterations.

Definition at line 193 of file smc.hpp.

◆ reset()

template<typename T, typename U>
void mckl::SMCSampler< T, U >::reset ( )
inline

Reset the sampler by clear all history, evaluation objects, and estimators.

Definition at line 203 of file smc.hpp.

◆ selection() [1/3]

template<typename T, typename U>
template<typename Eval >
std::size_t mckl::SMCSampler< T, U >::selection ( Eval &&  eval,
std::enable_if_t<!std::is_integral< Eval >::value > *  = nullptr 
)
inline

Add a new evaluation object for the selection step.

Definition at line 237 of file smc.hpp.

◆ selection() [2/3]

template<typename T, typename U>
eval_type& mckl::SMCSampler< T, U >::selection ( std::size_t  k)
inline

Definition at line 243 of file smc.hpp.

◆ selection() [3/3]

template<typename T, typename U>
const eval_type& mckl::SMCSampler< T, U >::selection ( std::size_t  k) const
inline

Definition at line 245 of file smc.hpp.

◆ selection_estimator() [1/3]

template<typename T, typename U>
template<typename Estimator >
std::size_t mckl::SMCSampler< T, U >::selection_estimator ( Estimator &&  estimator,
std::enable_if_t<!std::is_integral< Estimator >::value > *  = nullptr 
)
inline

Definition at line 301 of file smc.hpp.

◆ selection_estimator() [2/3]

template<typename T, typename U>
estimator_type& mckl::SMCSampler< T, U >::selection_estimator ( std::size_t  k)
inline

Definition at line 307 of file smc.hpp.

◆ selection_estimator() [3/3]

template<typename T, typename U>
const estimator_type& mckl::SMCSampler< T, U >::selection_estimator ( std::size_t  k) const
inline

Definition at line 312 of file smc.hpp.

◆ size()

template<typename T, typename U>
size_type mckl::SMCSampler< T, U >::size ( ) const
inline

this->particle().size()

Definition at line 187 of file smc.hpp.