core.converters.fqaoa#
This module implements the Fermionic QAOA (FQAOA) converter for the Qamomile framework [Yoshioka et al., 2023]. FQAOA translates the Hamiltonians into the representation of fermion systems, and the equality constraint is naturally incorporated as a constant number of particles condition.
The parameterized state \(|\vec{\beta},\vec{\gamma}\rangle\) of \(p\)-layer QAOA is defined as:
where \(H_P\) is the cost Hamiltonian, \(H_M\) is the mixer Hamiltonian and \(\gamma_l\) and \(\beta_l\) are the variational parameters. The \(2p\) variational parameters are optimized classically to minimize the expectation value \(\langle \vec{\beta},\vec{\gamma}|H_P|\vec{\beta},\vec{\gamma}\rangle\). \(U_{init}\) prepares the initial state using Givens rotation gates [Jiang et al., 2018].
This module provides functionality to convert optimization problems which written by jijmodeling into FQAOA circuits (\(U(\vec{\beta}, \vec{\gamma})\)), construct cost Hamiltonians (\(H_P\)), and decode quantum computation results.
The QAOAConverter class extends the QuantumConverter base class, specializing in FQAOA-specific operations such as ansatz circuit generation and result decoding.
- Key Features:
Generation of FQAOA ansatz circuits
Construction of cost Hamiltonians for QAOA
Decoding of quantum computation results into classical optimization solutions
Note
This module requires jijmodeling and jijmodeling_transpiler for problem representation.
Zhang Jiang, Kevin J Sung, Kostyantyn Kechedzhi, Vadim N Smelyanskiy, and Sergio Boixo. Quantum algorithms to simulate many-body physics of correlated fermions. Physical Review Applied, 9(4):044036, 2018.
Takuya Yoshioka, Keita Sasada, Yuichiro Nakano, and Keisuke Fujii. Fermionic quantum approximate optimization algorithm. Physical Review Research, 5(2):023071, 2023.
Classes#
FQAOA (Fermionic Quantum Approximate Optimization Algorithm) converter class. |
Module Contents#
- class FQAOAConverter(instance: ommx.v1.Instance, num_fermions: int, normalize_model: bool = False, normalize_ising: Literal['abs_max', 'rms'] | None = None)#
Bases:
qamomile.core.converters.converter.QuantumConverter
FQAOA (Fermionic Quantum Approximate Optimization Algorithm) converter class.
This class provides methods to convert optimization problems into FQAOA circuits, construct cost Hamiltonians, and decode quantum computation results.
Examples:
from qamomile.core.qaoa.fqaoa import FQAOAConverter # Initialize with a compiled optimization problem instance fqaoa_converter = FQAOAConverter(compiled_instance, num_fermion=4) # Generate QAOA circuit and cost Hamiltonian p = 2 # Number of QAOA layers fqaoa_circuit = fqaoa_converter.get_ansatz_circuit(p) cost_hamiltonian = fqaoa_converter.get_cost_hamiltonian()
Initialize the FQAOAConverter.
This method initializes the converter with the compiled instance of the optimization problem.
- Parameters:
compiled_instance – ommx.v1.Instance.
num_fermions (int) – Number of fermions. This means the constraint \(M = \sum_{l,d} x_{l,d}\).
normalize_model (bool) – The objective function and the constraints are normalized using the maximum absolute value of the coefficients contained in each. Defaults to False
normalize_ising (Literal["abs_max", "rms"] | None) – The normalization method for the Ising Hamiltonian. Available options: - “abs_max”: Normalize by absolute maximum value - “rms”: Normalize by root mean square Defaults to None.
- num_fermions#
- var_map#
- ising#
- num_qubits#
- fqaoa_instance_to_qubo() tuple[dict[tuple[int, int], float], float] #
Convert the instance to QUBO format.
This method converts the optimization problem instance into a QUBO (Quadratic Unconstrained Binary Optimization) representation, which is suitable for quantum computation.
- Returns:
A tuple containing the QUBO dictionary and the constant term.
- Return type:
tuple[dict[int, float], float]
- fqaoa_get_ising() qamomile.core.ising_qubo.IsingModel #
Get the Ising model representation of the problem.
- Returns:
The Ising model representation.
- Return type:
- fqaoa_ising_encode() qamomile.core.ising_qubo.IsingModel #
- cyclic_mapping() dict[tuple[int, int], int] #
Get variable maps between decision variable indices \((l,d)\) and qubit index \(i\).
- Returns:
A variable map for ring driver.
- Return type:
dict[tuple[int, int], int]
- get_fermi_orbital() numpy.ndarray #
Compute the single-particle wave functions of the occupied spin orbitals.
- Returns:
A 2D numpy array of shape (num_fermions, num_qubits)
- Return type:
numpy.ndarray
- givens_rotation(givens_angles) qamomile.core.circuit.QuantumCircuit #
Generate givens rotation gates for the initial state preparation of FQAOA.
- Parameters:
givens_angles (list[tuple[int, int], float]) – Parameters which represents a givens rotation of coordinates \((i,j)\) by angles \(theta\).
- Returns:
A givens rotation gate.
- Return type:
qm_c.QuantumCircuit
- get_init_state() qamomile.core.circuit.QuantumCircuit #
Generate the initial state preparation for FQAOA.
- get_mixer_ansatz(beta: qamomile.core.circuit.Parameter, hopping: float = 1.0, name: str = 'Mixer') qamomile.core.circuit.QuantumCircuit #
Generate the fermionic mixer ansatz circuit (\(e^{-\beta H_d}\)) for FQAOA.
- Parameters:
beta (qm_c.Parameter) – The beta parameter for the mixer ansatz.
hopping (float) – The hopping integral. Defaults to 1.0.
name (str, optional) – Name of the circuit. Defaults to “Mixer”.
- Returns:
The fermionic mixer ansatz circuit.
- Return type:
qm_c.QuantumCircuit
- get_cost_ansatz(gamma: qamomile.core.circuit.Parameter, name: str = 'Cost') qamomile.core.circuit.QuantumCircuit #
Generate the cost ansatz circuit (\(e^{-\gamma H_P}\)) for QAOA. This function is mainly used when you have designed your own mixer Hamiltonian and only need the cost Hamiltonian.
- Parameters:
gamma (qm_c.Parameter) – The gamma parameter for the cost ansatz.
name (str, optional) – Name of the circuit. Defaults to “Cost”.
- Returns:
The cost ansatz circuit.
- Return type:
qm_c.QuantumCircuit
- get_fqaoa_ansatz(p: int, hopping: float = 1.0) qamomile.core.circuit.QuantumCircuit #
Generate the FQAOA ansatz circuit.
- Parameters:
p (int) – Number of QAOA layers.
hopping (float) – The hopping integral.
- Returns:
The FQAOA ansatz circuit.
- Return type:
qm_c.QuantumCircuit
- get_cost_hamiltonian() qamomile.core.operator.Hamiltonian #
Construct the cost Hamiltonian (\(H_P\)) for FQAOA.
- Returns:
The cost Hamiltonian.
- Return type:
qm_o.Hamiltonian