Cutting Stock Problem (CSP) deals with planning the cutting of items (rods / sheets) from given stock items (which are usually of fixed size).
![Video Tutorial on Cutting Stock Problem](https://raw.githubusercontent.com/benlawraus/csp/master/./github/video-thumb.jpg)
This implementation of CSP tries to answer
How to minimize number of stock items used while cutting customer order
while doing so, it also caters
How to cut the stock for customer orders so that waste is minimum
The OR Tools also helps us in calculating the number of possible solutions for your problem. So in addition, we can also compute
In how many ways can we cut given order from fixed size Stock?
This is how CSP Tools looks in action. Click CSP Tool to use it
$ git clone https://github.com/emadehsan/csp
$ pip install ortools
If you run the stock_cutter_1d.py
file directly, it runs the example which uses 120 as length of stock Rod and generates some customer rods to cut. You can update these at the end of stock_cutter_1d.py
.
$ python stock_cutter_1d.py
Output:
numRollsUsed 5
Status: OPTIMAL
Roll #0: [0.0, [33, 33, 18, 18, 18]]
Roll #1: [2.9999999999999925, [33, 30, 18, 18, 18]]
Roll #2: [5.999999999999993, [30, 30, 18, 18, 18]]
Roll #3: [2.9999999999999987, [33, 33, 33, 18]]
Roll #4: [21.0, [33, 33, 33]]```
- Works with integers only: IP (Integer Programming) problems working 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).
- You cannot specify units: Whether your input is in Inches or Meters, you have to keep a record of that yourself and conversions if any.
The whole code for this project is taken from Serge Kruk's