Coder Social home page Coder Social logo

csp's Introduction

Cutting Stock Problem

Cutting Stock Problem (CSP) deals with planning the cutting of rods from given stock items.

  • This implementation of CSP tries to answer
    How to minimize number of stock items used while cutting customer order?
  • While doing so, it also optimizes for
    How to cut the stock for customer orders so that waste is minimum?

Quick start

Clone this project and install required packages:

$ git clone [email protected]:jaburjak/csp.git
$ cd csp
$ python -m venv env
$ source env/bin/activate
$ pip install -r requirements.txt

Usage

To solve your Cutting Stock Problem, run the stock_cutter_1d.py file:

(env) $ python csp/stock_cutter_1d.py infile.txt

Output:

{
    "statusName": "OPTIMAL",
    "numSolutions": 1,
    "numUniqueSolutions": 1,
    "numRollsUsed": 5,
    "solutions": [
    	[
            // [unused_stock_width, [item_width...]]
            [0, [3400, 500, 500, 500, 220, 220, 220, 220, 220]],
            [80, [500, 500, 500, 500, 220, 1850, 1850]],
            [10, [220, 220, 1850, 1850, 1850]],
            [90, [3400, 220, 220, 220, 1850]],
            [880, [3400, 500, 500, 500, 220]]
        ]
    ]
}

You can use option --no-fast to use a more precise model (also slower) algorithm for calculation.

Using the input file

The first number in the input file must be the stock width followed by requested item widths. Numbers should be separated by whitespace.

Libraries

Limitations

  • Works with integers only. If you have some values that have decimal part, you can multiply all of your inputs with some number that will make them integers (or close estimation).

Acknowledgements

This project is a fork of Emad Ehsan’s CSP solver, which in turn builds on the code of Serge Kruk.

csp's People

Contributors

benlawraus avatar dependabot[bot] avatar emadehsan avatar jaburjak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.