QAOA¶
- class QAOA¶
Quantum Approximate Optimization Algorithm (QAOA).
A variational quantum algorithm that alternates between a cost Hamiltonian and a mixer Hamiltonian to find approximate solutions to combinatorial optimization problems encoded as Ising models.
Pass this class to any
QuantumBaseClientsubclass to run QAOA on the corresponding backend.Methods
Return the polynomial degrees accepted by the selected QAOA variant.
Run QAOA on the given optimization model.
- class Parameters¶
Configuration parameters for a QAOA run.
- __eq__(other)¶
Return self==value.
- __init__(reps: int = 10, shots: int = 1024, qaoa_type: QAOAType | tuple[type[QAOAImplProtocol], AcceptableDegrees] = QAOAType.AUTO, minimize: MinimizeProtocol = <factory>) None¶
- __repr__()¶
Return repr(self).
- __dataclass_fields__ = {'minimize': Field(name='minimize',type='MinimizeProtocol',default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'amplify_quantum.minimize.scipy.ScipyMinimize'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'qaoa_type': Field(name='qaoa_type',type='QAOAType | tuple[type[QAOAImplProtocol], AcceptableDegrees]',default=<QAOAType.AUTO: (<class 'amplify_quantum.algo.qaoa.impls.qaoa_auto.AutoQAOAImpl'>, <amplify.AcceptableDegrees object>)>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'reps': Field(name='reps',type='int',default=10,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'shots': Field(name='shots',type='int',default=1024,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __hash__ = None¶
- __match_args__ = ('reps', 'shots', 'qaoa_type', 'minimize')¶
- minimize: MinimizeProtocol¶
Classical optimizer used to tune the variational circuit parameters. Defaults to
ScipyMinimizewith the COBYLA method.
- qaoa_type: QAOAType | tuple[type[QAOAImplProtocol], AcceptableDegrees] = (<class 'amplify_quantum.algo.qaoa.impls.qaoa_auto.AutoQAOAImpl'>, <amplify.AcceptableDegrees object>)¶
QAOA implementation to use. Either a
QAOATypevalue for the built-in strategies, or a custom class implementing theQAOAImplProtocolinterface.
- class Result¶
ベースクラス:
Generic[SamplingMeta_co]Result of a QAOA run.
- __init__(result: QAOAResult[SamplingMeta_co]) None¶
- durations: QAOADurations¶
Total timing breakdown for the entire QAOA run.
- history: Sequence[QAOAHistoryItem[SamplingMeta_co]]¶
Per-evaluation records accumulated during classical optimization, in the order they were evaluated.
- num_execution: int¶
Number of objective function evaluations performed during classical optimization.
- optimized_counts: IsingSeqFreqList¶
Measurement results from the circuit evaluated at
optimized_parameters, as a list of(spin_sequence, frequency)pairs.
- static acceptable_degrees(parameters: Parameters) AcceptableDegrees¶
Return the polynomial degrees accepted by the selected QAOA variant.
- パラメータ:
parameters (Parameters) -- QAOA configuration from which the
qaoa_typeis read.- 戻り値:
The degree constraints for the objective polynomial, determined by the chosen
QAOATypeor custom implementation tuple.- 戻り値の型:
- static run(
- sampler: SamplerProtocol[SamplingMeta_co, SupportsAnsatz | SupportsCAnsatz],
- model: Model,
- parameters: Parameters,
- dry_run: Literal[False] = False,
- static run(
- sampler: SamplerProtocol[SamplingMeta_co, SupportsAnsatz | SupportsCAnsatz],
- model: Model,
- parameters: Parameters,
- dry_run: Literal[True],
Run QAOA on the given optimization model.
- パラメータ:
sampler (SamplerProtocol[SamplingMeta_co, SupportsAnsatz | SupportsCAnsatz]) -- Backend sampler that executes quantum circuits and returns measurement results.
model (Model) -- The optimization model containing the objective function and constraints.
parameters (Parameters) -- QAOA configuration (circuit depth, shots, optimizer, etc.).
dry_run (bool) -- If
True, validate inputs without executing circuits and returnNone.
- 戻り値:
The QAOA result, or
Noneif dry_run isTrue.- 戻り値の型:
Result[SamplingMeta_co] | None