Mostly finished ex3.

This commit is contained in:
Filipe Rodrigues 2024-01-06 15:32:29 +00:00
parent 72c7af3dc5
commit e4eadab3b8
Signed by: zenithsiz
SSH Key Fingerprint: SHA256:Mb5ppb3Sh7IarBO/sBTXLHbYEOz37hJAlslLQPPAPaU
5 changed files with 70 additions and 6 deletions

View File

@ -24,7 +24,7 @@ objective[c(idx_x_12, idx_x_13, idx_x_23, idx_x_24, idx_x_34)] <- c(cost_12, cos
# (Node 1): x_12 + x_13 = 1
# (Node 2): x_12 - x_24 - x_23 = 0
# (Node 3): x_13 + x_23 - x_34 = 0
# (Node 4): -x_24 -x_34 = -1
# (Node 4): -x_24 - x_34 = -1
mat <- matrix(
0,
nrow = 5,

6
typst/appendixes/3.typ Normal file
View File

@ -0,0 +1,6 @@
#import "/typst/util.typ" as util: indent_par, code_figure
#code_figure(
text(size: 0.8em, raw(read("/code/3.R"), lang: "R", block: true)),
caption: "Code used for exercise 3",
)

View File

@ -6,7 +6,7 @@
#indent_par[We define additional variables to determine the number of circuits for each link, named $y_"ab"$. We also remove the variable $r$, since our objective is now to minimize the overall cost, which only depends on the $y_"ab"$ variables and other constants.]
#indent_par[The following are our updated equations.]
#indent_par[The following are our updated equations in table 5.]
#figure(
pad(1em, table(
@ -45,7 +45,7 @@
#indent_par[Similarly to the previous exercise, for bifurcated flow, we allow $x_(n_1 n_2 ... n_r)$ to be real numbers, but we must restrict $y_"ab"$ to a positive integer, because we can only have an integer amount of modules.]
#indent_par[This results in the following solution in table 5:]
#indent_par[This results in the following solution in table 6:]
#figure(
pad(1em, table(
@ -106,3 +106,5 @@
)
#indent_par[We also reach a network cost of 10000€.]
#pagebreak()

52
typst/exercises/3.typ Normal file
View File

@ -0,0 +1,52 @@
#import "/typst/util.typ" as util: indent_par, code_figure
#indent_par[We've resorted to the node-link routing formulation to determine the shortest path.]
#indent_par[Since we're using the same network and flows as in exercise 1, the routes specified in table 1 stay the same as well]
#indent_par[Similarly to the previous 2 exercise, we define the variables $x_"ab"$, where $a -> b$ is a link, as the ratio of traffic passing through that link.]
#indent_par[The following are our equations in table 8.]
#figure(
pad(1em, table(
columns: (auto, 1fr),
align: left + horizon,
[Description], [Equation],
[Node 1], [$x_12 + x_13 = 1$],
[Node 2], [$x_12 - x_24 - x_23 = 0$],
[Node 3], [$x_13 + x_23 - x_34 = 0$],
[Node 4], [$-x_24 - x_34 = -1$],
)),
kind: table,
caption: [Problem equations]
)
#indent_par[Our objective function is the following in equation 1:]
$ 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[We achieve the following results in table 9:]
#figure(
pad(1em, table(
columns: (auto, auto),
align: left,
[Variable], [ Value ],
[$x_12$], [1],
[$x_13$], [0],
[$x_23$], [1],
[$x_24$], [0],
[$x_34$], [1],
)),
kind: table,
caption: [Solution]
)
#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.]

View File

@ -53,14 +53,18 @@
=== 2. Exercise 2
#include "exercises/2.typ"
=== 3. Exercise 3
#include "exercises/3.typ"
#pagebreak()
= Appendix
=== 1. Exercise 1
#include "appendixes/1.typ"
=== 2. Exercise 2
=== 2. Exercise 2 <appendix2>
#include "appendixes/2.typ"
=== 3. Exercise 3 <appendix3>
#include "appendixes/3.typ"