-
Notifications
You must be signed in to change notification settings - Fork 0
/
varying_parameters_vs_time.py
49 lines (40 loc) · 1.94 KB
/
varying_parameters_vs_time.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
This file runs time-tests on ILP_solver by only varying one parameter.
Graphs are also generated of results.
"""
import matplotlib.pyplot as plt
from ILP_solver.ILP_solver import solve_TCP_instance
from graph_tools.graph_generator import generate_graph
def modulate_num_nodes():
num_nodes = [25*i for i in range(1,9)]
times = []
for node_count in num_nodes:
graph, existence_for_node_time, connectivity_demand = generate_graph(num_nodes=node_count)
times.append(solve_TCP_instance(graph, existence_for_node_time, connectivity_demand, time_output=True))
print num_nodes, times
plot(num_nodes, times, "Number of Nodes", "Time (Seconds)", "TCP Runtime for Nodes vs Time ")
def modulate_edge_percentage_active():
percentage_edges_active = [0.05*i for i in range(1,21)]
times = []
for percentage in percentage_edges_active:
graph, existence_for_node_time, connectivity_demand = generate_graph(edge_connectivity=percentage)
times.append(solve_TCP_instance(graph, existence_for_node_time, connectivity_demand, time_output=True))
print percentage_edges_active, times
plot(percentage_edges_active, times, "Percentage of Edges Active", "Time (Seconds)", "TCP Runtime for Percentage of Edge Active vs Time ")
def modulate_node_percentage_active():
percentage_nodes_active = [0.05*i for i in range(1,21)]
times = []
for percentage in percentage_nodes_active:
graph, existence_for_node_time, connectivity_demand = generate_graph(active_time_percent=percentage)
times.append(solve_TCP_instance(graph, existence_for_node_time, connectivity_demand, time_output=True))
print percentage_nodes_active, times
plot(percentage_nodes_active, times, "Percentage of Edges Active", "Time (Seconds)", "TCP Runtime for Percentage of Edge Active vs Time ")
def plot(x,y, x_axis, y_axis, title):
plt.title(title)
plt.xlabel(x_axis)
plt.ylabel(y_axis)
plt.plot(x, y, "-o")
plt.show()
#modulate_num_nodes()
#modulate_edge_percentage_active()
#modulate_node_percentage_active()