Simplex using Jordan exchanges taught in 236A

Overview

Simplex for 236A

Python script to solve LP using simplex by Jordan exchanges taught in 236A.

You will need python installed along with the 'numpy' and 'fractions' libraries for this. Most probably you'll already having both of these installed by default.

How to run?

Step 0: Run the script in 'interactive mode' using the below command:

python -i jordan.py

Step 1: Define your initial tableau (doesn't need to be feasible, doesn't need to be at the desired start point). It's as simple as writing the LP in the form:

And the convert this into a numpy 2D array. For example, if the given LP is:

Then the tableau will look like this:

So in the shell, define the tableau like this:

P3=np.array([[-1,0,0,0.5],[0,-1,0,0.5],[0,0,-1,0.5],[1,1,1,-1],[-1,-1,-1,1],[1,-1,0,0]])

Step 2: Next, just run the below command to solve the LP:

ans,top,left=run(P3)

Here, the run function returns the final tableau in 'ans', and top/left can be used to display the final result if needed:

disp(ans,top,left)

Additional Features

Active Set: If you need to start at a certain vertex (instead of all 0 vertex - irrespective of feasibility), then you can mention the subscripts of those variables (which are 0 in the desired vertex) in the argument I as shown:

ans,top,left=run(P3,[3,4,5])

This will start the tableau from all-0 point and forcibly reach the desired vertex (mentioned as 'Phase 1.5' in prints). And then it starts the actual algorithm from that point.

Latex Format: If you need to get all the tables in Latex format, just set the lyx flag to True as shown:

ans,top,left=run(P3,[3,4,5],lyx=True)

This will print the tableau in latex format which you can directly paste in your latex workbook. Example:

The table in latex would look like this:

Miscellaneous

Note: The algo uses the Bland's pivoting rule everytime.

If you wanna perform Jordan exchange manually step by step yourself, just use the function ex(A,s,r) as shown below:

A = np.array([[-1,1,4],[-1,-1,6],[1,-1,0]]) # your tableau
s = 1 # index of the pivot column
r = 2 # index of the pivot row
A_new = ex(A,s,r)

That's all Folks!

If this helped you, you're welcome! If you have any modifications or corrections in the code, feel free to initiate a pull-request. K bye!

Owner
Kunal Kishore
Kunal Kishore
Here, I find the Fibonacci Series using python

Fibonacci-Series-using-python Here, I find the Fibonacci Series using python Requirements No Special Requirements Contribution I have strong belief on

Sachin Vinayak Dabhade 4 Sep 24, 2021
A tiny Python library for generating public IDs from integers

pids Create short public identifiers based on integer IDs. Installation pip install pids Usage from pids import pid public_id = pid.from_int(1234) #

Simon Willison 7 Nov 11, 2021
Trying to replicate (albeit unsuccessfully) the phenomenon of boids using Ursina in a naive manner.

Boids_Boi Trying to replicate (albeit unsuccessfully) the phenomenon of boids using Ursina in a naive manner. Please install the Ursina module before

2 Oct 19, 2021
A Program that generates and checks Stripe keys 24x7.

A Program that generates and checks Stripe keys 24x7. This was made only for Educational Purposes, I'm not responsible for the damages cause by you

iNaveen 18 Dec 17, 2022
Airspy-Utils is a small software collection to help with firmware related operations on Airspy HF+ devices.

Airspy-Utils Airspy-Utils is a small software collection to help with firmware related operations on Airspy HF+ devices on Linux (and other free syste

Dhiru Kholia 11 Oct 04, 2022
A small python tool to get relevant values from SRI invoices

SriInvoiceProcessing A small python tool to get relevant values from SRI invoices Some useful info to run the tool Login into your SRI account and ret

Wladymir Brborich 2 Jan 07, 2022
A work in progress box containing various Python utilities

python-wipbox A set of modern Python libraries under development to simplify the execution of reusable routines by different projects. Table of Conten

Deepnox 2 Jan 20, 2022
JeNot - A tool to notify you when Jenkins builds are done.

JeNot - Jenkins Notifications NOTE: under construction, buggy, and not production-ready What A tool to notify you when Jenkins builds are done. Why Je

1 Jun 24, 2022
Multipurpose Growtopia Server tools, can be used for newbie to learn things.

Information Multipurpose Growtopia Server tools, can be used for newbie to learn things. Requirements - Python 3.x - Operating System (Recommended : W

Morphias 2 Oct 29, 2021
Customized python validations.

A customized python validations.

Wilfred V. Pine 2 Apr 20, 2022
A functional standard library for Python.

Toolz A set of utility functions for iterators, functions, and dictionaries. See the PyToolz documentation at https://toolz.readthedocs.io LICENSE New

4.1k Dec 30, 2022
'ToolBurnt' A Set Of Tools In One Place =}

'ToolBurnt' A Set Of Tools In One Place =}

MasterBurnt 5 Sep 10, 2022
Factoral Methods using two different method

Factoral-Methods-using-two-different-method Here, I am finding the factorial of a number by using two different method. The first method is by using f

Sachin Vinayak Dabhade 4 Sep 24, 2021
Python utilities for writing cross-version compatible libraries

Python utilities for writing cross-version compatible libraries

Tyler M. Kontra 85 Jun 29, 2022
Manage your exceptions in Python like a PRO

A linter to manage all your python exceptions and try/except blocks (limited only for those who like dinosaurs).

Guilherme Latrova 353 Dec 31, 2022
✨ Un DNS Resolver totalement fait en Python par moi, et en français

DNS Resolver ❗ Un DNS Resolver totalement fait en Python par moi, et en français. 🔮 Grâce a une adresse (url) vous pourrez avoir l'ip ainsi que le DN

MrGabin 3 Jun 06, 2021
Dependency Injector is a dependency injection framework for Python.

What is Dependency Injector? Dependency Injector is a dependency injection framework for Python. It helps implementing the dependency injection princi

ETS Labs 2.6k Jan 04, 2023
Find version automatically based on git tags and commit messages.

GIT-CONVENTIONAL-VERSION Find version automatically based on git tags and commit messages. The tool is very specific in its function, so it is very fl

0 Nov 07, 2021
Simple web index to use bloom filter for Pwned Passwords

pwbloom Simple web index to use bloom filter for Pwned Passwords The index.py runs a simple CGI web service checking passwords with a bloom filter for

Hanno Böck 4 Nov 23, 2021
A utility tool to create .env files

A utility tool to create .env files dump-env takes an .env.template file and some optional environmental variables to create a new .env file from thes

wemake.services 89 Dec 08, 2022