vSMC  v3.0.0
Scalable Monte Carlo
Public Types | Public Member Functions | Static Public Member Functions | List of all members
vsmc::Sampler< T > Class Template Reference

SMC Sampler. More...

#include <vsmc/core/sampler.hpp>

Public Types

using eval_type = std::function< std::size_t(std::size_t, Particle< T > &)>
 
using size_type = typename Particle< T >::size_type
 

Public Member Functions

template<typename... Args>
 Sampler (Args &&...args)
 Construct a Sampler. More...
 
Sampler< T > clone () const
 Clone the Sampler except the RNG engines. More...
 
double ess_history (std::size_t iter) const
 Get ESS of a given iteration, (initialization count as iter zero) More...
 
Sampler< T > & eval (const eval_type &new_eval, SamplerStage stage, bool append=true)
 Add a new evaluation object. More...
 
Sampler< T > & initialize ()
 Initialization. More...
 
std::size_t iter_num () const
 Current iteration number (initialization count as zero) More...
 
std::size_t iter_size () const
 Number of iterations (including initialization) More...
 
Sampler< T > & iterate (std::size_t num=1)
 Iteration. More...
 
Sampler< T > & monitor (const std::string &name, const Monitor< T > &mon)
 Add a monitor. More...
 
Monitor< T > & monitor (const std::string &name)
 Read and write access to a named monitor. More...
 
const Monitor< T > & monitor (const std::string &name) const
 Read only access to a named monitor. More...
 
bool monitor_clear (const std::string &name)
 Erase a named monitor. More...
 
Sampler< T > & monitor_clear ()
 Erase all monitors. 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 CharT , typename Traits >
std::basic_ostream< CharT, Traits > & print (std::basic_ostream< CharT, Traits > &os, char sepchar= '\t') const
 Print the history of the Sampler. More...
 
template<typename OutputIter >
OutputIter read_ess_history (OutputIter first) const
 Read ESS history through an output iterator. More...
 
template<typename OutputIter >
OutputIter read_resampled_history (OutputIter first) const
 Read resampling indicator history through an output iterator. More...
 
template<typename OutputIter >
OutputIter read_size_history (OutputIter first) const
 Read sampler size history through an output iterator. More...
 
Sampler< T > & resample_method (ResampleScheme scheme, double threshold=resample_threshold_always())
 Set resampling method by a built-in ResampleScheme scheme name. More...
 
Sampler< T > & resample_method (const eval_type &res_eval, double threshold=resample_threshold_always())
 Set resampling method by a eval_type object. More...
 
double resample_threshold () const
 Get resampling threshold. More...
 
Sampler< T > & resample_threshold (double threshold)
 Set resampling threshold. More...
 
bool resampled_history (std::size_t iter) const
 Get resampling indicator of a given iteration. More...
 
void reserve (std::size_t num)
 Reserve space for a specified number of iterations. More...
 
size_type size () const
 Number of particles. More...
 
size_type size_history (std::size_t iter) const
 Get sampler size of a given iteration (initialization count as iteration zero) More...
 
std::size_t status_history (std::size_t iter, std::size_t id) const
 Get the status of a given move id and the iteration. More...
 
std::map< std::string, Vector< double > > summary () const
 Summary of sampler history. More...
 

Static Public Member Functions

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

Detailed Description

template<typename T>
class vsmc::Sampler< T >

SMC Sampler.

Definition at line 99 of file sampler.hpp.

Member Typedef Documentation

template<typename T>
using vsmc::Sampler< T >::eval_type = std::function<std::size_t(std::size_t, Particle<T> &)>

Definition at line 103 of file sampler.hpp.

template<typename T>
using vsmc::Sampler< T >::size_type = typename Particle<T>::size_type

Definition at line 102 of file sampler.hpp.

Constructor & Destructor Documentation

template<typename T>
template<typename... Args>
vsmc::Sampler< T >::Sampler ( Args &&...  args)
inlineexplicit

Construct a Sampler.

All arguments are passed to the constructor of Particle

Definition at line 110 of file sampler.hpp.

Member Function Documentation

template<typename T>
Sampler<T> vsmc::Sampler< T >::clone ( ) const
inline

Clone the Sampler except the RNG engines.

Definition at line 118 of file sampler.hpp.

template<typename T>
double vsmc::Sampler< T >::ess_history ( std::size_t  iter) const
inline

Get ESS of a given iteration, (initialization count as iter zero)

Definition at line 311 of file sampler.hpp.

template<typename T>
Sampler<T>& vsmc::Sampler< T >::eval ( const eval_type new_eval,
SamplerStage  stage,
bool  append = true 
)
inline

Add a new evaluation object.

Definition at line 149 of file sampler.hpp.

template<typename T>
Sampler<T>& vsmc::Sampler< T >::initialize ( )
inline

Initialization.

Definition at line 271 of file sampler.hpp.

template<typename T>
std::size_t vsmc::Sampler< T >::iter_num ( ) const
inline

Current iteration number (initialization count as zero)

Definition at line 146 of file sampler.hpp.

template<typename T>
std::size_t vsmc::Sampler< T >::iter_size ( ) const
inline

Number of iterations (including initialization)

Definition at line 143 of file sampler.hpp.

template<typename T>
Sampler<T>& vsmc::Sampler< T >::iterate ( std::size_t  num = 1)
inline

Iteration.

Definition at line 279 of file sampler.hpp.

template<typename T>
Sampler<T>& vsmc::Sampler< T >::monitor ( const std::string &  name,
const Monitor< T > &  mon 
)
inline

Add a monitor.

Parameters
nameThe name of the monitor
monThe new monitor to be added

Definition at line 227 of file sampler.hpp.

template<typename T>
Monitor<T>& vsmc::Sampler< T >::monitor ( const std::string &  name)
inline

Read and write access to a named monitor.

Definition at line 235 of file sampler.hpp.

template<typename T>
const Monitor<T>& vsmc::Sampler< T >::monitor ( const std::string &  name) const
inline

Read only access to a named monitor.

Definition at line 245 of file sampler.hpp.

template<typename T>
bool vsmc::Sampler< T >::monitor_clear ( const std::string &  name)
inline

Erase a named monitor.

Definition at line 256 of file sampler.hpp.

template<typename T>
Sampler<T>& vsmc::Sampler< T >::monitor_clear ( )
inline

Erase all monitors.

Definition at line 263 of file sampler.hpp.

template<typename T>
Particle<T>& vsmc::Sampler< T >::particle ( )
inline

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

Definition at line 290 of file sampler.hpp.

template<typename T>
const Particle<T>& vsmc::Sampler< T >::particle ( ) const
inline

Read only access to the Particle<T> object.

Definition at line 293 of file sampler.hpp.

template<typename T>
template<typename CharT , typename Traits >
std::basic_ostream<CharT, Traits>& vsmc::Sampler< T >::print ( std::basic_ostream< CharT, Traits > &  os,
char  sepchar = '\t' 
) const
inline

Print the history of the Sampler.

Parameters
osThe ostream to which the contents are printed
sepcharThe seperator of fields

Definition at line 398 of file sampler.hpp.

template<typename T>
template<typename OutputIter >
OutputIter vsmc::Sampler< T >::read_ess_history ( OutputIter  first) const
inline

Read ESS history through an output iterator.

Definition at line 315 of file sampler.hpp.

template<typename T>
template<typename OutputIter >
OutputIter vsmc::Sampler< T >::read_resampled_history ( OutputIter  first) const
inline

Read resampling indicator history through an output iterator.

Definition at line 328 of file sampler.hpp.

template<typename T>
template<typename OutputIter >
OutputIter vsmc::Sampler< T >::read_size_history ( OutputIter  first) const
inline

Read sampler size history through an output iterator.

Definition at line 304 of file sampler.hpp.

template<typename T>
Sampler<T>& vsmc::Sampler< T >::resample_method ( ResampleScheme  scheme,
double  threshold = resample_threshold_always() 
)
inline

Set resampling method by a built-in ResampleScheme scheme name.

Definition at line 161 of file sampler.hpp.

template<typename T>
Sampler<T>& vsmc::Sampler< T >::resample_method ( const eval_type res_eval,
double  threshold = resample_threshold_always() 
)
inline

Set resampling method by a eval_type object.

Definition at line 190 of file sampler.hpp.

template<typename T>
double vsmc::Sampler< T >::resample_threshold ( ) const
inline

Get resampling threshold.

Definition at line 200 of file sampler.hpp.

template<typename T>
Sampler<T>& vsmc::Sampler< T >::resample_threshold ( double  threshold)
inline

Set resampling threshold.

Definition at line 203 of file sampler.hpp.

template<typename T>
static double vsmc::Sampler< T >::resample_threshold_always ( )
inlinestatic

Special value of resampling threshold that indicate no resampling will always be performed.

Definition at line 218 of file sampler.hpp.

template<typename T>
static double vsmc::Sampler< T >::resample_threshold_never ( )
inlinestatic

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

Definition at line 211 of file sampler.hpp.

template<typename T>
bool vsmc::Sampler< T >::resampled_history ( std::size_t  iter) const
inline

Get resampling indicator of a given iteration.

Definition at line 321 of file sampler.hpp.

template<typename T>
void vsmc::Sampler< T >::reserve ( std::size_t  num)
inline

Reserve space for a specified number of iterations.

Definition at line 131 of file sampler.hpp.

template<typename T>
size_type vsmc::Sampler< T >::size ( ) const
inline

Number of particles.

Definition at line 128 of file sampler.hpp.

template<typename T>
size_type vsmc::Sampler< T >::size_history ( std::size_t  iter) const
inline

Get sampler size of a given iteration (initialization count as iteration zero)

Definition at line 297 of file sampler.hpp.

template<typename T>
std::size_t vsmc::Sampler< T >::status_history ( std::size_t  iter,
std::size_t  id 
) const
inline

Get the status of a given move id and the iteration.

Definition at line 335 of file sampler.hpp.

template<typename T>
std::map<std::string, Vector<double> > vsmc::Sampler< T >::summary ( ) const
inline

Summary of sampler history.

Definition at line 341 of file sampler.hpp.