|
| 1 | +<!-- Sources for Intro: |
| 2 | + - Slides 1-5 of PLAN/08_SLIDE_SKELETON.md |
| 3 | + - Bead 1 (LP/MIP as problem classes + naming conventions): PLAN/06_BEADS.md |
| 4 | + - Bead 3 (Guessing game): PLAN/06_BEADS.md |
| 5 | + - Bead 4 (Pattern recognition / Box framing): PLAN/06_BEADS.md |
| 6 | + - Active element on slide 4: PLAN/10_ACTIVE_ELEMENTS.md §10.1 |
| 7 | + - MathOpt (Bead 2) lives in _01-mathopt.qmd |
| 8 | +--> |
| 9 | + |
| 10 | +# LP/MIP Modeling {background-image="assets/symbol_lpmip.png" background-opacity="0.3" background-size="cover" background-color="#2d4059"} |
| 11 | + |
| 12 | +<!-- Story Line: |
| 13 | +1. There are these two problem classes, LP and MIP, with powerful solvers. Which problems can we solve with them? |
| 14 | +2. Here are the canonical base problems each class handles, and the industrial patterns they map onto. |
| 15 | +3. Speaking to these solvers is quite easy, and the solvers are interchangeable. |
| 16 | +4. More expressions than you might think are actually linear. |
| 17 | +5. Tension between accuracy and tractability. |
| 18 | +--> |
| 19 | +## Two Problem Classes with Powerful Solvers |
| 20 | + |
| 21 | +[**Linear Expressions**]{style="display:block; text-align:center;"} |
| 22 | + |
| 23 | +<svg viewBox="0 0 400 60" preserveAspectRatio="none" style="width:100%; height:60px; display:block;" aria-hidden="true"> |
| 24 | + <defs> |
| 25 | + <marker id="arrowhead" markerWidth="8" markerHeight="8" refX="4" refY="4" orient="auto"> |
| 26 | + <path d="M0,0 L8,4 L0,8 z" fill="currentColor"/> |
| 27 | + </marker> |
| 28 | + </defs> |
| 29 | + <path d="M 200 0 L 200 25 L 96 25 L 96 50" stroke="currentColor" stroke-width="2" fill="none" marker-end="url(#arrowhead)"/> |
| 30 | + <path d="M 200 0 L 200 25 L 304 25 L 304 50" stroke="currentColor" stroke-width="2" fill="none" marker-end="url(#arrowhead)"/> |
| 31 | +</svg> |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +:::: {.columns} |
| 36 | +::: {.column width="48%"} |
| 37 | +$$ |
| 38 | +\begin{aligned} |
| 39 | +\max\quad & \sum_{e \in \delta^+(s)} x_e \\ |
| 40 | +\text{s.t.}\quad & \sum_{e \in \delta^+(v)} x_e = \sum_{e \in \delta^-(v)} x_e & \forall v \in V \\ |
| 41 | + & 0 \le x_e \le u_e & \forall e \in E |
| 42 | +\end{aligned} |
| 43 | +$$ |
| 44 | + |
| 45 | +::: |
| 46 | +::: {.column width="4%"} |
| 47 | +::: |
| 48 | +::: {.column width="48%"} |
| 49 | + |
| 50 | +$$ |
| 51 | +\begin{aligned} |
| 52 | +\max\quad & \sum_i v_i\, b_i \\ |
| 53 | +\text{s.t.}\quad & \sum_i w_i\, b_i \le W \\ |
| 54 | + & b_i \in \{0, 1\} && \forall i |
| 55 | +\end{aligned} |
| 56 | +$$ |
| 57 | + |
| 58 | +::: |
| 59 | +:::: |
| 60 | +:::: {.columns} |
| 61 | +::: {.column width="48%"} |
| 62 | + |
| 63 | +[Continuous Variables (Linear Programs)]{style="display:block; text-align:center;"} |
| 64 | + |
| 65 | +[*Solvable in polynomial time.*]{style="color:#6aa84f; display:block; text-align:center;"} |
| 66 | +::: |
| 67 | +::: {.column width="4%"} |
| 68 | +::: |
| 69 | +::: {.column width="48%"} |
| 70 | + |
| 71 | +[Discrete Variables (Mixed-Integer Programs)]{style="display:block; text-align:center;"} |
| 72 | + |
| 73 | +[*NP-hard in general but often tractable.*]{style="color:#c0392b; display:block; text-align:center;"} |
| 74 | +::: |
| 75 | +:::: |
| 76 | + |
| 77 | +::: {.fragment} |
| 78 | +::: {.platypus-question} |
| 79 | +For both problem classes, there are highly engineered solvers. How much can we express in each class? How do we know if it is the right technology? |
| 80 | +::: |
| 81 | +::: |
| 82 | + |
| 83 | +## The diet problem |
| 84 | + |
| 85 | +:::: {.columns} |
| 86 | + |
| 87 | +::: {.column width="38%"} |
| 88 | +$$ |
| 89 | +\begin{aligned} |
| 90 | +\min\quad & \sum_j c_j\, x_j \\ |
| 91 | +\text{s.t.}\quad & \sum_j a_{ij}\, x_j \;\ge\; b_i & \forall i \\ |
| 92 | + & x_j \ge 0 |
| 93 | +\end{aligned} |
| 94 | +$$ |
| 95 | + |
| 96 | +*Choose food quantities $x_j$ to meet every nutrient requirement $b_i$ at minimum cost. Coefficient $a_{ij}$ = nutrient $i$ per unit of food $j$.* |
| 97 | +::: |
| 98 | + |
| 99 | +::: {.column width="4%"} |
| 100 | +::: |
| 101 | + |
| 102 | +::: {.column width="58%"} |
| 103 | + |
| 104 | +::: {.compact-table} |
| 105 | +| Food $j$ | kcal | protein (g) | calcium (mg) | $c_j$ (€/unit) | |
| 106 | +|---|---:|---:|---:|---:| |
| 107 | +| Oats | 380 | 13 | 50 | 0.20 | |
| 108 | +| Milk | 150 | 8 | 300 | 0.80 | |
| 109 | +| Eggs | 80 | 7 | 30 | 0.30 | |
| 110 | +| Beans | 230 | 15 | 80 | 0.40 | |
| 111 | +| **Daily req. $b_i$** | **2000** | **50** | **800** | | |
| 112 | +::: |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +::: {.fragment} |
| 117 | +Real-world siblings: |
| 118 | + |
| 119 | +- **Feed formulation**: livestock rations from grains |
| 120 | +- **Alloy blending**: composition spec from raw metals |
| 121 | +- **Fuel mix**: octane rating from crude streams |
| 122 | +- **Fertilizer mixing**: N/P/K from base products |
| 123 | +- **Production mix**: products from limited resources |
| 124 | +::: |
| 125 | + |
| 126 | +::: |
| 127 | + |
| 128 | +:::: |
| 129 | + |
| 130 | +## Network Flow |
| 131 | + |
| 132 | +:::: {.columns} |
| 133 | + |
| 134 | +::: {.column width="48%"} |
| 135 | +$$ |
| 136 | +\min\quad \sum_{e \in E} c_e\, x_e |
| 137 | +$$ |
| 138 | +$$ |
| 139 | +\sum_{e \in \delta^-(v)} x_e - \sum_{e \in \delta^+(v)} x_e = b_v\quad \forall v \in V \\ |
| 140 | + 0 \le x_e \le u_e \quad \forall e \in E |
| 141 | +$$ |
| 142 | + |
| 143 | +{fig-align="center" width="100%"} |
| 144 | +::: |
| 145 | + |
| 146 | + |
| 147 | +::: {.column width="52%"} |
| 148 | +::: {.fragment} |
| 149 | +Real-world siblings: |
| 150 | + |
| 151 | +- **Shipping & logistics**: origins to destinations |
| 152 | +- **Telecom routing**: link capacities, endpoint demand |
| 153 | +- **Power dispatch**: generation, load, transmission |
| 154 | +- **Supply chains**: multi-stage production |
| 155 | +- **Pipeline scheduling**: capacitated arcs |
| 156 | + |
| 157 | +Special cases: **shortest path**, **max-flow**, **transportation**, **assignment**. |
| 158 | +::: |
| 159 | + |
| 160 | +--- |
| 161 | + |
| 162 | +*Edge labels: flow $x_e$ / capacity $u_e$. $b_v < 0$ supplies, $b_v > 0$ demands.* |
| 163 | +::: |
| 164 | + |
| 165 | +:::: |
| 166 | + |
| 167 | +## Matchings/Assignments |
| 168 | + |
| 169 | +:::: {.columns} |
| 170 | + |
| 171 | +::: {.column width="38%"} |
| 172 | +$$ |
| 173 | +\begin{aligned} |
| 174 | +\max\quad & \sum_{e \in E} c_e\, x_e \\ |
| 175 | +\text{s.t.}\quad & \sum_{e \in \delta(v)} x_e \;\le\; 1 && \forall v \in V \\ |
| 176 | + & x_e \in \{0,1\} |
| 177 | +\end{aligned} |
| 178 | +$$ |
| 179 | + |
| 180 | +*Pick edges of an undirected graph to maximize total weight, no two chosen edges sharing a vertex. A vertex may stay unmatched.* |
| 181 | +::: |
| 182 | + |
| 183 | +::: {.column width="4%"} |
| 184 | +::: |
| 185 | + |
| 186 | +::: {.column width="58%"} |
| 187 | +::: {.fragment} |
| 188 | +Real-world siblings: |
| 189 | + |
| 190 | +- **Roommate pairing**: dorm allocation |
| 191 | +- **Tournament rounds**: chess Swiss-style pairings |
| 192 | +- **Ride-share pairing**: two riders share a car |
| 193 | +- **Kidney exchange**: donor-recipient pairs |
| 194 | +- **Peer programming**: students paired by skill |
| 195 | +::: |
| 196 | + |
| 197 | +::: |
| 198 | + |
| 199 | +::: {.fragment} |
| 200 | +::: {.platypus-info} |
| 201 | +The basic version is polynomial, but as soon as there are interdependencies between edges or we have t-wise instead of pairwise matchings, the Blossom algorithm fails and we need MIP. |
| 202 | +::: |
| 203 | +::: |
| 204 | + |
| 205 | +:::: |
| 206 | + |
| 207 | +## Set Cover |
| 208 | + |
| 209 | +:::: {.columns} |
| 210 | + |
| 211 | +::: {.column width="38%"} |
| 212 | +$$ |
| 213 | +\begin{aligned} |
| 214 | +\min\quad & \sum_{S \in \mathcal{S}} c_S\, y_S \\ |
| 215 | +\text{s.t.}\quad & \sum_{S \ni i} y_S \;\ge\; 1 && \forall\ i\\ |
| 216 | + & y_S \in \{0,1\} |
| 217 | +\end{aligned} |
| 218 | +$$ |
| 219 | + |
| 220 | +*Pick subsets $S$ so every element $i$ is covered at least once, at minimum cost.* |
| 221 | +::: |
| 222 | + |
| 223 | +::: {.column width="4%"} |
| 224 | +::: |
| 225 | + |
| 226 | +::: {.column width="58%"} |
| 227 | +::: {.fragment} |
| 228 | +Real-world siblings: |
| 229 | + |
| 230 | +- **Crew scheduling**: duty patterns covering all flights |
| 231 | +- **Facility location**: depots covering all customer regions |
| 232 | +- **Survey routing**: routes covering all neighborhoods |
| 233 | +- **Sensor placement**: cameras covering all zones |
| 234 | +- **Vaccine outreach**: clinics covering all populations |
| 235 | +::: |
| 236 | + |
| 237 | +::: |
| 238 | + |
| 239 | +::: {.fragment} |
| 240 | +::: {.platypus-tip} |
| 241 | +Surprisingly many difficult combinatorial optimization problems turn out to be variants of Set Cover ($\geq 1$), Set Packing ($\leq 1$), or Set Partitioning ($=1$) at heart. |
| 242 | +::: |
| 243 | +::: |
| 244 | + |
| 245 | +:::: |
| 246 | + |
| 247 | +## But what if my problem has non-linear expressions? |
| 248 | + |
| 249 | +| # | Expression | $\mathrel{\hat{=}}\text{LP}$ | $\mathrel{\hat{=}}\text{MIP}$ | approx. only | |
| 250 | +|---|---|:-:|:-:|:-:| |
| 251 | +| 1 | $\min\ \max_i\, c_i^\top x_i, x\in \mathbb{R}^n$ | [✓]{.fragment} | | | |
| 252 | +| 2 | $\max\ \sum_i \lvert x_i \rvert, x\in \mathbb{R}^n$ | | [✓]{.fragment} | | | |
| 253 | +| 3 | $\min\ \sum_i \lvert x_i \rvert, x\in \mathbb{R}^n$ | [✓]{.fragment} | | | |
| 254 | +| 4 | $\min\ \sum_i x_i^2, x\in \mathbb{R}^n$ | | | [✓]{.fragment} | |
| 255 | +| 5 | $c^\top x \ge a\ \ \lor\ \ c'^\top x \le a', x\in \mathbb{R}^n$| | [✓]{.fragment} | | |
| 256 | +| 6 | $z = x\,y,\ x \in \{0,1\},\ y \in [L, U]$ | | [✓]{.fragment} | | |
| 257 | +| 7 | $z = x\,y,\ x, y \in [L, U]$ | | | [✓]{.fragment} | |
| 258 | + |
| 259 | +::: {.platypus-question} |
| 260 | +Things are not always as they seem. Which of these non-linear expressions are actually linear in disguise? |
| 261 | +::: |
| 262 | + |
| 263 | +## "All models are wrong, but some are useful." (George Box) |
| 264 | + |
| 265 | +::: {.incremental} |
| 266 | +- Modeling is a constant tension between **accuracy** and **tractability**. |
| 267 | +- LPs are one of the most benign (optimization) problem classes available. |
| 268 | + - Highly optimized solvers solving millions of variables in seconds. |
| 269 | +- Well-formulated MIPs are also often quite tractable. |
| 270 | + - In particular, if the LP relaxation is tight. |
| 271 | +- Detecting tractable modeling patterns is the **critical skill** for building useful models. |
| 272 | +::: |
| 273 | + |
| 274 | +::: {.platypus-confucypus} |
| 275 | +“Every hard problem has a weakness. |
| 276 | +The modeler’s art is to find it before the solver finds despair.” |
| 277 | + |
| 278 | +— Confucypus |
| 279 | +::: |
| 280 | + |
0 commit comments