A Python implementation of the cutting stock problem solver
Project description
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
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
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 cutting_stock-0.1.3.tar.gz.
File metadata
- Download URL: cutting_stock-0.1.3.tar.gz
- Upload date:
- Size: 70.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5d7031f9fc7250eabe1c8fc3ae0905c3172a1fff1141a95962cf82361ddccae
|
|
| MD5 |
9cd0f41ed957f0485f1b8bb24ca8d1d3
|
|
| BLAKE2b-256 |
208325735c35a6ebc3172c01a6ec932f8c3f9a3a59cf3da76a36b521fde7fc01
|
File details
Details for the file cutting_stock-0.1.3-py3-none-any.whl.
File metadata
- Download URL: cutting_stock-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72548ab0333a5f9093006fc8630fb6a6be39f816e080c367387313539fd38b15
|
|
| MD5 |
b567e4ecac0b31ac4cab2b54771c8f95
|
|
| BLAKE2b-256 |
1c458b0b31bbc107ac3bcbe01cf18db35a58d955085231287673776b09e6ce62
|