vSMC
vSMC: Scalable Monte Carlo
|
#include <vsmc/core/sampler.hpp>
Public Types | |
typedef cxx11::function< std::size_t(Particle< T > &, void *)> | init_type |
typedef cxx11::function< std::size_t(std::size_t, Particle< T > &)> | mcmc_type |
typedef std::map< std::string, Monitor< T > > | monitor_map_type |
typedef cxx11::function< std::size_t(std::size_t, Particle< T > &)> | move_type |
typedef Particle< T >::resample_type | resample_type |
typedef Particle< T >::size_type | size_type |
typedef T | value_type |
Public Member Functions | |
Sampler (size_type N) | |
Construct a Sampler without selection of resampling method. More... | |
Sampler (size_type N, ResampleScheme scheme) | |
Construct a Sampler with a built-in resampling scheme. More... | |
Sampler (size_type N, ResampleScheme scheme, double resample_threshold) | |
Construct a Sampler with a built-in resampling scheme and a threshold for resampling. More... | |
Sampler (size_type N, const resample_type &res_op, double resample_threshold=0.5) | |
Construct a Sampler with a user defined resampling operation. More... | |
std::size_t | accept_history (std::size_t id, std::size_t iter) const |
Get the accept count of a given move id and the iteration. More... | |
bool | clear_monitor (const std::string &name) |
Erase a named monitor. More... | |
Sampler< T > & | clear_monitor () |
Erase all monitors. More... | |
Sampler< T > | clone (bool new_rng) const |
Clone the sampler system except the RNG engines. More... | |
Sampler< T > & | clone (const Sampler< T > &other, bool retain_rng) |
Clone another sampler system except the RNG engines. More... | |
Sampler< T > & | clone (Sampler< T > &&other, bool retain_rng) |
double | ess_history (std::size_t iter) const |
Get ESS of a given iteration, initialization count as iter 0. More... | |
Sampler< T > & | init (const init_type &new_init) |
Set the initialization object of type init_type. More... | |
Sampler< T > & | init_by_iter (bool initialize_by_iterate) |
Set if initialization should use the move and mcmc queue. More... | |
Sampler< T > & | init_by_move (const move_type &new_init) |
Set the initialization object with a type move_type object. More... | |
Sampler< T > & | initialize (void *param=nullptr) |
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 > & | mcmc (const mcmc_type &new_mcmc, bool append) |
Add a new mcmc. More... | |
template<typename InputIter > | |
Sampler< T > & | mcmc (InputIter first, InputIter last, bool append) |
Add a sequence of new mcmcs. More... | |
Sampler< T > & | mcmc_queue_clear () |
Clear the mcmc queue. More... | |
bool | mcmc_queue_empty () const |
Check if mcmc queue is empty. More... | |
std::size_t | mcmc_queue_size () const |
Check the size of the mcmc queue. More... | |
Sampler< T > & | monitor (const std::string &name, const Monitor< T > &mon) |
Add a monitor. More... | |
Sampler< T > & | monitor (const std::string &name, std::size_t dim, const typename Monitor< T >::eval_type &eval, bool record_only=false) |
Add a monitor with an evaluation object. 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... | |
monitor_map_type & | monitor () |
Read and write access to all monitors to the monitor_map_type object. More... | |
const monitor_map_type & | monitor () const |
Read only access to all monitors to the the monitor_map_type object. More... | |
Sampler< T > & | move (const move_type &new_move, bool append) |
Add a new move. More... | |
template<typename InputIter > | |
Sampler< T > & | move (InputIter first, InputIter last, bool append) |
Add a sequence of new moves. More... | |
Sampler< T > & | move_queue_clear () |
Clear the move queue. More... | |
bool | move_queue_empty () const |
Check if move queue is empty. More... | |
std::size_t | move_queue_size () const |
Check the size of the move queue. 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... | |
Path< T > & | path () |
Read and write access to the Path sampling monitor. More... | |
const Path< T > & | path () const |
Read only access to the Path sampling monitor. More... | |
Sampler< T > & | path_sampling (const typename Path< T >::eval_type &eval, bool record_only=false) |
Set the Path sampling evaluation object. More... | |
double | path_sampling () const |
Path sampling estimate of the logarithm of normalizing constants ratio. 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 > | |
void | read_ess_history (OutputIter first) const |
Read ESS history through an output iterator. More... | |
template<typename OutputIter > | |
void | read_resampled_history (OutputIter first) const |
Read resampling indicator history through an output iterator. More... | |
Sampler< T > & | resample () |
Force resample. More... | |
Sampler< T > & | resample_scheme (const resample_type &res_op) |
Set resampling method by a resample_type object. More... | |
Sampler< T > & | resample_scheme (ResampleScheme scheme) |
Set resampling method by a built-in ResampleScheme scheme name. 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... | |
template<MatrixOrder Order, typename OutputIter > | |
void | summary_data (OutputIter first) const |
Sampler summary data. More... | |
std::size_t | summary_data_size () const |
The size of Sampler summary data. More... | |
template<typename OutputIter > | |
void | summary_header (OutputIter first) const |
Sampler summary header. More... | |
std::size_t | summary_header_size () const |
The size of Sampler summary header. 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... | |
SMC Sampler.
Definition at line 58 of file sampler.hpp.
typedef cxx11::function<std::size_t (Particle<T> &, void *)> vsmc::Sampler< T >::init_type |
Definition at line 65 of file sampler.hpp.
typedef cxx11::function<std::size_t (std::size_t, Particle<T> &)> vsmc::Sampler< T >::mcmc_type |
Definition at line 69 of file sampler.hpp.
typedef std::map<std::string, Monitor<T> > vsmc::Sampler< T >::monitor_map_type |
Definition at line 70 of file sampler.hpp.
typedef cxx11::function<std::size_t (std::size_t, Particle<T> &)> vsmc::Sampler< T >::move_type |
Definition at line 67 of file sampler.hpp.
typedef Particle<T>::resample_type vsmc::Sampler< T >::resample_type |
Definition at line 63 of file sampler.hpp.
typedef Particle<T>::size_type vsmc::Sampler< T >::size_type |
Definition at line 62 of file sampler.hpp.
typedef T vsmc::Sampler< T >::value_type |
Definition at line 64 of file sampler.hpp.
|
inlineexplicit |
Construct a Sampler without selection of resampling method.
If no resampling method, either built-in ones or user defined are provided, then it is assumed that no resamling shall be performed at all. And the threshold is set to resample_threshold_never()
. If resampling is consdiered, then use the other two versions of the constructor to make the intention clear to the library.
Definition at line 80 of file sampler.hpp.
|
inline |
Construct a Sampler with a built-in resampling scheme.
If a built-in scheme is chosen, then it is assumed that the user always want to perform resampling.
Definition at line 90 of file sampler.hpp.
|
inline |
Construct a Sampler with a built-in resampling scheme and a threshold for resampling.
If a built-in scheme is chosen, then it is assumed that at least the user want to perform resampling at least sometime. So the threshold is set to 0.5 if not provided as the third parameter.
Definition at line 102 of file sampler.hpp.
|
inline |
Construct a Sampler with a user defined resampling operation.
If a user defined resampling operation is set, then it is assumed that at least the user want to perform resampling at least sometime. So the threshold is set to 0.5 if not provided as the third parameter.
Definition at line 113 of file sampler.hpp.
|
inline |
Get the accept count of a given move id and the iteration.
Definition at line 300 of file sampler.hpp.
|
inline |
Erase a named monitor.
Definition at line 553 of file sampler.hpp.
|
inline |
Erase all monitors.
Definition at line 560 of file sampler.hpp.
|
inline |
Clone the sampler system except the RNG engines.
new_rng | If true, the new particle system has new-seeded RNG. Otherwise false, it is exactly the same as the current. |
Definition at line 123 of file sampler.hpp.
|
inline |
Clone another sampler system except the RNG engines.
other | The particle system to be cloned |
retain_rng | If true, retain the current system's RNG. Otherwise, it is exactly the same as the new one. |
Definition at line 140 of file sampler.hpp.
|
inline |
Definition at line 173 of file sampler.hpp.
|
inline |
Get ESS of a given iteration, initialization count as iter 0.
Definition at line 283 of file sampler.hpp.
|
inline |
Set the initialization object of type init_type.
Definition at line 310 of file sampler.hpp.
|
inline |
Set if initialization should use the move and mcmc queue.
If set to false
, then the initialization step use the initialization object if it is not empty. Otherwise, it perform the same steps as the iteration step.
Definition at line 325 of file sampler.hpp.
|
inline |
Set the initialization object with a type move_type object.
When called, the iteration parameter passed to this object will be 0 and the void *
parameter will be ignored.
Definition at line 337 of file sampler.hpp.
|
inline |
Initialization.
param | Additional parameters passed to the initialization object of type init_type |
All histories (ESS, resampled, accept, Monitor and Path) are clared before callling the initialization object. Monitors and Path's evaluation objects are untouched.
Definition at line 440 of file sampler.hpp.
|
inline |
Current iteration number (initialization count as zero)
The value of iter_size() - iter_num()
is always 1. iter_size
emphasize that it returns the total number of iterations. iter_num
is more of an index of the sampler, starting from zero.
Definition at line 222 of file sampler.hpp.
|
inline |
Number of iterations (including initialization)
Definition at line 214 of file sampler.hpp.
|
inline |
Iteration.
Moves performed first. Then ESS/N is compared to the threshold and possible resampling is performed. Then mcmcs are performed. Then monitors and Path are computed
Definition at line 464 of file sampler.hpp.
|
inline |
Add a new mcmc.
Definition at line 406 of file sampler.hpp.
|
inline |
Add a sequence of new mcmcs.
Definition at line 419 of file sampler.hpp.
|
inline |
Clear the mcmc queue.
Definition at line 397 of file sampler.hpp.
|
inline |
Check if mcmc queue is empty.
Definition at line 400 of file sampler.hpp.
|
inline |
Check the size of the mcmc queue.
Definition at line 403 of file sampler.hpp.
|
inline |
Add a monitor.
name | The name of the monitor |
mon | The new monitor to be added |
Definition at line 501 of file sampler.hpp.
|
inline |
Add a monitor with an evaluation object.
name | The name of the monitor |
dim | The dimension of the monitor, i.e., the number of variables |
eval | The evaluation object of type Monitor::eval_type |
record_only | The monitor only records results |
Definition at line 512 of file sampler.hpp.
|
inline |
Read and write access to a named monitor.
Definition at line 523 of file sampler.hpp.
|
inline |
Read only access to a named monitor.
Definition at line 534 of file sampler.hpp.
|
inline |
Read and write access to all monitors to the monitor_map_type object.
Definition at line 546 of file sampler.hpp.
|
inline |
Read only access to all monitors to the the monitor_map_type object.
Definition at line 550 of file sampler.hpp.
|
inline |
Add a new move.
Definition at line 370 of file sampler.hpp.
|
inline |
Add a sequence of new moves.
Definition at line 383 of file sampler.hpp.
|
inline |
Clear the move queue.
Definition at line 361 of file sampler.hpp.
|
inline |
Check if move queue is empty.
Definition at line 364 of file sampler.hpp.
|
inline |
Check the size of the move queue.
Definition at line 367 of file sampler.hpp.
|
inline |
Read and write access to the Particle<T> object.
Definition at line 304 of file sampler.hpp.
|
inline |
Read only access to the Particle<T> object.
Definition at line 307 of file sampler.hpp.
|
inline |
Read and write access to the Path sampling monitor.
Definition at line 483 of file sampler.hpp.
|
inline |
Read only access to the Path sampling monitor.
Definition at line 486 of file sampler.hpp.
|
inline |
Set the Path sampling evaluation object.
Definition at line 489 of file sampler.hpp.
|
inline |
Path sampling estimate of the logarithm of normalizing constants ratio.
Definition at line 495 of file sampler.hpp.
|
inline |
Print the history of the Sampler.
os | The ostream to which the contents are printed |
sepchar | The seperator of fields |
Definition at line 650 of file sampler.hpp.
|
inline |
Read ESS history through an output iterator.
Definition at line 287 of file sampler.hpp.
|
inline |
Read resampling indicator history through an output iterator.
Definition at line 296 of file sampler.hpp.
|
inline |
Force resample.
Definition at line 225 of file sampler.hpp.
|
inline |
Set resampling method by a resample_type object.
Definition at line 234 of file sampler.hpp.
|
inline |
Set resampling method by a built-in ResampleScheme scheme name.
Definition at line 239 of file sampler.hpp.
|
inline |
Get resampling threshold.
Definition at line 266 of file sampler.hpp.
|
inline |
Set resampling threshold.
Definition at line 269 of file sampler.hpp.
|
inlinestatic |
Special value of resampling threshold that indicate no resampling will always be performed.
Definition at line 279 of file sampler.hpp.
|
inlinestatic |
Special value of resampling threshold that indicate no resampling will be ever performed.
Definition at line 274 of file sampler.hpp.
|
inline |
Get resampling indicator of a given iteration.
Definition at line 291 of file sampler.hpp.
|
inline |
Reserve space for a specified number of iterations.
Definition at line 198 of file sampler.hpp.
|
inline |
Number of particles.
Definition at line 195 of file sampler.hpp.
|
inline |
Sampler summary data.
first | The beginning of the output |
Definition at line 633 of file sampler.hpp.
|
inline |
The size of Sampler summary data.
Definition at line 626 of file sampler.hpp.
|
inline |
Sampler summary header.
Definition at line 583 of file sampler.hpp.
|
inline |
The size of Sampler summary header.
Definition at line 563 of file sampler.hpp.