mqt.problemsolver.partial_compiler.qaoa

Module Contents

class QAOA(num_qubits: int, repetitions: int = 1, sample_probability: float = 0.5, considered_following_qubits: int = 3, satellite_use_case: bool = False)[source]
num_qubits
repetitions = 1
sample_probability = 0.5
backend
satellite_use_case = False
qc
qc_baseline
remove_pairs = []
remove_gates = []
qc_compiled
to_be_removed_gates_indices = []
penalty = 5
get_uncompiled_circuits(considered_following_qubits: int) tuple[qiskit.QuantumCircuit, qiskit.QuantumCircuit, list[bool | str], list[tuple[int, int]]][source]

Get the uncompiled circuits.

Returns:

  • A circuit with only the needed two-qubit gates

  • A circuit with all possible two-qubit gates

  • A list of gates that will be removed

  • A list of corresponding qubit pairs

Return type:

A tuple of

compile_qc(baseline: bool = False, opt_level: int = 3) qiskit.QuantumCircuit[source]

Compiles the circuit.

get_to_be_removed_gate_indices() list[int][source]

Returns the indices of the gates to be removed.

remove_unnecessary_gates(qc: qiskit.QuantumCircuit, optimize_swaps: bool = True) qiskit.QuantumCircuit[source]

Removes the gates to be checked from the circuit at online time.

create_model_from_pair_list() numpy.typing.NDArray[numpy.float64][source]

Constructs the QUBO matrix Q for the optimization problem.

The matrix Q is of size num_qubits x num_qubits and encodes the following:
  • Objective: Minimize the linear term -∑ x_i, where Q[i, i] = -1.

  • Constraints: Ensure x_i + x_j ≤ 1 by adding a penalty term P·x_i x_j for each pair (i, j) in remove_pairs.

Returns:

The QUBO matrix representing the optimization problem.

Return type:

Q

apply_factors_to_qc(qc: qiskit.QuantumCircuit) qiskit.QuantumCircuit[source]

Updates the parameterized QAOA-style circuit qc with actual Ising coefficients.

This function assigns values to the circuit parameters based on the Ising model derived from the QUBO matrix. Parameters are named “qubit_<i>” for single-qubit Z-rotations and “a_<i>_<j>” (or just “a_…”) for ZZ-interaction gates.

Parameters:

qc – QuantumCircuit object representing the parameterized QAOA circuit.

Returns:

QuantumCircuit object with updated parameter values based on the Ising model.

get_backend(num_qubits: int) BackendV2[source]