pygsti.algorithms.scoring
Common functions used in scoring germ and fiducial sets.
Module Contents
Classes
Class for storing and comparing scores calculated from eigenvalues. 
Functions

Score an array of eigenvalues. Smaller scores are better. 

Create a restricted candidate list (RCL) based on CompositeScore objects. 
 pygsti.algorithms.scoring.list_score(input_array, score_func='all')
Score an array of eigenvalues. Smaller scores are better.
Parameters
 input_arraynumpy array
The eigenvalues to be scored.
 score_func{‘all’, ‘worst’}, optional
Sets the objective function for scoring the eigenvalues. If ‘all’, score is
sum(1/input_array)
. If ‘worst’, score is1/min(input_array)
.Note: we use this function in various optimization routines, and sometimes choosing one or the other objective function can help avoid suboptimal local minima.
Returns
 float
Score for the eigenvalues.
 class pygsti.algorithms.scoring.CompositeScore(major, minor, n)
Class for storing and comparing scores calculated from eigenvalues.
The comparison functions operate according to the logic that a lower score is better. The score value is broken into two parts: ‘major’ and ‘minor’. A CompositeScore with a smaller ‘major’ part is always smaller than one with a larger ‘major’ part. The ‘minor’ parts are only compared when the major parts are equal. Typically, the negative of the number of nonzero eigenvalues is used to as the major part so that a score that has more nonzero eigenvalues (higher N) will always compare as less than a score that has fewer nonzero eigenvalues (lower N), with ties for N being resolved by comparing the minor score in the straightforward manner (since the nonAC score is assumed to be better for lower values). For bookeeping, the CompositeScore object also separately holds the number of nonzero eigenvalues, as this may not always be recovered from the major part of the score.
Parameters
 majorfloat
Major (more significant) component of score.
 minorfloat
Minor (less significant) component of score.
 nint
Number of nonzero eigenvalues.
 pygsti.algorithms.scoring.filter_composite_rcl(candidate_scores, alpha)
Create a restricted candidate list (RCL) based on CompositeScore objects.
Parameters
 candidate_scoreslist of CompositScore
List of scores to be sorted in RCL and not RCL.
 alphafloat
A number between 0 and 1 that roughly specifies a score threshold relative to the spread of scores that a germ must score better than in order to be included in the RCL. A value of 0 for alpha corresponds to a purely greedy algorithm (only the bestscoring element is included in the RCL), while a value of 1 for alpha will include all elements in the RCL.
Intermediate values of alpha attempt to mimic the behavior of alpha for simple float scores. For those scores, the score that all elements must beat is
(1  alpha)*best + alpha*worst
. For CompositeScore objects, thresholding is done on the major part of the score unless all the candidates have the same major score, in which case thresholding is performed using only the minor score.
Returns
 numpy.array
The indices of the scores sufficiently good to be in the RCL.