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
ecowater-softner is a Python library for collecting information from Ecowater water softeners.

Ecowater Softner ecowater-softner is a Python library for collecting information from Ecowater water softeners. Installation Use the package manager p

6 Dec 08, 2022
✨ Un générateur de mot de passe aléatoire totalement fait en Python par moi, et en français.

Password Generator ❗ Un générateur de mot de passe aléatoire totalement fait en Python par moi, et en français. 🔮 Grâce a une au module random et str

MrGabin 3 Jul 29, 2021
produces PCA on genotypes from fasta files (popPhyl's ID format)

popPhyl_PCA Performs PCA of genotypes. Works in two steps. 1. Input file A single fasta file containing different loci, in different populations/speci

camille roux 2 Oct 08, 2021
Implementing C++ Semantics in Python

Implementing C++ Semantics in Python

Tamir Bahar 7 May 18, 2022
A string to hashtags module

A string to hashtags module

Fayas Noushad 4 Dec 01, 2021
Rabbito is a mini tool to find serialized objects in input values

Rabbito-ObjectFinder Rabbito is a mini tool to find serialized objects in input values What does Rabbito do Rabbito has the main object finding Serial

7 Dec 13, 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
Report Bobcat Status to Google Sheets

bobcat-status-reporter Report Bobcat Status to Google Sheets Why? I recently relocated my miner from my root into the attic. Bobcat recommends operati

Jasmit Tarang 3 Sep 22, 2021
Dynamic key remapper for Wayland Window System, especially for Sway

wayremap Dynamic keyboard remapper for Wayland. It works on both X Window Manager and Wayland, but focused on Wayland as it intercepts evdev input and

Kay Gosho 50 Nov 29, 2022
Python program for analyzing the output files of phonopy.

PhononTools Description Python program to analyze the results generated by phonopy. Using the .yaml and .dat files that phonopy generates one can plot

Harry LaBollita 8 Nov 27, 2022
Dice Rolling Simulator using Python-random

Dice Rolling Simulator As the name of the program suggests, we will be imitating a rolling dice. This is one of the interesting python projects and wi

PyLaboratory 1 Feb 02, 2022
A python program to find binary, octal and hexadecimal of a decimal.

decimal-converter This little python program can convert a decimal in to, Binary Octal Hexadecimal Needed Python 3 or later or a online python compile

Chandula Janith 0 Nov 27, 2021
Modeling Category-Selective Cortical Regions with Topographic Variational Autoencoders

Modeling Category-Selective Cortical Regions with Topographic Variational Autoencoders Getting Started Install requirements with Anaconda: conda env c

T. Andy Keller 4 Aug 22, 2022
Functional UUIDs for Python.

🏷️FUUID stands for Functional Universally Unique IDentifier. FUUIDs are compatible with regular UUIDs but are naturally ordered by generation time, collision-free and support succinct representations

Phil Demetriou 147 Oct 27, 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
Small Python script to parse endlessh's output and print some neat statistics

endlessh_parser endlessh_parser is a small Python script that parses endlessh's output and prints some neat statistics about it Usage Install all the

ManicRobot 1 Oct 18, 2021
A module for account creation with python

A module for account creation with python

Fayas Noushad 3 Dec 01, 2021
Python module and its web equivalent, to hide text within text by manipulating bits

cacherdutexte.github.io This project contains : Python modules (binary and decimal system 6) with a dedicated tkinter program to use it. A web version

2 Sep 04, 2022
Cleaning-utils - a collection of small Python functions and classes which make cleaning pipelines shorter and easier

cleaning-utils [] [] [] cleaning-utils is a collection of small Python functions

4 Aug 31, 2022
Python HTTP Agent Parser

Features Fast Detects OS and Browser. Does not aim to be a full featured agent parser Will not turn into django-httpagentparser ;) Usage import ht

Shekhar 213 Dec 06, 2022