qat.plugins.ScipyMinimizePlugin

class qat.plugins.ScipyMinimizePlugin(collective=False, binding_args=None, **kwargs)

A variational plugin for hybrid quantum classical optimization based on the scipy.optimize.minimize method.

It is a particularization of the Optimizer class.

Parameters
  • x0 (np.array, optional) – initial value of the parameters. Defaults to None, in which case we assume random initilization.

  • binding_args (dict) – arguments passed to the variable binding method

  • kwargs – minimize parameters (see scipy.optimize.minimize documentation), e.g ‘method’, ‘tol’, ‘options’…

Note

Parameters can be changed dynamically using the qat.plugins.ScipyMinimizePlugin.set_options() method.

Example:

import numpy as np
form qat.plugins import ScipyMinimizePlugin
from qat.linalg import LinAlg

plugin = ScipyMinimizePlugin(x0=np.random.random(10),
                             method="COBYLA",
                             tol=1e-3,
                             options={"maxiter": 300})

stack = plugin | LinAlg()
# Any job will run, as long as it contains 10 variables!
result = stack.submit(my_job)
compile(batch: Batch) Batch

Loops a batch through all the plugins present inside the QPU.

Parameters

batch (Batch) – a batch of jobs. If a single job is provided, the job is embedded into a Batch, compiled, and the first result is returned.

Returns

a batch of jobs

Return type

Batch

set_options(**kwargs)

Sets new options for the minimize function.

Parameters

kwargs – a new set of options