Skip to content

Commit 6d19e45

Browse files
committed
adjust some math for lp_intro for aligned
1 parent fe6b9cf commit 6d19e45

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

lectures/lp_intro.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ Let $x_i$ denote the quantity of Product $i$ that the firm produces.
118118
This problem can be formulated as:
119119
120120
$$
121-
\begin{align*}
121+
\begin{aligned}
122122
\max_{x_1,x_2} \ & z = 3 x_1 + 4 x_2 \\
123123
\mbox{subject to } \ & 2 x_1 + 5 x_2 \le 30 \\
124124
& 4 x_1 + 2 x_2 \le 20 \\
125125
& x_1, x_2 \ge 0 \\
126-
\end{align*}
126+
\end{aligned}
127127
$$
128128
129129
The following graph illustrates the firm's constraints and iso-revenue lines.
@@ -240,7 +240,7 @@ $$
240240
Thus, the mutual fund confronts the linear program:
241241
242242
$$
243-
\begin{align*}
243+
\begin{aligned}
244244
\max_{x} \ & 1.30 \cdot 3x_1 + 1.06 x_4 + 1.30 x_5 \\
245245
\mbox{subject to } \ & x_1 + x_2 = 100,000\\
246246
& x_1 - 1.06 x_2 + x_3 + x_5 = 0\\
@@ -251,7 +251,7 @@ $$
251251
& x_5 \le 50,000\\
252252
& x_j \ge 0, \quad j = 1,5\\
253253
& x_j \ \text{unrestricted}, \quad j = 2,3,4\\
254-
\end{align*}
254+
\end{aligned}
255255
$$
256256
257257
## Standard Form
@@ -267,14 +267,14 @@ it is useful to devote some effort to describe a **standard form**.
267267
Our standard form is:
268268
269269
$$
270-
\begin{align*}
270+
\begin{aligned}
271271
\min_{x} \ & c_1 x_1 + c_2 x_2 + \dots + c_n x_n \\
272272
\mbox{subject to } \ & a_{11} x_1 + a_{12} x_2 + \dots + a_{1n} x_n = b_1 \\
273273
& a_{21} x_1 + a_{22} x_2 + \dots + a_{2n} x_n = b_2 \\
274274
& \quad \vdots \\
275275
& a_{m1} x_1 + a_{m2} x_2 + \dots + a_{mn} x_n = b_m \\
276276
& x_1, x_2, \dots, x_n \ge 0 \\
277-
\end{align*}
277+
\end{aligned}
278278
$$
279279
280280
Let
@@ -294,11 +294,11 @@ $$
294294
The standard form LP problem can be expressed concisely as:
295295
296296
$$
297-
\begin{align*}
297+
\begin{aligned}
298298
\min_{x} \ & c'x \\
299299
\mbox{subject to } \ & Ax = b\\
300300
& x >= 0\\
301-
\end{align*}
301+
\end{aligned}
302302
$$ (lpproblem)
303303
304304
Here, $Ax = b$ means that the $i$-th entry of $Ax$ equals the $i$-th entry of $b$ for every $i$.
@@ -324,31 +324,31 @@ Let's apply the above steps to the two examples described above.
324324
The original problem is:
325325
326326
$$
327-
\begin{align*}
327+
\begin{aligned}
328328
\max_{x_1,x_2} \ & 3 x_1 + 4 x_2 \\
329329
\mbox{subject to } \ & 2 x_1 + 5 x_2 \le 30 \\
330330
& 4 x_1 + 2 x_2 \le 20 \\
331331
& x_1, x_2 \ge 0 \\
332-
\end{align*}
332+
\end{aligned}
333333
$$
334334
335335
This problem is equivalent to the following problem with a standard form:
336336
337337
$$
338-
\begin{align*}
338+
\begin{aligned}
339339
\min_{x_1,x_2} \ & -(3 x_1 + 4 x_2) \\
340340
\mbox{subject to } \ & 2 x_1 + 5 x_2 + s_1 = 30 \\
341341
& 4 x_1 + 2 x_2 + s_2 = 20 \\
342342
& x_1, x_2, s_1, s_2 \ge 0 \\
343-
\end{align*}
343+
\end{aligned}
344344
$$
345345
346346
### Example 2: Investment Problem
347347
348348
The original problem is:
349349
350350
$$
351-
\begin{align*}
351+
\begin{aligned}
352352
\max_{x} \ & 1.30 \cdot 3x_1 + 1.06 x_4 + 1.30 x_5 \\
353353
\mbox{subject to } \ & x_1 + x_2 = 100,000\\
354354
& x_1 - 1.06 x_2 + x_3 + x_5 = 0\\
@@ -359,13 +359,13 @@ $$
359359
& x_5 \le 50,000\\
360360
& x_j \ge 0, \quad j = 1,5\\
361361
& x_j \ \text{unrestricted}, \quad j = 2,3,4\\
362-
\end{align*}
362+
\end{aligned}
363363
$$
364364
365365
This problem is equivalent to the following problem with a standard form:
366366
367367
$$
368-
\begin{align*}
368+
\begin{aligned}
369369
\min_{x} \ & -(1.30 \cdot 3x_1 + 1.06 x_4^+ - 1.06 x_4^- + 1.30 x_5) \\
370370
\mbox{subject to } \ & x_1 + x_2^+ - x_2^- = 100,000\\
371371
& x_1 - 1.06 (x_2^+ - x_2^-) + x_3^+ - x_3^- + x_5 = 0\\
@@ -377,20 +377,20 @@ $$
377377
& x_j \ge 0, \quad j = 1,5\\
378378
& x_j^+, x_j^- \ge 0, \quad j = 2,3,4\\
379379
& s_j \ge 0, \quad j = 1,2,3,4\\
380-
\end{align*}
380+
\end{aligned}
381381
$$
382382
383383
## Computations
384384
385385
The package *scipy.optimize* provides a function ***linprog*** to solve linear programming problems with a form below:
386386
387387
$$
388-
\begin{align*}
388+
\begin{aligned}
389389
\min_{x} \ & c' x \\
390390
\mbox{subject to } \ & A_{ub}x \le b_{ub} \\
391391
& A_{eq}x = b_{eq} \\
392392
& l \le x \le u \\
393-
\end{align*}
393+
\end{aligned}
394394
$$
395395
396396
```{note}
@@ -404,12 +404,12 @@ Let's apply this great Python tool to solve our two example problems.
404404
The problem is:
405405
406406
$$
407-
\begin{align*}
407+
\begin{aligned}
408408
\max_{x_1,x_2} \ & 3 x_1 + 4 x_2 \\
409409
\mbox{subject to } \ & 2 x_1 + 5 x_2 \le 30 \\
410410
& 4 x_1 + 2 x_2 \le 20 \\
411411
& x_1, x_2 \ge 0 \\
412-
\end{align*}
412+
\end{aligned}
413413
$$
414414
415415
```{code-cell} ipython3
@@ -449,7 +449,7 @@ This problem is to maximize the objective, so that we need to put a minus sign i
449449
The problem is:
450450
451451
$$
452-
\begin{align*}
452+
\begin{aligned}
453453
\max_{x} \ & 1.30 \cdot 3x_1 + 1.06 x_4 + 1.30 x_5 \\
454454
\mbox{subject to } \ & x_1 + x_2 = 100,000\\
455455
& x_1 - 1.06 x_2 + x_3 + x_5 = 0\\
@@ -460,7 +460,7 @@ $$
460460
& x_5 \le 50,000\\
461461
& x_j \ge 0, \quad j = 1,5\\
462462
& x_j \ \text{unrestricted}, \quad j = 2,3,4\\
463-
\end{align*}
463+
\end{aligned}
464464
$$
465465
466466
Let's solve this problem using *linprog*.
@@ -508,15 +508,15 @@ Associated with a linear programming of form {eq}`linprog` with $m$ constraints
508508
there is an **dual** linear programming problem that takes the form (please see {cite}`bertsimas_tsitsiklis1997`)
509509
510510
$$
511-
\begin{align*}
511+
\begin{aligned}
512512
\max_{p} \ & b' p \\
513513
\mbox{subject to } \ & p_i \ge 0, & i \in M_1 \\
514514
& p_i \le 0, & i \in M_2 \\
515515
& p_i\ \text{unrestricted}, & i \in M_3 \\
516516
& A_j' p \le c_j, & j \in N_1 \\
517517
& A_j' p \ge c_j, & j \in N_2 \\
518518
& A_j' p = c_j, & j \in N_3 \\
519-
\end{align*}
519+
\end{aligned}
520520
$$
521521
522522
Where $A_j$ is $j$-th column of the $m$ by $n$ matrix $A$.
@@ -562,30 +562,30 @@ The following table summarizes relationships between objects in primal and dual
562562
As an example, the dual problem of the standard form {eq}`lpproblem` is:
563563
564564
$$
565-
\begin{align*}
565+
\begin{aligned}
566566
\max_{p} \ & b'p \\
567567
\mbox{subject to } \ & A'p \le c\\
568-
\end{align*}
568+
\end{aligned}
569569
$$
570570
571571
As another example, consider a linear programming problem with form:
572572
573573
$$
574-
\begin{align*}
574+
\begin{aligned}
575575
\max_{x} \ & c'x \\
576576
\mbox{subject to } \ & A x \le b\\
577577
& x \ge 0\\
578-
\end{align*}
578+
\end{aligned}
579579
$$ (linprog2)
580580
581581
Its dual problem is:
582582
583583
$$
584-
\begin{align*}
584+
\begin{aligned}
585585
\min_{p} \ & b'p \\
586586
\mbox{subject to } \ & A' p \ge c\\
587587
& p \ge 0\\
588-
\end{align*}
588+
\end{aligned}
589589
$$
590590
591591
## Duality Theorems
@@ -690,12 +690,12 @@ This problem is one specific instance of the problem {eq}`linprog2`, whose econo
690690
Its dual problem is:
691691
692692
$$
693-
\begin{align*}
693+
\begin{aligned}
694694
\min_{x_1,x_2} \ & 30 p_1 + 20 p_2 \\
695695
\mbox{subject to } \ & 2 p_1 + 4 p_2 \ge 3 \\
696696
& 5 p_1 + 2 p_2 \ge 4 \\
697697
& p_1, p_2 \ge 0 \\
698-
\end{align*}
698+
\end{aligned}
699699
$$
700700
701701
We then solve this dual problem by function *linprog*. Since parameters used here are defined before when solving the primal problem, we don't need to define them here.
@@ -714,7 +714,7 @@ The optimal of the dual problem is 27.5, which is the same as the primal problem
714714
The dual problem is:
715715
716716
$$
717-
\begin{align*}
717+
\begin{aligned}
718718
\min_{p} \ & 100,000 p_1 - 20,000 p_4 - 20,000 p_5 - 20,000 p_6 + 50,000 p_7 \\
719719
\mbox{subject to } \ & p_1 + p_2 + p_3 \ge 1.30 \cdot 3 \\
720720
& p_1 - 1.06 p_2 + p_4 = 0 \\
@@ -724,7 +724,7 @@ $$
724724
& p_i \ \text{unrestricted}, \quad i = 1,2,3 \\
725725
& p_i \le 0, \quad i = 4,5,6 \\
726726
& p_7 \ge 0 \\
727-
\end{align*}
727+
\end{aligned}
728728
$$
729729
730730
We then solve this dual problem by function *linprog*.

0 commit comments

Comments
 (0)