Skip to main content

Primal Simplex Method solver with exact rational arithmetic (Big-M)

Project description

simplex-primal

A pure-Python implementation of the Primal Simplex Method for Linear Programming.


Features:

  • ✅ Exact rational arithmetic - no floating-point drift, thanks to fractions.Fraction
  • ✅ Big-M method for artificial variables ($>=$ and $=$ constraints)
  • ✅ Supports MIN and MAX objectives
  • ✅ Handles $<=0$ and unrestricted ($R$) variables via substitution
  • ✅ Full iteration-by-iteration snapshots for teaching / debugging
  • ✅ Zero third-party dependencies (stdlib only)

Quick Start:

from simplex_primal import solve

# Maximise f = 5x1 + 4x2
# subject to:
#   6x1 + 4x2 <= 24
#    x1 + 2x2 <= 6
#   x1, x2 >= 0

result = solve(
    c=[5, 4],
    A=[[6, 4], [1, 2]],
    b=[24, 6],
    constraint_types=["<=", "<="],
    var_types=[">=0", ">=0"],
    opt="MAX",
)

print(result["status"])        # "optimal"
print(result["x_opt"])         # [Fraction(3,1), Fraction(3,2)]
print(result["f_opt"])         # Fraction(21,1)
print(result["sol_text"])      # formatted solution + verification

Installation

pip install simplex-primal

pip install git+https://github.com/cosminelulul/simplex-primal.git

References:

Coursework from Faculty of Applied Sciences, University POLITEHNICA of Bucharest.

  1. Curs_1_CO - PL(1) (S. Bibic).pdf
  2. Curs_2_CO - PL(2) (S. Bibic).pdf
  3. Cursul_3_CO - PL(3) (S. Bibic).pdf
  4. Seminar_1_CO - PL(1) (S. Bibic).pdf
  5. Seminar_2_CO - PL(2) (S. Bibic).pdf

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

simplex_primal-1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

simplex_primal-1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file simplex_primal-1.0.tar.gz.

File metadata

  • Download URL: simplex_primal-1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for simplex_primal-1.0.tar.gz
Algorithm Hash digest
SHA256 e900e07f4da5878b7b65f57c3b1c9ba1ad3250eddac49937ddabb760d5221067
MD5 4fef16b28481d3e61615abfdffeb282c
BLAKE2b-256 0d741fa30b72be9dc1778a9687a80471994b3aa74f8fa3feff8a42e8bd205699

See more details on using hashes here.

File details

Details for the file simplex_primal-1.0-py3-none-any.whl.

File metadata

  • Download URL: simplex_primal-1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for simplex_primal-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c1fcddce7734de5b15618fe23cfc163f90b720fff41c6a408935bebb66e4878
MD5 a096833612adad817c0cc7d60b429290
BLAKE2b-256 fa5e11f10952f9c0dc0d2178aaeb4659608ac080075ec416d6d22fee82b380f1

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