12
12
13
13
14
14
@jit (nopython = True , cache = True )
15
- def _pivoting (tableau , pivot , pivot_row ):
15
+ def _pivoting (tableau , pivot_col , pivot_row ):
16
16
"""
17
17
Perform a pivoting step. Modify `tableau` in place.
18
18
@@ -21,8 +21,8 @@ def _pivoting(tableau, pivot, pivot_row):
21
21
tableau : ndarray(float, ndim=2)
22
22
Array containing the tableau.
23
23
24
- pivot : scalar(int)
25
- Pivot.
24
+ pivot_col : scalar(int)
25
+ Pivot column index .
26
26
27
27
pivot_row : scalar(int)
28
28
Pivot row index.
@@ -35,14 +35,14 @@ def _pivoting(tableau, pivot, pivot_row):
35
35
"""
36
36
nrows , ncols = tableau .shape
37
37
38
- pivot_elt = tableau [pivot_row , pivot ]
38
+ pivot_elt = tableau [pivot_row , pivot_col ]
39
39
for j in range (ncols ):
40
40
tableau [pivot_row , j ] /= pivot_elt
41
41
42
42
for i in range (nrows ):
43
43
if i == pivot_row :
44
44
continue
45
- multiplier = tableau [i , pivot ]
45
+ multiplier = tableau [i , pivot_col ]
46
46
if multiplier == 0 :
47
47
continue
48
48
for j in range (ncols ):
@@ -53,7 +53,8 @@ def _pivoting(tableau, pivot, pivot_row):
53
53
54
54
@jit (nopython = True , cache = True )
55
55
def _min_ratio_test_no_tie_breaking (tableau , pivot , test_col ,
56
- argmins , num_candidates ):
56
+ argmins , num_candidates ,
57
+ tol_piv , tol_ratio_diff ):
57
58
"""
58
59
Perform the minimum ratio test, without tie breaking, for the
59
60
candidate rows in `argmins[:num_candidates]`. Return the number
@@ -78,6 +79,13 @@ def _min_ratio_test_no_tie_breaking(tableau, pivot, test_col,
78
79
num_candidates : scalar(int)
79
80
Number of candidate rows in `argmins`.
80
81
82
+ tol_piv : scalar(float)
83
+ Pivot tolerance below which a number is considered to be
84
+ nonpositive.
85
+
86
+ tol_ratio_diff : scalar(float)
87
+ Tolerance to determine a tie between ratio values.
88
+
81
89
Returns
82
90
-------
83
91
num_argmins : scalar(int)
@@ -89,12 +97,12 @@ def _min_ratio_test_no_tie_breaking(tableau, pivot, test_col,
89
97
90
98
for k in range (num_candidates ):
91
99
i = argmins [k ]
92
- if tableau [i , pivot ] <= TOL_PIV : # Treated as nonpositive
100
+ if tableau [i , pivot ] <= tol_piv : # Treated as nonpositive
93
101
continue
94
102
ratio = tableau [i , test_col ] / tableau [i , pivot ]
95
- if ratio > ratio_min + TOL_RATIO_DIFF : # Ratio large for i
103
+ if ratio > ratio_min + tol_ratio_diff : # Ratio large for i
96
104
continue
97
- elif ratio < ratio_min - TOL_RATIO_DIFF : # Ratio smaller for i
105
+ elif ratio < ratio_min - tol_ratio_diff : # Ratio smaller for i
98
106
ratio_min = ratio
99
107
num_argmins = 1
100
108
else : # Ratio equal
@@ -105,7 +113,8 @@ def _min_ratio_test_no_tie_breaking(tableau, pivot, test_col,
105
113
106
114
107
115
@jit (nopython = True , cache = True )
108
- def _lex_min_ratio_test (tableau , pivot , slack_start , argmins ):
116
+ def _lex_min_ratio_test (tableau , pivot , slack_start , argmins ,
117
+ tol_piv = TOL_PIV , tol_ratio_diff = TOL_RATIO_DIFF ):
109
118
"""
110
119
Perform the lexico-minimum ratio test.
111
120
@@ -124,6 +133,14 @@ def _lex_min_ratio_test(tableau, pivot, slack_start, argmins):
124
133
Empty array used to store the row indices. Its length must be no
125
134
smaller than the number of the rows of `tableau`.
126
135
136
+ tol_piv : scalar(float), optional
137
+ Pivot tolerance below which a number is considered to be
138
+ nonpositive. Default value is {TOL_PIV}.
139
+
140
+ tol_ratio_diff : scalar(float), optional
141
+ Tolerance to determine a tie between ratio values. Default value
142
+ is {TOL_RATIO_DIFF}.
143
+
127
144
Returns
128
145
-------
129
146
found : bool
@@ -142,17 +159,25 @@ def _lex_min_ratio_test(tableau, pivot, slack_start, argmins):
142
159
for i in range (nrows ):
143
160
argmins [i ] = i
144
161
145
- num_argmins = _min_ratio_test_no_tie_breaking (tableau , pivot , - 1 ,
146
- argmins , num_candidates )
162
+ num_argmins = _min_ratio_test_no_tie_breaking (
163
+ tableau , pivot , - 1 , argmins , num_candidates , tol_piv , tol_ratio_diff
164
+ )
147
165
if num_argmins == 1 :
148
166
found = True
149
167
elif num_argmins >= 2 :
150
168
for j in range (slack_start , slack_start + nrows ):
151
169
if j == pivot :
152
170
continue
153
- num_argmins = _min_ratio_test_no_tie_breaking (tableau , pivot , j ,
154
- argmins , num_argmins )
171
+ num_argmins = _min_ratio_test_no_tie_breaking (
172
+ tableau , pivot , j , argmins , num_argmins ,
173
+ tol_piv , tol_ratio_diff
174
+ )
155
175
if num_argmins == 1 :
156
176
found = True
157
177
break
158
178
return found , argmins [0 ]
179
+
180
+
181
+ _lex_min_ratio_test .__doc__ = _lex_min_ratio_test .__doc__ .format (
182
+ TOL_PIV = TOL_PIV , TOL_RATIO_DIFF = TOL_RATIO_DIFF
183
+ )
0 commit comments