Skip to content

Commit

Permalink
use definition lists instead of tables
Browse files Browse the repository at this point in the history
  • Loading branch information
tomli380576 committed Nov 7, 2023
1 parent c12d318 commit 224a947
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 102 deletions.
69 changes: 32 additions & 37 deletions Lecture Notes/W1 - Basic Inventory Models.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ A coffee shop needs to decide how much coffee beans to purchase and how frequent

#### Assumption

1. Everything is deterministic
2. Demand is constant (always the same amount of customers)
3. Only 1 product (1 type of coffee)
4. No backorders (coffee bean provider is always available)
5. Zero load time (supply instantly appears when ordered)
6. No discounts (coffee is always flat rate)
- Everything is deterministic
- Demand is constant (always the same amount of customers)
- Only 1 product (1 type of coffee)
- No backorders (coffee bean provider is always available)
- Zero load time (supply instantly appears when ordered)
- No discounts (coffee is always flat rate)

#### Input
### Variables

$d$
: Total annual demand (in this case pounds of coffee needed per year)
Expand All @@ -39,13 +39,10 @@ $c$
$h$
: Holding / Storage cost per item per year


#### Decision Variables / Output

$Q$
$Q$ [!badge variant="success" text="Decision Variable"]
: Quantity

#### Optimal Order Quantity $Q^*$
### Optimal Order Quantity $Q^*$

Since orders are fulfilled instantly, we only order a batch of coffee beans when stock goes to 0.

Expand Down Expand Up @@ -119,18 +116,9 @@ $$

## The News Vendor Model

### Scenario. Selling Newspapers

A newspaper vendor needs to decide how many newspapers to buy from the news publisher. Newspapers expire in a day. Expired newspapers can be salvaged (returned to vendor) for a lower price.

#### Decision Variable

$B$
: The number of newspapers to buy from the supplier

---

#### Input & Objective Function
### Variables

$d$
: Discrete R.V., the uncertain demand of newspapers
Expand All @@ -147,6 +135,9 @@ $c$
$s$
: Salvage price, sale price for expired newspapers. (e.g. recycling the paper)

$B$ [!badge variant="success" text="Decision Variable"]
: The number of newspapers to buy from the supplier


The 3 prices have the following inequality:

Expand Down Expand Up @@ -292,7 +283,7 @@ s\uparrow\implies p-s\darr \implies\frac{p-c}{p-s}\uarr\implies B^*\uarr
$$

## Buying services
[!badge variant='warning' text="Key Example."]
[!badge variant='warning' text="Key Example"]

### Scenario. Signing a contract

Expand All @@ -301,24 +292,28 @@ Suppose we want to sign a contract with a lighting company to purchase their mai
- Contract too much: We get refunded for remaining services at a less price
- Contract too little: We need to pay more for the extra services on the fly

#### Decision Variable

|Variable| Definition|
| --- | --- |
| $B$ | The number of services to buy from the contracting company |
#### Variables

#### Input & Objective Function
$D$
: A discrete random variable, the uncertain number of services we actually need

$c$
: Price of each service on the contract

|Variable| Definition|
| --- | --- |
| $D$ | A discrete random variable, the uncertain number of services we actually need |
$s$
: Refund price

$p$
: Price of extra services

$q(d)$
: PMF of $D$, same as $\Bbb P(D=d)$, in this case $d = 0,1,2,\dots$

$Q(d)$
: CDF of $D$, same as $\Bbb P(D\leqslant d)$

| $c$ | Price of each service on the contract |
| $s$ | Refund price |
| $p$ | Price of extra services |
| $q(d)$ | PMF of $D$, same as $\Bbb P(D=d)$, in this case $d = 0,1,2,\dots$ |
| $Q(d)$ | CDF of $D$, same as $\Bbb P(D\leqslant d)$ |
$B$ [!badge variant="success" text="Decision Variable"]
: The number of services to buy from the contracting company

The objective is to minimize the expected total cost $\text {TC}$ by picking the optimal $B$.

Expand Down
4 changes: 2 additions & 2 deletions Lecture Notes/W2 - Linear Programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ icon: check-circle
# W2 - Linear Programming


!!!secondary
!!!warning
We will use $\bold x$ to indicate a vector, $x_i$ to indicate the element of $\bold x$. The $\leqslant, \geqslant$ comparators are element–wise comparison. $\bold 0$ is the zero vector.
!!!

Expand Down Expand Up @@ -112,7 +112,7 @@ $$

|||

!!! **Def.** Standard Form
!!!info **Def.** Standard Form

$$
\begin{aligned}
Expand Down
70 changes: 35 additions & 35 deletions Lecture Notes/W3 - Network Flow Pt 1.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,37 @@ icon: check-circle

#### Scenario. Sending supplies to stores

Suppose you own a clothing business and owns both factories and stores.
Suppose you own a clothing business and owns both factories and stores. Let $\bigcirc$ be the factories (supply nodes) and $\triangle$ be the stores (demand node). The supply system looks like a directed graph:

Let $\bigcirc$ be the factories (supply nodes) and $\triangle$ be the stores (demand node).

The supply system looks like a directed graph:

![](/assets/Screenshot_2023-10-14_at_00.00.58.png){class="image-m"}

The placements are arbitrary
![The placements are arbitrary](/assets/Screenshot_2023-10-14_at_00.00.58.png){class="image-m"}

There’s also a unit cost to ship cloths from $i$ to $j$.

$$
{\Large\text{\textcircled{$\normalsize i$}}}\xrightarrow{\normalsize c_{ij}}{\Large\triangle}\!\!\!\!\!\!j
$$

#### Inputs
### Variables

$I$
: Set of supply nodes

|Variable| Definition|
| --- | --- |
| $I$ | Set of supply nodes |
| $J$ | Set of demand nodes |
| $s_i$ | Supply capacity of node $i$ |
| $d_j$ | Demand at node $j$ |
| $c_{ij}$ | Unit transportation cost to go from $i$ to $j$ |
$J$
: Set of demand nodes

#### Decision Variables
$s_i$
: Supply capacity of node $i$

|Variable| Definition|
| --- | --- |
| $x_{ij}$ | Amount of items to ship from supply node $i$ to demand node $j$. $\forall i\in I, j\in J$ |
$d_j$
: Demand at node $j$

#### Objective
$c_{ij}$
: Unit transportation cost to go from $i$ to $j$

$x_{ij}$ [!badge variant="success" text="Decision Variable"]
: Amount of items to ship from supply node $i$ to demand node $j$. $\forall i\in I, j\in J$

### Objective

We want to minimize the total shipping cost.

Expand All @@ -56,7 +54,7 @@ x_{ij}&\geqslant 0
\end{aligned}
$$

!!!primary **Proposition.** Integer Constraints ⇒ Integer Solutions, Existence
!!!secondary **Proposition.** Integer Constraints ⇒ Integer Solutions, Existence

1. If $d_j, s_i\in \Z$, the solution are also integers.
2. If the total demand is less than total supply, the the problem is feasible.
Expand All @@ -78,8 +76,7 @@ Define $x_{ij}$ to be the **flow** on the arc $i\to j$.
Each node $i$ has the flow conservation constraint


!!!
**Def.** Flow Conservation
!!!info **Def.** Flow Conservation

For each node $i$,

Expand All @@ -91,7 +88,7 @@ $$
$$
!!!

#### Objective
### Objective

Minimize the total cost. $c_{ij}$ is the unit cost to go from $i\to j$.

Expand All @@ -106,7 +103,7 @@ $$
l_{ij}\leqslant x_{ij}\leqslant u_{ij}
$$

### Special Case: Transportation Problem
## Special Case: Transportation Problem

Continue from above, define the vertices to be:

Expand Down Expand Up @@ -139,17 +136,20 @@ A ={}&\{i\to j: i\text{ is supply node}, j\text{ is demand node}\}\cup{}\\
\end{aligned}
$$

#### Decision Variables
### Decision Variables

$y_i$ and $z_j$ are new for this model.

$y_i$ and $z_j$ are new
$x_{ij}$
: Amount of items to ship from supply node $i$ to demand node $j$.

$y_i$
: The flow from $u$ to $i$ for each supply node $i$

|Variable| Definition|
| --- | --- |
| $x_{ij}$ | Amount of items to ship from supply node $i$ to demand node $j$. |
| $y_i$ | The flow from $u$ to $i$ for each supply node $i$ |
| $z_j$ | The from from $j$ to $u$ for each demand node $j$ |
$z_j$
: The from from $j$ to $u$ for each demand node $j$

#### Objective
### Objective

Minimize the total cost.

Expand All @@ -159,7 +159,7 @@ $$

Note that the under-braced parts are 0, because we only use $y_i, z_j$ for flow conservation. There’s no unit cost associated with arcs from or into $u$.

#### Constraints
### Constraints

For each supply node $i$, total flow out should equal to total flow in.

Expand Down
1 change: 0 additions & 1 deletion Lecture Notes/W4 - Network Flow Pt 2.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ $$
\min\sum_{(i\to j)\in A}c_{ij}x_{ij} + \sum_{(i\to j)\in A}d_{ij}y_{ij}
$$

idk what happened this week
48 changes: 30 additions & 18 deletions Lecture Notes/W5 - Dynamic Programming Pt 1.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ We could solve the shortest path problem with a general LP solver, but we have m

The following pseudocode is from my own [algorithm notes](https://www.notion.so/Single-Source-Shortest-Paths-ccab559c3b5c4f018913429bf3b1091c?pvs=21) but it does the same thing as what we did in class.

||| :icon-code: Pseudocode
|||:icon-code: Pseudocode
```c
function Initialize(G, start):
for each vertex v in G:
Expand All @@ -74,7 +74,7 @@ function NonNegativeDijkstras(G, start):
pred[v] = u
queue.UpdatePriority(v, dist[v])
```
||| :icon-rocket: Complexity
|||:icon-rocket: Complexity
```
// matched to each line

Expand Down Expand Up @@ -104,7 +104,7 @@ O(log V) for heaps
where `queue.ExtractMin()` grabs the vertex with the shortest distance.
#### EX. In-class practice graph
=== **Ex.** In-class practice graph
![Source: Canvas, `Shortest_path_problem_in_class.pdf`](/assets/Screenshot_2023-10-23_at_15.33.56.png){class="image-m"}
Expand All @@ -129,6 +129,8 @@ Running Dijkstra’s algorithm with $\text{start} = A$ gives us shortest path fr
│ L │ ['A', 'E', 'F', 'G', 'K', 'L'] │ 61 │ <== Path from A to L
╰──────────────┴────────────────────────────────┴────────────╯
```
===
### Optimal Substructure
Expand Down Expand Up @@ -183,16 +185,16 @@ The graph should also be connected, no isolated subgraphs
We don’t want (1) basically, since there’s complete tour. [Source](https://www.mdpi.com/2075-1680/10/1/19)
#### The ****Dantzig-Fulkerson-Johnson (DFJ) formulation****
#### The Dantzig-Fulkerson-Johnson (DFJ) formulation
$$
\forall S\sub V, S\ne \varnothing,\text{ define }\delta ^+(S) =\{i\to j\in A:i\in S, j\notin S\}\\[10pt]
\sum_{a\in \delta^+(S)}x_a\geqslant 1
$$
This constraint is what makes TSP an NP-Hard problem, the number of possible $S$’s is the size of the power set of $V$, which is $|{\cal P}(V)|=2^{|V|}$
This constraint is what makes TSP an NP-Hard problem, the number of possible $S$’s is the size of the power set of $V$, which is ${\cal P}(V)=2^{V}$
#### **The Miller–Tucker–Zemlin (MTZ)** formulation
#### The Miller–Tucker–Zemlin (MTZ) formulation
For each node $i\in V$, label with $u_i\in\N$ except the starting node.
Expand Down Expand Up @@ -255,20 +257,27 @@ $$
Every DP problem has the following properties:
|Variable| Definition|
| --- | --- |
| $t=1,2,\dots ,T$ | Stages |
| $s_t$ | State at time $t$ |
| $v_t(s_t)$ | Value function |
| $c(s_{t-1}, s_t)$ | Transition cost |
Stages
: $t=1,2,\dots ,T$
State at stage $t$
: $s_t$
Value function
: $v_t(s_t)$
Transition cost
: $c(s_{t-1}, s_t)$
$$
v_t(s_t) = \min/\max\{v_{t-1}(s_{t-1}) + c(s_{t-1}, s_t)\}
$$
#### Thm. Principle of optimality
!!!success Theorem. Principle of optimality
If $v_t(s_t)$ is optimal, then all the subproblems $v_{t-1}(s_{t-1})$ are also optimal.
!!!
### 0-1 Knapsack
Expand All @@ -294,11 +303,14 @@ If we don’t have the integer constraint $x_i\in\{0,1\}$, we can just take the
#### DP Formulation
|Element| Corresponding varaible|
| --- | --- |
| Stage | The maximum item index $1, 2,\dots,n$. If we are in stage $k$, we only consider items $1,2,\dots, k$. |
| State | $w$, remaining capacity of the backpack |
| Value function | $v_k(w)$, max profit given capacity $w$ and items $1,2,\dots k$ |
Stage
: The maximum item index $1, 2,\dots,n$. If we are in stage $k$, we only consider items $1,2,\dots, k$.
State
: $w$, remaining capacity of the backpack
Value function
: $v_k(w)$, max profit given capacity $w$ and items $1,2,\dots k$
$$
v_k(w) = \max\left\{\begin{gathered}v_{k-1}(w-a_k) + c_k\\v_{k-1}(w)\end{gathered}\right\}
Expand Down
Loading

0 comments on commit 224a947

Please sign in to comment.