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
Copy file name to clipboardExpand all lines: lectures/lp_intro.md
+10-16Lines changed: 10 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,6 @@ jupytext:
3
3
text_representation:
4
4
extension: .md
5
5
format_name: myst
6
-
format_version: 0.13
7
-
jupytext_version: 1.14.4
8
6
kernelspec:
9
7
display_name: Python 3 (ipykernel)
10
8
language: python
@@ -53,7 +51,7 @@ from matplotlib.patches import Polygon
53
51
54
52
Let's start with some examples of linear programming problem.
55
53
56
-
+++
54
+
57
55
58
56
## Example 1: Production Problem
59
57
@@ -141,13 +139,13 @@ The intersection of the feasible set and the highest orange line delineates the
141
139
142
140
In this example, the optimal set is the point $(2.5, 5)$.
143
141
144
-
+++
142
+
145
143
146
144
### Computation: Using OR-Tools
147
145
148
146
Let's try to solve the same problem using the package *ortools.linear_solver*
149
147
150
-
+++
148
+
151
149
152
150
The following cell instantiates a solver and creates two variables specifying the range of values that they can have.
153
151
@@ -276,7 +274,7 @@ $$
276
274
\end{aligned}
277
275
$$
278
276
279
-
+++
277
+
280
278
281
279
### Computation: Using OR-Tools
282
280
@@ -348,7 +346,7 @@ OR-Tools tells us that the best investment strategy is:
348
346
349
347
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 $ \$141018.24 $, so that it's total net rate of return over the three periods is $ 41.02\%$.
350
348
351
-
+++
349
+
352
350
353
351
## Standard Form
354
352
@@ -439,7 +437,7 @@ $$
439
437
\end{aligned}
440
438
$$
441
439
442
-
+++
440
+
443
441
444
442
### Computation: Using SciPy
445
443
@@ -501,7 +499,7 @@ See the [official documentation](https://docs.scipy.org/doc/scipy/reference/gene
501
499
This problem is to maximize the objective, so that we need to put a minus sign in front of parameter vector c.
502
500
```
503
501
504
-
+++
502
+
505
503
506
504
### Example 2: Investment Problem
507
505
@@ -592,27 +590,25 @@ SciPy tells us that the best investment strategy is:
592
590
593
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 $ \$141018.24 $, so that it's total net rate of return over the three periods is $ 41.02\% $.
594
592
595
-
+++
593
+
596
594
597
595
```{note}
598
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.
599
597
```
600
598
601
-
+++
599
+
602
600
603
601
## Exercises
604
602
605
603
```{exercise-start}
606
604
:label: ex1
607
605
```
608
606
609
-
### Exercise 1
610
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.
611
608
612
609
```{exercise-end}
613
610
```
614
611
615
-
+++
616
612
617
613
```{solution-start} ex1
618
614
:class: dropdown
@@ -675,8 +671,6 @@ else:
675
671
```{exercise-start}
676
672
:label: ex2
677
673
```
678
-
### Exercise 2
679
-
680
674
681
675
A carpenter manufactures $2$ products - $A$ and $B$.
682
676
@@ -692,7 +686,7 @@ Find the number of units of $A$ and product $B$ that he should manufacture in or
0 commit comments