This is a simple implementation of the simplex method, which is a simple method for solving linear programming problems (LPPs).
The only requirement for this progrram is numpy which can be installed as
pip install -r requirements.txt
The LPP is divided into three numpy arrays (say A, B, C).
Consider the LPP as
Maximize F = c1x1+c2x2
Subject to constraints
a11x1+a12x2≤b1
a21x1+a22x2≤b2
x1,x2≥0
Then we define 3 numpy arrays A, B, C as:
A = np.array([[a11, a12]
[a21, a22]])
B = np.array([b1, b2])
C = np.array([c1, c2])
Now we can use the LinearModel
class to create the simplex tableau and then find the optimal solution.
lm = LinearModel(A, B, C)
OR
lm = LinearModel()
lm.setA(A)
lm.setB(B)
lm.setC(C)
Now we can optimize the solution using
lm.optimize()
Now, we can look at the optimized value of {x1,x2, ...} as a numpy array is returned by lm.optimalSoln()
method.
Similarly, we can look at the optimized value of F using lm.optimialVal()
method.
You can also look at the example program or example notebook to see how it is applied.
Note: Currently only maximization problems can be solved and minimization problems will soon be implemented as well. Further preetifying and visualization of simplex tableau is also planned to be implemented.
Feel free to review my code and roast me. I am just a dumbass.