示例#1
0
    def _run_simulation(self, current_parameters):  # pylint: disable=R0914
        """The _run_simulation method is where the actual code to simulate
        the system is.

        The implementation of this method is required by every subclass of
        SimulationRunner.

        Parameters
        ----------
        current_parameters : SimulationParameters object
            SimulationParameters object with the parameters for the
            simulation. The self.params variable is not used directly. It
            is first unpacked (in the SimulationRunner.simulate method
            which then calls _run_simulation) for each combination.

        """
        # xxxxxxxxxx Prepare the scenario for this iteration. xxxxxxxxxxxxx
        # This will place the users at the locations specified by the
        # scenario (random locations or not), calculate the path loss and
        # generate a new random channel (in the self.multiuser_channel
        # variable).
        self._create_users_according_to_scenario(current_parameters)

        # This will calculate pathloss and generate random channels from
        # all transmitters to all receivers as well as from the external
        # interference sources to all receivers. This method must be called
        # after the _create_users_according_to_scenario method so that the
        # users are already created (we need their positions for the
        # pathloss)
        self._create_users_channels(current_parameters)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxx Perform the block diagonalization for each metric xxxxxxxxx
        # None Metric
        (MsPk_all_users_None,
         Wk_all_users_None,
         Ns_all_users_None) \
            = self.bd_obj_None.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        # Naive Metric
        (MsPk_all_users_naive,
         Wk_all_users_naive,
         Ns_all_users_naive) \
            = self.bd_obj_naive.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        # Fixed Metric
        (MsPk_all_users_fixed,
         Wk_all_users_fixed,
         Ns_all_users_fixed) \
            = self.bd_obj_fixed.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        # Capacity Metric
        (MsPk_all_users_capacity,
         Wk_all_users_capacity,
         Ns_all_users_capacity) \
            = self.bd_obj_capacity.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        # effective_throughput Metric
        (MsPk_all_users_effec_throughput,
         Wk_all_users_effec_throughput,
         Ns_all_users_effec_throughput) \
            = self.bd_obj_effec_throughput.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        (Ms_all_users_Whitening,
         Wk_all_users_Whitening,
         Ns_all_users_Whitening) \
            = self.bd_obj_whitening.block_diagonalize_no_waterfilling(
                self.multiuser_channel)

        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # Since we will use the same data for the external interference no
        # matter which metric is used, lets create that data here.
        external_int_data_all_metrics = (np.sqrt(self.pe) * misc.randn_c_RS(
            self.ext_data_RS, current_parameters['ext_int_rank'],
            current_parameters['NSymbs']))

        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # xxx Run the Simulation and get the results for each metric xxxxxx
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # None metric
        (ber_result_None, ser_result_None, per_result_None,
         spec_effic_result_None,
         sinr_result_None) = self.__simulate_for_one_metric(
             Ns_all_users_None, external_int_data_all_metrics,
             MsPk_all_users_None, Wk_all_users_None, 'None',
             current_parameters)

        # naive metric
        (ber_result_naive, ser_result_naive, per_result_naive,
         spec_effic_result_naive,
         sinr_result_naive) = self.__simulate_for_one_metric(
             Ns_all_users_naive, external_int_data_all_metrics,
             MsPk_all_users_naive, Wk_all_users_naive, 'naive',
             current_parameters)

        # fixed metric
        (ber_result_fixed, ser_result_fixed, per_result_fixed,
         spec_effic_result_fixed,
         sinr_result_fixed) = self.__simulate_for_one_metric(
             Ns_all_users_fixed, external_int_data_all_metrics,
             MsPk_all_users_fixed, Wk_all_users_fixed, 'fixed',
             current_parameters)

        # capacity metric
        (ber_result_capacity, ser_result_capacity, per_result_capacity,
         spec_effic_result_capacity,
         sinr_result_capacity) = self.__simulate_for_one_metric(
             Ns_all_users_capacity, external_int_data_all_metrics,
             MsPk_all_users_capacity, Wk_all_users_capacity, 'capacity',
             current_parameters)

        # effective throughput metric
        (ber_result_effec_throughput, ser_result_effec_throughput,
         per_result_effec_throughput, spec_effic_result_effec_throughput,
         sinr_result_effec_throughput) = self.__simulate_for_one_metric(
             Ns_all_users_effec_throughput, external_int_data_all_metrics,
             MsPk_all_users_effec_throughput, Wk_all_users_effec_throughput,
             'effec_throughput', current_parameters)

        # Whitening BD
        (ber_result_Whitening, ser_result_Whitening, per_result_Whitening,
         spec_effic_result_Whitening,
         sinr_result_Whitening) = self.__simulate_for_one_metric(
             Ns_all_users_Whitening, external_int_data_all_metrics,
             Ms_all_users_Whitening, Wk_all_users_Whitening, 'Whitening',
             current_parameters)

        simResults = SimulationResults()
        # Add the 'None' results
        simResults.add_result(ber_result_None)
        simResults.add_result(ser_result_None)
        simResults.add_result(per_result_None)
        simResults.add_result(spec_effic_result_None)
        simResults.add_result(sinr_result_None)

        # Add the naive results
        simResults.add_result(ber_result_naive)
        simResults.add_result(ser_result_naive)
        simResults.add_result(per_result_naive)
        simResults.add_result(spec_effic_result_naive)
        simResults.add_result(sinr_result_naive)

        # Add the fixed results
        simResults.add_result(ber_result_fixed)
        simResults.add_result(ser_result_fixed)
        simResults.add_result(per_result_fixed)
        simResults.add_result(spec_effic_result_fixed)
        simResults.add_result(sinr_result_fixed)

        # Add the capacity results
        simResults.add_result(ber_result_capacity)
        simResults.add_result(ser_result_capacity)
        simResults.add_result(per_result_capacity)
        simResults.add_result(spec_effic_result_capacity)
        simResults.add_result(sinr_result_capacity)

        # Add the effective throughput results
        simResults.add_result(ber_result_effec_throughput)
        simResults.add_result(ser_result_effec_throughput)
        simResults.add_result(per_result_effec_throughput)
        simResults.add_result(spec_effic_result_effec_throughput)
        simResults.add_result(sinr_result_effec_throughput)

        # Add the 'Whitening' results
        simResults.add_result(ber_result_Whitening)
        simResults.add_result(ser_result_Whitening)
        simResults.add_result(per_result_Whitening)
        simResults.add_result(spec_effic_result_Whitening)
        simResults.add_result(sinr_result_Whitening)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        return simResults
示例#2
0
    def _run_simulation(self, current_parameters):  # pylint: disable=R0914
        """The _run_simulation method is where the actual code to simulate
        the system is.

        The implementation of this method is required by every subclass of
        SimulationRunner.

        Parameters
        ----------
        current_parameters : SimulationParameters object
            SimulationParameters object with the parameters for the
            simulation. The self.params variable is not used directly. It
            is first unpacked (in the SimulationRunner.simulate method
            which then calls _run_simulation) for each combination.

        """
        # xxxxxxxxxx Prepare the scenario for this iteration. xxxxxxxxxxxxx
        # This will place the users at the locations specified by the
        # scenario (random locations or not), calculate the path loss and
        # generate a new random channel (in the self.multiuser_channel
        # variable).
        self._create_users_according_to_scenario(current_parameters)

        # This will calculate pathloss and generate random channels from
        # all transmitters to all receivers as well as from the external
        # interference sources to all receivers. This method must be called
        # after the _create_users_according_to_scenario method so that the
        # users are already created (we need their positions for the
        # pathloss)
        self._create_users_channels(current_parameters)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxx Perform the block diagonalization for each metric xxxxxxxxx
        # None Metric
        (MsPk_all_users_None,
         Wk_all_users_None,
         Ns_all_users_None) \
            = self.bd_obj_None.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        # Naive Metric
        (MsPk_all_users_naive,
         Wk_all_users_naive,
         Ns_all_users_naive) \
            = self.bd_obj_naive.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        # Fixed Metric
        (MsPk_all_users_fixed,
         Wk_all_users_fixed,
         Ns_all_users_fixed) \
            = self.bd_obj_fixed.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        # Capacity Metric
        (MsPk_all_users_capacity,
         Wk_all_users_capacity,
         Ns_all_users_capacity) \
            = self.bd_obj_capacity.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        # effective_throughput Metric
        (MsPk_all_users_effec_throughput,
         Wk_all_users_effec_throughput,
         Ns_all_users_effec_throughput) \
            = self.bd_obj_effec_throughput.block_diagonalize_no_waterfilling(
            self.multiuser_channel)

        (Ms_all_users_Whitening,
         Wk_all_users_Whitening,
         Ns_all_users_Whitening) \
            = self.bd_obj_whitening.block_diagonalize_no_waterfilling(
                self.multiuser_channel)

        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # Since we will use the same data for the external interference no
        # matter which metric is used, lets create that data here.
        external_int_data_all_metrics = (
            np.sqrt(self.pe) *
            misc.randn_c_RS(
                self.ext_data_RS,
                current_parameters['ext_int_rank'],
                current_parameters['NSymbs']))

        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # xxx Run the Simulation and get the results for each metric xxxxxx
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # None metric
        (ber_result_None,
         ser_result_None,
         per_result_None,
         spec_effic_result_None,
         sinr_result_None) = self.__simulate_for_one_metric(
            Ns_all_users_None,
            external_int_data_all_metrics,
            MsPk_all_users_None,
            Wk_all_users_None,
            'None',
            current_parameters)

        # naive metric
        (ber_result_naive,
         ser_result_naive,
         per_result_naive,
         spec_effic_result_naive,
         sinr_result_naive) = self.__simulate_for_one_metric(
            Ns_all_users_naive,
            external_int_data_all_metrics,
            MsPk_all_users_naive,
            Wk_all_users_naive,
            'naive',
            current_parameters)

        # fixed metric
        (ber_result_fixed,
         ser_result_fixed,
         per_result_fixed,
         spec_effic_result_fixed,
         sinr_result_fixed) = self.__simulate_for_one_metric(
            Ns_all_users_fixed,
            external_int_data_all_metrics,
            MsPk_all_users_fixed,
            Wk_all_users_fixed,
            'fixed',
            current_parameters)

        # capacity metric
        (ber_result_capacity,
         ser_result_capacity,
         per_result_capacity,
         spec_effic_result_capacity,
         sinr_result_capacity) = self.__simulate_for_one_metric(
            Ns_all_users_capacity,
            external_int_data_all_metrics,
            MsPk_all_users_capacity,
            Wk_all_users_capacity,
            'capacity',
            current_parameters)

        # effective throughput metric
        (ber_result_effec_throughput,
         ser_result_effec_throughput,
         per_result_effec_throughput,
         spec_effic_result_effec_throughput,
         sinr_result_effec_throughput) = self.__simulate_for_one_metric(
            Ns_all_users_effec_throughput,
            external_int_data_all_metrics,
            MsPk_all_users_effec_throughput,
            Wk_all_users_effec_throughput,
            'effec_throughput',
            current_parameters)

        # Whitening BD
        (ber_result_Whitening,
         ser_result_Whitening,
         per_result_Whitening,
         spec_effic_result_Whitening,
         sinr_result_Whitening) = self.__simulate_for_one_metric(
            Ns_all_users_Whitening,
            external_int_data_all_metrics,
            Ms_all_users_Whitening,
            Wk_all_users_Whitening,
            'Whitening',
            current_parameters)

        simResults = SimulationResults()
        # Add the 'None' results
        simResults.add_result(ber_result_None)
        simResults.add_result(ser_result_None)
        simResults.add_result(per_result_None)
        simResults.add_result(spec_effic_result_None)
        simResults.add_result(sinr_result_None)

        # Add the naive results
        simResults.add_result(ber_result_naive)
        simResults.add_result(ser_result_naive)
        simResults.add_result(per_result_naive)
        simResults.add_result(spec_effic_result_naive)
        simResults.add_result(sinr_result_naive)

        # Add the fixed results
        simResults.add_result(ber_result_fixed)
        simResults.add_result(ser_result_fixed)
        simResults.add_result(per_result_fixed)
        simResults.add_result(spec_effic_result_fixed)
        simResults.add_result(sinr_result_fixed)

        # Add the capacity results
        simResults.add_result(ber_result_capacity)
        simResults.add_result(ser_result_capacity)
        simResults.add_result(per_result_capacity)
        simResults.add_result(spec_effic_result_capacity)
        simResults.add_result(sinr_result_capacity)

        # Add the effective thoughput results
        simResults.add_result(ber_result_effec_throughput)
        simResults.add_result(ser_result_effec_throughput)
        simResults.add_result(per_result_effec_throughput)
        simResults.add_result(spec_effic_result_effec_throughput)
        simResults.add_result(sinr_result_effec_throughput)

        # Add the 'Whitening' results
        simResults.add_result(ber_result_Whitening)
        simResults.add_result(ser_result_Whitening)
        simResults.add_result(per_result_Whitening)
        simResults.add_result(spec_effic_result_Whitening)
        simResults.add_result(sinr_result_Whitening)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        return simResults