Skip to content

Commit 226413d

Browse files
authored
DOC, FIX: Correct docstring for linprog_simplex (#778)
1 parent bbed434 commit 226413d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

quantecon/optimize/linprog_simplex.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Contain `linprog_simplex`, a Numba-jitted linear programming solver
33
based on the Simplex Method.
44
5-
The formulation of linear program `linprog_simplex` assumes is:
5+
The formulation of linear program that `linprog_simplex` assumes is:
66
77
maximize::
88
@@ -16,7 +16,7 @@
1616
1717
Examples
1818
--------
19-
1. A problem inequality constraints:
19+
1. A problem with inequality constraints:
2020
2121
.. math::
2222
@@ -49,7 +49,7 @@
4949
>>> res.lambd
5050
array([0.45, 0.25, 1.1 ])
5151
52-
2. A problem equality constraints:
52+
2. A problem with equality constraints:
5353
5454
.. math::
5555
@@ -99,27 +99,27 @@
9999
100100
.. math::
101101
102-
\max_{z_0, z_1, z_2}\ \ & z_0 + z_1 - 4z_2 \\
103-
\mbox{such that}\ \ & -3z_0 -3z_1 + z_2 \leq 9, \\
104-
& z_0 + z_1 + 2z_2 \leq -2, \\
102+
\max_{z_0, z_1, z_2}\ \ & z_0 - z_1 - 4z_2 \\
103+
\mbox{such that}\ \ & -3z_0 + 3z_1 + z_2 \leq 9, \\
104+
& z_0 - z_1 + 2z_2 \leq 10, \\
105105
& z_0, z_1, z_2 \geq 0.
106106
107107
Solve the latter problem with `linprog_simplex`:
108108
109-
>>> c = np.array([1, 1, -4])
110-
>>> A = np.array([[-3, -3, 1], [1, 1, 2]])
109+
>>> c = np.array([1, -1, -4])
110+
>>> A = np.array([[-3, 3, 1], [1, -1, 2]])
111111
>>> b = np.array([9, 10])
112112
>>> res = linprog_simplex(c, A_ub=A, b_ub=b)
113113
114114
The optimal value of the original problem:
115115
116-
>>> -(res.fun + 12) # -(z_0 + z_1 - 4 (z_2 - 3))
117-
-22.0
116+
>>> -(res.fun + 12) # -(z_0 - z_1 - 4 (z_2 - 3))
117+
-21.999999999999996
118118
119119
And the solution found:
120120
121121
>>> res.x[0] - res.x[1], res.x[2] - 3 # (z_0 - z_1, z_2 - 3)
122-
(10.0, -3.0)
122+
(np.float64(9.999999999999998), np.float64(-3.0))
123123
124124
"""
125125
from collections import namedtuple
@@ -192,7 +192,7 @@ def linprog_simplex(c, A_ub=np.empty((0, 0)), b_ub=np.empty((0,)),
192192
ndarray of shape (k,).
193193
194194
max_iter : int, optional(default=10**6)
195-
Maximum number of iteration to perform.
195+
Maximum number of iterations to perform.
196196
197197
piv_options : PivOptions, optional
198198
PivOptions namedtuple to set the following tolerance values:
@@ -204,7 +204,7 @@ def linprog_simplex(c, A_ub=np.empty((0, 0)), b_ub=np.empty((0,)),
204204
Pivot tolerance (default={TOL_PIV}).
205205
206206
tol_ratio_diff : float
207-
Tolerance used in the the lexicographic pivoting
207+
Tolerance used in the lexicographic pivoting
208208
(default={TOL_RATIO_DIFF}).
209209
210210
tableau : ndarray(float, ndim=2), optional

0 commit comments

Comments
 (0)