No project description provided
Project description
Simplex
A 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.
Run Help to get a list of available commandline options.
usage: simplex.py [-h] [--equs EQUS] [--slack SLACK] [--aux AUX] [--iter ITER]
[--min] [--verbose] [--debug] [--numba]
options:
-h, --help show this help message and exit
--equs EQUS, -e EQUS the file containing the equations
--slack SLACK, -s SLACK
slack variable base name, names are cretedby adding a
number to the string
--aux AUX, -a AUX aux variable base name, names are cretedby adding a
number to the string
--iter ITER, -i ITER maximum number of iterations
--min, -m determines whether its a minimization problem.if not,
its a maximization problem
--verbose, -v whether to print output verbosely
--debug, -d whether to print debug info
Example usage:
dsimplex -e ./tests/equ6.py -a xa -v -s z -m
The Equation File
Each 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 like
4/5*x1
is illegal. Use.8*x1
instead. - 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 * x7
x1 + 0.25 * x4 - 8 * x5 - x6 + 9 * x7 == 0
x2 + 0.5 * x4 - 12 * x5 - 0.5 * x6 + 3 * x7 == 0
x3 + x6 == 1
x1 >= 0
x2 >= 0
x3 >= 0
x4 >= 0
x5 >= 0
x6 >= 0
x7 >= 0
How to Get
You can get it from pypi:
pip3 install dsimplex
Or you can clone this repo and run it like that:
git clone https://github.com/terminaldweller/simplex && cd simplex && poetry install
TODO
- Use numba
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dsimplex-0.1.11.tar.gz
(22.5 kB
view hashes)
Built Distribution
dsimplex-0.1.11-py3-none-any.whl
(33.8 kB
view hashes)
Close
Hashes for dsimplex-0.1.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28ecc5d40db6bdaf1a43ed8aadb976a009f91bbe28dbc3c9246d8db54f2eed43 |
|
MD5 | c34c9961642e7a0c4346d49a8c545388 |
|
BLAKE2b-256 | 4379e9477beaff20012f4b886b4925c1b96aa13cf58f62b0158824a620604c63 |