QAOA
class qiskit.algorithms.minimum_eigensolvers.QAOA(sampler, optimizer, *, reps=1, initial_state=None, mixer=None, initial_point=None, aggregation=None, callback=None)
Bases: SamplingVQE
The Quantum Approximate Optimization Algorithm (QAOA).
QAOA is a well-known algorithm for finding approximate solutions to combinatorial-optimization problems [1].
The QAOA implementation directly extends SamplingVQE
and inherits its optimization structure. However, unlike VQE, which can be configured with arbitrary ansatzes, QAOA uses its own fine-tuned ansatz, which comprises parameterized global rotations and different parameterizations of the problem hamiltonian. QAOA is thus principally configured by the single integer parameter, reps
, which dictates the depth of the ansatz, and thus affects the approximation quality.
An optional array of parameter values, as the initial_point
, may be provided as the starting and parameters for the QAOA ansatz [1].
An operator or a parameterized quantum circuit may optionally also be provided as a custom mixer
Hamiltonian. This allows in the case of quantum annealing [2] and QAOA [3], to run constrained optimization problems where the mixer constrains the evolution to a feasible subspace of the full Hilbert space.
The following attributes can be set via the initializer but can also be read and updated once the QAOA object has been constructed.
sampler
optimizer
A classical optimizer to find the minimum energy. This can either be a Qiskit Optimizer
or a callable implementing the Minimizer
protocol.
Type
reps
initial_state
An optional initial state to prepend the QAOA circuit with.
mixer
The mixer Hamiltonian to evolve with or a custom quantum circuit. Allows support of optimizations in constrained subspaces [2, 3] as well as warm-starting the optimization [4].
Type
QuantumCircuit | BaseOperator | PauliSumOp
aggregation
A float or callable to specify how the objective function evaluated on the basis states should be aggregated. If a float, this specifies the parameter for a CVaR expectation value.
Type
callback
A callback that can access the intermediate data at each optimization step. These data are: the evaluation count, the optimizer parameters for the ansatz, the evaluated value, the the metadata dictionary, and the best measurement.
Type
Callable[[int, np.ndarray, float, dict[str, Any]], None] | None
References
[1]: Farhi, E., Goldstone, J., Gutmann, S., “A Quantum Approximate Optimization Algorithm”
[2]: Hen, I., Spedalieri, F. M., “Quantum Annealing for Constrained Optimization”
[3]: Hadfield, S. et al, “From the Quantum Approximate Optimization Algorithm to a Quantum
Alternating Operator Ansatz” arXiv:1709.03489
[4]: Egger, D. J., Marecek, J., Woerner, S., “Warm-starting quantum optimization”
Parameters
- sampler (BaseSampler) – The sampler primitive to sample the circuits.
- optimizer (Optimizer |Minimizer) – A classical optimizer to find the minimum energy. This can either be a Qiskit
Optimizer
or a callable implementing theMinimizer
protocol. - reps (int) – The integer parameter . Has a minimum valid value of 1.
- initial_state (QuantumCircuit | None) – An optional initial state to prepend the QAOA circuit with.
- mixer (QuantumCircuit | BaseOperator |PauliSumOp) – The mixer Hamiltonian to evolve with or a custom quantum circuit. Allows support of optimizations in constrained subspaces [2, 3] as well as warm-starting the optimization [4].
- initial_point (np.ndarray | None) – An optional initial point (i.e. initial parameter values) for the optimizer. The length of the initial point must match the number of
ansatz
parameters. IfNone
, a random point will be generated within certain parameter bounds.QAOA
will look to the ansatz for these bounds. If the ansatz does not specify bounds, bounds of , will be used. - aggregation (float | Callable[[list[float]], float] | None) – A float or callable to specify how the objective function evaluated on the basis states should be aggregated. If a float, this specifies the parameter for a CVaR expectation value.
- callback (Callable[[int, np.ndarray, float, dict[str, Any]], None] | None) – A callback that can access the intermediate data at each optimization step. These data are: the evaluation count, the optimizer parameters for the ansatz, the evaluated value, the metadata dictionary.
Attributes
initial_point
Return the initial point.
Methods
compute_minimum_eigenvalue
compute_minimum_eigenvalue(operator, aux_operators=None)
Compute the minimum eigenvalue of a diagonal operator.
Parameters
- operator (BaseOperator | PauliSumOp) – Diagonal qubit operator.
- aux_operators (ListOrDict[BaseOperator | PauliSumOp] | None) – Optional list of auxiliary operators to be evaluated with the final state.
Returns
A SamplingMinimumEigensolverResult
containing the optimization result.
Return type
supports_aux_operators
classmethod supports_aux_operators()
Whether computing the expectation value of auxiliary operators is supported.
If the minimum eigensolver computes an eigenstate of the main operator then it can compute the expectation value of the aux_operators for that state. Otherwise they will be ignored.
Returns
True if aux_operator expectations can be evaluated, False otherwise
Return type