vSMC
vSMC: Scalable Monte Carlo
|
Monitor for Monte Carlo integration. More...
#include <vsmc/core/monitor.hpp>
Public Types | |
using | eval_type = std::function< void(std::size_t, std::size_t, Particle< T > &, double *)> |
using | value_type = T |
Public Member Functions | |
Monitor (std::size_t dim, const eval_type &eval, bool record_only=false, MonitorStage stage=MonitorMCMC) | |
void | clear () |
Clear all records of the index and integrations. More... | |
std::size_t | dim () const |
The dimension of the Monitor. More... | |
bool | empty () const |
Whether the evaluation object is valid. More... | |
void | eval (std::size_t iter, Particle< T > &particle, MonitorStage stage) |
Perform the evaluation for a given iteration and a Particle<T> object. More... | |
std::size_t | index (std::size_t iter) const |
Get the iteration index of the sampler of a given Monitor iteration. More... | |
const std::size_t * | index_data () const |
Read only access to the raw data of the index vector. More... | |
std::size_t | iter_size () const |
The number of iterations has been recorded. More... | |
std::string & | name (std::size_t id) |
Read and write access to the names of variables. More... | |
const std::string & | name (std::size_t id) const |
Read only access to the names of variables. More... | |
template<typename OutputIter > | |
void | read_index (OutputIter first) const |
Read the index history through an output iterator. More... | |
template<typename OutputIter > | |
void | read_record (std::size_t id, OutputIter first) const |
Read the record history for a given variable through an output iterator. More... | |
template<typename OutputIterIter > | |
void | read_record_matrix (OutputIterIter first) const |
Read the record history of all variables through an array of output iterators. More... | |
template<MatrixOrder Order, typename OutputIter > | |
void | read_record_matrix (OutputIter first) const |
Read the record history of all variables through an output iterator. More... | |
double | record (std::size_t id) const |
Get the latest Monte Carlo integration record of a given variable. More... | |
double | record (std::size_t id, std::size_t iter) const |
Get the Monte Carlo integration record of a given variable and the Monitor iteration. More... | |
const double * | record_data () const |
Read only access to the raw data of records (a row major matrix) More... | |
const double * | record_data (std::size_t iter) const |
Read only access to the raw data of records for a given Monitor iteration. More... | |
bool | record_only () const |
If this is a record only Monitor. More... | |
bool | recording () const |
Whether the Monitor is actively recording results. More... | |
void | reserve (std::size_t num) |
Reserve space for a specified number of iterations. More... | |
void | set_eval (const eval_type &new_eval) |
Set a new evaluation object of type eval_type. More... | |
MonitorStage | stage () const |
The stage of the Montior. More... | |
void | turn_off () |
Turn off the recording. More... | |
void | turn_on () |
Turn on the recording. More... | |
Monitor for Monte Carlo integration.
Definition at line 63 of file monitor.hpp.
using vsmc::Monitor< T >::eval_type = std::function<void(std::size_t, std::size_t, Particle<T> &, double *)> |
Definition at line 68 of file monitor.hpp.
using vsmc::Monitor< T >::value_type = T |
Definition at line 66 of file monitor.hpp.
|
inlineexplicit |
Definition at line 70 of file monitor.hpp.
|
inline |
Clear all records of the index and integrations.
Definition at line 269 of file monitor.hpp.
|
inline |
The dimension of the Monitor.
Definition at line 82 of file monitor.hpp.
|
inline |
Whether the evaluation object is valid.
Definition at line 101 of file monitor.hpp.
|
inline |
Perform the evaluation for a given iteration and a Particle<T> object.
Definition at line 242 of file monitor.hpp.
|
inline |
Get the iteration index of the sampler of a given Monitor iteration.
For example, if a Monitor is only added to the sampler at the sampler's iteration siter
. Then index(0)
will be siter
and so on. If the Monitor is added before the sampler's initialization and continued to be evaluated during the iterations without calling turnoff()
, then iter(iter) shall just be iter
.
Definition at line 134 of file monitor.hpp.
|
inline |
Read only access to the raw data of the index vector.
Definition at line 176 of file monitor.hpp.
|
inline |
The number of iterations has been recorded.
Definition at line 91 of file monitor.hpp.
|
inline |
Read and write access to the names of variables.
By default, each variable of a Monitor is unnamed and the returned string is empty. However, the user can selectively set the names of each variable. This effect how Sampler will print the headers of the summary table.
Definition at line 110 of file monitor.hpp.
|
inline |
Read only access to the names of variables.
Definition at line 118 of file monitor.hpp.
|
inline |
Read the index history through an output iterator.
Definition at line 170 of file monitor.hpp.
|
inline |
Read the record history for a given variable through an output iterator.
Definition at line 192 of file monitor.hpp.
|
inline |
Read the record history of all variables through an array of output iterators.
first | An iterator of container of output iterators |
Definition at line 205 of file monitor.hpp.
|
inline |
Read the record history of all variables through an output iterator.
first | The output iterator |
For example, say first
is of type double *
, then if order == ColMajor
, then, first[j * iter_size() + i] == record(i, j)
. Otherwise, if order == RowMajor
, then first[i * dim() + j] == record(i, j)
. That is, the output is an iter_size()
by dim()
matrix, with the usual meaning of column or row major order.
Definition at line 222 of file monitor.hpp.
|
inline |
Get the latest Monte Carlo integration record of a given variable.
For a dim
dimension Monitor, id
shall be 0 to dim
- 1
Definition at line 146 of file monitor.hpp.
|
inline |
Get the Monte Carlo integration record of a given variable and the Monitor iteration.
For a dim
dimension Monitor, id
shall be 0 to dim
- 1
Definition at line 160 of file monitor.hpp.
|
inline |
Read only access to the raw data of records (a row major matrix)
Definition at line 180 of file monitor.hpp.
|
inline |
Read only access to the raw data of records for a given Monitor iteration.
Definition at line 184 of file monitor.hpp.
|
inline |
If this is a record only Monitor.
Definition at line 85 of file monitor.hpp.
|
inline |
Whether the Monitor is actively recording results.
Definition at line 276 of file monitor.hpp.
|
inline |
Reserve space for a specified number of iterations.
Definition at line 94 of file monitor.hpp.
|
inline |
Set a new evaluation object of type eval_type.
Definition at line 238 of file monitor.hpp.
|
inline |
The stage of the Montior.
Definition at line 88 of file monitor.hpp.
|
inline |
Turn off the recording.
Definition at line 282 of file monitor.hpp.
|
inline |
Turn on the recording.
Definition at line 279 of file monitor.hpp.