From 9cdaeccb3803cfd163abfb32e25519f1f6b3793d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Tue, 3 Dec 2019 14:27:22 +0000 Subject: [PATCH] [doc] Update README. --- README.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b542b6..7426900 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,50 @@ # Simplex dictionary -Small package to manipulate a simplex dictionary in python. +[![Python Versions](https://img.shields.io/badge/python-3.6%20|%203.7-blue.svg)](https://img.shields.io/badge/python-3.6%20|%203.7-blue.svg) +[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://img.shields.io/badge/license-MIT-green.svg) +[![Build Status](https://drone.typename.fr/api/badges/mikael.capelle/simplex/status.svg)](https://drone.typename.fr/mikael.capelle/simplex) + +`simplex` is a small python module that implements a `simplex_dictionary` structure representing +a dictionary for the [Simplex algorithm](https://en.wikipedia.org/wiki/Simplex_algorithm). + +# Basic usage + +The following code creates a simplex dictionary with 5 variables: + +```python +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: + +```python +sdict.display(name='S_0') +``` + +