Quanlse/Calibration/TwoQubit.py
def _singleQubitCaliLoss(x):
        """
        Obtain the calibration pulse jobs and calculate the loss function.
        """

        # Generate the pulse jobs for calibration
        caliJobs, _ = caliSingleQubitGatesJob(sche, q0, q1, [x[0], x[1]], [x[2], x[3]], False)

        # Simulate the calibration pulse
        if isinstance(sche, PulseModel):
            results = sche.simulate(jobList=caliJobs, options=options)
        else:
            if runner is None or not callable(runner):
                raise ArgumentError("Please input a callable runner!")
            results = runner(jobList=caliJobs, options=options)

        lossSum = 0.
        for _jobIdx, _idealMat in enumerate(idealMatrixList):
            # Obtain the output population value
            pop = project(numpy.square(abs(results[_jobIdx]["state"])).T[0], sche.subSysNum, sche.sysLevel, 2)

            # Obtain the ideal population
            stateIdeal = _idealMat @ basis(_idealMat.shape[0], 0).T[0]
            popIdeal = numpy.square(abs(stateIdeal))

            # Calculate the loss function
            lossSum += numpy.sum(numpy.abs(pop - popIdeal)) / len(pop)

        aveLoss = lossSum / len(idealMatrixList)
        return aveLoss

        Obtain the calibration pulse jobs and calculate the loss function.
        
Obtain the calibration pulse jobs and calculate the loss function.
Obtain the calibration pulse jobs and calculate the loss function .
def _singleQubitCaliLoss(x):
        caliJobs, _ = caliSingleQubitGatesJob(sche, q0, q1, [x[0], x[1]], [x[2], x[3]], False)
        if isinstance(sche, PulseModel):
            results = sche.simulate(jobList=caliJobs, options=options)
        else:
            if runner is None or not callable(runner):
                raise ArgumentError("Please input a callable runner!")
            results = runner(jobList=caliJobs, options=options)
        lossSum = 0.
        for _jobIdx, _idealMat in enumerate(idealMatrixList):
            pop = project(numpy.square(abs(results[_jobIdx]["state"])).T[0], sche.subSysNum, sche.sysLevel, 2)
            stateIdeal = _idealMat @ basis(_idealMat.shape[0], 0).T[0]
            popIdeal = numpy.square(abs(stateIdeal))
            lossSum += numpy.sum(numpy.abs(pop - popIdeal)) / len(pop)
        aveLoss = lossSum / len(idealMatrixList)
        return aveLoss
def _singleQubitCaliLoss ( x ) : caliJobs , _ = caliSingleQubitGatesJob ( sche , q0 , q1 , [ x [ 0 ] , x [ 1 ] ] , [ x [ 2 ] , x [ 3 ] ] , False ) if isinstance ( sche , PulseModel ) : results = sche . simulate ( jobList = caliJobs , options = options ) else : if runner is None or not callable ( runner ) : raise ArgumentError ( "Please input a callable runner!" ) results = runner ( jobList = caliJobs , options = options ) lossSum = 0. for _jobIdx , _idealMat in enumerate ( idealMatrixList ) : pop = project ( numpy . square ( abs ( results [ _jobIdx ] [ "state" ] ) ) . T [ 0 ] , sche . subSysNum , sche . sysLevel , 2 ) stateIdeal = _idealMat @ basis ( _idealMat . shape [ 0 ] , 0 ) . T [ 0 ] popIdeal = numpy . square ( abs ( stateIdeal ) ) lossSum += numpy . sum ( numpy . abs ( pop - popIdeal ) ) / len ( pop ) aveLoss = lossSum / len ( idealMatrixList ) return aveLoss
Obtain the calibration pulse jobs and calculate the loss function.
Obtain the calibration pulse jobs and calculate the loss function .
"""
        Obtain the calibration pulse jobs and calculate the loss function.
        """ # Generate the pulse jobs for calibration # Simulate the calibration pulse # Obtain the output population value # Obtain the ideal population # Calculate the loss function
x