Skip to content

Commit 9c6606d

Browse files
jstacclaude
andcommitted
Fix errors in lp_intro lecture
- Fix OR-Tools prose: x3 (bank) and x5 (bond) values were swapped in the investment strategy description. - Remove incorrect note claiming OR-Tools and SciPy give different solutions — the solution is unique. - Fix math error in slack variable transformation: RHS should be b_i, not 0. - Fix wrong comment: A_ex2/b_ex2 are equality constraints, not inequality. - Fix prose: iso-revenue lines show product combinations, not materials/labor; clarify firm's objective sentence. - Fix prose: "creates two variables" → correct for 5-variable example. - Fix grammar: "keep invest" → "keep investing", "it's" → "its", "where in" → "where". - Add missing x, y >= 0 constraint in Exercise 2 formulation. Addresses second part of #599. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3df6093 commit 9c6606d

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

lectures/lp_intro.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ $$
9696

9797
The following graph illustrates the firm's constraints and iso-revenue lines.
9898

99-
Iso-revenue lines show all the combinations of materials and labor that produce the same revenue.
99+
Iso-revenue lines show all the combinations of Product 1 and Product 2 that generate the same revenue.
100100

101101
```{code-cell} ipython3
102102
---
@@ -133,9 +133,9 @@ The blue region is the feasible set within which all constraints are satisfied.
133133

134134
Parallel black lines are iso-revenue lines.
135135

136-
The firm's objective is to find the parallel black lines to the upper boundary of the feasible set.
136+
The firm's objective is to push the iso-revenue line as high as possible while remaining in the feasible set.
137137

138-
The intersection of the feasible set and the highest black line delineates the optimal set.
138+
The intersection of the feasible set and the highest iso-revenue line delineates the optimal set.
139139

140140
In this example, the optimal set is the point $(2.5, 5)$.
141141

@@ -278,7 +278,7 @@ $$
278278

279279
Let's try to solve the above problem using the package `ortools.linear_solver`.
280280

281-
The following cell instantiates a solver and creates two variables specifying the range of values that they can have.
281+
The following cell instantiates a solver.
282282

283283
```{code-cell} ipython3
284284
# Instantiate a GLOP(Google Linear Optimization Package) solver
@@ -338,9 +338,9 @@ OR-Tools tells us that the best investment strategy is:
338338

339339
1. At the beginning of the first year, the mutual fund should buy $ \$24,927.755$ of the annuity. Its bank account balance should be $ \$75,072.245$.
340340

341-
2. At the beginning of the second year, the mutual fund should buy $ \$4,648.825$ of the corporate bond and borrow $ \$20,000$ from the bank.
341+
2. At the beginning of the second year, the mutual fund should buy $ \$50,000$ of the corporate bond and keep investing in the annuity. Its bank account balance should be $ \$4,648.825$.
342342

343-
3. At the beginning of the third year, the bank balance should be $ \$50,000$.
343+
3. At the beginning of the third year, the mutual fund should borrow $ \$20,000$ from the bank and invest in the annuity.
344344

345345
4. At the end of the third year, the mutual fund will get payouts from the annuity and corporate bond and repay its loan from the bank, leaving it with $ \$141,018.24$ and a total net rate of return over the three periods of $41.02\%$.
346346

@@ -407,7 +407,7 @@ By deploying the following steps, any linear programming problem can be transfor
407407
408408
2. Decision variables: Given a variable $x_j$ satisfying $x_j \le 0$, we can introduce a new variable $x_j' = - x_j$ and substitute it into original problem. Given a free variable $x_i$ with no restriction on its sign, we can introduce two new variables $x_j^+$ and $x_j^-$ satisfying $x_j^+, x_j^- \ge 0$ and replace $x_j$ by $x_j^+ - x_j^-$.
409409
410-
3. Inequality constraints: Given an inequality constraint $\sum_{j=1}^n a_{ij}x_j \le 0$, we can introduce a new variable $s_i$, called a **slack variable** that satisfies $s_i \ge 0$ and replace the original constraint by $\sum_{j=1}^n a_{ij}x_j + s_i = 0$.
410+
3. Inequality constraints: Given an inequality constraint $\sum_{j=1}^n a_{ij}x_j \le b_i$, we can introduce a new variable $s_i$, called a **slack variable** that satisfies $s_i \ge 0$ and replace the original constraint by $\sum_{j=1}^n a_{ij}x_j + s_i = b_i$.
411411
412412
Let's apply the above steps to the two examples described above.
413413
@@ -545,7 +545,7 @@ rate = 1.06
545545
# Objective function parameters
546546
c_ex2 = np.array([1.30*3, 0, 0, 1.06, 1.30])
547547
548-
# Inequality constraints
548+
# Equality constraints
549549
A_ex2 = np.array([[1, 1, 0, 0, 0],
550550
[1, -rate, 1, 0, 1],
551551
[1, 0, -rate, 1, 0]])
@@ -584,18 +584,13 @@ SciPy tells us that the best investment strategy is:
584584
585585
1. At the beginning of the first year, the mutual fund should buy $ \$24,927.75$ of the annuity. Its bank account balance should be $ \$75,072.25$.
586586
587-
2. At the beginning of the second year, the mutual fund should buy $ \$50,000 $ of the corporate bond and keep invest in the annuity. Its bank account balance should be $ \$ 4,648.83$.
587+
2. At the beginning of the second year, the mutual fund should buy $ \$50,000 $ of the corporate bond and keep investing in the annuity. Its bank account balance should be $ \$ 4,648.83$.
588588
589589
3. At the beginning of the third year, the mutual fund should borrow $ \$20,000$ from the bank and invest in the annuity.
590590
591-
4. At the end of the third year, the mutual fund will get payouts from the annuity and corporate bond and repay its loan from the bank. At the end it will own $ \$141,018.24 $, so that it's total net rate of return over the three periods is $ 41.02\% $.
592-
591+
4. At the end of the third year, the mutual fund will get payouts from the annuity and corporate bond and repay its loan from the bank. At the end it will own $ \$141,018.24 $, so that its total net rate of return over the three periods is $ 41.02\% $.
593592
594593
595-
```{note}
596-
You might notice the difference in the values of optimal solution using OR-Tools and SciPy but the optimal value is the same. It is because there can be many optimal solutions for the same problem.
597-
```
598-
599594
600595
601596
## Exercises
@@ -604,7 +599,7 @@ You might notice the difference in the values of optimal solution using OR-Tools
604599
:label: lp_intro_ex1
605600
```
606601
607-
Implement a new extended solution for the Problem 1 where in the factory owner decides that number of units of Product 1 should not be less than the number of units of Product 2.
602+
Implement a new extended solution for Problem 1 where the factory owner decides that the number of units of Product 1 should not be less than the number of units of Product 2.
608603
609604
```{exercise-end}
610605
```
@@ -700,6 +695,7 @@ $$
700695
\max_{x,y} \ & z = 23 x + 10 y \\
701696
\mbox{subject to } \ & x + y \le 20 \\
702697
& 2 x + 0.8 y \le 25 \\
698+
& x, y \ge 0 \\
703699
\end{aligned}
704700
$$
705701

0 commit comments

Comments
 (0)