KJB
|
#include <sample_step.h>
Public Member Functions | |
Basic_hmc_step (const Target_distribution &log_target, int num_dynamics_steps, const Gradient &gradient, const Move_parameter &move_parameter, const Get_step_size &get_step_size, const Get_dimension &get_dimension, double alpha=0.0) | |
Creates a Basic_hmc_step by initializing target and proposer functors (or functions) to the given arguments. More... | |
Basic_hmc_step (const Target_distribution &log_target, int num_dynamics_steps, const Gradient &gradient, const Move_parameter &move_parameter, const Get_step_size &get_step_size, const Get_dimension &get_dimension, const Get_parameter &get_parameter, const Get_lower_bounds &get_lower_bounds, const Get_upper_bounds &get_upper_bounds, double alpha=0.0) | |
void | record_extra (bool enable) |
void | set_post_move_callback (const boost::function2< void, Model &, kjb::Vector & > &f) |
Copy-constructor. More... | |
virtual | ~Basic_hmc_step () |
virtual const Target_distribution & | get_log_target () const |
Returns a reference to the target distribution. Returned object must comply with the ModelEvaluator concept. More... | |
virtual const Gradient & | get_gradient () const |
Returns a reference to the mechanism to compute the gradient of the target distribution. More... | |
virtual const Move_parameter & | get_move_parameter () const |
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 |
Returns a reference to the mechanism for choosing the neighborhoods for each parameters. More... | |
virtual const Get_dimension & | get_dimension_function () const |
Returns a reference to the mechanism for computing the dimension of the model. More... | |
virtual bool | record_extra () const |
if true is returned, the step log will contain metadata about the step More... | |
virtual const Get_parameter & | get_parameter_function () const |
Returns a reference to the mechanism for getting the value of a dimension of the model. More... | |
virtual const Get_lower_bounds & | get_lower_bounds_function () const |
Returns a reference to the mechanism for getting the lower bounds of a function. More... | |
virtual const Get_upper_bounds & | get_upper_bounds_function () const |
Returns a reference to the mechanism for getting the upper bounds of a function. More... | |
virtual void | post_move_callback (Model &q, kjb::Vector &p) const |
Public Member Functions inherited from Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE > | |
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... | |
void | set_temperature (const double T) |
virtual | ~Abstract_hmc_step () |
Protected Attributes | |
Target_distribution | m_log_target |
Gradient | m_gradient |
Move_parameter | m_move_parameter |
Get_step_size | m_get_step_size |
Get_dimension | m_get_dimension |
bool | m_record_extra |
Get_parameter | m_get_parameter |
Get_lower_bounds | m_get_lower_bounds |
Get_upper_bounds | m_get_upper_bounds |
boost::function2< void, Model &, kjb::Vector & > | m_post_move_callback |
Protected Attributes inherited from Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE > | |
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. Must comply with HmcModel concept. |
accept_step | Do a accept/reject step? This is true by default, which, if alpha = 0, makes this a true HMC step. |
Basic_hmc_step is a functor that runs a single step of the generalized Hybrid Monte Carlo algorithm on a model.
This class is a subclass of the abstract class Abstract_hmc_step. It implements the get_* member functions from the abstract class in the obvious way: it returns references to private members of the correct types. These members are initialized from references received in the constructor.
typedef Parent::Get_dimension Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_dimension |
typedef Parent::Get_lower_bounds Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_lower_bounds |
typedef Parent::Get_parameter Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_parameter |
typedef Parent::Get_step_size Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_step_size |
typedef Parent::Get_upper_bounds Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_upper_bounds |
typedef Parent::Gradient Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Gradient |
typedef Parent::Move_parameter Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Move_parameter |
typedef Abstract_hmc_step<Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE> Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Parent |
typedef Parent::Target_distribution Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Target_distribution |
|
inline |
Creates a Basic_hmc_step by initializing target and proposer functors (or functions) to the given arguments.
log_target | Target_distribution object used to initialize internal target distribution used in operator(). |
num_dynamics_steps | Number of dynamics steps to take before accepting/rejecting. |
gradient | Mechanism to compute the gradient of the (log) target distribution. |
move_parameter | Mechanism to change a parameter of the of the model by a certain amount. |
get_step_size | Mechanism to get the etas; that is the sizes of the neighborhood used to compute the gradients. |
get_dimension | Mechanism to obtain the dimension of the model. |
alpha | Parameter which controls how much randomness there is in the update of the momentum. |
|
inline |
|
inlinevirtual |
|
inlinevirtual |
Returns a reference to the mechanism for computing the dimension of the model.
Implements Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inlinevirtual |
Returns a reference to the mechanism to compute the gradient of the target distribution.
Implements Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inlinevirtual |
Returns a reference to the target distribution. Returned object must comply with the ModelEvaluator concept.
Implements Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inlinevirtual |
Returns a reference to the mechanism for getting the lower bounds of a function.
Implements Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inlinevirtual |
Returns a reference to the parameter-changing mechanism. Must comply with the ChangeParameter concept.
Implements Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inlinevirtual |
Returns a reference to the mechanism for getting the value of a dimension of the model.
Implements Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inlinevirtual |
Returns a reference to the mechanism for choosing the neighborhoods for each parameters.
Implements Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inlinevirtual |
Returns a reference to the mechanism for getting the upper bounds of a function.
Implements Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
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 from Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inline |
Enable/disable recording of extra metadata in Step_log
|
inlinevirtual |
if true is returned, the step log will contain metadata about the step
Implements Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >.
|
inline |
Copy-constructor.
Assignment
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |