Skip to content
Snippets Groups Projects
Verified Commit 0500da53 authored by iliya.saroukha's avatar iliya.saroukha :first_quarter_moon:
Browse files

fix: wrong code was used for the leaving row

parent 2b6d7709
No related branches found
No related tags found
No related merge requests found
...@@ -311,39 +311,39 @@ class Simplexe: ...@@ -311,39 +311,39 @@ class Simplexe:
# rowCount = self.TableauRowCount - 2 if self.IsPhaseI else self.TableauRowCount - 1 # rowCount = self.TableauRowCount - 2 if self.IsPhaseI else self.TableauRowCount - 1
# for index in range(rowCount): # 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 \ # rowCount = self.TableauRowCount - 2 if self.IsPhaseI else \
# self.TableauRowCount - 1 # self.TableauRowCount - 1
# #
# for index in range(rowCount): # lhs = self.__tableau[:rowCount, pivotColId]
# # Si le ration est positif # rhs = self.__tableau[:rowCount, -1]
# 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 # 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): def __pivotTableau(self, pivotIDs):
if pivotIDs is None or pivotIDs[0] < 0 or pivotIDs[1] < 0: if pivotIDs is None or pivotIDs[0] < 0 or pivotIDs[1] < 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment