Skip to main content

deeplp

PyPI version License: MIT

deeplp is a Python package for solving linear programming problems using deep learning techniques. It leverages PyTorch for its backend computations and provides a simple API for defining problems and training models.

Features

  • Define linear programming problems with a simple API.
  • Train deep learning models to solve LPs.
  • Built-in support for plotting results and saving models.
  • A command-line interface (CLI) for running experiments.
  • Available on PyPI for easy installation.

Requirements

deeplp requires:

  • Python 3.10+
  • PyTorch (with GPU support if desired)

Installing PyTorch

Visit the PyTorch website for installation instructions. For example, to install PyTorch with CUDA 11.3 support on Windows:

pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118

For CPU-only support, run:

pip install torch torchvision torchaudio

Installation

You can install deeplp either from PyPI or directly from GitHub.

Installing from PyPI

pip install deeplp

Installing from GitHub

pip install git+https://github.com/yourusername/deeplp.git

Basic Usage

Example 1: Solving a Simple LP

from deeplp import train, createProblem

# Define your problem data:
c = [1.0, 2.0]  # Objective coefficients
A = [[3, -5], [3, -1], [3, 1], [3, 4], [1, 3]]  # Constraint matrix
b = [15, 21, 27, 45, 30]  # Right-hand side values
tspan = (0.0, 10.0)  # Time span

# Create the problem (if no name is provided, a name is generated automatically)
problem = createProblem(
    c,
    A,
    b,
    tspan,
    name="Custom Example 1",
    b_testing_points=[[15, 21, 27, 45, 30], [15, 12, 20, 25, 50]],
    c_testing_points=[[2, 5], [12, 20]],
)

# Train the model
sols = train(
    batches=1,
    batch_size=32,
    epochs=100,
    problem=problem,
    problems_ids=[],
    cases=[1, 2, 3],
    do_plot=True,
    model_type="pinn",
)

Example 2: Solving an LP with Equality Constraints

from deeplp import train, createProblem

# Define your problem data:
c = [1.0, 2.0, -1.0, -2.0, 0, 0, 0, 0, 0]  # Objective coefficients
A = [
    [3, -5, -3, 5, 1, 0, 0, 0, 0],
    [3, -1, -3, 1, 0, 1, 0, 0, 0],
    [3, 1, -3, -1, 0, 0, 1, 0, 0],
    [3, 4, -3, -4, 0, 0, 0, 1, 0],
    [1, 3, -1, -3, 0, 0, 0, 0, 1],
]  # Constraint matrix
b = [15, 21, 27, 45, 30]  # Right-hand side values
tspan = (0.0, 10.0)  # Time span

# Create the problem
problem = createProblem(
    c,
    A,
    b,
    tspan,
    name="Custom Example 2 (Equality)",
    b_testing_points=[[15, 21, 27, 45, 30], [15, 12, 20, 25, 50]],
    c_testing_points=[c],
)

# Train the model
sols = train(
    batches=1,
    batch_size=32,
    epochs=100,
    problem=problem,
    problems_ids=[],
    cases=[3],
    do_plot=True,
    model_type="rnn",
)

Running the CLI

After installing the package, you can run:

deeplp --batches 1 --batch_size 128 --iterations 1000 --case 1 --example 1 --do_plot --folder saved_models

For other options, type

python deeplp --help

This command starts training with the specified options using the RNN model for case 3, example 2, with 2 iterations, 2 batches, and a batch size of 1.

Metadata

Release files for deeplp 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deeplp 0.7.1
File Size Uploaded Provenance
deeplp-0.7.1.tar.gz 15.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for deeplp 0.7.1
File Interpreter ABI Platform
deeplp-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 32.7 kB

Release files / deeplp-0.7.1.tar.gz

Download URL deeplp-0.7.1.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6513131f632965b24702bbf54139104d33caa227086af1acb9afda701b0512fe
BLAKE2b-256 checksum
How to use checksums
b50f906daac99680c3db5b8fd218be9e24571fcb36ec90c7f1504d59442dfb3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Windows/11

Release files / deeplp-0.7.1-py3-none-any.whl

Download URL deeplp-0.7.1-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9038b328f6bd2396496d13c9f71c883db285722f4ed6076f96ff711d883bbf58
BLAKE2b-256 checksum
How to use checksums
2c87e8c26216cf6c5d360a888b0deac67bc10becc1bb2d757b5a22ba44316476
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Windows/11

Security for deeplp 0.7.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page