Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ISC2
maths
simplex
Commits
b93a87ab
Verified
Commit
b93a87ab
authored
1 year ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
cleanup: refactored Aliya's ideas
parent
f2711b0c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/simplexe.py
+48
-9
48 additions, 9 deletions
src/simplexe.py
with
48 additions
and
9 deletions
src/simplexe.py
+
48
−
9
View file @
b93a87ab
...
...
@@ -255,19 +255,32 @@ class Simplexe:
# to iterate over basic variables do:
for
rowId
,
baseColId
in
enumerate
(
self
.
__basicVariables
):
if
self
.
RHS
[
rowId
]
/
self
.
__tableau
[
rowId
][
baseColId
]
<
0
:
if
self
.
__getBasicVariableValue
(
rowId
,
baseColId
)
<
0
:
return
False
# raise Exception(
# 'Not implemented', 'Simplexe.__isSolutionFeasible: missing code to be implemented.')
return
True
# returns index of entering col Id
# return None or -1 if there is pivot
def
__selectEnteringColumn
(
self
):
# find an entering column for pivot => return -1 if none is found!
raise
Exception
(
'
Not implemented
'
,
'
Simplexe.__selectEnteringColumn: missing code to be implemented.
'
)
# print(self.__tableau[0])
# for rowId, baseColId in enumerate(self.__basicVariables):
# print(self.__tableau[rowId, baseColId])
#
# This maybe ain't that dumb but it works half the time which is weird
# if self.__PivotCount > self.AMatrix.shape[1] - 1:
# return -1
#
# return self.__PivotCount
if
np
.
size
(
self
.
__tableau
[
-
1
,
:
-
1
][
np
.
where
(
self
.
__tableau
[
-
1
,
:
-
1
]
<
0
)])
==
0
:
return
-
1
return
np
.
argmin
(
self
.
__tableau
[
-
1
,
:
-
1
])
# returns leaving row ID
# return None or -1 if there is pivot (sets optimisation status accoringly before returning)
...
...
@@ -276,8 +289,21 @@ class Simplexe:
# iterate using :
# rowCount = self.TableauRowCount - 2 if self.IsPhaseI else self.TableauRowCount - 1
# for index in range(rowCount):
raise
Exception
(
'
Not implemented
'
,
'
Simplexe.__selectLeavingRow: missing code to be implemented.
'
)
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
()
def
__pivotTableau
(
self
,
pivotIDs
):
if
pivotIDs
is
None
or
pivotIDs
[
0
]
<
0
or
pivotIDs
[
1
]
<
0
:
...
...
@@ -302,8 +328,21 @@ class Simplexe:
# iterate using
# pivotRow = self.__tableau[pivotRowId, :] / pivotVal
# for rowId in range(self.TableauRowCount):
raise
Exception
(
'
Not implemented
'
,
'
Simplexe.__pivotTableau: missing code to be implemented.
'
)
# Calculer la ligne du pivot normalisée (avoir la valeur 1 à la colonne du pivot)
pivotRow
=
self
.
__tableau
[
pivotRowId
,
:]
/
pivotVal
# Pour chaque ligne autre que le pivot
for
rowId
in
range
(
self
.
TableauRowCount
):
if
rowId
!=
pivotRowId
:
# Mettre la colonne du pivot à 0
multiplier
=
self
.
__tableau
[
rowId
,
pivotColId
]
self
.
__tableau
[
rowId
,
:]
-=
multiplier
*
pivotRow
self
.
__tableau
[
pivotRowId
,
:]
=
pivotRow
# raise Exception(
# 'Not implemented', 'Simplexe.__pivotTableau: missing code to be implemented.')
# For a given unfeasible initial problem, this method creates the corresponding Tableau of the Phase I, then launches the optimization of Phase I
def
initPhaseI
(
self
,
simplexe
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment