qsearch.multistart_solvers

This module defines solvers that use multiple starting points in order to have a higher chance at finding the global minimum.

Module Contents

Classes

MultiStart_Solver

A higher accuracy solver based on APOSMM https://www.mcs.anl.gov/~jlarson/APOSMM/

NaiveMultiStart_Solver

A naive but effective multi-start solver which tries to cover as much of the optimization space at once

Functions

distance_for_x(x, options, circuit)

Calculate the distance between circuit and the target for input x based on the distance metric

optimize_worker(circuit, options, q, x0, error_func)

Worker function used to run the inner solver in parallel

qsearch.multistart_solvers.distance_for_x(x, options, circuit)

Calculate the distance between circuit and the target for input x based on the distance metric

qsearch.multistart_solvers.optimize_worker(circuit, options, q, x0, error_func)

Worker function used to run the inner solver in parallel

class qsearch.multistart_solvers.MultiStart_Solver(num_threads)

Bases: qsearch.solvers.Solver

A higher accuracy solver based on APOSMM https://www.mcs.anl.gov/~jlarson/APOSMM/

MultiStart_Solver generally gets better results than other optimizers due to the advanced algorithm to start multiple local optimizers (“inner solvers”) and find the global optimum more often.

Create a MultiStart_Solver instance. Pass num_threads to set how many threads to use in parallel optimization runs

solve_for_unitary(self, circuit, options, x0=None)

Optimize the given circuit based on the provided options with initial point x0 (optional).

Parameters
  • circuit – A qsearch.gates.Gate describing the circuit to optimize

  • options – This uses the following options: - inner_solver : which optimizer to use for local optimization runs - target : the target unitary of synthesis - logger : A qsearch.logging.Logger that will be used for logging the synthesis process. - error_func : The function that the Solver will attempt to minimize. - error_residuals : A function that returns an array of real-valued residuals to be used by a least-squares-based Solver.

  • x0 – the starting point for the optimzier

class qsearch.multistart_solvers.NaiveMultiStart_Solver(num_threads)

Bases: qsearch.solvers.Solver

A naive but effective multi-start solver which tries to cover as much of the optimization space at once

Create a NaiveMultiStart_Solver instance. Pass num_threads to set how many threads to use in parallel optimization runs

solve_for_unitary(self, circuit, options, x0=None)

Finds the best parameters that minimize error_func or error_residuals between the unitary from the circuit and options.target.