A package that solves Linear Programs using pytorch
Project description
deeplp
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.8+
- 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
If you're using Poetry for dependency management, add it to your pyproject.toml like so:
[tool.poetry.dependencies]
deeplp = "^0.1.0" # or use the Git URL for the latest version
Basic Usage
Defining a Problem
Use the provided createProblem function to define your linear programming problem. For example:
from deeplp import 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=None, test_points=None)
Training a Model
The main training function has the following signature:
model, loss_list, mov = train(
batches=2,
batch_size=256,
epochs=500,
problems_ids=[1, 2],
cases=[1, 2],
do_plot=True,
saving_dir="my_saved_models"
)
Running the CLI
After installing the package (which sets up a CLI entry point via Poetry), you can run:
deeplp --batches 1 --batch_size 128 --iterations 1000 --case 1 --example 1 --do_plot --folder saved_models
This command runs your CLI to start training with the specified options.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deeplp-0.5.15.tar.gz.
File metadata
- Download URL: deeplp-0.5.15.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
495320c4d557e1945523d2f51eeb642eee2c90745a69f4e412384e09f5264c59
|
|
| MD5 |
27b418263d206a7647455b0728193313
|
|
| BLAKE2b-256 |
45325f378e74442dbab9c50aa1b6be715310df9e7912b3acc374641218e98c72
|
File details
Details for the file deeplp-0.5.15-py3-none-any.whl.
File metadata
- Download URL: deeplp-0.5.15-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6165ce8d7a63262f4d7fd4b4bf3a20d3a80c9ad7e694f5824e83136887075633
|
|
| MD5 |
a84946f8d53c455ba0e87c174c467fa4
|
|
| BLAKE2b-256 |
d87e846fb89839b87eac3cfec6d9c1fc9d89c4fef5f4a3514b62d963c9b4986f
|