Class model::Clock
Inherited Members
Constructors
Clock()
Declaration
model::Clock::Clock()
Methods
get_identifier()
Returns the identifier string of the model type (e.g., "ising").
Declaration
std::string model::Clock::get_identifier() const override
get_version()
Returns the version of the input format this implementation expects.
Declaration
std::string model::Clock::get_version() const override
calculate_cost()
Calculate the Clock Hamiltonian.
The standard clock Hamiltonian is defined for edges involving two nodes: \(\mathcal{H}' = \sum_{ij} \mathrm{cost}_{ij}\vec{s_i}\vec{s_j}\), Where \(\vec{s_i}\) are equi-distributed 2d vectors on the unit circle. (Equivalently: \(\vec{s_i}\vec{s_j} = \cos(\theta_i - \theta_j)\) with \(\theta_i = 2\pi i/q\).) Here we use a generalization to n-node hyperedges using the sum of planar vectors partcipating in the edge: \(v_e = \frac{1}{|e|} \sum_{i\in e} \vec{s_i}\), Where \(\vec{s_i}\) is defined as above and \(|e|\) is the number of nodes in the hyper-edge. With this our Hamiltonian can be expressed as: $ \mathcal{H} = \sum_e \mathrm{cost}_e (2*v_e^2-1), where the rescaling ensures that the generalization corresponds to the standard defintion for edges with 2 nodes (i.e, +1 when aligned, -1 when anti-aligned, 0 when perpendicular). This means that the contribution is
+1 * cost_e
when the clock spins are aligned (in any direction) and-1 * cost_e
when the clock spins add up to zero.
Declaration
double model::Clock::calculate_cost(const State_T&state) const override
calculate_cost_difference()
Compute the difference resulting from transition
This recomputes v_e for each of the terms in which transition.spin_id
is involved.
Declaration
double model::Clock::calculate_cost_difference(const State_T&state, const Transition_T&transition) const override
get_random_state()
Build a random Clock state.
This function decides on the number of discretized clock spins and the possible values of each to return (according to the model configuration). Partially precomputed terms (term[j].x
, etc.) are populated here.
Declaration
Clock::State_T model::Clock::get_random_state(utils::RandomGenerator&rng) const override
get_random_transition()
Create a random transition for state
.
This picks a random spin_id
and proposes a new_value
that is different from the current one.
Declaration
Clock::Transition_T model::Clock::get_random_transition(const State_T&state, utils::RandomGenerator&rng) const override
apply_transition()
Change state
according to transition
.
This sets the modified spin to its new value and updates the partially precomputed terms that are affected by this change.
Declaration
void model::Clock::apply_transition(const Transition_T&transition, State_T&state) const override
configure()
Serialize the number of states q
and the underlying graph.
Declaration
void model::Clock::configure(const utils::Json&json) override
configure()
Declaration
void model::Clock::configure(Configuration_T&conf)
initialize_terms()
Initialize the state.terms
according to the model and current state.spins
.
Declaration
void model::Clock::initialize_terms(State_T&state) const
state_memory_estimate()
Estimate memory consumption for state.
Declaration
size_t model::Clock::state_memory_estimate() const override
state_only_memory_estimate()
Declaration
size_t model::Clock::state_only_memory_estimate() const override
calculate_term()
This computes the Hamiltonian contribution of the edge edge_id
.
If specified, dx and dy are applied to the term (this is used to emulate a modified configuration within calculate_cost_difference
).
Declaration
double model::Clock::calculate_term(const State_T&state, size_t edge_id, double dx=0, double dy=0) const
set_number_of_states()
Set the number of states to q and precompute the cos/sin values for the discretized angles corresponding to 1..(q-1) * 2\pi/q.
Declaration
void model::Clock::set_number_of_states(size_t q)