Git Product home page Git Product logo

simplexalgorithm's Introduction

Implements Non-Tablaue Simplex Algorithm.

Able to tell if the solution id unbounded or infeasible. Also can handle Degenerate Linear Programs.

  • use python 3+

  • Please read this readme correctly to understand the functioning and assumptions made by the program.

  • testcase.txt is provided. Please enter the values given in the txt file for checking for various cases if you want to use them.

  • Please insert the correct input as asked by the program. Do not enter wrong inputs program will crash.

  • The code is commented refer to it for any doubts.

  • The code implements the algorithm as discussed in class

  • The input for matrix A and B should ignore these condition: x_1>=0,x_2>=0,x_3>=0 ..... These conditions are automatically inserted in the A and B matrix

  • degeneracy is solved using bland's rule

  • The degenerate.simplex.py file handles the degenerate examples and also outputs wether the solution is unbounded or infeasible.

  • The simplex.py file handles non degenerate examples and also outputs wether the solution is unbounded or infeasible

  • Do not enter degenerate question in the simplex.py file the program will crash.

  • The program implements simplex algorithm according to notes taught.

    AX <=B and maximize CX

Note ** -> The input is assumed to exempt the conditions x_1,x_2,x_3,... >=0 so the vector A and B is assumed to contain non trivial conditions.

The trivial conditions are added automatically

Pseudo code :

  • choose x to be the initial feasible solution
  • find A' and A'' given A'X = b' and A''X < b''
  • find neighbour vectors given by the columns of the negative of inverse of A'
  • Check which neighbours will give greater cost if C(x_i - x) > 0 and choose the neighbour that gives the max cost
  • Then find the neighbour point given by x' = x + tv_i v_i is the vector containing the direction of the selected neighbour
  • to find the value of t t = min over s ( (b_s - (A_s)x)/ ((A_s)v_i) ) s ranges over the rows of A'' and the corresponding b values
  • set x = x' and repeat the steps until not neighbour that gives greater cost is found
  • To solve degeneracy blands rule is used

Note :

  • If all the values in the vector B are positive then [0,0,0,....] is chosen as initial feasible solution
  • if any value in the vector B is negative two phase method is used which uses the same simplex algorithm more details given below

Details to tackle if [0,0,0...] is not the initial feasible solution:

If any value in b vector is negative then [0,0,...] is not a feasible solution. In order to find the feasible solution
we use two phase method in the first phase the initial feasible solution is found using the same simplex algorithm and in the second phase using the obtained solution
of the previous phase as initial feasible solution we again run the simplex algorithm with original constraints. This gives the correct solution.

For the first phase to work:

we change the constraints.

New objective function :->   maximize  -x_0   where x_0 is the artificial variable/dimension introduced

New constraits :->    AX - X_0 <= B  where X_0 is the vector of shape (number of rows in A,1) so X_0 = [[x_0],[x_0],...] 
                    and  x_0 >= 0

    and the initial feasible solution for this phase is where x_1,x_2,... is set to zeros and x_0 is set to the absolute value of min(B)

simplexalgorithm's People

Contributors

tujjieve avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.