@@ -107,8 +107,8 @@ def generate_col_titles(self) -> list[str]:
107107
108108 def find_pivot (self ) -> tuple [Any , Any ]:
109109 """Finds the pivot row and column.
110- >>> Tableau(np.array([[-2,1,0,0,0], [3,1,1,0,6], [1,2,0,1,7.]]) ,
111- ... 2, 0).find_pivot()
110+ >>> tuple(int(x) for x in Tableau(np.array([[-2,1,0,0,0], [3,1,1,0,6],
111+ ... [1,2,0,1,7.]]), 2, 0).find_pivot() )
112112 (1, 0)
113113 """
114114 objective = self .objectives [- 1 ]
@@ -215,56 +215,56 @@ def run_simplex(self) -> dict[Any, Any]:
215215 Max: x1 + x2
216216 ST: x1 + 3x2 <= 4
217217 3x1 + x2 <= 4
218- >>> Tableau(np.array([[-1,-1,0,0,0],[1,3,1,0,4],[3,1,0,1,4.]]) ,
219- ... 2, 0).run_simplex()
218+ >>> {key: float(value) for key, value in Tableau(np.array([[-1,-1,0,0,0],
219+ ... [1,3,1,0,4],[3,1,0,1,4.]]), 2, 0).run_simplex().items()}
220220 {'P': 2.0, 'x1': 1.0, 'x2': 1.0}
221221
222222 # Standard linear program with 3 variables:
223223 Max: 3x1 + x2 + 3x3
224224 ST: 2x1 + x2 + x3 ≤ 2
225225 x1 + 2x2 + 3x3 ≤ 5
226226 2x1 + 2x2 + x3 ≤ 6
227- >>> Tableau(np.array([
227+ >>> {key: float(value) for key, value in Tableau(np.array([
228228 ... [-3,-1,-3,0,0,0,0],
229229 ... [2,1,1,1,0,0,2],
230230 ... [1,2,3,0,1,0,5],
231231 ... [2,2,1,0,0,1,6.]
232- ... ]),3,0).run_simplex() # doctest: +ELLIPSIS
232+ ... ]),3,0).run_simplex().items()} # doctest: +ELLIPSIS
233233 {'P': 5.4, 'x1': 0.199..., 'x3': 1.6}
234234
235235
236236 # Optimal tableau input:
237- >>> Tableau(np.array([
237+ >>> {key: float(value) for key, value in Tableau(np.array([
238238 ... [0, 0, 0.25, 0.25, 2],
239239 ... [0, 1, 0.375, -0.125, 1],
240240 ... [1, 0, -0.125, 0.375, 1]
241- ... ]), 2, 0).run_simplex()
241+ ... ]), 2, 0).run_simplex().items()}
242242 {'P': 2.0, 'x1': 1.0, 'x2': 1.0}
243243
244244 # Non-standard: >= constraints
245245 Max: 2x1 + 3x2 + x3
246246 ST: x1 + x2 + x3 <= 40
247247 2x1 + x2 - x3 >= 10
248248 - x2 + x3 >= 10
249- >>> Tableau(np.array([
249+ >>> {key: float(value) for key, value in Tableau(np.array([
250250 ... [2, 0, 0, 0, -1, -1, 0, 0, 20],
251251 ... [-2, -3, -1, 0, 0, 0, 0, 0, 0],
252252 ... [1, 1, 1, 1, 0, 0, 0, 0, 40],
253253 ... [2, 1, -1, 0, -1, 0, 1, 0, 10],
254254 ... [0, -1, 1, 0, 0, -1, 0, 1, 10.]
255- ... ]), 3, 2).run_simplex()
255+ ... ]), 3, 2).run_simplex().items()}
256256 {'P': 70.0, 'x1': 10.0, 'x2': 10.0, 'x3': 20.0}
257257
258258 # Non standard: minimisation and equalities
259259 Min: x1 + x2
260260 ST: 2x1 + x2 = 12
261261 6x1 + 5x2 = 40
262- >>> Tableau(np.array([
262+ >>> {key: float(value) for key, value in Tableau(np.array([
263263 ... [8, 6, 0, 0, 52],
264264 ... [1, 1, 0, 0, 0],
265265 ... [2, 1, 1, 0, 12],
266266 ... [6, 5, 0, 1, 40.],
267- ... ]), 2, 2).run_simplex()
267+ ... ]), 2, 2).run_simplex().items()}
268268 {'P': 7.0, 'x1': 5.0, 'x2': 2.0}
269269
270270
@@ -275,15 +275,15 @@ def run_simplex(self) -> dict[Any, Any]:
275275 2x1 + 4x2 <= 48
276276 x1 + x2 >= 10
277277 x1 >= 2
278- >>> Tableau(np.array([
278+ >>> {key: float(value) for key, value in Tableau(np.array([
279279 ... [2, 1, 0, 0, 0, -1, -1, 0, 0, 12.0],
280280 ... [-8, -6, 0, 0, 0, 0, 0, 0, 0, 0.0],
281281 ... [1, 3, 1, 0, 0, 0, 0, 0, 0, 33.0],
282282 ... [4, 2, 0, 1, 0, 0, 0, 0, 0, 60.0],
283283 ... [2, 4, 0, 0, 1, 0, 0, 0, 0, 48.0],
284284 ... [1, 1, 0, 0, 0, -1, 0, 1, 0, 10.0],
285285 ... [1, 0, 0, 0, 0, 0, -1, 0, 1, 2.0]
286- ... ]), 2, 2).run_simplex() # doctest: +ELLIPSIS
286+ ... ]), 2, 2).run_simplex().items()} # doctest: +ELLIPSIS
287287 {'P': 132.0, 'x1': 12.000... 'x2': 5.999...}
288288 """
289289 # Stop simplex algorithm from cycling.
@@ -307,11 +307,11 @@ def run_simplex(self) -> dict[Any, Any]:
307307 def interpret_tableau (self ) -> dict [str , float ]:
308308 """Given the final tableau, add the corresponding values of the basic
309309 decision variables to the `output_dict`
310- >>> Tableau(np.array([
310+ >>> {key: float(value) for key, value in Tableau(np.array([
311311 ... [0,0,0.875,0.375,5],
312312 ... [0,1,0.375,-0.125,1],
313313 ... [1,0,-0.125,0.375,1]
314- ... ]),2, 0).interpret_tableau()
314+ ... ]),2, 0).interpret_tableau().items()}
315315 {'P': 5.0, 'x1': 1.0, 'x2': 1.0}
316316 """
317317 # P = RHS of final tableau
0 commit comments