KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE > Class Template Referenceabstract

#include <sample_step.h>

Inheritance diagram for Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >:
Basic_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE > Basic_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE > Real_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE > Vector_hmc_step< Model, CONSTRAIN_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >

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_distributionget_log_target () const =0
 Returns a reference to the target distribution. Returned object must comply with the ModelEvaluator concept. More...
 
virtual const Gradientget_gradient () const =0
 Returns a reference to the mechanism to compute the gradient of the target distribution. More...
 
virtual const Move_parameterget_move_parameter () const =0
 Returns a reference to the parameter-changing mechanism. Must comply with the ChangeParameter concept. More...
 
virtual const Get_step_sizeget_step_size_function () const =0
 Returns a reference to the mechanism for choosing the neighborhoods for each parameters. More...
 
virtual const Get_dimensionget_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_parameterget_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_boundsget_upper_bounds_function () const =0
 Returns a reference to the mechanism for getting the upper bounds of a function. More...
 
virtual const Get_lower_boundsget_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
 

Detailed Description

template<typename Model, bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
class Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >

Template Parameters
ModelThe model type.
accept_stepDo a accept/reject step? If this is true this becomes a true HMC step.
reversibleWhether 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_ignoreIf 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.

Member Typedef Documentation

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
typedef Model_dimension<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_dimension
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
typedef Model_parameter_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_lower_bounds
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
typedef Get_model_parameter<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_parameter
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
typedef Model_parameter_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_step_size
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
typedef Model_parameter_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Get_upper_bounds
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
typedef Model_parameter_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Gradient
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
typedef Move_model_parameter<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Move_parameter
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
typedef Model_evaluator<Model>::Type Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Target_distribution

Constructor & Destructor Documentation

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Abstract_hmc_step ( int  num_dynamics_steps,
double  alpha 
)
inline
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::Abstract_hmc_step ( const Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE > &  ahs)
inline
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::~Abstract_hmc_step ( )
inlinevirtual

Member Function Documentation

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::BOOST_CONCEPT_ASSERT ( (BaseModel< Model >)  )
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual const Get_dimension& Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::get_dimension_function ( ) const
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 >.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual const Gradient& Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::get_gradient ( ) const
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 >.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual const Target_distribution& Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::get_log_target ( ) const
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 >.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual const Get_lower_bounds& Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::get_lower_bounds_function ( ) const
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 >.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual const Move_parameter& Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::get_move_parameter ( ) const
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 >.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual const Get_parameter& Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::get_parameter_function ( ) const
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 >.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual const Get_step_size& Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::get_step_size_function ( ) const
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 >.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual const Get_upper_bounds& Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::get_upper_bounds_function ( ) const
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 >.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
bool Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::is_first_p_full ( const bool  alpha,
const bool  accept_step,
const bool  reversible 
)
inline
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
bool Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::is_last_p_ignored ( const bool  alpha,
const bool  accept_step,
const bool  reversible 
)
inline
template<class Model , bool CONSTRAINED_TARGET, bool INCLUDE_ACCEPT_STEP, bool REVERSIBLE>
Step_log< Model > Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::operator() ( Model &  q,
double  lt_q 
) const
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.

Note
This method uses swap(Model a, Model b), whose generalized implementation is very inefficient. For best performance, swap() should be specialized for Model.
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual void Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::post_move_callback ( Model &  ,
kjb::Vector  
) const
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 >.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
virtual bool Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::record_extra ( ) const
pure virtual
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
void Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::set_temperature ( const double  T)
inline

Member Data Documentation

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
double Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::m_alpha
protected

Amount of stochastic update to apply to momentum. Set to zero for strict HMC.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
bool Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::m_first_p_full
protected

Optimization constants. Set to false for true MCMC.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
bool Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::m_last_p_ignore
protected
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
const int Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::m_num_dynamics_steps
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.

template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
double Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::m_temperature
protected
template<typename Model , bool CONSTRAINED_TARGET = false, bool INCLUDE_ACCEPT_STEP = true, bool REVERSIBLE = true>
kjb::Vector Abstract_hmc_step< Model, CONSTRAINED_TARGET, INCLUDE_ACCEPT_STEP, REVERSIBLE >::p
mutableprotected

Momentum.


The documentation for this class was generated from the following file: