Skip to main content

Implementation of simplex algorithm controlled by the primal-dual gap

Project description

Gap controlled Simplex

Test and publish package PyPI - Version PyPI - Python Version PyPI - Downloads License

gsimplex is a lightweight Python package that implements a simplex solver governed by the primal-dual gap. It integrates directly with pulp and uses numpy for its linear algebra routines. The current release supports continuous linear programming problems; mixed-integer support may be added in a future version.

Features

  • pulp compatible solver backend
  • Gap-controlled primal/dual simplex algorithms
  • Easy installation from PyPI or source
  • Built-in benchmark downloader for Plato and Netlib test sets

Installation

Install from PyPI:

python -m pip install gsimplex

Install from source for local development:

git clone https://github.com/Richie314/GapControlledSimplex.git
cd GapControlledSimplex
python -m pip install -e .
python -m pip install -e .[dev]

Run the test suite with:

python -m pytest

Usage

from pulp import LpVariable, LpProblem, LpMaximize
from gsimplex.solvers import PrimalSimplex

x1 = LpVariable("x1", lowBound=0, upBound=1)
x2 = LpVariable("x2", lowBound=0, upBound=3)

problem = LpProblem("Problem", LpMaximize)
problem += x1 + x2
problem += x1 + x2 <= 2
problem += x1 <= 1
problem += x2 <= 3
problem += x1 >= 0
problem += x2 >= 0

solver = PrimalSimplex()
problem.solve(solver)

print("Optimal value:", problem.objective.value()) # 2.0
print("Solution:", [var.varValue for var in problem.variables()]) # [1.0, 1.0]

Download benchmark problems

This package installs a command-line helper called gsimplex-download-benchmarks. It downloads the Plato and Netlib benchmark sets into a local directory, so you can test the solver on real LP problems.

By default, benchmark files are saved under the benchmark/ directory in the current working directory. Plato files are stored in benchmark/plato/, and Netlib files are stored in benchmark/netlib/.

Download all benchmarks

gsimplex-download-benchmarks

Download only one benchmark set

gsimplex-download-benchmarks --plato True --netlib False
# or
gsimplex-download-benchmarks --plato False --netlib True

Note: the CLI uses boolean flags for --plato and --netlib, so set the one you want to disable to False.

Change the destination directory

gsimplex-download-benchmarks --dir benchmark

Quiet mode

gsimplex-download-benchmarks --quiet

If you installed the package editable with pip install -e ., the command will be available immediately.

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

gsimplex-0.0.3.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

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

gsimplex-0.0.3-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file gsimplex-0.0.3.tar.gz.

File metadata

  • Download URL: gsimplex-0.0.3.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gsimplex-0.0.3.tar.gz
Algorithm Hash digest
SHA256 2a3bf2af5a6de736f7712e12f7fe541694e71e5f1104d8b582249a898dc6356f
MD5 374530c0fea36ac17f0f60310929959a
BLAKE2b-256 0fd4b772d219cbf714addcb17b6dbab38b7597b8a5abe73fcc9d7d51cce43801

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsimplex-0.0.3.tar.gz:

Publisher: pypi.yml on Richie314/GapControlledSimplex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gsimplex-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: gsimplex-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gsimplex-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 66d97a7eccd608c2abfbcd444e01505562303620807df652b58eedc38f54b270
MD5 5c00b918931a30b25da529e832115d28
BLAKE2b-256 74ddb4c6cd723aee5589795087d22664db36122667b6fb3f8996497fb5d15211

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsimplex-0.0.3-py3-none-any.whl:

Publisher: pypi.yml on Richie314/GapControlledSimplex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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