Go to file
Mikaël Capelle 16453c424d
Some checks failed
continuous-integration/drone/push Build is failing
[simplex] Add __str__ method for simplex dictionary.
2019-12-03 15:00:58 +00:00
simplex [simplex] Add __str__ method for simplex dictionary. 2019-12-03 15:00:58 +00:00
tests [lint] Add lint and tests. 2019-11-28 17:06:23 +01:00
.dir-locals.el [lint] Add lint and tests. 2019-11-28 17:06:23 +01:00
.drone.yml [ci] Add .drone.yml. 2019-12-03 13:15:46 +00:00
.gitignore [lint] Add lint and tests. 2019-11-28 17:06:23 +01:00
LICENSE [simplex] Initial commit. 2019-10-30 19:37:08 +01:00
README.md [doc] Update README. 2019-12-03 14:42:21 +00:00
setup.cfg [setup] Fix configuration for tox and update minimum python version. 2019-12-03 09:51:36 +00:00
setup.py [setup] Fix configuration for tox and update minimum python version. 2019-12-03 09:51:36 +00:00

Simplex dictionary

Python Versions License Build Status

simplex is a small python module that implements a simplex_dictionary structure representing a dictionary for the Simplex algorithm.

Basic usage

The following code creates a simplex dictionary with 5 variables:

from simplex import simplex_dictionary

# The list of variables (can be anything):
x1, x2, x3, x4, x5 = ('x_{}'.format(i + 1) for i in range(5))
variables = [x1, x2, x3, x4, x5]

# The simplex dictionary with B = (x3, x4, x5):
sdict = simplex_dictionary(B=[x3, x4, x5], N=[x1, x2])

# Set the values of the basic variables:
sdict.b = {x3: 18, x4: 42, x5: 24}

# Coefficients of the non-basic variables in the dictionary (we represent
# the positive coefficients):
sdict.a = {
    x3: {x1: 2, x2: 1},
    x4: {x1: 2, x2: 3},
    x5: {x1: 3, x2: 1}
}

# Current value of the objective:
sdict.z = 0

# Coefficients of the non-basic variables in the objective function:
sdict.c[x1] = 3
sdict.c[x2] = 2

When using the simplex module within a jupyter notebook, the display() method outputs a latex version of the dictionary:

sdict.display(name='S_0')