Skip to content
Snippets Groups Projects
Commit 75274871 authored by Mancini, Kevin's avatar Mancini, Kevin
Browse files

Merge branch 'adam-feature' into 'master'

small changes

See merge request !15
parents 63122fe9 1643d1f4
1 merge request!15small changes
......@@ -17,7 +17,6 @@ class UserSolution(Solution):
self.used_bw_in = 0
self.used_bw_out = 0
self.used_size = 0
self.failed_requests = 0
self.nodes_info_dict = {}
for node_info in nodes_info:
self.nodes_info_dict.update({node_info[4]:node_info})
......@@ -54,8 +53,6 @@ class UserSolution(Solution):
self.used_bw_in = 0
self.used_bw_out = 0
local_failures = self.failed_requests
for i,request in enumerate(request_list):
if self.size >= request.data_size + self.used_size:
self.used_size += request.data_size
......@@ -64,8 +61,6 @@ class UserSolution(Solution):
for j in range(request.data_size):
new_msg = Message(-1, self.node_id, request.target_node_id, request.request_id, j, request.begin_time)
self.messages[request.begin_time][(request.request_id, j)] = new_msg
else:
self.failed_requests += 1
def ask_round_solution(self, neighbor_info_list: List[SwitchStatsInfo]) -> List[Message]:
sending_messages: List[Message] = []
......@@ -81,7 +76,13 @@ class UserSolution(Solution):
neighbor_dict.update({neighbor_info.info[6]:neighbor_info.info})
for begin_time in range(self.max_time_seen + 2):
for message in list(self.messages[begin_time].values()):
all_messages = list(self.messages[begin_time].values())
# sort the messages starting with the ones with the fewest requests
request_counts = {}
for message in all_messages:
request_counts[message.request_id] = request_counts.get(message.request_id, 0) + 1
all_messages.sort(key=lambda message: request_counts[message.request_id])
for message in all_messages:
if self.bw_out - self.used_bw_out <= 0 or self.used_bw_out + len(sending_messages) >= self.bw_out:
return sending_messages
......@@ -93,7 +94,7 @@ class UserSolution(Solution):
next_node = rnd.choice(self.aggregates)
else:
used_rate = [neighbor_dict.get(aggregate)[4]/neighbor_dict.get(aggregate)[5] for aggregate in self.aggregates]
if min(used_rate) < 0.85:
if min(used_rate) < 0.75:
next_node = self.aggregates[used_rate.index(min(used_rate))]
else:
continue
......@@ -108,7 +109,7 @@ class UserSolution(Solution):
break
if next_node is None:
used_rate = [neighbor_dict.get(core)[4]/neighbor_dict.get(core)[5] for core in self.cores]
if min(used_rate) < 0.85:
if min(used_rate) < 0.75:
next_node = self.cores[used_rate.index(min(used_rate))]
else:
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment