:py:mod:`pygsti.algorithms.contract` ==================================== .. py:module:: pygsti.algorithms.contract .. autoapi-nested-parse:: GST contraction algorithms Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: pygsti.algorithms.contract.contract .. py:function:: contract(model, to_what, dataset=None, maxiter=1000000, tol=0.01, use_direct_cp=True, method='Nelder-Mead', verbosity=0) Contract a Model to a specified space. All contraction operations except 'vSPAM' operate entirely on the gate matrices and leave state preparations and measurments alone, while 'vSPAM' operations only on SPAM. Parameters ---------- model : Model The model to contract to_what : string Specifies which space is the model is contracted to. Allowed values are: - 'TP' -- All gates are manifestly trace-preserving maps. - 'CP' -- All gates are manifestly completely-positive maps. - 'CPTP' -- All gates are manifestly completely-positive and trace-preserving maps. - 'XP' -- All gates are manifestly "experimentally-positive" maps. - 'XPTP' -- All gates are manifestly "experimentally-positive" and trace-preserving maps. - 'vSPAM' -- state preparation and measurement operations are valid. - 'nothing' -- no contraction is performed. dataset : DataSet, optional Dataset to use to determine whether a model is in the "experimentally-positive" (XP) space. Required only when contracting to XP or XPTP. maxiter : int, optional Maximum number of iterations for iterative contraction routines. tol : float, optional Tolerance for iterative contraction routines. use_direct_cp : bool, optional Whether to use a faster direct-contraction method for CP contraction. This method essentially transforms to the Choi matrix, truncates any negative eigenvalues to zero, then transforms back to a operation matrix. method : string, optional The method used when contracting to XP and non-directly to CP (i.e. use_direct_cp == False). verbosity : int, optional How much detail to send to stdout. Returns ------- Model The contracted model