Beispiel #1
0
    def __init__(self, sim_param=SimParam(), no_seed=False):
        """
        Initialize the Simulation object.
        :param sim_param: is an optional SimParam object for parameter pre-configuration
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be initialized without a
        a specific seed.
        """
        self.sim_param = sim_param
        self.sim_state = SimState()
        self.system_state = SystemState(self)
        self.event_chain = EventChain()
        self.sim_result = SimResult(self)
        # TODO Task 2.4.3: Uncomment the line below
        self.counter_collection = CounterCollection(self)
        # TODO Task 3.1.2: Uncomment the line below and replace the "None"

        if no_seed:
            #if the mean = 1.0, then 1/lambda_ = 1.0 -> lambda_ = 1
            self.rng = RNG(ExponentialRNS(1.0),
                           ExponentialRNS(1. / float(self.sim_param.RHO)))
        else:
            self.rng = RNG(
                ExponentialRNS(1.0, self.sim_param.SEED_IAT),
                ExponentialRNS(1. / float(self.sim_param.RHO),
                               self.sim_param.SEED_ST))
 def reset(self):
     """
     Reset the Simulation object.
     """
     self.sim_state = SimState()
     self.system_state = SystemState(self)
     self.event_chain = EventChain()
     self.sim_result = SimResult(self)
     self.counter_collection = CounterCollection(self)
     self.rng.iat_rns.set_parameters(1.)
     self.rng.st_rns.set_parameters(1. / float(self.sim_param.RHO))
Beispiel #3
0
 def reset(self, no_seed=False):
     """
     Reset the Simulation object.
     :param no_seed: is an optional parameter. If it is set to True, the RNG should be reset without a
     a specific seed.
     """
     self.sim_state = SimState()
     self.system_state = SystemState(self)
     self.event_chain = EventChain()
     self.sim_result = SimResult(self)
     # TODO Task 2.4.3: Uncomment the line below
     self.counter_collection = CounterCollection(self)
     # TODO Task 3.1.2: Uncomment the line below and replace the "None"
     """
Beispiel #4
0
 def __init__(self, sim_param=SimParam(), no_seed=False):
     """
     Initialize the Simulation object.
     :param sim_param: is an optional SimParam object for parameter pre-configuration
     :param no_seed: is an optional parameter. If it is set to True, the RNG should be initialized without a
     a specific seed.
     """
     self.sim_param = sim_param
     self.sim_state = SimState()
     self.system_state = SystemState(self)
     self.event_chain = EventChain()
     self.sim_result = SimResult(self)
     # TODO Task 2.4.3: Uncomment the line below
     self.counter_collection = CounterCollection(self)
     # TODO Task 3.1.2: Uncomment the line below and replace the "None"
     """
Beispiel #5
0
    def __init__(self, slice_param):
        """
        Initialize the Slice Simulation object.
        :param slice_param: is an optional SliceParam object for parameter pre-configuration
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be initialized without a
        a specific seed.
        """
        self.slice_param = slice_param
        self.sim_state = SimState()
        self.slice_result = SliceResult(self)
        self.event_chain_slice_manager = EventChain()
        self.slice_manager = SliceManager(self)

        self.user_list = []
        self.server_list = []
        self.server_list_dict = {}
Beispiel #6
0
 def reset(self, no_seed=False):
     """
     Reset the Simulation object.
     :param no_seed: is an optional parameter. If it is set to True, the RNG should be reset without a
     a specific seed.
     """
     self.sim_state = SimState()
     self.system_state = SystemState(self)
     self.event_chain = EventChain()
     self.sim_result = SimResult(self)
     # TODO Task 2.4.3: Uncomment the line below
     self.counter_collection = CounterCollection(self)
     # TODO Task 3.1.2: Uncomment the line below and replace the "None"
     if no_seed:
         self.rng = RNG(ExponentialRNS(1.0), ExponentialRNS(1./float(self.sim_param.RHO)))
     else:
         self.rng = RNG(ExponentialRNS(1.0, self.sim_param.SEED_IAT), ExponentialRNS(1./float(self.sim_param.RHO),self.sim_param.SEED_ST))
Beispiel #7
0
 def insert_users(self, user_list):
     self.user_list = user_list
     self.server_list = []
     self.server_list_dict = {}
     for i in self.user_list:
         temp_server = Server(self, i, EventChain())
         self.server_list.append(temp_server)
         self.server_list_dict.update({i.user_id: self.server_list[-1]})
 def reset(self, no_seed=False):
     """
     Reset the Simulation object.
     :param no_seed: is an optional parameter. If it is set to True, the RNG should be reset without a
     a specific seed.
     """
     self.sim_state = SimState()
     self.system_state = SystemState(self)
     self.event_chain = EventChain()
     self.sim_result = SimResult(self)
     self.counter_collection = CounterCollection(self)
     if no_seed:
         self.rng = RNG(ExponentialRNS(1),
                        ExponentialRNS(1. / float(self.sim_param.RHO)))
     else:
         self.rng = RNG(
             ExponentialRNS(1, self.sim_param.SEED_IAT),
             ExponentialRNS(1. / float(self.sim_param.RHO),
                            self.sim_param.SEED_ST))
 def __init__(self, sim_param=SimParam(), no_seed=False):
     """
     Initialize the Simulation object.
     :param sim_param: is an optional SimParam object for parameter pre-configuration
     :param no_seed: is an optional parameter. If it is set to True, the RNG should be initialized without a
     a specific seed.
     """
     self.sim_param = sim_param
     self.sim_state = SimState()
     self.system_state = SystemState(self)
     self.event_chain = EventChain()
     self.sim_result = SimResult(self)
     self.counter_collection = CounterCollection(self)
     if no_seed:
         self.rng = RNG(ExponentialRNS(1),
                        ExponentialRNS(1. / float(self.sim_param.RHO)))
     else:
         self.rng = RNG(
             ExponentialRNS(1, self.sim_param.SEED_IAT),
             ExponentialRNS(1. / float(self.sim_param.RHO),
                            self.sim_param.SEED_ST))
Beispiel #10
0
class Simulation(object):
    def __init__(self, sim_param=SimParam(), no_seed=False):
        """
        Initialize the Simulation object.
        :param sim_param: is an optional SimParam object for parameter pre-configuration
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be initialized without a
        a specific seed.
        """
        self.sim_param = sim_param
        self.sim_state = SimState()
        self.system_state = SystemState(self)
        self.event_chain = EventChain()
        self.sim_result = SimResult(self)
        # TODO Task 2.4.3: Uncomment the line below
        self.counter_collection = CounterCollection(self)
        # TODO Task 3.1.2: Uncomment the line below and replace the "None"

        if no_seed:
            #if the mean = 1.0, then 1/lambda_ = 1.0 -> lambda_ = 1
            self.rng = RNG(ExponentialRNS(1.0),
                           ExponentialRNS(1. / float(self.sim_param.RHO)))
        else:
            self.rng = RNG(
                ExponentialRNS(1.0, self.sim_param.SEED_IAT),
                ExponentialRNS(1. / float(self.sim_param.RHO),
                               self.sim_param.SEED_ST))

    def reset(self, no_seed=False):
        """
        Reset the Simulation object.
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be reset without a
        a specific seed.
        """
        self.sim_state = SimState()
        self.system_state = SystemState(self)
        self.event_chain = EventChain()
        self.sim_result = SimResult(self)
        # TODO Task 2.4.3: Uncomment the line below
        self.counter_collection = CounterCollection(self)
        # TODO Task 3.1.2: Uncomment the line below and replace the "None"
        self.rng.iat_rns.set_parameters(1.)
        self.rng.st_rns.set_parameters(1. / float(self.sim_param.RHO))

    def do_simulation(self):
        """
        Do one simulation run. Initialize simulation and create first and last event.
        After that, one after another event is processed.
        :return: SimResult object
        """
        # insert first and last event
        self.event_chain.insert(CustomerArrival(self, 0))
        self.event_chain.insert(
            SimulationTermination(self, self.sim_param.SIM_TIME))

        # start simulation (run)
        while not self.sim_state.stop:

            # TODO Task 1.4.1: Your code goes here
            """
            Hint:

            You can use and adapt the following lines in your realization
            e = self.event_chain.remove_oldest_event()
            e.process()
            """
            e = self.event_chain.remove_oldest_event()
            if e:
                if self.sim_state.now <= e.timestamp:
                    self.sim_state.now = e.timestamp
                    self.counter_collection.count_queue()
                    e.process()

            else:
                self.sim_state.stop = True

            #pass
            # TODO Task 2.4.3: Your code goes here somewhere
        # gather results for sim_result object
        self.sim_result.gather_results()
        return self.sim_result

    def do_simulation_n_limit(self, n, first_batch):
        """
        Call this function, if the simulation should stop after a given number of packets
        Do one simulation run. Initialize simulation and create first event.
        After that, one after another event is processed.
        :param n: number of customers, that are processed before the simulation stops
        :return: SimResult object
        """
        # insert first event
        if not first_batch:  # if this is a first batch
            self.event_chain.insert(CustomerArrival(self, 0))

        # start simulation (run)
        while not self.sim_state.stop:

            # TODO Task 4.3.2: Your code goes here
            # TODO Task 5.2.2: Your code goes here
            e = self.event_chain.remove_oldest_event()
            if e:
                if self.sim_state.now <= e.timestamp:
                    self.sim_state.now = e.timestamp
                    self.counter_collection.count_queue()
                    e.process()
                    if (self.sim_state.num_packets) >= n:
                        self.sim_state.stop = True
            else:
                self.sim_state.stop = True
            #pass

        # gather results for sim_result object
        self.sim_result.gather_results()
        return self.sim_result
class Simulation(object):
    def __init__(self, sim_param=SimParam(), no_seed=False):
        """
        Initialize the Simulation object.
        :param sim_param: is an optional SimParam object for parameter pre-configuration
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be initialized without a
        a specific seed.
        """
        self.sim_param = sim_param
        self.sim_state = SimState()
        self.system_state = SystemState(self)
        self.event_chain = EventChain()
        self.sim_result = SimResult(self)
        self.counter_collection = CounterCollection(self)
        if no_seed:
            self.rng = RNG(ExponentialRNS(1),
                           ExponentialRNS(1. / float(self.sim_param.RHO)))
        else:
            self.rng = RNG(
                ExponentialRNS(1, self.sim_param.SEED_IAT),
                ExponentialRNS(1. / float(self.sim_param.RHO),
                               self.sim_param.SEED_ST))
        self.number_served_packets = 0

    def reset(self, no_seed=False):
        """
        Reset the Simulation object.
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be reset without a
        a specific seed.
        """
        self.sim_state = SimState()
        self.system_state = SystemState(self)
        self.event_chain = EventChain()
        self.sim_result = SimResult(self)
        self.counter_collection = CounterCollection(self)
        if no_seed:
            self.rng = RNG(ExponentialRNS(1),
                           ExponentialRNS(1. / float(self.sim_param.RHO)))
        else:
            self.rng = RNG(
                ExponentialRNS(1, self.sim_param.SEED_IAT),
                ExponentialRNS(1. / float(self.sim_param.RHO),
                               self.sim_param.SEED_ST))

    def do_simulation(self):
        """
        Do one simulation run. Initialize simulation and create first and last event.
        After that, one after another event is processed.
        :return: SimResult object
        """
        # insert first and last event
        self.event_chain.insert(CustomerArrival(self, 0))
        self.event_chain.insert(
            SimulationTermination(self, self.sim_param.SIM_TIME))

        # start simulation (run)
        while not self.sim_state.stop:

            # get next simevent from events
            e = self.event_chain.remove_oldest_event()
            if e:
                # if event exists and timestamps are ok, process the event
                if self.sim_state.now <= e.timestamp:
                    self.sim_state.now = e.timestamp
                    self.counter_collection.count_queue()
                    e.process()
                else:
                    print "NOW: " + str(
                        self.sim_state.now) + ", EVENT TIMESTAMP: " + str(
                            e.timestamp)
                    raise RuntimeError(
                        "ERROR: TIMESTAMP OF EVENT IS SMALLER THAN CURRENT TIME."
                    )

            else:
                print "Event chain is empty. Abort"
                self.sim_state.stop = True

        # gather results for sim_result object
        self.sim_result.gather_results()
        return self.sim_result

    def do_simulation_n_limit(self, n):
        """
        Call this function, if the simulation should stop after a given number of packets
        Do one simulation run. Initialize simulation and create first event.
        After that, one after another event is processed.
        :param n: number of customers, that are processed before the simulation stops
        :return: SimResult object
        """
        # insert first event
        self.event_chain.insert(CustomerArrival(self, 0))

        # start simulation (run)
        while (not self.sim_state.stop) and (self.number_served_packets <= n):

            # TODO Task 4.3.2: Your code goes here
            # TODO Task 5.2.2: Your code goes here
            # get next simevent from events
            e = self.event_chain.remove_oldest_event()
            if e:
                # if event exists and timestamps are ok, process the event
                if self.sim_state.now <= e.timestamp:
                    self.sim_state.now = e.timestamp
                    self.counter_collection.count_queue()
                    e.process()
                else:
                    print "NOW: " + str(
                        self.sim_state.now) + ", EVENT TIMESTAMP: " + str(
                            e.timestamp)
                    raise RuntimeError(
                        "ERROR: TIMESTAMP OF EVENT IS SMALLER THAN CURRENT TIME."
                    )

            else:
                print "Event chain is empty. Abort"
                self.sim_state.stop = True

        # gather results for sim_result object
        self.sim_result.gather_results()
        return self.sim_result
class Simulation(object):
    def __init__(self, sim_param=SimParam(), no_seed=False):
        """
        Initialize the Simulation object.
        :param sim_param: is an optional SimParam object for parameter pre-configuration
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be initialized without a
        a specific seed.
        """
        self.sim_param = sim_param
        self.sim_state = SimState()
        self.system_state = SystemState(self)
        self.event_chain = EventChain()
        self.sim_result = SimResult(self)
        # TODO Task 2.4.3: Uncomment the line below
        # self.counter_collection = CounterCollection()
        # TODO Task 3.1.2: Uncomment the line below and replace the "None"
        """
        if no_seed:
            self.rng = RNG(None, None)
        else:
            self.rng = RNG(None, None)
        """

    def reset(self, no_seed=False):
        """
        Reset the Simulation object.
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be reset without a
        a specific seed.
        """
        self.sim_state = SimState()
        self.system_state = SystemState(self)
        self.event_chain = EventChain()
        self.sim_result = SimResult(self)
        # TODO Task 2.4.3: Uncomment the line below
        # self.counter_collection = CounterCollection()
        # TODO Task 3.1.2: Uncomment the line below and replace the "None"
        """
        if no_seed:
            self.rng = RNG(None, None)
        else:
            self.rng = RNG(None, None)
        """

    def do_simulation(self):
        """
        Do one simulation run. Initialize simulation and create first and last event.
        After that, one after another event is processed.
        :return: SimResult object
        """
        # insert first and last event
        self.event_chain.insert(CustomerArrival(self, 0))
        self.event_chain.insert(
            SimulationTermination(self, self.sim_param.SIM_TIME))

        # start simulation (run)
        while not self.sim_state.stop:
            # TODO Task 1.4.1: Your code goes here
            """
            Hint:

            You can use and adapt the following lines in your realization
            e = self.event_chain.remove_oldest_event()
            e.process()
            """
            pass
            # TODO Task 2.4.3: Your code goes here somewhere

        # gather results for sim_result object
        self.sim_result.gather_results()
        return self.sim_result

    def do_simulation_n_limit(self, n):
        """
        Call this function, if the simulation should stop after a given number of packets
        Do one simulation run. Initialize simulation and create first event.
        After that, one after another event is processed.
        :param n: number of customers, that are processed before the simulation stops
        :return: SimResult object
        """
        # insert first event
        self.event_chain.insert(CustomerArrival(self, 0))

        # start simulation (run)
        while not self.sim_state.stop:
            # TODO Task 4.3.2: Your code goes here
            # TODO Task 5.2.2: Your code goes here
            pass

        # gather results for sim_result object
        self.sim_result.gather_results()
        return self.sim_result
Beispiel #13
0
    def test_event_chain(self):
        """
        Test module EventChain. Add and remove SimEvents and check the correct order.
        """
        # priorities: SC = 0, CA = 1, ST = 2
        e = EventChain()
        e.insert(CustomerArrival(None, 10))
        e.insert(SimulationTermination(None, 10))
        e.insert(ServiceCompletion(None, 10))
        e.insert(CustomerArrival(None, 5))
        e.insert(ServiceCompletion(None, 2))
        results = [[2, 0], [5, 1], [10, 0], [10, 1], [10, 2]]

        for r in results:
            ev = e.remove_oldest_event()
            self.assertEqual(
                [ev.timestamp, ev.priority],
                r,
                msg=
                "Error in EventChain or SimEvent. Events are sorted or returned in the wrong order."
            )

        self.assertEqual(
            len(e.event_list),
            0,
            msg="Error in EventChain or SimEvent. EventChain should be empty.")
Beispiel #14
0
class Simulation(object):
    def __init__(self, sim_param=SimParam(), no_seed=False):
        """
        Initialize the Simulation object.
        :param sim_param: is an optional SimParam object for parameter pre-configuration
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be initialized without a
        a specific seed.
        """
        self.sim_param = sim_param
        self.sim_state = SimState()
        self.system_state = SystemState(self)
        self.event_chain = EventChain()
        self.sim_result = SimResult(self)
        # TODO Task 2.4.3: Uncomment the line below
        self.counter_collection = CounterCollection(self)
        # TODO Task 3.1.2: Uncomment the line below and replace the "None"
        rns1 = ExponentialRNS(1.0)
        rns2 = ExponentialRNS(1.0 / self.sim_param.RHO)
        rns1_seed = ExponentialRNS(1.0, self.sim_param.SEED_IAT)
        rns2_seed = ExponentialRNS(1.0 / self.sim_param.RHO,
                                   self.sim_param.SEED_ST)
        if no_seed:
            self.rng = RNG(rns1, rns2)
        else:
            self.rng = RNG(rns1_seed, rns2_seed)

    def reset(self, no_seed=False):
        """
        Reset the Simulation object.
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be reset without a
        a specific seed.
        """
        self.sim_state = SimState()
        self.system_state = SystemState(self)
        self.event_chain = EventChain()
        self.sim_result = SimResult(self)
        # TODO Task 2.4.3: Uncomment the line below
        self.counter_collection = CounterCollection(self)
        # TODO Task 3.1.2: Uncomment the line below and replace the "None"
        rns1 = ExponentialRNS(1.0)
        rns2 = ExponentialRNS(1.0 / self.sim_param.RHO)
        rns1_seed = ExponentialRNS(1.0, self.sim_param.SEED_IAT)
        rns2_seed = ExponentialRNS(1.0 / self.sim_param.RHO,
                                   self.sim_param.SEED_ST)
        if no_seed:
            self.rng = RNG(rns1, rns2)
        else:
            self.rng = RNG(rns1_seed, rns2_seed)

    def do_simulation(self):
        """
        Do one simulation run. Initialize simulation and create first and last event.
        After that, one after another event is processed.
        :return: SimResult object
        """
        # insert first and last event
        self.event_chain.insert(CustomerArrival(self, 0))
        self.event_chain.insert(
            SimulationTermination(self, self.sim_param.SIM_TIME))

        # start simulation (run)
        while not self.sim_state.stop:

            # TODO Task 1.4.1: Your code goes here
            """
            Hint:

            You can use and adapt the following lines in your realization
            e = self.event_chain.remove_oldest_event()
            e.process()
            """
            e = self.event_chain.remove_oldest_event()
            if e:
                # if event exists and timestamps are ok, process the event
                if self.sim_state.now <= e.timestamp:
                    self.sim_state.now = e.timestamp
                    self.counter_collection.count_queue()
                    e.process()
                else:
                    print "NOW: " + str(
                        self.sim_state.now) + ", EVENT TIMESTAMP: " + str(
                            e.timestamp)
                    raise RuntimeError(
                        "ERROR: TIMESTAMP OF EVENT IS SMALLER THAN CURRENT TIME."
                    )

            else:
                print "Event chain is empty. Abort"
                self.sim_state.stop = True
            # TODO Task 2.4.3: Your code goes here somewhere
            #self.counter_collection.count_queue()

        # gather results for sim_result object
        self.sim_result.gather_results()
        return self.sim_result

    def do_simulation_n_limit(self, n):
        """
        Call this function, if the simulation should stop after a given number of packets
        Do one simulation run. Initialize simulation and create first event.
        After that, one after another event is processed.
        :param n: number of customers, that are processed before the simulation stops
        :return: SimResult object
        """
        # insert first event
        self.event_chain.insert(CustomerArrival(self, 0))

        # start simulation (run)
        while not self.sim_state.stop:

            # TODO Task 4.3.2: Your code goes here
            # TODO Task 5.2.2: Your code goes here
            pass

        # gather results for sim_result object
        self.sim_result.gather_results()
        return self.sim_result
Beispiel #15
0
class SliceSimulation(object):

    def __init__(self, slice_param):
        """
        Initialize the Slice Simulation object.
        :param slice_param: is an optional SliceParam object for parameter pre-configuration
        :param no_seed: is an optional parameter. If it is set to True, the RNG should be initialized without a
        a specific seed.
        """
        self.slice_param = slice_param
        self.sim_state = SimState()
        self.slice_result = SliceResult(self)
        self.event_chain_slice_manager = EventChain()
        self.slice_manager = SliceManager(self)

        self.user_list = []
        self.server_list = []
        self.server_list_dict = {}

    def insert_users(self, user_list):
        self.user_list = user_list
        self.server_list = []
        self.server_list_dict = {}
        for i in self.user_list:
            temp_server = Server(self, i, EventChain())
            self.server_list.append(temp_server)
            self.server_list_dict.update({i.user_id: self.server_list[-1]})

    def reset(self):
        """
        Reset the Simulation object.
        """
        self.sim_state = SimState()
        self.slice_result = SliceResult(self)

    def remove_upcoming_events(self):
        """
        Check the timestamps of oldest events from each event chain of users and SliceManager
        Find the smallest timestamp and remove only the events with this timestamp
        Return current_events[]
        """
        current_events = []
        current_events_dict = {}
        t_arr = []
        for i in self.server_list:      # t_arr includes timestamps of oldest events in all event_chains
            #t_arr.append(i.event_chain.event_list[0].timestamp)
            if len(i.event_chain.event_list)!=0:
                t_arr.append(float(i.event_chain.copy_oldest_event().timestamp))
            else:
                t_arr.append(np.inf)
        #t_arr.append(self.event_chain_slice_manager.event_list[0].timestamp)  # last element of t_arr belongs event_chain_slice_manager
        t_arr.append(float(self.event_chain_slice_manager.copy_oldest_event().timestamp))
        t_arr = np.array(t_arr)
        current_events_idx = (t_arr == t_arr.min())

        for i in range(len(current_events_idx) - 1):
            if current_events_idx[i]:
                current_events.append(self.server_list[i].event_chain.remove_oldest_event())  # remove oldest elements from event chains
                current_events_dict.update({current_events[-1]: self.server_list[i]})

        if current_events_idx[-1]:
            current_events.append(self.event_chain_slice_manager.remove_oldest_event())     # remove oldest element from event_chain_slice_manager
            current_events_dict.update({current_events[-1]: self.event_chain_slice_manager})

        return current_events, current_events_dict

    def prep_next_round(self, RB_mapping):
        """
        Prepares the Simulation object for the next round.
        """
        self.sim_state.prep_next_round()
        for i in self.server_list:
            i.server_state.prep_next_round()
        self.slice_param.RB_mapping = RB_mapping
        #self.slice_result = SliceResult(self)  # server results are not reset due to counters
        # self.rng.iat_rns.set_parameters(1.)
        # self.rng.st_rns.set_parameters(1. / float(self.slice_param.RHO))

    def simulate_one_round(self):  
        """
        Do one simulation run. Initialize simulation and create first and last event.
        After that, one after another event is processed.
        :return: SliceResult object
        """
        self.sim_state.t_round_start = self.sim_state.now

        # insert first and last event
        self.event_chain_slice_manager.insert(RoundTermination(self, self.sim_state.now + self.slice_param.T_C))

        # insert periodic RB_Allocation events
        t_arr = np.arange(self.sim_state.now, self.sim_state.now + self.slice_param.T_C, self.slice_param.T_SM)
        for t in t_arr:
            self.event_chain_slice_manager.insert(RB_Allocation(self, t))

        # insert packet arrivals from traffic lists of users
        for u in self.user_list:
            tmp = u.traffic_list_dict[self.slice_param.SLICE_ID]
            tmp_traffic_list = filter(lambda item: (
                    self.sim_state.now <= item.timestamp < self.sim_state.now + self.slice_param.T_C),
                            tmp)
            tmp_server = self.server_list_dict[u.user_id]
            for pa in tmp_traffic_list:
                #t_drop = pa.timestamp + self.slice_param.DELAY_REQ
                #pd = PacketDrop(self, t_drop)
                tmp_server.event_chain.insert(pa)
                #tmp_server.event_chain.insert(pd)

        # start simulation (run)
        while not self.sim_state.stop:
            # remove upcoming events
            [current_events, current_events_dict] = self.remove_upcoming_events()
            if len(current_events) != len(current_events_dict):
                raise RuntimeError("ERROR: Event to server mapping error.")

            for e in current_events:
                if e:
                    # if event exists and timestamps are ok, process the event
                    if self.sim_state.now <= e.timestamp:
                        self.sim_state.now = e.timestamp

                        if not (e.priority == 4 or e.priority == 5):    # dont count for for slice manager events
                            current_events_dict[e].counter_collection.count_queue()
                        e.process(current_events_dict[e])
                        #if e.timestamp % 1000 == 0:
                        #    print("TIMESTAMP: " + str(e.timestamp) + ",PRIORITY " + str(e.priority))
                    else:
                        print("NOW: " + str(self.sim_state.now) + ", EVENT TIMESTAMP: " + str(e.timestamp) + " " + str(e.priority))
                        raise RuntimeError("ERROR: TIMESTAMP OF EVENT IS SMALLER THAN CURRENT TIME.")

                else:
                    print("Event chain is empty. Abort")
                    self.sim_state.stop = True

        #  gather results for slice_result object and all servers results
        self.server_results = []
        self.server_results_dict = {}
        for i in self.user_list:
            tmp_server = self.server_list_dict[i.user_id]
            self.server_results.append(tmp_server.server_result.gather_results)
            self.server_results_dict.update({i.user_id: self.server_results[-1]})

        self.slice_result.gather_results(self.server_results)
        #return self.slice_result

    def simulate_one_slot(self):
        """

        """
        # insert RB_Allocation event
        self.event_chain_slice_manager.insert(RB_Allocation(self, self.sim_state.now))

        # insert packet arrivals from traffic lists of users
        for i in self.user_list:
            tmp = i.traffic_list_dict[self.slice_param.SLICE_ID]
            tmp_traffic_list = filter(lambda item: (
                    self.sim_state.now <= item.timestamp < self.sim_state.now + self.slice_param.T_SM),
                            tmp)
            tmp_server = self.server_list_dict[i.user_id]
            for j in tmp_traffic_list:
                tmp_server.event_chain.insert(j)

        # start simulation (run)
        while not self.sim_state.stop:
            # remove upcoming events
            [current_events, current_events_dict] = self.remove_upcoming_events()
            if len(current_events) != len(current_events_dict):
                raise RuntimeError("ERROR: Event to server mapping error.")

            for e in current_events:
                if e.timestamp == 80:
                    msa = 3
                if e.priority == 0:
                    msa = 3
                if e:
                    # if event exists and timestamps are ok, process the event
                    if self.sim_state.now <= e.timestamp:
                        self.sim_state.now = e.timestamp

                        if not (e.priority == 4 or e.priority == 5):    # dont count for for slice manager events
                            current_events_dict[e].counter_collection.count_queue()
                        e.process(current_events_dict[e])
                        if e.timestamp % 1000 == 0:
                            print("TIMESTAMP: " + str(e.timestamp) + ",PRIORITY " + str(e.priority))
                    else:
                        print("NOW: " + str(self.sim_state.now) + ", EVENT TIMESTAMP: " + str(e.timestamp) + " " + str(e.priority))
                        raise RuntimeError("ERROR: TIMESTAMP OF EVENT IS SMALLER THAN CURRENT TIME.")

                else:
                    print("Event chain is empty. Abort")
                    self.sim_state.stop = True

        #  gather results for slice_result object and all servers results
        self.server_results = []
        self.server_results_dict = {}
        for i in self.user_list:
            tmp_server = self.server_list_dict[i.user_id]
            self.server_results.append(tmp_server.server_result.gather_results)
            self.server_results_dict.update({i.user_id: self.server_results[-1]})

        self.slice_result.gather_results(self.server_results)
        return self.slice_result