Skip to main content

Solving linear programming problems step-by-step

Project description

Elpee

PyPI Latest Release PyPI - Python Version PyPI Downloads License - Apache-2.0 ReadtheDocs Libraries.io dependency status for latest release

Solving linear programming problems one step at a time.

Elpee (short for L inear P rogramming) is a Python library for students and academics to viusalize the steps and iterations required to solve constrained linear optimization problems using linear programming methods.

Demo

Static Badge

View how linear programming problems can be solved using the elpee-calc.streamlit.app powered by the elpee library.

Documentation

Static Badge

Follow the documentation to get the best use of elpee.

Install

To use elpee Python library, install it using pip:

(.venv) $ pip install elpee

Example Problem

Define the Linear Programming Problem to be solved using the All Stack Starting Method by defining the Objective Function and the Constraint Expressions.

from elpee import LinearProblem

# set up a maximization problem
problem = LinearProblem(is_maximization=True)

# define the objective function
problem.add_objective('x + y')

# add the constraints to the problem
problem.add_constraint('-x + y <= 2')
problem.add_constraint('6*x + 4*y >= 24')
problem.add_constraint('y >= 1')

Add additional configurations to apply Big-M or Dual Simplex Method

problem.use_dual_simplex() # use to configure problem to use dual simplex method
problem.use_bigM() # use to configure problem to use big M method

Apply the Solver to solve the Linear Problem. The iterations to produce the results will be printed on the command line.

from elpee import ElpeeSolver

solution = ElpeeSolver.solve(problem)

Sample Output will be as follows (using dual_simplex).

...Generating Initial Feasible Solution for
     MIN           x            y            S1           S2           S3          Sol
      P           -1.0         -1.0          0            0            0            0
      S1          -1.0         1.0           1            0            0           2.0
      S2          -6.0         -4.0          0            1            0          -24.0
      S3           0           -1.0          0            0            1           -1.0
===========================================================================================

Taking S2 = 0; Entering x as a new basic variable;

...Generating Initial Feasible Solution for
     MIN           x            y            S1           S2           S3          Sol
      P           0.0         -0.333        0.0         -0.167        0.0          4.0
      S1          0.0         1.667         1.0         -0.167        0.0          6.0
      x           1.0         0.667         -0.0        -0.167        -0.0         4.0
      S3           0           -1.0          0            0            1           -1.0
===========================================================================================

Taking S3 = 0; Entering y as a new basic variable;

Feasible Solution # 1
     MIN           x            y            S1           S2           S3          Sol
      P           0.0          0.0          0.0         -0.167       -0.333       4.333
      S1          0.0          0.0          1.0         -0.167       1.667        4.333
      x           1.0          0.0          0.0         -0.167       0.667        3.333
      y           -0.0         1.0          -0.0         -0.0         -1.0         1.0
===========================================================================================

Optimized Solution Received!

And obtain an interpretation to the solution

Minimum Value for Objective Function = 4.333

Values for Decision Variables :
      x       = 3.333
      y       = 1.0

Surplus & Slack variables
  Constraint #1 Surplus    = 4.333 units
  Constraint #2 Surplus    : Satisfied at Boundary
  Constraint #3 Surplus    : Satisfied at Boundary

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elpee-1.0.3.tar.gz (82.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elpee-1.0.3-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file elpee-1.0.3.tar.gz.

File metadata

  • Download URL: elpee-1.0.3.tar.gz
  • Upload date:
  • Size: 82.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.0 Windows/10

File hashes

Hashes for elpee-1.0.3.tar.gz
Algorithm Hash digest
SHA256 fe4cf8bdef1293c889861e62a40211c4b0a298e151f9a0c135552b8543d14421
MD5 d4b7120150b06786069b5250fc8c11a4
BLAKE2b-256 38fb4811edb0885b5a2940cf7345a12b94d7a524df780fb87dda57c15a1e9416

See more details on using hashes here.

File details

Details for the file elpee-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: elpee-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.0 Windows/10

File hashes

Hashes for elpee-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c951e6c03285fde91cf02b0cecc71edd8daeba32d4b8d925e3c909f18d7bd005
MD5 9168b2dbef467b519d8a9baa140cc4ee
BLAKE2b-256 76d1a38ef81d24bbe2b0ea4e3414fad8fbe588e8bc8919440ff1db21632638a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page