pygsti.optimize_gauge¶
-
pygsti.
optimize_gauge
(gateset, toGetTo, maxiter=100000, maxfev=None, tol=1e-08, method='L-BFGS-B', targetGateset=None, targetFactor=0.0001, constrainToTP=False, constrainToCP=False, constrainToValidSpam=False, returnAll=False, gateWeight=1.0, spamWeight=0.0, targetGatesMetric='frobenius', targetSpamMetric='frobenius', verbosity=0)¶ Optimize the gauge of a GateSet using some ‘goodness’ function.
Parameters: - gateset (GateSet) – The gateset to gauge-optimize
- toGetTo (string) –
Specifies which goodness function is used. Allowed values are:
- ‘target’ – minimize the frobenius norm of the difference between gateset and targetGateset, which must be specified.
- ‘CPTP’ – minimize the non-CPTP-ness of the gateset.
- ‘TP’ – minimize the non-TP-ness of the gateset.
- ‘TP and target’ – minimize the non-TP-ness of the gateset and the frobenius norm distance to targetGateset using targetFactor to multiply this distance.
- ‘CPTP and target’ – minimize the non-CPTP-ness of the gateset and the frobenius norm distance to targetGateset using targetFactor to multiply this distance.
- ‘Completely Depolarized’ – minimize the frobenius norm distance between gateset and the completely-depolarized gateset.
- 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.
- 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
- targetGateset (GateSet, optional) – The target gateset used by the ‘target’, ‘TP and target’ and ‘CPTP and target’ values of the toGetTo parameter (above).
- targetFactor (float, optional) – A weighting factor that multiplies by the frobenius norm difference between gateset and targetGateset with toGetTo is either “TP and target” or “CPTP and target”.
- constrainToTP (bool, optional) – When toGetTo == ‘target’, whether gauge optimization is constrained to TP gatesets.
- constrainToCP (bool, optional) – When toGetTo == ‘target’, whether gauge optimization is constrained to CP gatesets.
- constrainToValidSpam (bool, optional) – When toGetTo == ‘target’, whether gauge optimization is constrained to gatesets with valid state preparation and measurements.
- returnAll (bool, optional) – When True, return best “goodness” value and gauge matrix in addition to the gauge optimized gateset.
- gateWeight (float, optional) – Weighting factor that multiplies each single-gate norm before summing it into the total frobenius norm between two gatesets.
- spamWeight (float, optional) – Weighting factor that multiplies the norms of between surface-preparation and measuement vectors (or gates, depending on the metric used) before summing them into the total norm between two gatesets.
- targetGatesMetric (string, optional) – When toGetTo == “target”, this specifies the metric used to evaluate what “close to the target” means for the gate matrices. Allowed values are “frobenius”, “fidelity”, and “tracedist”. Contributions for the individual gates are summed, and in the case of frobenius, ultimately normalized by the number of elements.
- targetSpamMetric (string, optional) – When toGetTo == “target”, this specifies the metric used to evaluate what “close to the target” means for the spam vectors. Allowed values are “frobenius”, “fidelity”, and “tracedist”. Contributions for the individual vectors are summed, and in the case of frobenius, ultimately normalized by the number of elements.
- verbosity (int, optional) – How much detail to send to stdout.
Returns: gateset if returnAll == False
(goodnessMin, gaugeMx, gateset) if returnAll == True –
where goodnessMin is the minimum value of the goodness function (the best ‘goodness’) found, gaugeMx is the gauge matrix used to transform the gateset, and gateset is the final gauge-transformed gateset.