Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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
z

where 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.