qemcmc.sampler.classical_proposal

Classes

ClassicalProposal

Classical Markov Chain Monte Carlo proposer.

Module Contents

class qemcmc.sampler.classical_proposal.ClassicalProposal(model: qemcmc.model.EnergyModel, method: str = 'uniform')[source]

Bases: qemcmc.sampler.Proposal

Classical Markov Chain Monte Carlo proposer.

This class implements purely classical proposal mechanisms for MCMC. New candidate states are generated either by sampling a completely random (uniform) configuration, or by performing a local single-spin or two-spin flip.

Parameters:
  • model (EnergyModel) – Energy model defining the target Boltzmann distribution.

  • method (str, optional) –

    Proposal mechanism used to generate candidate states.

    • "uniform" : propose a completely random spin configuration.

    • "local" : flip a single randomly chosen spin.

    • "2-local" : flip two randomly chosen spins.

    Default is "uniform".

METHODS[source]
method = 'uniform'[source]
update(current_state_bitstring: str) str[source]

Generate a candidate state from the current state using the proposal mechanism.

This method should be implemented by subclasses to define the specific proposal strategy (e.g., single-spin flips, block updates, or quantum proposals).

Parameters:

state (MCMCState) – The current state of the Markov chain.

Returns:

A new candidate state.

Return type:

MCMCState

update_uniform(current_state_bitstring: str) str[source]

Proposes a new state by generating a random bitstring.

Parameters:

current_state_bitstring (str) – The current state represented as a bitstring (not used, but required by the API).

Returns:

A new random state bitstring of the same length.

Return type:

str

update_local(current_state_bitstring: str) str[source]

Proposes a new state by flipping a single randomly chosen spin.

Parameters:

current_state_bitstring (str) – The current state represented as a bitstring.

Returns:

The new state bitstring after flipping one spin.

Return type:

str

update_2local(current_state_bitstring: str) str[source]

Proposes a new state by flipping two randomly chosen spins.

Parameters:

current_state_bitstring (str) – The current state represented as a bitstring.

Returns:

The new state bitstring after flipping two spins.

Return type:

str