Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ivzeng/simplex_alogrithm
This is a simple LP problem solver with simplex algorithm.
https://github.com/ivzeng/simplex_alogrithm
Last synced: 22 days ago
JSON representation
This is a simple LP problem solver with simplex algorithm.
- Host: GitHub
- URL: https://github.com/ivzeng/simplex_alogrithm
- Owner: ivzeng
- Created: 2022-10-09T17:28:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-19T18:34:47.000Z (about 1 year ago)
- Last Synced: 2023-12-20T13:53:59.002Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simplex Algorithm
This is a python implementation of the simplex algorithm.
The program would take a valid linear programming problem, in form of:$max(cx+z)$ subjected to:
$Ax = b$In the future, I will improve the program so that it will accept more variations of LP.
The program would produce the optimal solution, as well as the steps.
## input:
The program can be run with no or one text file as an argument, if no text tile is provided, the program will run with the provided default example.To run it, try something like the following:
```
Python simplex.py (name of input file)
Python simplex.py
```The given file should consist of lines containing only integers or decimal numbers or fractions, separated by spaces or tab. Although the program provides a basic check of the numerical input, invalid input may still cause the program to crash. (So please be nice to my program 'v'.)
The input file should be like this:
m n
A11 ... A1n
. . .
. . .
. . .
Am1 ... Amn
b1 ... bm
c1 ... cn
zwhere m is the number of rows of A (i.e. constraints) and n is the number of columns (i.e. unknown);
Aij is the ij-entry of A;
bi is the ith element of b;
ci is the ith element of c;
z is a constant.
## functions:
#
```
readIn() -> LP
```This function would convert the input to an LP, which consists of [m, n], A, b, c, z
#
```
simplex(LP, init_B = [], mode = 'a')
```
This function, by default, would produce the result of the LP (optimal cx and x if they exist). Set the mode = 's' to see detailed step or 'r' to see the basic result.