sampler_MCMC_base Class Referenceabstract
Inheritance diagram for sampler_MCMC_base:
Collaboration diagram for sampler_MCMC_base:
Public Member Functions | |
sampler_MCMC_base (int seed, likelihood &L, std::vector< std::string > var_names, size_t dimension) | |
virtual void | set_initial_location (std::vector< double > initial_parameters)=0 |
virtual void | run_sampler (int nsteps, int thin, int refresh, int verbosity=1)=0 |
virtual void | set_output_stream (std::string chain_name, std::string state_name, std::string sampler_name, int output_precision=8) |
Sets the output names for the chains and sampler states. This must be implemented in any classes inheriting sampler_exploration_mcmc_base. More... | |
virtual std::vector< double > | find_best_fit (std::string chain_file, std::string state_file) const |
Finds the best fit within provided chain file and returns it. More... | |
virtual std::vector< double > | find_best_fit () const |
Finds the best fit from the chain and state file saved in set_output_stream. More... | |
void | set_checkpoint (int ckpt_stride, std::string ckpt_file) |
Sets the checkpoint/restart functionality. More... | |
virtual void | write_checkpoint (std::ostream &out)=0 |
virtual void | read_checkpoint (std::string ckpt_file) |
Restarts the sampler from the state specified in the ckpt_file. More... | |
virtual void | read_checkpoint (std::istream &ckpt_in)=0 |
virtual void | reset_sampler_step () |
void | reset_likelihood_sum () |
double | get_likelihood_sum () |
virtual double | get_rand () |
virtual void | reset_rng_seed (int seed) |
virtual void | get_chain_state (std::vector< double > ¶meters, std::vector< double > &sample_state)=0 |
virtual void | set_chain_state (std::vector< double > parameters, std::vector< double > sample_state)=0 |
void | set_mpi_communicator (MPI_Comm comm) |
Sets the MPI_Comm to be used for the likelihood evaluation. More... | |
void | close_streams () |
Helper function that closes the streams from a sampler. | |
Protected Member Functions | |
virtual void | write_state ()=0 |
virtual void | write_chain_header () |
virtual void | write_state_header () |
Protected Attributes | |
int | _seed |
Ran2RNG | _rng |
std::vector< std::string > | _var_names |
size_t | _dimension |
size_t | _step_count |
likelihood * | _L |
std::string | _chain_file |
std::string | _state_file |
std::string | _sampler_file |
std::string | _ckpt_file |
std::ofstream | _chain_out |
std::ofstream | _state_out |
std::ofstream | _sampler_out |
int | _output_precision |
int | _ckpt_stride |
double | _sum_lklhd |
MPI_Comm | _comm |
int | _rank |
Member Function Documentation
|
virtual |
- Parameters
-
chain_file The file name of the chain. state_file The file name of the saved state.
- Note
- if no chain_file or state_file is provided it will just read in the one that was saved using set_output_stream. This also assumes that the first element of the state vector is the log-likelihood value.
Reimplemented in sampler_deo_tempering_MCMC< S >.
|
virtual |
- Note
- Only run this after calling run sampler.
Reimplemented in sampler_deo_tempering_MCMC< S >.
|
virtual |
- Parameters
-
ckpt_file The file where the checkpoint information was saved.
Reimplemented in sampler_deo_tempering_MCMC< S >, sampler_stan_adapt_dense_e_nuts_MCMC, sampler_stan_adapt_diag_e_nuts_MCMC, and sampler_automated_factor_slice_sampler_MCMC.
Here is the caller graph for this function:
void set_checkpoint | ( | int | ckpt_stride, |
std::string | ckpt_file | ||
) |
- Parameters
-
ckpt_stride Number of steps between writing a new checkpoint. ckpt_file String variable holding the name of the output checkpoint file.
- Note
- If this isn't called no checkpointing will occur, since ckpt_stride=-1 by default.
void set_mpi_communicator | ( | MPI_Comm | comm | ) |
- Parameters
-
comm The MPI communicator for the likelihood evaluation.
Here is the call graph for this function:
|
virtual |
- Parameters
-
chain_name File name for the chain during the run. state_name File name for the state of the sampler, i.e. likelihood value and other sampler specific output. sampler_name File name that stores sampler information for a run, e.g. the adaptation parameters. output_precision Sets how many decimal points are saved for floats. Default is 8.
Reimplemented in sampler_deo_tempering_MCMC< S >.
The documentation for this class was generated from the following files:
- sampling/sampler_MCMC_base.h
- sampling/sampler_MCMC_base.cpp