RQAOA

class RQAOA

Recursive Quantum Approximate Optimization Algorithm (RQAOA).

A recursive variant of QAOA that iteratively reduces the problem size by eliminating variables based on correlation information obtained from QAOA solutions, until the problem is small enough to be solved directly. All constraints are converted to penalty terms in the objective.

Pass this class to any QuantumBaseClient subclass to run RQAOA on the corresponding backend.

Methods

acceptable_degrees

Return the polynomial degrees accepted by the selected QAOA variant.

run

Run RQAOA on the given optimization model.

class Parameters

Configuration parameters for an RQAOA run.

__eq__(other)

Return self==value.

__init__(reps: int = 10, shots: int = 1024, min_size: int = 2, max_degree: int | None = None, min_corr: float = 0, qaoa_type: RQAOAType | Literal[QAOAType.ORIGINAL, QAOAType.ORIGINAL_QUADRATIC] | tuple[type[QAOAImplProtocol], AcceptableDegrees] = RQAOAType.ORIGINAL, minimize: MinimizeProtocol = <factory>) None
__repr__()

Return repr(self).

__dataclass_fields__ = {'max_degree': Field(name='max_degree',type='int | None',default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'min_corr': Field(name='min_corr',type='float',default=0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'min_size': Field(name='min_size',type='int',default=2,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), '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='RQAOAType | Literal[QAOAType.ORIGINAL, QAOAType.ORIGINAL_QUADRATIC] | tuple[type[QAOAImplProtocol], AcceptableDegrees]',default=<RQAOAType.ORIGINAL: (<class 'amplify_quantum.algo.qaoa.impls.qaoa_original.OriginalQAOAImpl'>, <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', 'min_size', 'max_degree', 'min_corr', 'qaoa_type', 'minimize')
max_degree: int | None = None

Maximum polynomial degree to retain when reducing the problem. None means no degree limit is applied. Must be greater than or equal to 0.

min_corr: float = 0

Minimum absolute correlation threshold for selecting a term to eliminate. Only terms whose measured correlation exceeds this value are considered for elimination. When set to 0 (default), any non-zero correlation is accepted. Must be greater than or equal to 0.

min_size: int = 2

Minimum problem size at which recursion stops and the remaining sub-problem is solved by exhaustive enumeration. Must be greater than or equal to 0.

minimize: MinimizeProtocol

Classical optimizer used to tune the variational circuit parameters. Defaults to ScipyMinimize with the COBYLA method.

qaoa_type: RQAOAType | Literal[QAOAType.ORIGINAL, QAOAType.ORIGINAL_QUADRATIC] | tuple[type[QAOAImplProtocol], AcceptableDegrees] = (<class 'amplify_quantum.algo.qaoa.impls.qaoa_original.OriginalQAOAImpl'>, <amplify.AcceptableDegrees object>)

QAOA implementation to use within each iteration. Either a RQAOAType value for the built-in strategies, or a custom (impl_class, acceptable_degrees) tuple.

reps: int = 10

Number of QAOA layers (circuit depth p) used in each RQAOA iteration. Increasing this value may improve solution quality at the cost of a deeper circuit. Must be greater than or equal to 0.

shots: int = 1024

Number of measurement shots per circuit evaluation. Must be greater than or equal to 0.

class Result

ベースクラス: Generic[SamplingMeta_co]

Result of an RQAOA run.

__init__(result: RQAOAResult[SamplingMeta_co]) None
durations

Total timing breakdown for the entire RQAOA run.

history

Per-iteration records accumulated during the RQAOA optimization process, in the order they were performed.

num_execution

Number of objective function evaluations performed during classical optimization.

optimized_objective

Best objective value found for the reduced problem.

optimized_solution

Best solution found, as a tuple of spin values.

static acceptable_degrees(parameters: Parameters) AcceptableDegrees

Return the polynomial degrees accepted by the selected QAOA variant.

パラメータ:

parameters (Parameters) -- RQAOA configuration from which the qaoa_type is read.

戻り値:

The degree constraints for the objective polynomial, determined by the chosen RQAOAType or custom implementation tuple.

戻り値の型:

AcceptableDegrees

static run(
sampler: SamplerProtocol[SamplingMeta_co, SupportsAnsatz | SupportsCAnsatz],
model: Model,
parameters: Parameters,
dry_run: Literal[False] = False,
) Result[SamplingMeta_co]
static run(
sampler: SamplerProtocol[SamplingMeta_co, SupportsAnsatz | SupportsCAnsatz],
model: Model,
parameters: Parameters,
dry_run: Literal[True],
) None

Run RQAOA 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) -- RQAOA configuration (circuit depth, shots, optimizer, etc.).

  • dry_run (bool) -- If True, validate inputs without executing circuits and return None.

戻り値:

The RQAOA result, or None if dry_run is True.

戻り値の型:

Result[SamplingMeta_co] | None