squlearn.optimizers.SPSA

class squlearn.optimizers.SPSA(options: dict = None, callback=<function default_callback>)

Wrapper class for Qiskit’s SPSA implementation.

Parameters:

options (dict) – Options for the SPSA optimizer. The options are the same as for qiskit_algorithms.optimizers.SPSA()

minimize(fun: callable, x0: ndarray, grad: callable = None, bounds=None) OptimizerResult

Function to minimize a given function using Qiskit’s SPSA optimizer.

Parameters:
  • fun (callable) – Function to minimize.

  • x0 (numpy.ndarray) – Initial guess.

  • grad (callable) – Gradient of the function to minimize.

  • bounds (sequence) – Bounds for the parameters.

Returns:

OptimizerResult format.

Return type:

Result of the optimization in class

set_callback(callback)

Set the callback function with additional iteration counter increasing.