Skip to content

Commit a79a3bb

Browse files
committed
minor changes
1 parent 265e65b commit a79a3bb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lectures/opt_transport.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ While the two LP solvers use different algorithms (HiGHS vs. simplex), both shou
513513
The solutions differs since there are multiple optimal solutions, but the objective values are the same
514514
515515
```{code-cell} ipython3
516-
- res_qe.fun == res.fun
516+
np.allclose(- res_qe.fun, res.fun)
517517
```
518518
519519
```{code-cell} ipython3
@@ -538,6 +538,10 @@ Let's do a speed comparison between `scipy.optimize.linprog` and `quantecon.opti
538538
539539
As you can see, the `quantecon.optimize.linprog_simplex` is much faster.
540540
541+
(Note however, that the SciPy version is probably more stable than the
542+
QuantEcon version, having been tested more extensively over a longer period of
543+
time.)
544+
541545
## The Dual Problem
542546
543547
Let $u, v$ denotes vectors of dual decision variables with entries $(u_i), (v_j)$.
@@ -591,15 +595,15 @@ print("u:", res_dual.x[:m])
591595
print("v:", res_dual.x[-n:])
592596
```
593597
594-
Fortunately, `quantecon.optimize.linprog_simplex` already computes and returns the dual variables alongside the primal solution, eliminating the need for a separate dual solve.
598+
`quantecon.optimize.linprog_simplex` computes and returns the dual variables alongside the primal solution.
595599
596600
The dual variables (shadow prices) can be extracted directly from the primal solution:
597601
598602
```{code-cell} ipython3
599-
# The dual variables are returned automatically by linprog_simplex
603+
# The dual variables are returned by linprog_simplex
600604
print("Dual variables from linprog_simplex:")
601-
print("u (factory shadow prices):", -res_qe.lambd[:m])
602-
print("v (location shadow prices):", -res_qe.lambd[m:])
605+
print("u:", -res_qe.lambd[:m])
606+
print("v:", -res_qe.lambd[m:])
603607
```
604608
605609
We can verify these match the dual solution from SciPy:

0 commit comments

Comments
 (0)