Пример #1
0
    def __init__(self,
                 IaSolverClass,
                 default_config_file,
                 spec,
                 read_command_line_args=True):
        SimulationRunner.__init__(self, default_config_file, spec,
                                  read_command_line_args)

        # Set the max_bit_errors and rep_max attributes
        self.max_bit_errors = self.params['max_bit_errors']
        self.rep_max = self.params['rep_max']

        # Create the modulator object
        M = self.params['M']
        modulator_options = {
            'PSK': fundamental.PSK,
            'QPSK': fundamental.QPSK,
            'QAM': fundamental.QAM,
            'BPSK': fundamental.BPSK
        }
        self.modulator = modulator_options[self.params['modulator']](M)

        # Create the channel object
        self.multiUserChannel = pyphysim.channels.multiuser.MultiUserChannelMatrix(
        )

        # Create the IA Solver object
        self.ia_solver = IaSolverClass(self.multiUserChannel)

        # For the ClosedFormIASolver class we manually add a
        # _runned_iterations member variable with value of 0. This member
        # variable is not used and does not exist in the ClosedFormIASolver
        # solver. However, since we will store this variable as a result
        # for each algorithm we manually added to the ClosedFormIASolver
        # object just to make the code in _run_simulation equal for all
        # solvers.
        if isinstance(self.ia_solver, algorithms.ClosedFormIASolver):
            self.ia_solver.runned_iterations = 0.0

        # This can be either 'screen' or 'file'. If it is 'file' then the
        # progressbar will write the progress to a file with appropriated
        # filename
        self.progress_output_type = 'screen'

        # xxxxxxxxxx Set the progressbar message xxxxxxxxxxxxxxxxxxxxxxxxxx
        self.progressbar_message = "SNR: {{SNR}}".format(self.modulator.name)
Пример #2
0
    def __init__(self, default_config_file, read_command_line_args=True):
        """
        Constructor of the IASimulationRunner class.
        """

        spec = """[Grid]
        cell_radius=float(min=0.01, default=1.0)
        num_cells=integer(min=3,default=3)
        num_clusters=integer(min=1,default=1)
        [Scenario]
        NSymbs=integer(min=10, max=1000000, default=200)
        SNR=real_numpy_array(min=-50, max=100, default=0:5:31)
        M=integer(min=4, max=512, default=4)
        modulator=option('QPSK', 'PSK', 'QAM', 'BPSK', default="PSK")
        Nr=integer_scalar_or_integer_numpy_array_check(min=2,default=3)
        Nt=integer_scalar_or_integer_numpy_array_check(min=2,default=3)
        Ns=integer_scalar_or_integer_numpy_array_check(min=1,default=3)
        N0=float(default=-116.4)
        scenario=string_list(default=list('Random', 'NoPathLoss'))
        [IA Algorithm]
        max_iterations=integer(min=1, default=120)
        initialize_with=string_list(default=list('random'))
        stream_sel_method=string_list(default=list('greedy', 'brute'))
        [General]
        rep_max=integer(min=1, default=2000)
        max_bit_errors=integer(min=1, default=3000)
        unpacked_parameters=string_list(default=list('SNR','stream_sel_method','scenario','initialize_with'))
        """.split(
            "\n"
        )

        SimulationRunner.__init__(self, default_config_file, spec, read_command_line_args)

        # xxxxxxxxxx General Parameters xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # Maximum number of repetitions for each unpacked parameters set
        self.rep_max = self.params["rep_max"]

        # # max_bit_errors is used in the _keep_going method to stop the
        # # simulation earlier if possible. We stop the simulation if the
        # # accumulated number of bit errors becomes greater then 5% of the
        # # total number of simulated bits
        # self.max_bit_errors = self.params['max_bit_errors']
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxx Channel and Path Loss Parameters xxxxxxxxxxxxxxxxxxxxx
        # Create the channel object
        self.multiUserChannel = multiuser.MultiUserChannelMatrix()

        # Create the Path loss object
        self.path_loss_obj = pathloss.PathLoss3GPP1()
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxx RandomState objects seeds xxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # This is only useful to reproduce a simulation for debugging
        # purposed
        self.channel_seed = None  # 22522
        self.noise_seed = None  # 4445
        self.data_gen_seed = np.random.randint(10000)  # 2105
        #
        self.multiUserChannel.set_channel_seed(self.channel_seed)
        self.multiUserChannel.set_noise_seed(self.noise_seed)
        self.data_RS = np.random.RandomState(self.data_gen_seed)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxx Create the modulator object xxxxxxxxxxxxxxxxxxxxxxxxxx
        M = self.params["M"]
        modulator_options = {
            "PSK": fundamental.PSK,
            "QPSK": fundamental.QPSK,
            "QAM": fundamental.QAM,
            "BPSK": fundamental.BPSK,
        }
        self.modulator = modulator_options[self.params["modulator"]](M)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxx Progress Bar xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # This can be either 'screen' or 'file'. If it is 'file' then the
        # progressbar will write the progress to a file with appropriated
        # filename
        self.progress_output_type = "screen"

        # Set the progressbar message
        self.progressbar_message = "SNR: {{SNR}}".format(self.modulator.name)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # xxxxxxxxxx Dependent parameters (don't change these) xxxxxxxxxxxx
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # Cell Grid
        self.cell_grid = cell.Grid()
        self.cell_grid.create_clusters(
            self.params["num_clusters"], self.params["num_cells"], self.params["cell_radius"]
        )

        # Note that the Noise variance will be set in the
        # _on_simulate_current_params_start method. In the NoPathLoss
        # scenario it will be set as 1.0 regardless of the value of
        # params['N0'] to avoid problens in the IA algorithms. In the other
        # scenarios it will be set to self.params['N0'].
        #
        # In any case the transmit power will be calculated accordingly in
        # the _run_simulation method and the simulation results will still
        # be correct.
        self.noise_var = None

        # Linear path loss from cell center to cell border.
        self._path_loss_border = self.path_loss_obj.calc_path_loss(self.params["cell_radius"])
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # TODO: Move code below to the _on_simulate_current_params_start
        # method
        # xxxxxxxxxx Interference Alignment objects xxxxxxxxxxxxxxxxxxxxxxx
        # Create the basic IA Solver object
        self.ia_solver = algorithms.MMSEIASolver(self.multiUserChannel)
        # This will be created in the _on_simulate_current_params_start
        # method. The class of self.ia_top_object will depend on the value
        # of the 'stream_sel_method' parameter
        self.ia_top_object = None
Пример #3
0
    def __init__(self, default_config_file, read_command_line_args=True):
        """
        Constructor of the IASimulationRunner class.
        """

        spec = """[Grid]
        cell_radius=float(min=0.01, default=1.0)
        num_cells=integer(min=3,default=3)
        num_clusters=integer(min=1,default=1)
        [Scenario]
        NSymbs=integer(min=10, max=1000000, default=200)
        SNR=real_numpy_array(min=-50, max=100, default=0:5:31)
        M=integer(min=4, max=512, default=4)
        modulator=option('QPSK', 'PSK', 'QAM', 'BPSK', default="PSK")
        Nr=integer_scalar_or_integer_numpy_array_check(min=2,default=3)
        Nt=integer_scalar_or_integer_numpy_array_check(min=2,default=3)
        Ns=integer_scalar_or_integer_numpy_array_check(min=1,default=3)
        N0=float(default=-116.4)
        scenario=string_list(default=list('Random', 'NoPathLoss'))
        [IA Algorithm]
        max_iterations=integer(min=1, default=120)
        initialize_with=string_list(default=list('random'))
        stream_sel_method=string_list(default=list('greedy', 'brute'))
        [General]
        rep_max=integer(min=1, default=2000)
        max_bit_errors=integer(min=1, default=3000)
        unpacked_parameters=string_list(default=list('SNR','stream_sel_method','scenario','initialize_with'))
        """.split("\n")

        SimulationRunner.__init__(self, default_config_file, spec,
                                  read_command_line_args)

        # xxxxxxxxxx General Parameters xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # Maximum number of repetitions for each unpacked parameters set
        self.rep_max = self.params['rep_max']

        # # max_bit_errors is used in the _keep_going method to stop the
        # # simulation earlier if possible. We stop the simulation if the
        # # accumulated number of bit errors becomes greater then 5% of the
        # # total number of simulated bits
        # self.max_bit_errors = self.params['max_bit_errors']
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxx Channel and Path Loss Parameters xxxxxxxxxxxxxxxxxxxxx
        # Create the channel object
        self.multiUserChannel = multiuser.MultiUserChannelMatrix()

        # Create the Path loss object
        self.path_loss_obj = pathloss.PathLoss3GPP1()
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxx RandomState objects seeds xxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # This is only useful to reproduce a simulation for debugging
        # purposed
        self.channel_seed = None  # 22522
        self.noise_seed = None  # 4445
        self.data_gen_seed = np.random.randint(10000)  # 2105
        #
        self.multiUserChannel.set_channel_seed(self.channel_seed)
        self.multiUserChannel.set_noise_seed(self.noise_seed)
        self.data_RS = np.random.RandomState(self.data_gen_seed)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxx Create the modulator object xxxxxxxxxxxxxxxxxxxxxxxxxx
        M = self.params['M']
        modulator_options = {
            'PSK': fundamental.PSK,
            'QPSK': fundamental.QPSK,
            'QAM': fundamental.QAM,
            'BPSK': fundamental.BPSK
        }
        self.modulator = modulator_options[self.params['modulator']](M)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxx Progress Bar xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # This can be either 'screen' or 'file'. If it is 'file' then the
        # progressbar will write the progress to a file with appropriated
        # filename
        self.progress_output_type = 'screen'

        # Set the progressbar message
        self.progressbar_message = "SNR: {{SNR}}".format(self.modulator.name)
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # xxxxxxxxxx Dependent parameters (don't change these) xxxxxxxxxxxx
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        # Cell Grid
        self.cell_grid = cell.Grid()
        self.cell_grid.create_clusters(self.params['num_clusters'],
                                       self.params['num_cells'],
                                       self.params['cell_radius'])

        # Note that the Noise variance will be set in the
        # _on_simulate_current_params_start method. In the NoPathLoss
        # scenario it will be set as 1.0 regardless of the value of
        # params['N0'] to avoid problems in the IA algorithms. In the other
        # scenarios it will be set to self.params['N0'].
        #
        # In any case the transmit power will be calculated accordingly in
        # the _run_simulation method and the simulation results will still
        # be correct.
        self.noise_var = None

        # Linear path loss from cell center to cell border.
        self._path_loss_border = self.path_loss_obj.calc_path_loss(
            self.params['cell_radius'])
        # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        # TODO: Move code below to the _on_simulate_current_params_start
        # method
        # xxxxxxxxxx Interference Alignment objects xxxxxxxxxxxxxxxxxxxxxxx
        # Create the basic IA Solver object
        self.ia_solver = algorithms.MMSEIASolver(self.multiUserChannel)
        # This will be created in the _on_simulate_current_params_start
        # method. The class of self.ia_top_object will depend on the value
        # of the 'stream_sel_method' parameter
        self.ia_top_object = None