|
vSMC
vSMC: Scalable Monte Carlo
|
#include <vsmc/core/sampler.hpp>
Public Types | |
| using | init_type = std::function< std::size_t(Particle< T > &, void *)> |
| using | mcmc_type = std::function< std::size_t(std::size_t, Particle< T > &)> |
| using | monitor_map_type = std::map< std::string, Monitor< T >> |
| using | move_type = std::function< std::size_t(std::size_t, Particle< T > &)> |
| using | resample_type = typename Particle< T >::resample_type |
| using | size_type = typename Particle< T >::size_type |
| using | value_type = T |
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, const resample_type &res_op) | |
| Construct a Sampler with a user defined resampling operation. 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) | |
| Construct a Sampler with a user defined resampling scheme and a threshold for resampling. 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, MonitorStage stage=MonitorMCMC) |
| 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... | |
| 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... | |
| template<typename OutputIter > | |
| void | read_size_history (OutputIter first) const |
| Read sampler size 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... | |
| double | size_history (std::size_t iter) const |
| Get sampler size of a given iteration (initialization count as iteration zero) More... | |
| template<MatrixLayout Layout, typename OutputIter > | |
| void | summary_data (OutputIter first) const |
| Sampler summary data (floating point data) More... | |
| template<MatrixLayout Layout, typename OutputIter > | |
| void | summary_data_int (OutputIter first) const |
| Sampler summary data (integer data) More... | |
| std::size_t | summary_data_size () const |
| The size of Sampler summary data (floating point data) More... | |
| std::size_t | summary_data_size_int () const |
| The size of Sampler summary data (integer data) More... | |
| template<typename OutputIter > | |
| void | summary_header (OutputIter first) const |
| Sampler summary header (floating point data) More... | |
| template<typename OutputIter > | |
| void | summary_header_int (OutputIter first) const |
| Sampler summary header (integer data) More... | |
| std::size_t | summary_header_size () const |
| The size of Sampler summary header (floating point data) More... | |
| std::size_t | summary_header_size_int () const |
| The size of Sampler summary header (integer data, size etc.) 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.
| using vsmc::Sampler< T >::init_type = std::function<std::size_t(Particle<T> &, void *)> |
Definition at line 64 of file sampler.hpp.
| using vsmc::Sampler< T >::mcmc_type = std::function<std::size_t(std::size_t, Particle<T> &)> |
Definition at line 66 of file sampler.hpp.
| using vsmc::Sampler< T >::monitor_map_type = std::map<std::string, Monitor<T>> |
Definition at line 67 of file sampler.hpp.
| using vsmc::Sampler< T >::move_type = std::function<std::size_t(std::size_t, Particle<T> &)> |
Definition at line 65 of file sampler.hpp.
| using vsmc::Sampler< T >::resample_type = typename Particle<T>::resample_type |
Definition at line 62 of file sampler.hpp.
| using vsmc::Sampler< T >::size_type = typename Particle<T>::size_type |
Definition at line 61 of file sampler.hpp.
| using vsmc::Sampler< T >::value_type = T |
Definition at line 63 of file sampler.hpp.
|
inlineexplicit |
Construct a Sampler without selection of resampling method.
Definition at line 70 of file sampler.hpp.
|
inline |
Construct a Sampler with a built-in resampling scheme.
By default, resampling will be performed at every iteration.
Definition at line 83 of file sampler.hpp.
|
inline |
Construct a Sampler with a user defined resampling operation.
By default, resampling will be performed at every iteration.
Definition at line 96 of file sampler.hpp.
|
inline |
Construct a Sampler with a built-in resampling scheme and a threshold for resampling.
Definition at line 107 of file sampler.hpp.
|
inline |
Construct a Sampler with a user defined resampling scheme and a threshold for resampling.
Definition at line 118 of file sampler.hpp.
|
inline |
Get the accept count of a given move id and the iteration.
Definition at line 305 of file sampler.hpp.
|
inline |
Erase a named monitor.
Definition at line 538 of file sampler.hpp.
|
inline |
Erase all monitors.
Definition at line 545 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 132 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 148 of file sampler.hpp.
|
inline |
Definition at line 168 of file sampler.hpp.
|
inline |
Get ESS of a given iteration, initialization count as iter 0.
Definition at line 282 of file sampler.hpp.
|
inline |
Set the initialization object of type init_type.
Definition at line 317 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 332 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 344 of file sampler.hpp.
|
inline |
Initialization.
| param | Additional parameters passed to the initialization object of type init_type |
All histories (ESS, resampled, acceptance count, Monitor) are clared before callling the initialization object. Monitors evaluation objects are untouched.
Definition at line 443 of file sampler.hpp.
|
inline |
Current iteration number (initialization count as zero)
Definition at line 208 of file sampler.hpp.
|
inline |
Number of iterations (including initialization)
Definition at line 205 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 are computed
Definition at line 464 of file sampler.hpp.
|
inline |
Add a new mcmc.
Definition at line 409 of file sampler.hpp.
|
inline |
Add a sequence of new mcmcs.
Definition at line 422 of file sampler.hpp.
|
inline |
Clear the mcmc queue.
Definition at line 395 of file sampler.hpp.
|
inline |
Check if mcmc queue is empty.
Definition at line 403 of file sampler.hpp.
|
inline |
Check the size of the mcmc queue.
Definition at line 406 of file sampler.hpp.
|
inline |
Add a monitor.
| name | The name of the monitor |
| mon | The new monitor to be added |
Definition at line 482 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 |
| stage | The stage of the Monitor |
Definition at line 498 of file sampler.hpp.
|
inline |
Read and write access to a named monitor.
Definition at line 509 of file sampler.hpp.
|
inline |
Read only access to a named monitor.
Definition at line 519 of file sampler.hpp.
|
inline |
Read and write access to all monitors to the monitor_map_type object.
Definition at line 531 of file sampler.hpp.
|
inline |
Read only access to all monitors to the the monitor_map_type object.
Definition at line 535 of file sampler.hpp.
|
inline |
Add a new move.
Definition at line 368 of file sampler.hpp.
|
inline |
Add a sequence of new moves.
Definition at line 381 of file sampler.hpp.
|
inline |
Clear the move queue.
Definition at line 355 of file sampler.hpp.
|
inline |
Check if move queue is empty.
Definition at line 362 of file sampler.hpp.
|
inline |
Check the size of the move queue.
Definition at line 365 of file sampler.hpp.
|
inline |
Read and write access to the Particle<T> object.
Definition at line 311 of file sampler.hpp.
|
inline |
Read only access to the Particle<T> object.
Definition at line 314 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 652 of file sampler.hpp.
|
inline |
Read ESS history through an output iterator.
Definition at line 286 of file sampler.hpp.
|
inline |
Read resampling indicator history through an output iterator.
Definition at line 299 of file sampler.hpp.
|
inline |
Read sampler size history through an output iterator.
Definition at line 276 of file sampler.hpp.
|
inline |
Force resample.
Definition at line 211 of file sampler.hpp.
|
inline |
Set resampling method by a resample_type object.
Definition at line 219 of file sampler.hpp.
|
inline |
Set resampling method by a built-in ResampleScheme scheme name.
Definition at line 228 of file sampler.hpp.
|
inline |
Get resampling threshold.
Definition at line 247 of file sampler.hpp.
|
inline |
Set resampling threshold.
Definition at line 250 of file sampler.hpp.
|
inlinestatic |
Special value of resampling threshold that indicate no resampling will always be performed.
Definition at line 265 of file sampler.hpp.
|
inlinestatic |
Special value of resampling threshold that indicate no resampling will be ever performed.
Definition at line 258 of file sampler.hpp.
|
inline |
Get resampling indicator of a given iteration.
Definition at line 292 of file sampler.hpp.
|
inline |
Reserve space for a specified number of iterations.
Definition at line 192 of file sampler.hpp.
|
inline |
Number of particles.
Definition at line 189 of file sampler.hpp.
|
inline |
Get sampler size of a given iteration (initialization count as iteration zero)
Definition at line 272 of file sampler.hpp.
|
inline |
Sampler summary data (floating point data)
Definition at line 636 of file sampler.hpp.
|
inline |
Sampler summary data (integer data)
Definition at line 623 of file sampler.hpp.
|
inline |
The size of Sampler summary data (floating point data)
Definition at line 616 of file sampler.hpp.
|
inline |
The size of Sampler summary data (integer data)
Definition at line 610 of file sampler.hpp.
|
inline |
Sampler summary header (floating point data)
Definition at line 590 of file sampler.hpp.
|
inline |
Sampler summary header (integer data)
Definition at line 577 of file sampler.hpp.
|
inline |
The size of Sampler summary header (floating point data)
Definition at line 562 of file sampler.hpp.
|
inline |
The size of Sampler summary header (integer data, size etc.)
Definition at line 553 of file sampler.hpp.
1.8.11