as3: fix task 1 pandoc compilation

This commit is contained in:
2026-03-26 18:19:29 +01:00
parent 86de063cb1
commit 36a5de1ba3
2 changed files with 4707 additions and 12 deletions

View File

@@ -1,3 +1,7 @@
---
mainfont: "Libertinus Serif"
---
## task 1
by implementing the `push-relabel`-algorithm in [odin](https://odin-lang.org/), i was able to get a better understanding of the algorithm and could more tangibly reason about the following questions.
@@ -9,6 +13,7 @@ when the two towers have equally many nodes and the capacity of the middle nodes
the iteration count can be seen by running the algorithm on different configurations of the problem, i.e. for different $n$.
first, let's explore the impact of varying the parameters.
- by varying $k$, which is not specified in this task, we can see that increasing it by 1, increases the iteration count by 2. which makes sense, since we need to first relabel, then push, for each middle node. this happens regardless of what $n$ is, as long as $n = m = C$.
- adding 1 to $n$ adds 5 to the iteration count.
@@ -20,6 +25,7 @@ $$
$$
trying out this fancy formula, we can predict the outcome of using certain parameters:
- c(1, 0) = 4 ok.
- c(1, 1) = 6 ok.
- c(2, 1) = 11 ok.
@@ -28,7 +34,7 @@ trying out this fancy formula, we can predict the outcome of using certain param
seems to work fine.
### b) $n = C, n >> m$
### b) $n = C, n \gg m$
in this case, the formula above won't work, because $n \ne m$.
@@ -38,15 +44,14 @@ let $c(n, m, k)$ denote the iteration count again.
fix $k = 1$, then let row denote n and col m:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
--+-----+-----+-----+-----+-----+-----+-----+-----+-----+
1 | 6 | | | | | | | | |
2 | 26 | 11 | | | | | | | |
3 | 44 | 47 | 16 | | | | | | |
4 | 58 | 71 | 74 | 21 | | | | | |
5 | 85 | 88 | 104 | 107 | 26 | | | | |
9 | 203 | 206 | 234 | 237 | 265 | 268 | 296 | 299 | 46 |
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|-----|-----|-----|-----|-----|-----|-----|-----|-----|
| 1 | 6 | | | | | | | | |
| 2 | 26 | 11 | | | | | | | |
| 3 | 44 | 47 | 16 | | | | | | |
| 4 | 58 | 71 | 74 | 21 | | | | | |
| 5 | 85 | 88 | 104 | 107 | 26 | | | | |
| 9 | 203 | 206 | 234 | 237 | 265 | 268 | 296 | 299 | 46 |
what's the pattern?
@@ -73,7 +78,7 @@ it might be more interesting looking at when $m = k = 1$, and only varying $n =
the differences $d$ are wild. it might be impossible to find an explicit formula for the iteration count in this case.
i suppose the general pattern is that the iteration count grows disproportionately to the number of nodes in the first tower, i.e. a lot faster, when $n >> m$.
i suppose the general pattern is that the iteration count grows disproportionately to the number of nodes in the first tower, i.e. a lot faster, when $n \gg m$.
but let's think about this. when $n$ grows and $m$ is fixed, it just means the algorithm will have to relabel only a few nodes in the second tower, since there are only a few nodes there to begin with. thus, the major time spent in the algorithm will be in the first tower, relabeling and pushing flow through that network. and since $n = C$, the flow coming out of the first tower is not restricted in any way, but it poses a problem for the second tower, which then acts as a bottle neck for the flow. a bottle neck would only mean that the algorithm terminates quicker, i.e. has a positive impact on the iteration count.
@@ -81,7 +86,7 @@ i'm sure you could argue about this more rigorously, but my current understandin
P.S: i found that the numbers got wild with $k = 0$, so i assume there's maybe a bug for that case, thus the fact that the formula in a) lined up for this might just be a coincidence (in the cases where i had $k=0$).
### c) $n << m, m = C$
### c) $n \ll m, m = C$
so now the situation is opposite, where the flow out of the first tower is (possibly) restricted and the flow into the second tower is unrestricted, since $m = C$.

4690
assignment-3/task1.pdf Normal file

File diff suppressed because it is too large Load Diff