GithubHelp home page GithubHelp logo

aru-py / dantzigs-simplex-algorithm Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 3.0 26 KB

Robust implementation of the Linear Programming Simplex Algorithm

Home Page: https://aru.ai/simplex

Python 100.00%
python linear-programming

dantzigs-simplex-algorithm's Introduction

dantzigs-simplex-algorithm

Documentation Status

This is an Python implementation of the Simplex Algorithm used in Linear Programming. The program requires specification of the objective function, technological coefficients, and the constraints of a linear programming problem and outputs the optimal solution and objective value (if any). The documentation is available here.

Features

  • Fast Numpy implementation
  • Bland's Rule for anti-cycling
  • Two-Phase Method
  • Supports infeasible and unbounded problems
  • Extensive documentation

Usage

Code

from simplex.solver import SimplexSolver
from test_cases import test_cases

problem = test_cases[1]

# initialize solver
solver = SimplexSolver(obj_func=problem['obj_func'],
                       coeffs=problem['coeffs'],
                       constraints=problem['constraints'])

# run solver
sol = solver.solve(use_blands_rule=False,
                   print_tableau=True)

Output

[0] Initial Tableau
      1x  2x  3x  4x  5x RHS
z   [-2. -3.  0.  0.  0.  0.]
x3  [ 1. -2.  1.  0.  0.  4.]
x4  [ 2.  1.  0.  1.  0. 18.]
x5  [ 0.  1.  0.  0.  1. 10.]
[1] Pivoted around (2, 1)
      1x  2x  3x  4x  5x RHS
z   [-2.  0.  0.  0.  3. 30.]
x3  [ 1.  0.  1.  0.  2. 24.]
x4  [ 2.  0.  0.  1. -1.  8.]
x2  [ 0.  1.  0.  0.  1. 10.]
[2] Pivoted around (1, 0)
      1x  2x  3x  4x  5x  RHS 
z   [ 0.  0.  0.  1.  2.  38.]
x3  [ 0.  0.  1. -.5  2.5 20.]
x1  [ 1.  0.  0.  .5 -0.5  4.]
x2  [ 0.  1.  0.  0.  1.  10.]
Solution: 
z*=38.0, 
x*=[4.0, 10.0, 20.0]

Contributing

All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome. Please make sure to adhere to the code style and add sufficient documentation.

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.