Class markov::ClusterWalker
ClusterWalker
is an abstract base class for quantum like space explorers
A ClusterWalker stores multiple state and costs and has pointers to a model and random number generator to make steps. It is specifically designed to allow copy assignment (assuming the Model::State_T does), such that it can be duplicated in population markovs. The Walker provides a base implementation of the step function, which
- proposes a random new states,
- computes the cost differences,
- uses virtual method to decide whether to create cluster binded
- variables from multiple states
- invokes a pure virtual method to decide whether to accept, and
- modifies the internal states using cluster if true is returned.
From this we can implement a QuantumWalker
by returning acceptance rate based on quantum transverse field.
Constructors
ClusterWalker()
The rng
and model
must be set before the object can be used. cost
is only intialized after a call to init()
Declaration
markov::ClusterWalker<Model>::ClusterWalker()
Methods
init()
Must be called after the rng_
and model_
have been set. It initializes the walker to a random state and precomputes its current cost.
Note
This is typically the only direct call to calculate_cost
; from here the current cost_
is updated from the computed difference at each step.
Declaration
virtual void markov::ClusterWalker<Model>::init(size_t n_states=1)
init_state()
Declaration
void markov::ClusterWalker<Model>::init_state(size_t state_index, ::utils::RandomGenerator&rng)
accept()
Implementations of the walker interface must provide a method to decide which steps to accept/reject. Currently this is only based on cost_difference
, but the state or transition could be added.
Declaration
virtual bool markov::ClusterWalker<Model>::accept(const typename Model::Cost_T&cost_difference, ::utils::RandomGenerator&rng)=0
accept_cluster()
Implementations of the walker interface must provide a method to decide which cluster to accept/reject.
Declaration
virtual bool markov::ClusterWalker<Model>::accept_cluster(::utils::RandomGenerator&rng)=0
get_transition()
For models with a 'size_t' transition type, do an ordered sweep.
Declaration
std::enable_if<std::is_same<TT, size_t>::value, void>::type markov::ClusterWalker<Model>::get_transition(size_t variable_index, typename Model::Transition_T&transition, utils::RandomGenerator&)
get_transition()
For any other transition type, do a random sweep.
Declaration
std::enable_if<!std::is_same<TT, size_t>::value, void>::type markov::ClusterWalker<Model>::get_transition(size_t, typename Model::Transition_T&transition, utils::RandomGenerator&rng)
set_model()
Provide a pointer to the (non-owned) model to use for cost calculations and proposing new steps.
Declaration
void markov::ClusterWalker<Model>::set_model(const Model *model)
model()
Return a constant reference to the model being used.
Declaration
const Model&markov::ClusterWalker<Model>::model()
get_evaluation_counter()
Declaration
solver::EvaluationCounter markov::ClusterWalker<Model>::get_evaluation_counter()
add_difference_evaluations()
Declaration
void markov::ClusterWalker<Model>::add_difference_evaluations(size_t number_evals)
add_function_evaluations()
Declaration
void markov::ClusterWalker<Model>::add_function_evaluations(size_t number_evals)
reset_evaluation_counter()
Declaration
void markov::ClusterWalker<Model>::reset_evaluation_counter()
get_lowest_cost()
Declaration
Model::Cost_T markov::ClusterWalker<Model>::get_lowest_cost() const
get_lowest_state()
Declaration
const Model::State_T&markov::ClusterWalker<Model>::get_lowest_state() const
get_states()
Declaration
const std::vector<typename Model::State_T>&markov::ClusterWalker<Model>::get_states()
get_costs()
Declaration
const std::vector<typename Model::Cost_T>&markov::ClusterWalker<Model>::get_costs()
size()
Declaration
size_t markov::ClusterWalker<Model>::size()
try_form_clusters()
Declaration
void markov::ClusterWalker<Model>::try_form_clusters(size_t state_index, const typename Model::Transition_T&transition, utils::RandomGenerator&rng)
try_flip_clusters()
Declaration
void markov::ClusterWalker<Model>::try_flip_clusters(size_t state_index, utils::RandomGenerator&rng)
calculate_cost_diff()
For models derived from model::FacedGraphModel, an extra parameter for a cost object is necessary to communicate cached calculations.
Declaration
std::enable_if<!std::is_base_of<model::FacedGraphModel<TS, TT>, TM>::value, void>::type markov::ClusterWalker<Model>::calculate_cost_diff(size_t state_index, const typename Model::Transition_T&transition)
calculate_cost_diff()
For models derived from model::FacedGraphModel, an extra parameter for a cost object is necessary to communicate cached calculations.
Declaration
std::enable_if<std::is_base_of<model::FacedGraphModel<TS, TT>, TM>::value, void>::type markov::ClusterWalker<Model>::calculate_cost_diff(size_t state_index, const typename Model::Transition_T&transition)
apply_transition()
For models derived from model::FacedGraphModel, an extra parameter for a cost object is necessary to communicate cached calculations.
Declaration
std::enable_if<!std::is_base_of<model::FacedGraphModel<TS, TT>, TM>::value, void>::type markov::ClusterWalker<Model>::apply_transition(size_t state_index, const typename Model::Transition_T&transition)
apply_transition()
For models derived from model::FacedGraphModel, an extra parameter for a cost object is necessary to communicate cached calculations.
Declaration
std::enable_if<std::is_base_of<model::FacedGraphModel<TS, TT>, TM>::value, void>::type markov::ClusterWalker<Model>::apply_transition(size_t state_index, const typename Model::Transition_T&transition)
save_lowest()
Store the current lowest state as the lowest.
Declaration
void markov::ClusterWalker<Model>::save_lowest()
memory_estimate()
Estimate memory consumtion using model parameters.
Declaration
static size_t markov::ClusterWalker<Model>::memory_estimate(const Model&model, size_t n_states)
compare()
Declaration
static bool markov::ClusterWalker<Model>::compare(const ClusterWalker<Model>&w1, const ClusterWalker<Model>&w2)