Skip to content

FlexQAOA Optimizers

LinearOptimizerParams

Bases: ScipyOptimizerParams

Optimizer for tuning a linear schedule of QAOA parameters.

Optimizes onyl two parameters: delta_beta and delta_gamma with the default ScipyOptimizer.

Wrapper for scipy.optimize.minimize. See https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html for more information of the available methods and parameters.

Attributes:

Name Type Description
method ScipyOptimizerMethod

Type of solver. See https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html for supported methods.

tol float | None

Tolerance for termination.

bounds None | tuple[float, float] | list[tuple[float, float]]

Bounds on variables for Nelder-Mead, L-BFGS-B, TNC, SLSQP, Powell, trust-constr, COBYLA, and COBYQA methods. None is used to specify no bounds, (min, max) is used to specify bounds for all variables. A sequence of (min, max) can be used to specify bounds for each parameter individually.

jac None | Literal['2-point', '3-point', 'cs']

Method for computing the gradient vector. Only for CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr.

hess None | Literal['2-point', '3-point', 'cs']

Method for computing the Hessian matrix. Only for Newton-CG, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr.

maxiter int

Maximum number of iterations to perform. Depending on the method each iteration may use several function evaluations. Will be ignored for TNC optimizer. Default: 100

options dict[str, float]

A dictionary of solver options.

bounds class-attribute instance-attribute

bounds: None | list[tuple[float, float]] = Field(
    default=None,
    description="Bounds on variables for Nelder-Mead, L-BFGS-B, TNC, SLSQP, Powell,trust-constr, COBYLA, and COBYQA methods. None is used to specify no bounds. A sequence of `(min, max)` can be used to specify bounds for each parameter individually.",
)

hess class-attribute instance-attribute

hess: None | Literal["2-point", "3-point", "cs"] = Field(
    default=None,
    description="Method for computing the Hessian matrix. Only for Newton-CG, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr.",
)

jac class-attribute instance-attribute

jac: None | Literal["2-point", "3-point", "cs"] = Field(
    default=None,
    description="Method for computing the gradient vector. Only for CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr.",
)

maxiter class-attribute instance-attribute

maxiter: int = Field(
    default=100,
    ge=1,
    le=10000,
    description="Maximum number of iterations to perform. Depending on the method each iteration may use several function evaluations. Will be ignored for TNC optimizer.",
)

method class-attribute instance-attribute

method: ScipyOptimizerMethod = Field(
    default="cobyla",
    description="Type of solver. See https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.htmlfor supported methods.",
)

optimizer_type class-attribute instance-attribute

optimizer_type: Literal['linear'] = 'linear'

options class-attribute instance-attribute

options: dict[str, float] = Field(
    default_factory=dict, description="A dictionary of solver options."
)

tol class-attribute instance-attribute

tol: float | None = Field(
    default=None, ge=0, description="Tolerance for termination."
)

CombinedOptimizerParams

Bases: BaseModel

Combination of LinearOptimizer and ScipyOptimizer.

Optimizer that first performs an optimization of the linear schedule and then fine tunes individual parameters.

Attributes:

Name Type Description
linear LinearOptimizerParams | Dict

Parameters of the linear optimizer.

fine_tune ScipyOptimizerParams | Dict

Parameters of the fine tuning optimizer.

fine_tune class-attribute instance-attribute

fine_tune: ScipyOptimizerParams = Field(
    default_factory=lambda: ScipyOptimizerParams()
)

linear class-attribute instance-attribute

linear: LinearOptimizerParams = Field(
    default_factory=lambda: LinearOptimizerParams()
)

optimizer_type class-attribute instance-attribute

optimizer_type: Literal['combined'] = 'combined'

InterpolateOptimizerParams

Bases: BaseModel

Optimizer with sequentially increasing number of QAOA layers.

Optimizer that starts with reps iteration and interpolates sequentially in reps_step steps to reps_end. In between it performs a full optimization routine tunes individual parameters.

Attributes:

Name Type Description
optimiezr LinearOptimizerParams | ScipyOptimizerParams | Dict

Parameters of the optimizer.

reps_step int

Number of QAOA layers added for one interpolation.

reps_end int

Final number of QAOA layers to be reached.

optimizer class-attribute instance-attribute

optimizer: ScipyOptimizerParams | LinearOptimizerParams = Field(
    default_factory=lambda: ScipyOptimizerParams()
)

optimizer_type class-attribute instance-attribute

optimizer_type: Literal['interpolate'] = 'interpolate'

reps_end class-attribute instance-attribute

reps_end: int = Field(default=10, ge=1)

reps_step class-attribute instance-attribute

reps_step: int = Field(default=1, ge=1)