Skip to main content

A Python implementation of the cutting stock problem solver

Project description

Cutting Stock Problem

A CVXPY implementation of the cutting-stock problem.

Installation

This project uses uv for fast Python package management. If you don't have uv installed, you can install it with:

curl -LsSf https://astral.sh/uv/install.sh | sh

Setup Development Environment

  1. Clone the repository:

    git clone <repository-url>
    cd cutting-stock
    
  2. You can run commands directly with uv without activating the environment or manually installing dependencies:

    uv run 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)

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

cutting_stock-0.1.2.tar.gz (70.5 kB view details)

Uploaded Source

Built Distribution

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

cutting_stock-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file cutting_stock-0.1.2.tar.gz.

File metadata

  • Download URL: cutting_stock-0.1.2.tar.gz
  • Upload date:
  • Size: 70.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.2

File hashes

Hashes for cutting_stock-0.1.2.tar.gz
Algorithm Hash digest
SHA256 42742e28f78c9e9f2a6f5a0fcf8e8e465f40816cf4ae4e0e1e8f28cd0d120aec
MD5 fd62e04f7277abbe421e22072ae9439b
BLAKE2b-256 5ce2deea23aa03c3bb18fa1045a682103b30d4a098b541bae81158dde4240968

See more details on using hashes here.

File details

Details for the file cutting_stock-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for cutting_stock-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 199d26ef6c2c27d294c77d9b53936a41d0ec294d0eeeaee377d93c272abc97b1
MD5 cf3a067b11c449cb69edb3edc291039c
BLAKE2b-256 738258285950654cf473abf88ff3290fbc10b5586c2fa24077bd508b45ef71c6

See more details on using hashes here.

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