A minimal Python implementation of the simplex algorithm, intended for academic and teaching purposes.
No installation is required beyond cloning this repository.
The solver has no external dependencies.
Python 3.11 or later is recommended.
git clone https://github.com/bloa/simplex.git
cd simplexTo try the solver, run it on the provided example problems:
python3 simplex --program examples/test_solved1You can choose between the big-M (with bigm, the default) and the Two-Phase (twophase) methods using --solver.
You can choose between a tableau-based (with tableau, compact, tableau_alt, or compact_alt) or dictionary-based (with dict, the default) representation using --method.
For example:
python3 simplex --program examples/test_solved6 --solver twophase --method tableauYou can construct and solve the dual program using --to_dual, or construct and solve the primal program using --to_dual.
In all cases, resolution will always follow the "primal" Simplex algorithm.
Finally, LaTeX formatting is supported through the --latex option:
python3 simplex --program examples/test_solved4 --method compact --latexIn doubt, consult the help message:
python3 simplex --helpRun the test suite with pytest:
pytestContributions are welcome via pull requests.
Planned improvements include:
- interactive mode for selecting pivots
- integer constraint support through branch and bound