basecircuitmaker
qemcmc.circuits.basecircuitmaker ¶
BaseCircuitMaker ¶
Constructs and simulates quantum circuits used to generate QeMCMC proposals.
This class builds the Hamiltonian corresponding to a given energy model and simulates its time evolution using PennyLane. Starting from a classical bitstring configuration, the circuit performs Trotterised quantum evolution and samples a new configuration from the resulting quantum state.
The generated sample serves as the proposal state in the quantum-enhanced MCMC algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
EnergyModel
|
Energy model defining the problem Hamiltonian. |
required |
Source code in src/qemcmc/circuits/basecircuitmaker.py
get_problem_hamiltonian ¶
Construct the problem Hamiltonian from symmetric coupling tensors.
This method supports both 'ising' (-1/+1) and 'binary' (0/1) models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
couplings
|
List[BinaryPolynomial]
|
A list of coupling polynomials. |
required |
sign
|
int
|
A sign to apply to the Hamiltonian. Default is |
1
|
Returns:
| Type | Description |
|---|---|
Hamiltonian
|
The problem Hamiltonian. |
Source code in src/qemcmc/circuits/basecircuitmaker.py
get_mixer_hamiltonian ¶
Constructs the Mixer Hamiltonian: Σ X_i.
This can be for the full system or a subgroup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_wires
|
int
|
The number of wires (qubits) for the mixer. If None, uses the total number of qubits. |
None
|
Returns:
| Type | Description |
|---|---|
Hamiltonian
|
The mixer Hamiltonian. |
Source code in src/qemcmc/circuits/basecircuitmaker.py
check_Hamiltonian ¶
Utility function to print the Energy of the Hamiltonian to be simulated. Naturally, for a classical problem, the energy of the Hamiltonian wrt to some basis state b H|b> = E|b> should equal the energy of the corresponding state in the classical model. This is a useful sanity check to ensure that the Hamiltonian is being constructed correctly from the coupling tensors.