pygsti.algorithms.gaugeopt.gaugeopt_custom

pygsti.algorithms.gaugeopt.gaugeopt_custom#

gaugeopt_custom(model, objective_fn, gauge_group=None, method='L-BFGS-B', maxiter=100000, maxfev=None, tol=1e-08, oob_check_interval=0, return_all=False, jacobian_fn=None, comm=None, verbosity=0)#

Optimize the gauge of a model using a custom objective function.

Parameters:
  • model (Model) – The model to gauge-optimize

  • objective_fn (function) – The function to be minimized. The function must take a GaugeGroupElement and a bool. If method == ‘ls’ then objective_fn must return an ndarray; if method != ‘ls’ then objective_fn must return a float.

  • gauge_group (GaugeGroup, optional) – The gauge group which defines which gauge transformations are optimized over. If None, then the model’s default gauge group is used.

  • method (string, optional) –

    The method used to optimize the objective function. Can be any method known by scipy.optimize.minimize such as ‘BFGS’, ‘Nelder-Mead’, ‘CG’, ‘L-BFGS-B’, or additionally:

    • ’custom’ – custom CG that often works better than ‘CG’

    • ’supersimplex’ – repeated application of ‘Nelder-Mead’ to converge it

    • ’basinhopping’ – scipy.optimize.basinhopping using L-BFGS-B as a local optimizer

    • ’swarm’ – particle swarm global optimization algorithm

    • ’evolve’ – evolutionary global optimization algorithm using DEAP

    • ’brute’ – Experimental: scipy.optimize.brute using 4 points along each dimensions

  • maxiter (int, optional) – Maximum number of iterations for the gauge optimization.

  • maxfev (int, optional) – Maximum number of function evaluations for the gauge optimization. Defaults to maxiter.

  • tol (float, optional) – The tolerance for the gauge optimization.

  • oob_check_interval (int, optional) – If greater than zero, gauge transformations are allowed to fail (by raising any exception) to indicate an out-of-bounds condition that the gauge optimizer will avoid. If zero, then any gauge-transform failures just terminate the optimization.

  • return_all (bool, optional) – When True, return best “goodness” value and gauge matrix in addition to the gauge optimized model.

  • jacobian_fn (function, optional) – The jacobian of objective_fn. The function must take three parameters, 1) the un-transformed Model, 2) the transformed Model, and 3) the GaugeGroupElement representing the transformation that brings the first argument into the second.

  • comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator for distributing the computation across multiple processors.

  • verbosity (int, optional) – How much detail to send to stdout.

Returns:

  • model – if return_all == False

  • (goodnessMin, gaugeMx, model) – if return_all == True where goodnessMin is the minimum value of the goodness function (the best ‘goodness’) found, gaugeMx is the gauge matrix used to transform the model, and model is the final gauge-transformed model.