In mathematical optimization, Dantzig's simplex algorithm (or simplex method) is a popular algorithm for linear programming.
The name of the algorithm is derived from the concept of a simplex and was suggested by T. S. Motzkin. Simplices are not actually used in the method, but one interpretation of it is that it operates on simplicial cones, and these become proper simplices with an additional constraint. The simplicial cones in question are the corners (i.e., the neighborhoods of the vertices) of a geometric object called a polytope. The shape of this polytope is defined by the constraints applied to the objective function.
Disclaimer: This SimplexSolver was created for educational purposes only. Its author is not responsible for any inaccuracies or errors in the results.
All the dependencies
and libraries
are included in the package. You do not need to install anything.
You will just need a browser to run the solver.
Download
orClone
the complete directory to your machine.- Run
Index.html
- Or you can directly visit Simplex Solver
kuldeepsinghsidhu.com/SimplexSolver
Use of this system is pretty intuitive: Press "Example
" to see an example of a linear programming problem already set up.
Then modify the example or enter your own linear programming problem in the space below using the same format as the example, and press "Solve
"
Note:
- Do not use commas in large numbers. For instance, enter
100,000
as100000
. - The right-hand side of each constraint must be non-negative, so multiply through by
−1
first if necessary. - The utility is quite flexible with input. For instance, the following format will also be accepted (inequalities separated by commas):
Maximize p = x+y subject to x+y <= 2, 3x+y >= 4
- Decimal mode displays all the tableaus (and results) as decimals, rounded to the number of significant digits you select (up to 13, depending on your processor and browser).
- Fraction mode converts all decimals to fractions and displays all the tableaus (and solutions) as fractions.
- Integer Mode eliminates decimals and fractions in all the tableaus (using the method described in the simplex method tutorial) and displays the solution as fractions.
- Mac users: you can use the inequality symbols "
option+<
" and "option+>
" instead of "<=
" and ">=
" if you like (although some browsers may have difficulties with this). - Important: Every variable you use must appear in the objective function (but not necessarily in the constraints). For example,
Maximize p = 0x + 2y + 0z
- Solution Display: Some browsers (including some versions of Internet Explorer) use a proportional width font (like Geneva or Times) in text boxes. This will cause the display of solutions to appear a little messy. You can remedy this by changing the "Sans Serif" font in your browser preferences to "Courier" or some other fixed-width font, and then reloading the page.
index.html
: Contains the front-end for the website depenencies of which are located inassets
which uses bootstrapAboutSimplex.html
: Contains a few more information about Simplex Algorithm.SimplexAlgorithm.pdf
: Is the Article on Simplex Algorithm.assets/js/Solver/simplex.js
: Contains all the functions as JavaScript that Solve the Linear Optimization Problems.
This is the complete SOLVER
functions in assets/js/Solver/simplex.js
:
function sesame(url,hsize,vsize)
: Form utilities to print in the formfunction doIt()
: Checks which button is pressed and calls the functions accordingly.function simplexMethod(InMatrix, rows, cols)
: Simplex starts here.function pivot(InMatrix,rows,cols,theRow,theCol)
: Makes the point in theInMatrix
as pivot.function parser (InString, Sep)
: returns an array 0th entry = number n of blocks (-1) if the character Sep does not occur subsequent n entries are the blocks themselves Here are the blocks ***block 1 *** SEP *** block 2 *** SEP *** block 3 *** (one more block than number of occurrences of SEP)function parseLinearExpr(InString)
: Returns an array: with 0th entry = an array of variable names (eg.["x", "x'", "y", "z"]
) and subsequent entries the coefficients. to get the number of coefficients, just take the length of the array in position 0. first remove a leading cr iffunction SetupTableau()
: reads problem and sets up the first tableaufunction rightString (InString, num)
: Returns a sub string from positionnum
till the end ofInString
function rightTrim (InString)
: Removes last character in theInString
function replaceChar (InString,oldSymbol,newSymbol)
: InInString
searches foroldSymbol
and replaces it withnewSymbol
function replaceSubstring (InString,oldSubstring,newSubstring)
: InInString
searches foroldSubstring
and replaces it withnewSubstring
function makeInteger(theMatrix, RowNum, ColNum,Strings)
: Makes a matrix integer by least common multiples of rows returms a matrix of STRINGSif Strings = true
else gives integers input = a matrix of real floats
also records the row lcm of row i in outArray[i][0]function toFrac(x, maxDenom, tol)
: tolerance is the largest errror you will tolerate before resorting to expressing the result as the input decimal in fraction form suggest no less than 10^-10, since we round all to 15 decimal places.function toFracArr(x, maxDenom, tol)
: identical totoFrac
, except this returns anarray [1] = numerator
;[2] = denom
rather than a string.function isCharHere (InString, RefString)
: Checks whether its a character or a string (Single digit or a larger number)function checkString(InString,subString,backtrack)
: check for subStringif backtrack = false
,returns -1
if not found, and left-most location in string if foundif backtrack = true
,returns -1
if not found, and right-most location in string if found note that location is to the left of the substring in both casesfunction looksLikeANumber(theString)
: Returns true if theString looks like it can be evaluated i.e. if it is a string with just numeric characters.function roundSix(theNumber)
: Rounds to six digits.function roundSigDig(theNumber, numDigits)
: RoundstheNumber
tillnumDigits
function shiftRight(theNumber, k)
: Shifts decimal k places to the right.function reduce(fraction)
: Reduces a fraction usingfunction hcf (a,b)
function hcf (a,b)
: Takesinput
as two numbers and converts them into possitive and calculates HCF (Highest Common Factor)function lcm(a,b)
: Takesinput
as two numbers and converts them into possitive and calculates LCM (Lowest Common Multiplier)function lastChar(theString)
: Returns the last Character in the string.function displayMatrix(number)
: Displays Tableaufunction makeArray3 (X,Y,Z)
: Makes 3 Dimensional Tableaufunction makeArray2 (X,Y)
: Makes 2 Dimensional Tableaufunction makeArray (Y)
: Makes 1 Dimensional Tableaufunction stripSpaces (InString)
: Removes Spaces inInString
function stripChar (InString,symbol)
: Removessymbol
fromInString
if presentfunction myErrorTrap(message,url,linenumber)
: This gives error alert in case the program crashes.function displayFinalStatus()
: Gives the solution or the error messages.
Kuldeep Singh Sidhu
Github: github/singhsidhukuldeep
https://github.com/singhsidhukuldeep
Website: Kuldeep Singh Sidhu (Website)
http://kuldeepsinghsidhu.com
LinkedIn: Kuldeep Singh Sidhu (LinkedIn)
https://www.linkedin.com/in/singhsidhukuldeep/