diff --git a/src/simplexe.py b/src/simplexe.py index 3ea1807f6640c49432c881d70d2f3298184a2f6c..698f96a604f2476422a6b45125cb3d867547800c 100644 --- a/src/simplexe.py +++ b/src/simplexe.py @@ -311,39 +311,39 @@ class Simplexe: # rowCount = self.TableauRowCount - 2 if self.IsPhaseI else self.TableauRowCount - 1 # for index in range(rowCount): - rowCount = self.TableauRowCount - 2 if self.IsPhaseI else \ - self.TableauRowCount - 1 - - lhs = self.__tableau[:rowCount, pivotColId] - rhs = self.__tableau[:rowCount, -1] - - ratios = rhs / lhs - - candidates = np.where(ratios > 0, ratios, np.inf) - - if len((np.unique(candidates))) == 0: - return -1 - - return candidates.argmin() - - # minRatio = float('inf') - # leavingRow = -1 - # # rowCount = self.TableauRowCount - 2 if self.IsPhaseI else \ # self.TableauRowCount - 1 # - # for index in range(rowCount): - # # Si le ration est positif - # if self.__tableau[index][pivotColId] > 0: - # ratio = self.__tableau[index][-1] / \ - # self.__tableau[index][pivotColId] - # if ratio < minRatio: - # minRatio = ratio - # leavingRow = index + # lhs = self.__tableau[:rowCount, pivotColId] + # rhs = self.__tableau[:rowCount, -1] # - # print("leaving row :", leavingRow) # vérification ok + # ratios = rhs / lhs + # + # candidates = np.where(ratios > 0, ratios, np.inf) + # + # if len((np.unique(candidates))) == 0: + # return -1 # - # return leavingRow + # return candidates.argmin() + + minRatio = float('inf') + leavingRow = -1 + + rowCount = self.TableauRowCount - 2 if self.IsPhaseI else \ + self.TableauRowCount - 1 + + for index in range(rowCount): + # Si le ration est positif + if self.__tableau[index][pivotColId] > 0: + ratio = self.__tableau[index][-1] / \ + self.__tableau[index][pivotColId] + if ratio < minRatio: + minRatio = ratio + leavingRow = index + + # print("leaving row :", leavingRow) # vérification ok + + return leavingRow def __pivotTableau(self, pivotIDs): if pivotIDs is None or pivotIDs[0] < 0 or pivotIDs[1] < 0: