Monte Carlo Markov Chain

Abstract class for a MarkovChainMonteCarlo.

class vulqano.mcmc.MarkovChainMonteCarlo(state, gates, hamiltonian, rules_classes='all', generators='std')[source]

Abstract model for a MCMC.

Arguments

stateAbstractCircuitState

Initial state of the MC.

gatesset of strings

Set of gates that can be created and destroyed in the transitions.

hamiltonianlist of (np.array of strings, float, mask)

Abstract description of the Hamiltonian. The energy is obtained by counting how many times each subcircuit hamiltonian_operator[i][0] appears on a region A of the circuit suck that that hamiltonian_operator[i][2] is True for all (t,q) in A. The counted number is multiplied by the weight hamiltonian_operator[i][1].

rules_classesstr or list of ints, optional

A list of the ints identifying the rule classes that we want to generate. Default is “all” and generates all the rule classes.

generators“std” or list of generators, optional

The list of generators producing the rules to be used. Default is “std”, in this case a standard list of rules is used.

Attributes

stateDiscreteMCState or ContinuousMCState

Current state of of the Marcov chain.

ruleslist of DiscreteMCRule(s) or ContinuousMCRule(s)

List of all the allowed transition rules.

transitions_classes_probsdictionary

A dictionary associating to each class of rules a probabiilty factor. This factor changes the probability by multipling the temperature in the Boltzmann distribution.

max_rule_shapetuple of ints

Max number of time steps in rules and qubits in rules for each direction of the time-qubit lattice.

mapdictionary

A map of all the possible transformations that can be applied to the actual circuit state. Each key represents the time steps and qubits window identifing the subcircuit to be replaced: (t0, q0, … t1-t0, q1-q0, …). Each item represents the rule to be applied, the direction of the rule (true if ->), and the rule type.

hamiltonianMCHamiltonian

System Hamiltonian for defining the Boltzamann distribution.

temperaturefloat

Temperature of the Boltzamann distribution for the transition probablity.

apply_boltzmann_transition()[source]

Selects a random transition and applies the transition with probability min(1,e^(E_f-E_i)/(T*alpha)), where alpha is a factor depending on the transition class (1 by default, time dependent tuning optional) then calls the method update() to update the transitions map. The energy difference is calculate locally, looking at a subcircuit which includes the region of the transition with an additional boundary depending on the range of the Hamiltonian.

Returns

energy_diff: float

Energy variation generated by the transition.

last_transition: MCRule

Last transition applied.

update_map(window)[source]

Updates the transitions map looking at the region where the circuit has been updated in the last transition and its boundary.

Parameters

windowtuple

Region of the last transition.

Returns

None.