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

        # Generate the pulse jobs for calibration
        caliJob = czCaliDynamicalPhaseJob(sche, q0, q1, x[0], x[1])

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

        # Obtain the output population value
        pop = project(numpy.square(abs(results[0]["state"])).T[0], sche.subSysNum, sche.sysLevel, 2)

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

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

        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 _dynamicalPhaseCaliLoss(x):
        caliJob = czCaliDynamicalPhaseJob(sche, q0, q1, x[0], x[1])
        if isinstance(sche, PulseModel):
            results = sche.simulate(job=caliJob, options=options)
        else:
            if runner is None or not callable(runner):
                raise ArgumentError("Please input a callable runner!")
            results = runner(job=caliJob, options=options)
        pop = project(numpy.square(abs(results[0]["state"])).T[0], sche.subSysNum, sche.sysLevel, 2)
        uIdeal = sche.getMatrix()
        stateIdeal = uIdeal @ basis(uIdeal.shape[0], 0).T[0]
        popIdeal = numpy.square(abs(stateIdeal))
        loss = numpy.sum(numpy.abs(pop - popIdeal)) / len(pop)
        return loss
def _dynamicalPhaseCaliLoss ( x ) : caliJob = czCaliDynamicalPhaseJob ( sche , q0 , q1 , x [ 0 ] , x [ 1 ] ) if isinstance ( sche , PulseModel ) : results = sche . simulate ( job = caliJob , options = options ) else : if runner is None or not callable ( runner ) : raise ArgumentError ( "Please input a callable runner!" ) results = runner ( job = caliJob , options = options ) pop = project ( numpy . square ( abs ( results [ 0 ] [ "state" ] ) ) . T [ 0 ] , sche . subSysNum , sche . sysLevel , 2 ) uIdeal = sche . getMatrix ( ) stateIdeal = uIdeal @ basis ( uIdeal . shape [ 0 ] , 0 ) . T [ 0 ] popIdeal = numpy . square ( abs ( stateIdeal ) ) loss = numpy . sum ( numpy . abs ( pop - popIdeal ) ) / len ( pop ) return loss
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