mirror of
https://github.com/Zenithsiz/ist-ddrs-lab2
synced 2026-02-03 14:10:05 +00:00
Started work on exercise 8b.
This commit is contained in:
parent
9d7a381728
commit
9bc2512b92
3
code/8b-report.R
Normal file
3
code/8b-report.R
Normal file
@ -0,0 +1,3 @@
|
||||
mm1_var <- var(sapply(1:100, \(...) calc_stats_mm1(...)$avg_delay))
|
||||
mg1_var1 <- var(sapply(1:100, \(...) calc_stats_mg1(...)$avg_delay))
|
||||
mg1_var2 <- var(sapply(1:100, \(...) calc_stats_mg1(...)$avg_delay))
|
||||
15
code/8b.R
15
code/8b.R
@ -1,13 +1,16 @@
|
||||
source("code/8.R")
|
||||
|
||||
set.seed(3)
|
||||
set.seed(0)
|
||||
|
||||
stopping_condition <- 10000
|
||||
mm1_var <- var(sapply(1:100, function(...) calc_stats_mm1(0.5, 1, 0.99, 101, 0.01, stopping_condition)$avg_delay))
|
||||
print(mm1_var)
|
||||
|
||||
mg1_var1 <- var(sapply(1:100, function(...) calc_stats_mg1(0.5, 1, 0.9, 11, 0.1, stopping_condition)$avg_delay))
|
||||
print(mg1_var1)
|
||||
|
||||
mg1_var2 <- var(sapply(1:100, function(...) calc_stats_mg1(0.5, 1, 0.99, 101, 0.01, stopping_condition)$avg_delay))
|
||||
print(mg1_var2)
|
||||
|
||||
output <- list(
|
||||
mm1_var = signif(mm1_var, 4),
|
||||
mg1_1_var = signif(mg1_var1, 4),
|
||||
mg1_2_var = signif(mg1_var2, 4)
|
||||
)
|
||||
str(output)
|
||||
write.table(output, "output/8b.csv", sep = "\t", row.names = FALSE)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
==== a.
|
||||
|
||||
#let results = csv("/output/8a.csv", delimiter: "\t")
|
||||
#let results_a = csv("/output/8a.csv", delimiter: "\t")
|
||||
|
||||
#indent_par[The following table 15 contains the results of the script. The simulated results have been run 10 times, and are displayed as a confidence interval of 95%.]
|
||||
|
||||
@ -29,20 +29,20 @@
|
||||
[ `M/M/1` ],
|
||||
rowspanx(3)[ 0.5 ],
|
||||
colspanx(4)[ N/A ],
|
||||
[ #results.at(1).at(0) .. #results.at(1).at(1) ],
|
||||
[ #results.at(1).at(2) ],
|
||||
[ #results.at(1).at(3) ],
|
||||
[ #results_a.at(1).at(0) .. #results_a.at(1).at(1) ],
|
||||
[ #results_a.at(1).at(2) ],
|
||||
[ #results_a.at(1).at(3) ],
|
||||
|
||||
rowspanx(2)[ `M/G/1` ],
|
||||
[ 1 ], [ 0.9 ], [ 11 ], [ 0.1 ],
|
||||
[ #results.at(1).at(4) .. #results.at(1).at(5) ],
|
||||
[ #results.at(1).at(6) ],
|
||||
[ #results.at(1).at(7) ],
|
||||
[ #results_a.at(1).at(4) .. #results_a.at(1).at(5) ],
|
||||
[ #results_a.at(1).at(6) ],
|
||||
[ #results_a.at(1).at(7) ],
|
||||
|
||||
[ 1 ], [ 0.99 ], [ 101 ], [ 0.01 ],
|
||||
[ #results.at(1).at(8) .. #results.at(1).at(9) ],
|
||||
[ #results.at(1).at(10) ],
|
||||
[ #results.at(1).at(11) ],
|
||||
[ #results_a.at(1).at(8) .. #results_a.at(1).at(9) ],
|
||||
[ #results_a.at(1).at(10) ],
|
||||
[ #results_a.at(1).at(11) ],
|
||||
)),
|
||||
kind: table,
|
||||
caption: [Results]
|
||||
@ -51,3 +51,55 @@
|
||||
#indent_par[The simulated average delay results line up quite well with the calculated theoretical ones, with all values inside of the confidence interval.]
|
||||
|
||||
#indent_par[We can also conclude that the higher the workload variability ($C^2$), the higher the average delay experienced by the system.]
|
||||
|
||||
==== b.
|
||||
|
||||
#let results_b = csv("/output/8b.csv", delimiter: "\t")
|
||||
|
||||
#indent_par[The following code 8 contains out approach to calculate the variance. The functions `calc_stats_mm1` and `calc_stats_mg1` simulate the corresponding systems and return a list where `$avg_delay` contains the simulated average delay.]
|
||||
|
||||
#code_figure(
|
||||
text(size: 0.8em, raw(read("/code/8b-report.R"), lang: "R", block: true)),
|
||||
caption: "Code for calculating the variance of the systems",
|
||||
)
|
||||
|
||||
#indent_par[The following table 16 contains the results to our approach:]
|
||||
|
||||
#figure(
|
||||
pad(1em, tablex(
|
||||
columns: (auto, auto, auto, auto, auto, auto, auto, auto),
|
||||
align: center + horizon,
|
||||
|
||||
[ System ],
|
||||
[ $ρ$ ],
|
||||
[ $S_1$ ],
|
||||
[ $p_1$ ],
|
||||
[ $S_2$ ],
|
||||
[ $p_2$ ],
|
||||
[ Variance ],
|
||||
[ $C^2$ ],
|
||||
|
||||
[ `M/M/1` ],
|
||||
rowspanx(3)[ 0.5 ],
|
||||
colspanx(4)[ N/A ],
|
||||
[ #results_b.at(1).at(0) ],
|
||||
[ #results_a.at(1).at(3) ],
|
||||
|
||||
rowspanx(2)[ `M/G/1` ],
|
||||
[ 1 ], [ 0.9 ], [ 11 ], [ 0.1 ],
|
||||
[ #results_b.at(1).at(1) ],
|
||||
[ #results_a.at(1).at(7) ],
|
||||
|
||||
[ 1 ], [ 0.99 ], [ 101 ], [ 0.01 ],
|
||||
[ #results_b.at(1).at(2) ],
|
||||
[ #results_a.at(1).at(11) ],
|
||||
)),
|
||||
kind: table,
|
||||
caption: [Results]
|
||||
)
|
||||
|
||||
#indent_par[We've included the workload variability from the previous exercise as the column $C^2$ to compare against. We can thus conclude that the variance and variability are correlated.]
|
||||
|
||||
#indent_par[This makes sense, as despite our _elephants_ occurring less often, their larger size ensures that the users that come after them have a much higher average queue delay, which in turn increases the variance of the system.]
|
||||
|
||||
#pagebreak()
|
||||
|
||||
12
zbuild.yaml
12
zbuild.yaml
@ -16,6 +16,7 @@ default:
|
||||
- rule: ex7_b
|
||||
- rule: ex7_c
|
||||
- rule: ex8_a
|
||||
- rule: ex8_b
|
||||
|
||||
rules:
|
||||
# Typst
|
||||
@ -217,3 +218,14 @@ rules:
|
||||
exec:
|
||||
- - Rscript
|
||||
- code/8a.R
|
||||
|
||||
# Exercise 8.b
|
||||
ex8_b:
|
||||
out:
|
||||
- output/8b.csv
|
||||
deps:
|
||||
- code/8.R
|
||||
- code/8b.R
|
||||
exec:
|
||||
- - Rscript
|
||||
- code/8b.R
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user