-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReal_Exp.py
79 lines (63 loc) · 2.85 KB
/
Real_Exp.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import matplotlib.pyplot as plt
import os
from Model import runRealData
time_periods = [4, 8] # weeks
num_nurses = [30, 40, 50, 60, 80, 100, 120]
if not os.path.exists("result"):
os.makedirs("result")
for id_h in [0, 1]:
for id_first_w in [0, 4]:
'''SECOND PLOT: FIXED MAX CALCULATION TIME'''
# fixed maximum time of calculation
max_time = 60 * 60 # 1h
for t in time_periods:
relative_gaps = []
for n in num_nurses:
elapsed_time, absolute_gap, relative_gap = runRealData(n, t, max_time, id_h, id_first_w)
relative_gaps.append(relative_gap*100)
plt.plot(num_nurses, relative_gaps, label=str(t)+"weeks")
plt.legend()
plt.xlabel('Numero di infermieri')
plt.ylabel('Gap percentuale (%)')
plt.title("Tempo massimo: {}s".format(max_time))
# per togliere il float in valori interi delle x
plt.xticks(num_nurses)
# per fare exp su server
plt.savefig(os.path.join("result","Gap_1h-h{}_w{}.png".format(id_h, id_first_w)))
plt.clf() # per non fare i grafici sempre sulla stessa figura
'''THIRD PLOT: FIXED MAX CALCULATION TIME (WIDE)'''
# fixed maximum time of calculation
max_time = 60 * 60 * 2 # 2h
for t in time_periods:
relative_gaps = []
for n in num_nurses:
elapsed_time, absolute_gap, relative_gap = runRealData(n, t, max_time, id_h, id_first_w)
relative_gaps.append(relative_gap*100)
plt.plot(num_nurses, relative_gaps, label=str(t)+"weeks")
plt.legend()
plt.xlabel('Numero di infermieri')
plt.ylabel('Gap percentuale (%)')
plt.title("Tempo massimo: {}s".format(max_time))
# per togliere il float in valori interi delle x
plt.xticks(num_nurses)
# per fare exp su server
plt.savefig(os.path.join("result","Gap_2h-h{}_w{}.png".format(id_h, id_first_w)))
plt.clf() # per non fare i grafici sempre sulla stessa figura
'''FIRST PLOT: TIME CALCULATION'''
# fixed a large time_period
# decreasing the nurses number
max_time = 60 * 60 # 1h
for t in time_periods:
elapsed_times = []
for n in num_nurses:
elapsed_time, absolute_gap, relative_gap = runRealData(n, t, max_time, id_h, id_first_w)
elapsed_times.append(elapsed_time)
plt.plot(num_nurses, elapsed_times, label=str(t)+"weeks")
plt.legend()
plt.xlabel('Numero di infermieri')
plt.ylabel('Tempo di calcolo (s)')
plt.title("Tempo di esecuzione")
plt.xticks(num_nurses)
# per fare exp su server
plt.savefig(os.path.join("result","Time_1h-h{}_w{}.png".format(id_h, id_first_w)))
plt.clf() # per non fare i grafici sempre sulla stessa figura