Mostly finished ex4.

This commit is contained in:
Filipe Rodrigues 2024-01-06 15:57:36 +00:00
parent e4eadab3b8
commit e61ce5b73e
Signed by: zenithsiz
SSH Key Fingerprint: SHA256:Mb5ppb3Sh7IarBO/sBTXLHbYEOz37hJAlslLQPPAPaU
6 changed files with 104 additions and 3 deletions

View File

@ -4,6 +4,8 @@
"ggplot",
"ggsave",
"linebreak",
"lsroute",
"Mbits",
"objval",
"typst",
"xlab",

BIN
images/4-diagram.png (Stored with Git LFS) Normal file

Binary file not shown.

13
typst/appendixes/4.typ Normal file
View File

@ -0,0 +1,13 @@
#import "/typst/util.typ" as util: indent_par, code_figure
==== Greedy Randomized
#code_figure(
text(size: 0.8em, raw(read("/code/util/greedy_randomized.R"), lang: "R", block: true)),
caption: [Implementation of `GreedyRandomized`],
)
==== c.
#code_figure(
text(size: 0.8em, raw(read("/code/4c.R"), lang: "R", block: true)),
caption: [Code used for exercise 4c],
)

View File

@ -29,7 +29,7 @@ $ sum_i c_"ab" dot x_"ab" $
#indent_par[Where $c_"ab"$ is the cost of the $a -> b$ link.]
#indent_par[For both of the following cases, the code we have used is presented in the appendix.]
#indent_par[The code we have used to calculate this is presented in the appendix.]
#indent_par[We achieve the following results in table 9:]
@ -50,3 +50,5 @@ $ sum_i c_"ab" dot x_"ab" $
)
#indent_par[The total cost ends end at 3. We conclude that the best solution is the route $1 -> 2 -> 3 -> 4$, with a cost of 3.]
#pagebreak()

75
typst/exercises/4.typ Normal file
View File

@ -0,0 +1,75 @@
#import "/typst/util.typ" as util: indent_par, code_figure
#indent_par[The following figure 2, from the guide, represents our network.]
#figure(
image("/images/4-diagram.png", width: 70%),
caption: [Network diagram]
)
==== a.
#indent_par[Using the provided script `lsrouteA.R`, we obtained the following results for a kilometric solution in table 10:]
#figure(
pad(1em, table(
columns: (auto, auto),
align: center,
[Maximum link load], [Average packet delay ($"ms"$)],
[0.999000], [2.055],
)),
kind: table,
caption: [Solution]
)
==== b.
#indent_par[To develop the `GreedyRandomized` function, we used the following approach:]
- Find all possible flows and shuffle them
- For each flow, find the shortest path, taking into account the previously installed flows.
#indent_par[In detail, we store a matrix `λ` with the installed traffic through each node, so we may compute the link delays using it. We update this matrix using delays calculated from `Tr` matrix and the speed of light.]
#indent_par[This function is present in the appendix.]
#indent_par[After running the provided script `lsrouteB.R`, we obtained the following results for a kilometric solution in table 11:]
#figure(
pad(1em, table(
columns: (auto, auto),
align: center,
[Maximum link load], [Average packet delay ($"ms"$)],
[0.864000], [1.207],
)),
kind: table,
caption: [Solution]
)
#indent_par[The solution found via this method is substantially better than in the previous exercise, by both the maximum link load, which is lower, and the average packet delay.]
#pagebreak()
==== c.
#indent_par[Using the solution from the previous exercise, we computed the rates matrix and used it to determine where we needed to add more capacity.]
#indent_par[In detail, we normalize the matrix to the $[0.0, 1.0]$ interval and added it to the `Mu` matrix using `Mu = (1 + extra_capacity) * 1e9 / 8e3`. This makes it so that, as specified, we don't remove any capacity and only add it where necessary. However, this lead to a maximum link load of higher than 70%. To fix this, we multiplied the original by the lowest factor that would yield a < 70% maximum link load.]
#indent_par[The code used for this, which includes the extra capacity, is present in the appendix.]
#indent_par[After running our solution, we obtained the following solution in table 12:]
#figure(
pad(1em, table(
columns: (auto, auto),
align: center,
[Maximum link load], [Average packet delay ($"ms"$)],
[0.699999], [1.163],
)),
kind: table,
caption: [Solution]
)

View File

@ -56,6 +56,9 @@
=== 3. Exercise 3
#include "exercises/3.typ"
=== 4. Exercise 4
#include "exercises/4.typ"
#pagebreak()
= Appendix
@ -63,8 +66,11 @@
=== 1. Exercise 1
#include "appendixes/1.typ"
=== 2. Exercise 2 <appendix2>
=== 2. Exercise 2
#include "appendixes/2.typ"
=== 3. Exercise 3 <appendix3>
=== 3. Exercise 3
#include "appendixes/3.typ"
=== 4. Exercise 4
#include "appendixes/4.typ"