KJB
|
#include <sample_step.h>
Public Types | |
typedef Model_evaluator< Model > ::Type | Target_distribution |
typedef Model_parameter_evaluator < Model >::Type | Gradient |
typedef Move_model_parameter < Model >::Type | Move_parameter |
typedef Model_parameter_evaluator < Model >::Type | Get_step_size |
typedef Model_dimension< Model > ::Type | Get_dimension |
typedef Get_model_parameter < Model >::Type | Get_parameter |
typedef Model_parameter_evaluator < Model >::Type | Get_lower_bounds |
typedef Model_parameter_evaluator < Model >::Type | Get_upper_bounds |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((BaseModel< Model >)) | |
Abstract_hmc_step (int num_dynamics_steps, double alpha) | |
bool | is_first_p_full (const bool alpha, const bool accept_step, const bool reversible) |
bool | is_last_p_ignored (const bool alpha, const bool accept_step, const bool reversible) |
Abstract_hmc_step (const Abstract_hmc_step &ahs) | |
virtual Step_log< Model > | operator() (Model &q, double lt_q) const |
Runs a step of Hybrid Monte-Carlo (HMC) on a model m. More... | |
virtual const Target_distribution & | get_log_target () const =0 |
Returns a reference to the target distribution. Returned object must comply with the ModelEvaluator concept. More... | |
virtual const Gradient & | get_gradient () const =0 |
Returns a reference to the mechanism to compute the gradient of the target distribution. More... | |
virtual const Move_parameter & | get_move_parameter () const =0 |
Returns a reference to the parameter-changing mechanism. Must comply with the ChangeParameter concept. More... | |
virtual const Get_step_size & | get_step_size_function () const =0 |
Returns a reference to the mechanism for choosing the neighborhoods for each parameters. More... | |
virtual const Get_dimension & | get_dimension_function () const =0 |
Returns a reference to the mechanism for computing the dimension of the model. More... | |
void | set_temperature (const double T) |
virtual bool | record_extra () const =0 |
if true is returned, the step log will contain metadata about the step More... | |
virtual const Get_parameter & | get_parameter_function () const =0 |
Returns a reference to the mechanism for getting the value of a dimension of the model. More... | |
virtual const Get_upper_bounds & | get_upper_bounds_function () const =0 |
Returns a reference to the mechanism for getting the upper bounds of a function. More... | |
virtual const Get_lower_bounds & | get_lower_bounds_function () const =0 |
Returns a reference to the mechanism for getting the lower bounds of a function. More... | |
virtual void | post_move_callback (Model &, kjb::Vector &) const |
virtual | ~Abstract_hmc_step () |
Protected Attributes | |
const int | m_num_dynamics_steps |
The number of leapfrog steps in the trajectory, "choosing a suitable trajectory length is crucial if HMC is to explore the stae space systematically, rather than by a random walk". "For a problem thought to be airly difficult, a trajectory with m_length = 100 might be a suitable starting point. More... | |
double | m_alpha |
Amount of stochastic update to apply to momentum. Set to zero for strict HMC. More... | |
kjb::Vector | p |
Momentum. More... | |
bool | m_first_p_full |
Optimization constants. Set to false for true MCMC. More... | |
bool | m_last_p_ignore |
double | m_temperature |
Model | The model type. |
accept_step | Do a accept/reject step? If this is true this becomes a true HMC step. |
reversible | Whether or not it's important for the leapfrog steps to be reversible. For true MCMC, this should be true, but passing false allows for fewer gradient evaluations, in some configurations (i.e. if we accept_step = false, and alpha > 0). |
last_p_ignore | If true, the last momentum update will be omitted. For true MCMC, this should be false. |
Abstract_hmc_step is a functor that runs a single step of HMC on a model.
This class implements the logic for one HMC algorithm step. A subclass need only define the model's get_* mechanisms. Specifically, it they must implement:
True boolean template parameters control whether certain optimizations are on or off.
typedef Model_dimension<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_dimension |
typedef Model_parameter_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_lower_bounds |
typedef Get_model_parameter<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_parameter |
typedef Model_parameter_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_step_size |
typedef Model_parameter_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_upper_bounds |
typedef Model_parameter_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Gradient |
typedef Move_model_parameter<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Move_parameter |
typedef Model_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Target_distribution |
|
inline |
|
inline |
|
inlinevirtual |
Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::BOOST_CONCEPT_ASSERT | ( | (BaseModel< Model >) | ) |
|
pure virtual |
Returns a reference to the mechanism for computing the dimension of the model.
Implemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
pure virtual |
Returns a reference to the mechanism to compute the gradient of the target distribution.
Implemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
pure virtual |
Returns a reference to the target distribution. Returned object must comply with the ModelEvaluator concept.
Implemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
pure virtual |
Returns a reference to the mechanism for getting the lower bounds of a function.
Implemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
pure virtual |
Returns a reference to the parameter-changing mechanism. Must comply with the ChangeParameter concept.
Implemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
pure virtual |
Returns a reference to the mechanism for getting the value of a dimension of the model.
Implemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
pure virtual |
Returns a reference to the mechanism for choosing the neighborhoods for each parameters.
Implemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
pure virtual |
Returns a reference to the mechanism for getting the upper bounds of a function.
Implemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inline |
|
inline |
|
virtual |
Runs a step of Hybrid Monte-Carlo (HMC) on a model m.
If the step is rejected, m remains unchanged; if the step is accepted, m will hold the new state. Returns a structure describing the results of the step.
|
inlinevirtual |
Callback that occurs every time the model state is updated during leapfrom simulation of dynamics. This is useful to apply constraints to the model and/or momentum after they've been perturbed
Reimplemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
pure virtual |
if true is returned, the step log will contain metadata about the step
Implemented in Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >, and Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inline |
|
protected |
Amount of stochastic update to apply to momentum. Set to zero for strict HMC.
|
protected |
Optimization constants. Set to false for true MCMC.
|
protected |
|
protected |
The number of leapfrog steps in the trajectory, "choosing a suitable trajectory length is crucial if HMC is to explore the stae space systematically, rather than by a random walk". "For a problem thought to be airly difficult, a trajectory with m_length = 100 might be a suitable starting point.
|
protected |
|
mutableprotected |
Momentum.