def make_decision(self, queue, decision_counter): if len(queue) <= 12: packets = [p.header for p in queue] else: packets = [p.header for p in queue[0:12]] decision = Decision(decision_counter, packets) return decision
def make_decision(self, queue_len, decision_counter): if queue_len <= 12: decision = queue_len else: decision = 12 print("Make decision No.{} for {} pilots".format( decision_counter, decision)) return Decision(decision_counter, decision)
def make_decision(self, queue, decision_counter): queue.sort(key=lambda x: x.deadline) if len(queue) <= 12: packets = [p.header for p in queue] else: packets = [p.header for p in queue[0:12]] decision = Decision(decision_counter, packets) return decision
def make_decision(self, queue, decision_counter): # self.decision_dict = dict.fromkeys(range(self.ue_max_index + 1),0) self.decision_list = self.create_active_ue_list(queue) # for k in self.decision_dict.keys(): # if self.decision_dict[k] > 0: # print("Node: {}, Pilots {}".format(k, self.decision_dict[k])) # input("Decision Made") decision = Decision(decision_counter, self.decision_list) return decision
def make_decision(self, queue, decision_counter): queue_to_consider = self.queue_saturate(queue) self.decision_list = self.create_active_ue_list(queue_to_consider) # for k in self.decision_dict.keys(): # if self.decision_dict[k] > 0: # print("Node: {}, Pilots {}".format(k, self.decision_dict[k])) # input("Decision Made") decision = Decision(decision_counter, self.decision_list) return decision
def test_assign_pilots_empty_queue(scheduler_edf, channel, nbr_nodes): queue = channel.get_queue() new_queue = [] queue_length = len(queue) nbr_packets = 0 nodes = scheduler_edf.create_active_ue_list(queue) selected_nodes = np.random.choice(nodes, size=nbr_nodes, replace=False) channel.queue = [] decision = Decision(1, selected_nodes) waste, served = scheduler_edf.assign_pilots(decision, channel) assert waste == nbr_nodes assert served == 0
def test_assign_pilots_has_waste(scheduler_edf, channel, nbr_nodes): queue = channel.get_queue() new_queue = [] queue_length = len(queue) nbr_packets = 1 nodes = scheduler_edf.create_active_ue_list(queue) selected_nodes = np.random.choice(nodes, size=nbr_nodes, replace=False) for node in selected_nodes: new_queue += list(np.random.choice([p for p in queue if p.header.node_id == node], size=nbr_packets)) channel.queue = new_queue decision = Decision(1, selected_nodes) waste, served = scheduler_edf.assign_pilots(decision, channel) assert waste == (scheduler_edf.beta - 1)/scheduler_edf.beta * nbr_nodes assert served == nbr_nodes assert len(channel.get_queue()) == 0
def test_assign_pilots_no_waste(scheduler_edf, channel, nbr_nodes): queue = channel.get_queue() queue_length = len(queue) nbr_packets = 2 nodes = scheduler_edf.create_active_ue_list(queue) selected_nodes = np.random.choice(nodes, size=nbr_nodes, replace=False) for node in selected_nodes: packets_from_ue = [p for p in queue if p.header.node_id == node] if len(packets_from_ue) < nbr_packets: for p in packets_from_ue: queue.remove(p) selected_nodes.remove(node) decision = Decision(1, selected_nodes) waste, served = scheduler_edf.assign_pilots(decision, channel) assert len(channel.get_queue()) == queue_length - served assert waste == 0
def init_decision(self): decision_id = 0 decision_list = self.ue_register decision = Decision(decision_id, decision_list) return decision
def init_decision(self): decision_id = 0 decision_packets = 12 decision = Decision(decision_id, decision_packets) return decision
def make_decision(self, queue_len, decision_counter): if queue_len <= 12: decision = queue_len else: decision = 12 return Decision(decision_counter, decision)
def update_init_decision(self): decision_id = 0 self.init_counter += 1 decision = Decision( 0, [PacketHeader(i, self.init_counter) for i in range(12)]) return decision