qilisdk.optimizers.scipy_optimizer

Classes

SciPyOptimizer

Helper class that provides a standard way to create an ABC using

Module Contents

class SciPyOptimizer(method: str | Callable | None = None, **kwargs: dict[str, Any])[fuente]

Bases: qilisdk.optimizers.optimizer.Optimizer

Helper class that provides a standard way to create an ABC using inheritance.

Create a new Gradient Based optimizer instance.

Parámetros:
  • method (str | Callable | None, optional) –

    Type of solver. Should be one of - “Nelder-Mead - “Powell” - “CG” - “BFGS” - “Newton-CG” - “L-BFGS-B” - “TNC” - “COBYLA” - “COBYQA” - “SLSQP” - “trust-constr - “dogleg” - “trust-ncg” - “trust-exact - “trust-krylov - custom - a callable object, see scipy.optimize.minimize for description.

    If not given, chosen to be one of BFGS, L-BFGS-B, SLSQP, depending on whether or not the problem has constraints or bounds.

  • bounds (list[tuple[int, int]] | None, optional) – Bounds on variables for Nelder-Mead, L-BFGS-B, TNC, SLSQP, Powell, trust-constr, COBYLA, and COBYQA methods. To specify it you can provide a sequence of (min, max) pairs for each element in parameter list.

Extra Args:

Any argument supported by scipy.optimize.minimize <https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html> can be passed. Note: the parameters, cost function and the args that are passed to this function will be specified in the optimize method. Moreover, callbacks are not supported for the moment.

method = None[fuente]
extra_arguments[fuente]
optimize(cost_function: Callable[[list[float]], float], init_parameters: list[float], bounds: list[tuple[float, float]], store_intermediate_results: bool = False) qilisdk.optimizers.optimizer_result.OptimizerResult[fuente]

optimize the cost function and return the optimal parameters.

Parámetros:
  • cost_function (Callable[[list[float]], float]) – a function that takes in a list of parameters and returns the cost.

  • init_parameters (list[float]) – the list of initial parameters. Note: the length of this list determines the number of parameters the optimizer will consider.

  • bounds (list[float, float]) – a list of the variable value bounds.

Devuelve:

the optimal set of parameters that minimize the cost function.

Tipo del valor devuelto:

list[float]