Cutting Stock Problem
A CVXPY implementation of the cutting-stock problem.
Installation
The project is available on PyPI. You can install it using pip:
pip install cutting-stock
Alternatively, if you are a uv user, you can install the associated CLI directly:
uvx cutting-stock
or you can add it to your environment dependencies:
uv add cutting-stock
Command Line Options
-r, --roll_length: The length of the roll. E.g. -r 12.0
-l, --lengths: The lengths of the items. Must be a list of floats. E.g. -l 3.4 3.0 2.7
-q, --quantities: The quantities of the items. Must be a list of floats. E.g. -q 34 13 5
-s, --solver: The solver to use. Must be either GLPK or ECOS. E.g. -s GLPK
-g, --ge_required: If specified, the constraint is >= instead of ==.
--verbose: If specified, the output will be more verbose.
Example
uv run cutting-stock -r 12.0 -l 3.4 3.0 2.7 -q 34 13 5
This produces the following output:
> uv run cutting-stock
Required pieces:
███ 3.4m ×34 ▓▓▓ 3.0m ×13 ▒▒▒ 2.7m ×5
Stock length: 12m
Solution: 16 stocks of 12m each, 23.9m waste
Use 10× → 3.4m |3.4m |3.4m |1.8m
█████|█████|█████|···· (12m stock)
Use 2× → 3.4m |3.4m |2.7m|2.5m
█████|█████|▒▒▒▒|···· (12m stock)
Use 3× → 3.0m |3.0m |3.0m |3.0m
▓▓▓▓▓|▓▓▓▓▓|▓▓▓▓▓|▓▓▓▓▓ (12m stock)
Use 1× → 3.0m |2.7m|2.7m|2.7m|0.9m
▓▓▓▓▓|▒▒▒▒|▒▒▒▒|▒▒▒▒|···· (12m stock)
Setup Development Environment
-
This project uses uv for fast Python package management. If you don't have uv installed, you can install it with: Install
uv:If you have
curlinstalled, you can run:curl -LsSf https://astral.sh/uv/install.sh | sh
-
Clone the repository:
git clone <repository-url> cd cutting-stock
-
You can run commands directly with uv without activating the environment or manually installing dependencies:
uv run cutting-stock
Development
Running Tests
uv run pytest
Code Formatting and Linting
uv run ruff check src/
Dependencies
- scipy: Scientific computing library
- numpy: Numerical computing library
- cvxpy: Convex optimization library
- cvxopt: Convex optimization library
License
MIT License
Metadata
Release files for cutting-stock 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cutting_stock-0.1.3.tar.gz | 70.6 kB | Without provenance | Details for cutting_stock-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cutting_stock-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for cutting_stock-0.1.3-py3-none-any.whl |
Total release size: 78.4 kB
Release files / cutting_stock-0.1.3.tar.gz
| Download URL | cutting_stock-0.1.3.tar.gz |
|---|---|
| Size | 70.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5d7031f9fc7250eabe1c8fc3ae0905c3172a1fff1141a95962cf82361ddccae
|
|
BLAKE2b-256 checksum How to use checksums |
208325735c35a6ebc3172c01a6ec932f8c3f9a3a59cf3da76a36b521fde7fc01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.2
|
Release files / cutting_stock-0.1.3-py3-none-any.whl
| Download URL | cutting_stock-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
72548ab0333a5f9093006fc8630fb6a6be39f816e080c367387313539fd38b15
|
|
BLAKE2b-256 checksum How to use checksums |
1c458b0b31bbc107ac3bcbe01cf18db35a58d955085231287673776b09e6ce62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.2
|
Security for cutting-stock 0.1.3
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.