You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 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>
Copy file name to clipboardExpand all lines: lectures/lp_intro.md
+12-16Lines changed: 12 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ $$
96
96
97
97
The following graph illustrates the firm's constraints and iso-revenue lines.
98
98
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.
100
100
101
101
```{code-cell} ipython3
102
102
---
@@ -133,9 +133,9 @@ The blue region is the feasible set within which all constraints are satisfied.
133
133
134
134
Parallel black lines are iso-revenue lines.
135
135
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.
137
137
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.
139
139
140
140
In this example, the optimal set is the point $(2.5, 5)$.
141
141
@@ -278,7 +278,7 @@ $$
278
278
279
279
Let's try to solve the above problem using the package `ortools.linear_solver`.
280
280
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.
282
282
283
283
```{code-cell} ipython3
284
284
# Instantiate a GLOP(Google Linear Optimization Package) solver
@@ -338,9 +338,9 @@ OR-Tools tells us that the best investment strategy is:
338
338
339
339
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$.
340
340
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$.
342
342
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.
344
344
345
345
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\%$.
346
346
@@ -407,7 +407,7 @@ By deploying the following steps, any linear programming problem can be transfor
407
407
408
408
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^-$.
409
409
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$.
411
411
412
412
Let's apply the above steps to the two examples described above.
413
413
@@ -545,7 +545,7 @@ rate = 1.06
545
545
# Objective function parameters
546
546
c_ex2 = np.array([1.30*3, 0, 0, 1.06, 1.30])
547
547
548
-
# Inequality constraints
548
+
# Equality constraints
549
549
A_ex2 = np.array([[1, 1, 0, 0, 0],
550
550
[1, -rate, 1, 0, 1],
551
551
[1, 0, -rate, 1, 0]])
@@ -584,18 +584,13 @@ SciPy tells us that the best investment strategy is:
584
584
585
585
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$.
586
586
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$.
588
588
589
589
3. At the beginning of the third year, the mutual fund should borrow $ \$20,000$ from the bank and invest in the annuity.
590
590
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\% $.
593
592
594
593
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
-
599
594
600
595
601
596
## Exercises
@@ -604,7 +599,7 @@ You might notice the difference in the values of optimal solution using OR-Tools
604
599
:label: lp_intro_ex1
605
600
```
606
601
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.
0 commit comments