A numerical implementation of the Simplex method for linear programming, from first principles.
- Overview
- Tech Stack
- Architecture
- Theoretical Background
- Installation
- Usage
- API Reference
- Case Study
- Testing
- Limitations
- Roadmap
- License
The Simplex method is a widely used algorithm for solving linear programming problems. It is an iterative method that starts with a basic feasible solution and improves it at each step until an optimal solution is found.
- Python 3.8+
- NumPy
- SciPy
simplex-method/
|--- notebooks/
| |--- exploration.py
|--- src/
| |--- simplex.py
| |--- tableau.py
| |--- utils.py
|--- tests/
| |--- test_simplex.py
| |--- test_tableau.py
|--- results/
| |--- findings.md
The Simplex method is based on the concept of a tableau, which is a matrix representation of the linear programming problem. The tableau is used to store the coefficients of the variables and the constraints, and to perform the necessary calculations to find the optimal solution.
The Simplex method consists of two main phases: the Phase I and Phase II. In Phase I, the method finds a basic feasible solution by minimizing the artificial variables. In Phase II, the method finds the optimal solution by maximizing the objective function.
To install the Simplex method implementation, run the following commands:
pip install -r requirements.txt
git clone https://github.com/user/simplex-method.gitTo use the Simplex method implementation, create an instance of the Simplex class and call the solve method:
from src.simplex import Simplex
# Define the coefficients of the objective function and the constraints
c = np.array([3, 4])
b = np.array([7, 11, 8])
A = np.array([[1, 2], [3, 2], [2, 1]])
# Create an instance of the Simplex class and solve the problem
simplex = Simplex(c, A, b)
result = simplex.solve()
print(result)Simplex(c, A, b): Creates an instance of theSimplexclass.solve(): Solves the linear programming problem using the Simplex method.
See the findings.md file for a written analysis of the results.
To run the tests, execute the following command:
pytest tests/The current implementation only supports problems with a small number of variables and constraints.
- Improve the performance of the implementation for large problems.
- Add support for more advanced features, such as integer programming.
This implementation is licensed under the MIT License.
pip install -r requirements.txt