changed n_slack calculation method

This commit is contained in:
imengus 2023-06-27 23:12:11 +01:00
parent 4bbae6bf7c
commit de6cb052a0

View File

@ -34,7 +34,7 @@ class Tableau:
raise ValueError("RHS must be > 0") raise ValueError("RHS must be > 0")
self.tableau = tableau self.tableau = tableau
self.n_rows, _ = tableau.shape self.n_rows, n_cols = tableau.shape
# Number of decision variables x1, x2, x3... # Number of decision variables x1, x2, x3...
self.n_vars, self.n_art_vars = n_vars, n_art_vars self.n_vars, self.n_art_vars = n_vars, n_art_vars
@ -47,7 +47,7 @@ class Tableau:
self.n_stages = (self.n_art_vars > 0) + 1 self.n_stages = (self.n_art_vars > 0) + 1
# Number of slack variables added to make inequalities into equalities # Number of slack variables added to make inequalities into equalities
self.n_slack = self.n_rows - self.n_stages self.n_slack = n_cols - self.n_vars - self.n_art_vars - 1
# Objectives for each stage # Objectives for each stage
self.objectives = ["max"] self.objectives = ["max"]
@ -115,7 +115,7 @@ class Tableau:
# Array filled with nans # Array filled with nans
nans = np.full(self.n_rows - self.n_stages, np.nan) nans = np.full(self.n_rows - self.n_stages, np.nan)
# If element in pivot column is greater than zeron_stages, return # If element in pivot column is greater than zero, return
# quotient or nan otherwise # quotient or nan otherwise
quotients = np.divide(dividend, divisor, out=nans, where=divisor > 0) quotients = np.divide(dividend, divisor, out=nans, where=divisor > 0)