Package: dsimplex
SimplexA python package that solve linear programming problems using the simplex method.Features:The Problem is input into the program by a file containing python expression.Solves both min and max problems(duh!).Uses the big M method to find a basic feasible solution when there are none available in the original program.Handles adding slack variables to convert the problem into standard form.Uses the lexicographic rule to prevent ending up in a loop due to degenerate extreme points.outputs in html.Run Help to get a list of available commandline options../test.py--help[INSERT]32mS0↵L3
usage:test.py[-h][--equsEQUS][--csvCSV][--delimDELIM][--slackSLACK][--auxAUX][--iterITER][--min][--verbose][--debug][--out][--numba]options:-h,--helpshowthishelpmessageandexit--equsEQUS,-eEQUSthepathtothefilecontainingtheequations--csvCSV,-cCSVthepathtotheCSVfilecontainingtheproblem--delimDELIM,-lDELIMtheseparatorforthecsvfile--slackSLACK,-sSLACKslackvariablebasename,namesarecretedbyaddinganumbertothestring--auxAUX,-aAUXauxvariablebasename,namesarecretedbyaddinganumbertothestring--iterITER,-iITERmaximumnumberofiterations--min,-mdetermineswhetheritsaminimizationproblem.ifnot,itsamaximizationproblem--verbose,-vwhethertoprintoutputverbosely--debug,-dwhethertoprintdebuginfo--out,-opathtotheoutputfile--numba,-nwhethertoprintdebuginfo]qExample usage:dsimplex-e./tests/equ6.py-axa-v-sz-mThe Equation Filedsimplex currently accepts two input formats:Python ExpressionsEach equation in the equations file should a valid python expression. There are a couple notes though:For conditions that end in equality you must use==instead of=to make it a legal python expression.Nothing will be evaluated so writing something like4/5*x1is illegal. Use.8*x1instead.You can use comments inside the equations file. They are the same format as the python comments.The cost equation is one without a binary comparison operator, e.g.<=,<,>=,>.The order of the equations in the equations file is not important. You can put them in in any order you want.
As an example:# cyclic test-0.75*x4+20*x5-0.5*x6+6*x7x1+0.25*x4-8*x5-x6+9*x7==0x2+0.5*x4-12*x5-0.5*x6+3*x7==0x3+x6==1x1>=0x2>=0x3>=0x4>=0x5>=0x6>=0x7>=0CSVThe order of the equations is not important. It is also not important where the cost function is in the csv file as long as it is there.The variables with zero coefficients should be left empty.x1,x2,x3,x4,x5,x6,x7,cond,rhs
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1,>=,0
x1,x2,x3,x4,x5,x6,x7,cond,rhs
,,,-0.75,20,-0.5,6,,
1,,,0.25,-8,-1,9,=,0
,1,,0.5,-12,-0.5,3,=,0
,,1,,,1,,=,1
1,,,,,,,>=,0
,1,,,,,,>=,0
,,1,,,,,>=,0
,,,1,,,,>=,0
,,,,1,,,>=,0
,,,,,1,,>=,0
,,,,,,1,>=,0How to GetYou can get it frompypi:pip3installdsimplexOr you can clone this repo and run it like that:gitclonehttps://github.com/terminaldweller/simplex&&cdsimplex&&poetryinstall