|
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... | |
| 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... | |
| 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<MatrixOrder Order, typename OutputIter > | |
| void | summary_data (OutputIter first) const |
| Sampler summary data (floating point data) More... | |
| template<MatrixOrder Order, 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 59 of file sampler.hpp.
| using vsmc::Sampler< T >::init_type = std::function<std::size_t(Particle<T> &, void *)> |
Definition at line 65 of file sampler.hpp.
| using vsmc::Sampler< T >::mcmc_type = std::function<std::size_t(std::size_t, Particle<T> &)> |
Definition at line 67 of file sampler.hpp.
| using vsmc::Sampler< T >::monitor_map_type = std::map<std::string, Monitor<T>> |
Definition at line 68 of file sampler.hpp.
| using vsmc::Sampler< T >::move_type = std::function<std::size_t(std::size_t, Particle<T> &)> |
Definition at line 66 of file sampler.hpp.
| using vsmc::Sampler< T >::resample_type = typename Particle<T>::resample_type |
Definition at line 63 of file sampler.hpp.
| using vsmc::Sampler< T >::size_type = typename Particle<T>::size_type |
Definition at line 62 of file sampler.hpp.
| using vsmc::Sampler< T >::value_type = T |
Definition at line 64 of file sampler.hpp.
|
inlineexplicit |
Construct a Sampler without selection of resampling method.
Definition at line 71 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 85 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 99 of file sampler.hpp.
|
inline |
Construct a Sampler with a built-in resampling scheme and a threshold for resampling.
Definition at line 111 of file sampler.hpp.
|
inline |
Construct a Sampler with a user defined resampling scheme and a threshold for resampling.
Definition at line 123 of file sampler.hpp.
|
inline |
Get the accept count of a given move id and the iteration.
Definition at line 313 of file sampler.hpp.
|
inline |
Erase a named monitor.
Definition at line 566 of file sampler.hpp.
|
inline |
Erase all monitors.
Definition at line 573 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 138 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 154 of file sampler.hpp.
|
inline |
Definition at line 174 of file sampler.hpp.
|
inline |
Get ESS of a given iteration, initialization count as iter 0.
Definition at line 290 of file sampler.hpp.
|
inline |
Set the initialization object of type init_type.
Definition at line 325 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 340 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 352 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 451 of file sampler.hpp.
|
inline |
Current iteration number (initialization count as zero)
Definition at line 216 of file sampler.hpp.
|
inline |
Number of iterations (including initialization)
Definition at line 213 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 472 of file sampler.hpp.
|
inline |
Add a new mcmc.
Definition at line 417 of file sampler.hpp.
|
inline |
Add a sequence of new mcmcs.
Definition at line 430 of file sampler.hpp.
|
inline |
Clear the mcmc queue.
Definition at line 403 of file sampler.hpp.
|
inline |
Check if mcmc queue is empty.
Definition at line 411 of file sampler.hpp.
|
inline |
Check the size of the mcmc queue.
Definition at line 414 of file sampler.hpp.
|
inline |
Add a monitor.
| name | The name of the monitor |
| mon | The new monitor to be added |
Definition at line 510 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 526 of file sampler.hpp.
|
inline |
Read and write access to a named monitor.
Definition at line 537 of file sampler.hpp.
|
inline |
Read only access to a named monitor.
Definition at line 547 of file sampler.hpp.
|
inline |
Read and write access to all monitors to the monitor_map_type object.
Definition at line 559 of file sampler.hpp.
|
inline |
Read only access to all monitors to the the monitor_map_type object.
Definition at line 563 of file sampler.hpp.
|
inline |
Add a new move.
Definition at line 376 of file sampler.hpp.
|
inline |
Add a sequence of new moves.
Definition at line 389 of file sampler.hpp.
|
inline |
Clear the move queue.
Definition at line 363 of file sampler.hpp.
|
inline |
Check if move queue is empty.
Definition at line 370 of file sampler.hpp.
|
inline |
Check the size of the move queue.
Definition at line 373 of file sampler.hpp.
|
inline |
Read and write access to the Particle<T> object.
Definition at line 319 of file sampler.hpp.
|
inline |
Read only access to the Particle<T> object.
Definition at line 322 of file sampler.hpp.
|
inline |
Read and write access to the Path sampling monitor.
Definition at line 487 of file sampler.hpp.
|
inline |
Read only access to the Path sampling monitor.
Definition at line 490 of file sampler.hpp.
|
inline |
Set the Path sampling evaluation object.
Definition at line 493 of file sampler.hpp.
|
inline |
Path sampling estimate of the logarithm of normalizing constants ratio.
Definition at line 504 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 686 of file sampler.hpp.
|
inline |
Read ESS history through an output iterator.
Definition at line 294 of file sampler.hpp.
|
inline |
Read resampling indicator history through an output iterator.
Definition at line 307 of file sampler.hpp.
|
inline |
Read sampler size history through an output iterator.
Definition at line 284 of file sampler.hpp.
|
inline |
Force resample.
Definition at line 219 of file sampler.hpp.
|
inline |
Set resampling method by a resample_type object.
Definition at line 227 of file sampler.hpp.
|
inline |
Set resampling method by a built-in ResampleScheme scheme name.
Definition at line 236 of file sampler.hpp.
|
inline |
Get resampling threshold.
Definition at line 255 of file sampler.hpp.
|
inline |
Set resampling threshold.
Definition at line 258 of file sampler.hpp.
|
inlinestatic |
Special value of resampling threshold that indicate no resampling will always be performed.
Definition at line 273 of file sampler.hpp.
|
inlinestatic |
Special value of resampling threshold that indicate no resampling will be ever performed.
Definition at line 266 of file sampler.hpp.
|
inline |
Get resampling indicator of a given iteration.
Definition at line 300 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 |
Get sampler size of a given iteration (initialization count as iteration zero)
Definition at line 280 of file sampler.hpp.
|
inline |
Sampler summary data (floating point data)
Definition at line 670 of file sampler.hpp.
|
inline |
Sampler summary data (integer data)
Definition at line 657 of file sampler.hpp.
|
inline |
The size of Sampler summary data (floating point data)
Definition at line 650 of file sampler.hpp.
|
inline |
The size of Sampler summary data (integer data)
Definition at line 644 of file sampler.hpp.
|
inline |
Sampler summary header (floating point data)
Definition at line 620 of file sampler.hpp.
|
inline |
Sampler summary header (integer data)
Definition at line 607 of file sampler.hpp.
|
inline |
The size of Sampler summary header (floating point data)
Definition at line 590 of file sampler.hpp.
|
inline |
The size of Sampler summary header (integer data, size etc.)
Definition at line 581 of file sampler.hpp.
1.8.11