Skip to content

Commit f23e2fd

Browse files
committed
calculations and some plots
1 parent 298c9ec commit f23e2fd

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

histogram.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import math
44
import numpy as np
55
from scipy import stats
6+
import seaborn as sns
67

78
data = pd.read_csv("data/500-4.txt", sep="\t")
89

@@ -24,7 +25,7 @@
2425
print("\n START MEAN, STDEV, CONF INT")
2526

2627
data = pd.read_csv(f"data/500-2.txt", sep="\t")
27-
example = data[data["SIM_TIME"] == 25]
28+
example = data[data["SIM_TIME"] == 150]
2829
example1 = data[data["SIM_TIME"] == 500]
2930
ex = example[example['RHO'] == 0.1]['AVG_WAIT']
3031
ex2 = example1[example1['RHO'] == 0.1]['AVG_WAIT']
@@ -40,16 +41,20 @@
4041

4142
fig = plt.figure(facecolor='w')
4243
ax = fig.add_subplot(111, facecolor='whitesmoke', axisbelow=True)
43-
ax.hist(ex_9, bins = 100, alpha=0.5, color = 'cornflowerblue')
44-
ax.hist(ex2_9, bins = 100, alpha = 0.6, color='springgreen')
45-
ax.set_xlabel(r'$Mean waiting time / time unit$', fontsize=12)
44+
ax.hist(ex_9, bins = 100, alpha=0.8, color = 'cornflowerblue', label="Simtime=150")
45+
ax.hist(ex2_9, bins = 100, alpha = 0.5, color='springgreen', label="Simtime=500")
46+
# sns.displot(ex_9,)
47+
# sns.displot(ex2_9)
48+
ax.set_xlabel('Mean waiting time / time unit', fontsize=12)
4649
ax.set_ylabel('Density', fontsize=12)
4750
ax.set_title('Distribution mean waiting time', fontsize = 14)
4851
ax.yaxis.set_tick_params(length=0)
4952
ax.xaxis.set_tick_params(length=0)
5053
ax.grid(b=True, which='major', c='w', lw=2, ls='-')
54+
legend = ax.legend()
55+
legend.get_frame().set_alpha(0.5)
5156
for spine in ('top', 'right', 'bottom', 'left'):
5257
ax.spines[spine].set_visible(False)
5358

54-
plt.savefig("plots/histogram-25-500.png", dpi=300)
59+
plt.savefig("plots/histogram-150-500-01.png", dpi=300)
5560
plt.show()

probabilities.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,28 @@ def expquel(c, rho):
6666

6767
# print(f'Probability that a job has to wait: {pwait(c, rho):.2f}')
6868
# print(f'Expected waiting time E(W): {expw(mu, c, rho):.2f} time units')
69-
# print(f'Expected queue length E(Lq): {expquel(c, rho):.2f} customers')
69+
# print(f'Expected queue length E(Lq): {expquel(c, rho):.2f} customers')
70+
# print dataframe with data
71+
# print(data)
72+
# run_data.loc[round(SIM_TIME/5)] = [rho, SIM_TIME, data["AVG_WAITING"].mean()]
73+
# print(f'Expected waiting time E(W): {expw(MU, SERVERS, RHO):.3f} time units')
74+
# print(f'AVG waiting: {data["AVG_WAITING"].mean():.3f} time units')
75+
# print(conf_int(data["AVG_WAITING"].mean(), data["AVG_WAITING"].var(), SIMULATIONS, p=0.95))
76+
# print()
77+
# print(f'AVG arriving: {data["AVG_ARRIVING"].mean():.3f} per time unit')
78+
# print(conf_int(data["AVG_ARRIVING"].mean(), data["AVG_ARRIVING"].var(), SIMULATIONS, p=0.95))
79+
# print()
80+
# print(f'AVG leaving: {data["AVG_LEAVING"].mean():.3f} per time unit')
81+
# print(conf_int(data["AVG_LEAVING"].mean(), data["AVG_LEAVING"].var(), SIMULATIONS, p=0.95))
82+
# print(f'Simulation {s+1}')
83+
# print(f'Average waiting time: {avg_waiting:.3f} time units')
84+
# print(f'Avg customers arriving per time unit: {avg_arrivals:.3f} time units')
85+
# print(f'Avg customers leaving per time unit: {avg_leavers:.3f} time units\n')
86+
87+
# print("EXPECTED VALUES AND PROBABILITIES")
88+
#
89+
# print(f'Rho: {RHO}\nMu: {MU}\nLambda: {LAMBDA}\nExpected interarrival time: {1 / LAMBDA:.2f} time units')
90+
# print(f'Expected processing time per server: {1 / MU:.2f} time units\n')
91+
# print(f'Probability that a job has to wait: {pwait(SERVERS, RHO):.2f}')
92+
# print(f'Expected waiting time E(W): {expw(MU, SERVERS, RHO):.2f} time units')
93+
# print(f'Expected queue length E(Lq): {expquel(SERVERS, RHO):.2f} customers\n')

0 commit comments

Comments
 (0)