Exemplo n.º 1
0
    def map_loss_trial(self,
                       true_map_,
                       SAMPLE_GLOBAL_MODEL,
                       measurements_controls_=None,
                       autocontrol_="ON",
                       var_thres_=1.0):
        '''Return an error vector for map reconstruction from one trial of an algorithm.'''

        self.qslamobj = qs.ParticleFilter(SAMPLE_GLOBAL_MODEL)
        self.qslamobj.QubitGrid.engineeredtruemap = true_map_

        self.qslamobj.qslamr(
            measurements_controls=measurements_controls_,
            autocontrol=autocontrol_,
            max_num_iterations=SAMPLE_GLOBAL_MODEL["MODELDESIGN"]
            ["MAX_NUM_ITERATIONS"],
            var_thres=var_thres_)

        posterior_map = self.qslamobj.QubitGrid.get_all_nodes(["f_state"])
        posterior_corrs = self.qslamobj.QubitGrid.get_all_nodes(["r_state"])

        map_residuals = self.loss(posterior_map, true_map_)
        controlpath = self.qslamobj.QubitGrid.control_sequence

        return posterior_map, map_residuals, posterior_corrs, controlpath
Exemplo n.º 2
0
    def qslam_trial(self,
                    measurements_controls_=None,
                    autocontrol_="ON",
                    var_thres_=1.0):
        '''
        Return posterior map, posterior lengthscales and control path for one
        QSLAM run.

        Parameters:
        -----------

        measurements_controls_ (`float` | dims: 2):
            External input for the most recent control directive and measurement
            outcome for the qubit, denoted by locaton index, node_j.
            Default value: None.
        autocontrol_ (`dtype` | string binary - "ON", "OFF"):
            "OFF" - next qubit measured is specified as a user input via measurement_controls_
            "ON" - next qubit measured is chosen by the algorithm.
            Default value: "ON".
        var_thres [NOT USED]:
            Error variance threshold where if the variance
            of length scales is less than interqubit separation, then algorithm
            terminates.

        Returns:
        --------
        posterior_f_state (`dtype` | numpy array):
            Posterior dephasing noise field estimate at each qubit on grid in
            vectorised form.
            Dims: len(self.GLOBALDICT["GRIDDICT"])
        posterior_r_state (`dtype` | numpy array):
            Posterior correlation length estimate at each qubit on grid in
            vectorised form.
            Dims: len(self.GLOBALDICT["GRIDDICT"])
        control_sequence (`dtype` | list ):
            List of control actions (qubits to measure) for every iteration step of qslam.
            Initialised as an empty list.

        '''

        qslamobj = qs.ParticleFilter(copy.deepcopy(self.GLOBALDICT),
                                     real_data=True,
                                     real_data_key=self.data_key)

        qslamobj.qslamr(max_num_iterations=self.GLOBALDICT["MODELDESIGN"]
                        ["MAX_NUM_ITERATIONS"],
                        measurements_controls=measurements_controls_,
                        autocontrol=autocontrol_,
                        var_thres=var_thres_)

        posterior_f_state = qslamobj.QubitGrid.get_all_nodes(["f_state"])
        posterior_r_state = qslamobj.QubitGrid.get_all_nodes(["r_state"])
        control_sequence = qslamobj.QubitGrid.control_sequence

        return posterior_f_state, posterior_r_state, control_sequence
Exemplo n.º 3
0
    def qslam_trial(self, measurements_controls_=None,
                         autocontrol_="ON",
                         var_thres_=1.0 ):
        
        qslamobj = qs.ParticleFilter(copy.deepcopy(self.GLOBALDICT), real_data=True, real_data_key=self.data_key)
        qslamobj.qslamr(max_num_iterations=self.GLOBALDICT["MODELDESIGN"]["MAX_NUM_ITERATIONS"],
                        measurements_controls=measurements_controls_,
                        autocontrol=autocontrol_,
                        var_thres=var_thres_)

        posterior_map = qslamobj.QubitGrid.get_all_nodes(["f_state"])
        posterior_corrs = qslamobj.QubitGrid.get_all_nodes(["r_state"])
        controlpath = qslamobj.QubitGrid.control_sequence

        return posterior_map, posterior_corrs, controlpath
Exemplo n.º 4
0
    def call_qslam(self):

        qslamobj = 0
        qslamobj = qs.ParticleFilter(
            self.SAMPLE_GLOBAL_MODEL,
            save_run=True,
            beta_expansion_mode=self.beta_expansion_mode,
            beta_skew_adjust=self.beta_skew_adjust)

        qslamobj.QubitGrid.engineeredtruemap = self.true_map_

        qslamobj.qslamr(
            measurements_controls=self.measurements_controls_,
            autocontrol=self.autocontrol_,
            max_num_iterations=self.SAMPLE_GLOBAL_MODEL["MODELDESIGN"]
            ["MAX_NUM_ITERATIONS"],
            var_thres=self.var_thres_)

        return qslamobj
Exemplo n.º 5
0
    def map_loss_trial(self,
                       true_map_,
                       SAMPLE_GLOBAL_MODEL,
                       measurements_controls_=None,
                       autocontrol_="ON",
                       var_thres_=1.0):
        '''Return posterior f_state, posterior r_state, residuals, and
        control path for map reconstruction from one trial of QSLAM.

        Parameters:
        -----------
            true_map_ (`dtype`| numpy array ):
                A set of phase values associated to each qubit location in an arrangement,
                where each phase take a value between [0, np.pi].

            SAMPLE_GLOBAL_MODEL (`dtype`| numpy array ):
                Dictionary object as given in qslamdesignparams.py that sets
                parameters to conduct an empirical risk analysis and configure QSLAM.

            measurements_controls_ (`dtype`| numpy array ):
                A list containing a measurement set and the control
                directive of the location of the measured qubit. Each control directive
                is a single iteration of the algorithm.

            autocontrol_ (`dtype`| string ):
                "OFF" - next qubit measured is specified as a user input via measurement_controls_
                "ON" - next qubit measured is chosen by the algorithm.
                Default value: "OFF".

            var_thres_ (`dtype`| numpy array ):
                Error variance threshold where if the variance
                of length scales is less than interqubit separation, then algorithm
                terminates.

        Returns:
        -------

            posterior_map (`type` | numpy array ):
                Posterior f_state at the end of a QSLAM filtering run.
            map_residuals (`type` | numpy array ):
                Difference between posterior f_state  and a true map at the end
                    of a QSLAM filtering run.
            posterior_corrs (`type` | numpy array ):
                Posterior r_state at the end of a QSLAM filtering run.
            controlpath (`type` | list ):
                List of qubit locations at which a physical measurement was performed.
                A single element of this list corresponds to one iteration of QSLAM;
                length of list output at the end of a QSLAM filtering run matches
                total number of algorithm iterations.

        '''

        self.qslamobj = qs.ParticleFilter(SAMPLE_GLOBAL_MODEL)
        self.qslamobj.QubitGrid.engineeredtruemap = true_map_

        self.qslamobj.qslamr(
            measurements_controls=measurements_controls_,
            autocontrol=autocontrol_,
            max_num_iterations=SAMPLE_GLOBAL_MODEL["MODELDESIGN"]
            ["MAX_NUM_ITERATIONS"],
            var_thres=var_thres_)

        posterior_map = self.qslamobj.QubitGrid.get_all_nodes(["f_state"])
        posterior_corrs = self.qslamobj.QubitGrid.get_all_nodes(["r_state"])

        map_residuals = self.loss(posterior_map, true_map_)
        controlpath = self.qslamobj.QubitGrid.control_sequence

        return posterior_map, map_residuals, posterior_corrs, controlpath