Giter Site home page Giter Site logo

lokeshsreenathj / revised-simplex-for-constraint-optimization Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 9 KB

Built a linear Constraints Optimization Algorithm from Scratch that works on any type of linear optimization problem

License: MIT License

MATLAB 100.00%
matlab optimization-algorithms revised-simplex-algorithm two-phase-algorithm

revised-simplex-for-constraint-optimization's Introduction

Revised-Simplex-for-Constraint-Optimization

Built a linear Constraints Optimization Algorithm from Scratch that works on any type of optimization problem

Built a Revised-Simplex with Two-Phase method.

PHASE-ONE Let us follow the outline of the revised simplex method given on p.97 of Bertsimas and Tsitsiklis, "Introduction to Linear Optimization." However, we deviate from this approach in the following ways: Step1) The Phase I problem can never be unbounded, so we do not check for unboundedness after finding an improving direction. Step2) Once an improving direction is found (i.e. once a nonbasic variable with a negative reduced cost is found (and decided upon) to enter the basis we force an artificial variable to leave the basis and immediately delete this artificial variable from the problem so that it cannot enter the basis in a subsequent iteration.

Inputs for Phase-One: c = cost vector (n x I) A = constraint matrix (m x n). includes artificial variables for Phase I b = right-hand-side vector (m x I) B = basis matrix (m x m) B_inv = inverse of basis matrix B (m x m) bvar = row vector of basic variable indices (1 x m) nbvar = row vector of nonbasic variable indices (1 x (n-m)) enteringVar = the index in the set of the nonbasic variables of the nonbasic variables that will enter the basis. For example, if bvar = [1,2,3,4] (i.e ., x1,..,x4 are in the basis), and nbvar= [5,6,7,8] (i.e., x5, ... ,x8 are nonbasic variables), then enteringVar= 2 means that x5, the second index in the set of nonbasic variables will enter the basis.

Output for Phase-One: soln_status = -1 if infeasible, 0 otherwise A= possibly modified (m x n) constraint matrix; redundant rows may have been eliminated b = possibly modified (m x 1) right-hand-side vector; B_inv = inverse of basis matrix B (m x m) bvar = row vector of basic variable indices (1 x m) nbvar = row vector of nonbasic variable indices (1 x (n-m))

If any artificial varaiable present in the basis and its value is 0, then Remove all artificial variables from the set of nonbasic variables& Eliminate the corresponding columns in the A matrix as well.

If any artificial variable is in the basis but its value is not equals to 0, then try to pivot this artificial variable with any non-artificial variable that is in non-basis. If non-zero artificial variable doesnot goes out from basis using above two steps then the given solution is infeasible.

"We never get a unbounded condition in the Phase-one step because the cost function doesnot contain the non-artificial variables, so having exteme direction does not affect the main cost function".

If there are no artificial variables in the final Phase 1 basis, all artificial variables have been eliminated from the problem, so we may return the current basis to begin Phase 2 of the simplex method.

PHASE-TWO Method: c = cost vector (n x 1) A= constraint matrix (m x n), includes artificial variables for Phase 1 b = right-hand-side vector (m x 1) c_B = cost vector of basic variables (m x 1) B = basis matrix (m x m) B_inv = inverse of basis matrix B (m x m) bvar = row vector of basic variable indices (1 x m) nbvar = row vector of nonbasic variable indices (1 x (n-m))

Output for the PHASE-TWO Method: soln_status = 1 if unbounded, 2 if finite optimal solution z = objective function value: -inf if unbounded, finite otherwise x = (n x 1) optimal solution if soln_status = 2, a direction "u" of unboundedness otherwise p = an (m x 1) dual vector B_inv = inverse of basis matrix B (m x m) bvar = row vector of basic variable indices ( I x m) nbvar = row vector of nonbasic variable indices ( 1 x (n-m))

We return the inverse basis matrix, the index set of basic variables, and the index set of nonbasic variables so that we can perform a warm-start in the future.

If the reduced costs of all nonbasic variables are nonnegative, the current basic feasible solution x_B is %optimal, and the algorithm terminates.

revised-simplex-for-constraint-optimization's People

Contributors

lokeshsreenathj 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.