Commit d15dd436 authored by Leon A. Okida Gonçalves's avatar Leon A. Okida Gonçalves
Browse files

registering route sizes

parent 79470960
No related merge requests found
Showing with 67 additions and 9 deletions
+67 -9
......@@ -76,18 +76,38 @@ def run_experiment(graph, name="experiment"):
def process_trip(trip):
source, dest = trip
# First calls
route_sta_d, _ = dijkstra_routing.initiate_find_route(source, dest, graph, sta_d_table)
route_frr_d, _ = frr_dijkstra_routing.initiate_find_route(source, dest, graph, frr_d_table)
route_mf_a, _ = mf_routing.initiate_find_route(source, dest, graph, mf_table_a)
route_mf_b, _ = mf_routing.initiate_find_route(source, dest, graph, mf_table_b)
route_mf_c, _ = mf_routing.initiate_find_route(source, dest, graph, mf_table_c)
# Fail on one of the vertices of the route and check how many backtracks happened
# Store first call route sizes
route_sizes_first = {
'sta_d': len(route_sta_d),
'frr_d': len(route_frr_d),
'mf_a': len(route_mf_a),
'mf_b': len(route_mf_b),
'mf_c': len(route_mf_c)
}
# Second calls (after failing one of the vertices)
route_sta_d, backtracks_sta_d = dijkstra_routing.initiate_find_route(source, dest, graph, sta_d_table, random.choice(route_sta_d[1:-1]))
route_frr_d, backtracks_frr_d = frr_dijkstra_routing.initiate_find_route(source, dest, graph, frr_d_table, random.choice(route_frr_d[1:-1]))
route_mf_a, backtracks_mf_a = mf_routing.initiate_find_route(source, dest, graph, mf_table_a, random.choice(route_mf_a[1:-1]))
route_mf_b, backtracks_mf_b = mf_routing.initiate_find_route(source, dest, graph, mf_table_b, random.choice(route_mf_b[1:-1]))
route_mf_c, backtracks_mf_c = mf_routing.initiate_find_route(source, dest, graph, mf_table_c, random.choice(route_mf_c[1:-1]))
# Store second call route sizes
route_sizes_second = {
'sta_d': len(route_sta_d),
'frr_d': len(route_frr_d),
'mf_a': len(route_mf_a),
'mf_b': len(route_mf_b),
'mf_c': len(route_mf_c)
}
# Update the progress counter
with counter_lock:
......@@ -96,7 +116,25 @@ def run_experiment(graph, name="experiment"):
if completed_count % 10 == 0 or completed_count == sample_size:
print(f"Progress: {completed_count}/{sample_size} trips completed")
return backtracks_sta_d, backtracks_frr_d, backtracks_mf_a, backtracks_mf_b, backtracks_mf_c
return (route_sizes_first, route_sizes_second,
backtracks_sta_d, backtracks_frr_d,
backtracks_mf_a, backtracks_mf_b, backtracks_mf_c)
avg_route_sizes_first = {
'sta_d': [],
'frr_d': [],
'mf_a': [],
'mf_b': [],
'mf_c': []
}
avg_route_sizes_second = {
'sta_d': [],
'frr_d': [],
'mf_a': [],
'mf_b': [],
'mf_c': []
}
avg_backtracks_sta_d = []
avg_backtracks_frr_d = []
......@@ -114,15 +152,26 @@ def run_experiment(graph, name="experiment"):
futures.append(executor.submit(process_trip, trip))
for future in concurrent.futures.as_completed(futures):
backtracks_sta_d, backtracks_frr_d, backtracks_mf_a, backtracks_mf_b, backtracks_mf_c = future.result()
(route_sizes_first, route_sizes_second,
backtracks_sta_d, backtracks_frr_d,
backtracks_mf_a, backtracks_mf_b, backtracks_mf_c) = future.result()
# Append route sizes to corresponding lists
for key in avg_route_sizes_first:
avg_route_sizes_first[key].append(route_sizes_first[key])
avg_route_sizes_second[key].append(route_sizes_second[key])
# Append backtracks to corresponding lists
avg_backtracks_sta_d.append(backtracks_sta_d)
avg_backtracks_frr_d.append(backtracks_frr_d)
avg_backtracks_mf_a.append(backtracks_mf_a)
avg_backtracks_mf_b.append(backtracks_mf_b)
avg_backtracks_mf_c.append(backtracks_mf_c)
results_file = open("backtrack_results.txt", "a")
# Output results
results_file = open("backtrack_and_route_size_results.txt", "a")
print(name, file=results_file)
print("===== Average backtracks on failures =====", file=results_file)
print("Considering", sample_size, "trips between non-neighbors", file=results_file)
print("Dijkstra without FRR:", statistics.mean(avg_backtracks_sta_d), file=results_file)
......@@ -130,7 +179,17 @@ def run_experiment(graph, name="experiment"):
print("MF with 2,-5:", statistics.mean(avg_backtracks_mf_a), file=results_file)
print("MF with 5,-5:", statistics.mean(avg_backtracks_mf_b), file=results_file)
print("MF with 5,-1:", statistics.mean(avg_backtracks_mf_c), file=results_file)
"""
print("===== Average route sizes =====", file=results_file)
print("First call average route sizes:", file=results_file)
for key in avg_route_sizes_first:
print(f"{key}: {statistics.mean(avg_route_sizes_first[key])}", file=results_file)
print("Second call average route sizes:", file=results_file)
for key in avg_route_sizes_second:
print(f"{key}: {statistics.mean(avg_route_sizes_second[key])}", file=results_file)
results_file.close()
run_experiment(nsg.random_graph(100, 0.1), "RANDOM GRAPH 0.1 - 100")
run_experiment(nsg.random_graph(100, 0.3), "RANDOM GRAPH 0.3 - 100")
run_experiment(nsg.random_graph(100, 0.5), "RANDOM GRAPH 0.5 - 100")
......@@ -149,8 +208,7 @@ run_experiment(nsg.random_graph(200, 0.5), "RANDOM GRAPH 0.5 - 200")
run_experiment(nsg.random_graph(200, 0.7), "RANDOM GRAPH 0.7 - 200")
run_experiment(nsg.small_world_graph(200), "SMALL WORLD - 200")
run_experiment(nsg.preferential_attachment_graph(200), "PREFERENTIAL ATTACHMENT - 200")
"""
run_experiment(utils.read_graph("topologies/geant.txt"), "GEANT")
run_experiment(utils.read_graph("topologies/internet2.txt"), "INTERNET2")
run_experiment(utils.read_graph("topologies/rnp.txt"), "RNP")
run_experiment(utils.read_graph("topologies/wide.txt"), "WIDE")
\ No newline at end of file
run_experiment(utils.read_graph("topologies/rnp_equal.txt"), "RNP")
run_experiment(utils.read_graph("topologies/wide_equal.txt"), "WIDE")
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment