Skip to content

Commit 6d20b1f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2ef70b0 commit 6d20b1f

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

linear_programming/simplex.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ def find_pivot(self) -> tuple[int, int]:
7373

7474
nans = np.full(self.n_rows - self.n_stages, np.nan)
7575

76-
quotients = np.divide(
77-
dividend, divisor, out=nans, where=divisor > 0
78-
)
76+
quotients = np.divide(dividend, divisor, out=nans, where=divisor > 0)
7977

8078
row_idx = int(np.nanargmin(quotients) + self.n_stages)
8179
return row_idx, col_idx
@@ -125,7 +123,6 @@ def run_simplex(self) -> Dict[str, float]:
125123
"""
126124

127125
for iteration in range(Tableau.maxiter):
128-
129126
if not self.objectives:
130127
return self.interpret_tableau()
131128

@@ -143,23 +140,20 @@ def run_simplex(self) -> Dict[str, float]:
143140
)
144141

145142
def interpret_tableau(self) -> Dict[str, float]:
146-
output: Dict[str, float] = {
147-
"P": float(abs(self.tableau[0, -1]))
148-
}
143+
output: Dict[str, float] = {"P": float(abs(self.tableau[0, -1]))}
149144

150145
for i in range(self.n_vars):
151146
nonzero = np.nonzero(self.tableau[:, i])[0]
152147

153148
if len(nonzero) == 1:
154149
row = nonzero[0]
155150
if self.tableau[row, i] == 1:
156-
output[self.col_titles[i]] = float(
157-
self.tableau[row, -1]
158-
)
151+
output[self.col_titles[i]] = float(self.tableau[row, -1])
159152

160153
return output
161154

162155

163156
if __name__ == "__main__":
164157
import doctest
165-
doctest.testmod()
158+
159+
doctest.testmod()

0 commit comments

Comments
 (0)