ivanovb / cspsol Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/cspsol
License: GNU General Public License v3.0
Automatically exported from code.google.com/p/cspsol
License: GNU General Public License v3.0
cspsol : Cutting stock problem solver, Version 1.0 Copyright (C) 2008, 2009, 2010, Vijay C. Patil Email : <[email protected]> cspsol is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License. See the file COPYING for the GNU General Public License, version 3. See the file INSTALL for compilation and installation instructions. ----------------------------- Introduction ----------------------------- This README describes some details of program 'cspsol'. Program 'cspsol' solves cutting stock problems and also bin packing problems. ----------------------------- Problem Definition ----------------------------- "Imagine that you work in a paper mill, and you are a manager in the paper cutting division. You have a number of rolls of paper of fixed width waiting to be cut, yet different manufacturers want different numbers of rolls of various-sized widths. How are you going to cut the rolls so that the least amount of left-overs are wasted? This turns out to be an optimization problem, or more specifically, an integer linear programming problem." Important node: Right now program minimizes number of rolls used. In other words, objective function is to minimize total number of rolls required to satisfy the demand. Other possible objective could be to minimize total amount of left over in each pattern. ----------------------------- Solution ----------------------------- Program 'cspsol' uses column generation (CG) technique and branch & bound (BB) algorithm. Best pattern/column is generated by solving sub-problem (which is integer knapsack problem). After solving the node lp using CG, if solution contains fractional variables then simple branching is used to create child nodes while becomes part of BB tree. Program stops when tree is exhausted/empty. ----------------------------- Usage ----------------------------- Following section describes usage of the program. Usage: cspsol [options...] --data filename Where filename contains orders data in following format. max_pattern_width order_width_1 demand_1 order_width_2 demand_2 order_width_n demand_n All order widths must be <= max_pattern_width. All demands, order widths and max_pattern_width must be INTEGERs. ----------------------------- Directory Structure ----------------------------- + src C++ Source code files. + include Header files. + data Sample CSP problems and test case. + data/bpp Sample BPP instances.
I just noticed strange results when given quite simple data, shown below.
Reading order data from file o1.txt
Total orders read from file = 2
2000 4
1000 4
Add order demand constraints. Total rows, cols = 2, 0
Added initial patterns. Total rows, cols = 2, 2
Node 1: new patterns = 2 Obj Func Value = 2 Branch.
Node 2: new patterns = 0 Obj Func Value = 2.33333 Branch.
Node 3: new patterns = 0 Obj Func Value = 5.33333 Branch.
Node 4: new patterns = 0 Obj Func Value = 3 INTEGER ***
Node 5: new patterns = 0 Obj Func Value = 3 INTEGER ***
Node 6: new patterns = 0 Obj Func Value = 6 INTEGER ***
Node 7: new patterns = 0 Obj Func Value = 6 INTEGER ***
Branch and bound tree exhausted.
# Solution Report #
Best integer obj. func. value = 3
Pattern count = 1: 1000 x 6,
Pattern count = 2: 2000 x 3,
# Total runtime = 0 Secs
I would expect it to give results of
Pattern count = 2: 2000 x 2, 1000 x 2
This would be optimal solution, no waste and less material needed. The
lenght of stock in this example is 6000. Attached is o1.txt file.
I'm using 0.3 version of this software. Is there something I could do to
debug this more ?
Original issue reported on code.google.com by [email protected]
on 7 Aug 2008 at 6:54
Attachments:
What steps will reproduce the problem?
1. Run those instances in the attachment through the algorithm.
Those might be just very troublesome instances, but I am wondering if there is
something wrong of if the instances are just hard. Very similar instances (with
a few less nodes 16*4 instead of 17*4) run pretty fast. Do you have any
suggestion on how to speed up this process?
-----------
Thanks a lot for this code and for making that available. I have one suggestion
for improvement: I wanted to run this code calling it from some other code I
have. It looks like it would be pretty easy to generate a lib that has a
function receiving one vector of (sizes,demands) and produce a packing (say an
assignment from items to bins). I'd be very helpful.
What version of the product are you using? On what operating system?
I am using cspsol-1.02 on Ubuntu 10.04.
Original issue reported on code.google.com by [email protected]
on 30 Jul 2010 at 6:43
Attachments:
XML report may under report the pattern count
ie: pattern count may be 4 but only 3 pattern XML reps in the report.
file:
reports.cpp
void BBNode::print_xml_report(ostream& fout, glp_prob * master_lp,
OrderWidthContainer& ow_set)
x (the pattern count) is defined as a double.
change
for (patcnt=0;patcnt<x;patcnt++) {
to
for (patcnt=0;patcnt<lround(x);patcnt++) {
Original issue reported on code.google.com by [email protected]
on 27 Oct 2009 at 3:26
I studied a little bit the litterature about cutting stock problem and I'm
wondering if could be too difficult to add existing stock (parts already
cutted) to the main problem.
Original issue reported on code.google.com by [email protected]
on 27 Oct 2009 at 11:52
Dear Vijay,
I'm trying to get as output just the quantity needed by the order
i.e. using this kind of order:
6000
334 20
I would like to get a pattern list like this:
Pattern count = 1: 334 x 3,
Pattern count = 1: 334 x 17
I'm not used to linear problem solution programming but looking at the code
and to the help file of the GLPK library I just tried to change the line to
the add_demand_constraints function in the model.cpp file like this:
glp_set_row_bnds(master_lp, row_index, GLP_FX, rhs, 0.0);
this actually did the job but the solution that I got is something similar to:
Pattern count = 3: 334 x 1,
Pattern count = 1: 334 x 17,
that is not what I'm looking for.
Could you give me an advice about this? It's possible to get what I'm
looking for?
Thank you very much,
Francesco
Original issue reported on code.google.com by [email protected]
on 17 Nov 2009 at 5:11
Consider the data set
5900
2949 130
2860 101
2849 101
1710 10
1680 11
1305 11
1230 42
1080 1
480 4
380 30
330 8
Command:
./cspsol --cgroot --data /cspsol-data.txt
On a modern OS X machine this takes approx 500 secs to exhaust the tree (even
with --cgroot).
Extending the stock length to 5950 gives a solution within just 7 secs or so.
I am using cspsol to drive a web based interactive solution.
In order to deal with the variability in timing I have modified cspsol as
follows:
1. Added a --maxtime N option that ends the node search after N seconds. This
does not exhaust the tree but merely returns the current optimal solution.
This works well in an interactive environment as the user can choose to balance
time against optimality.
2. Also added a --vsilent option that redirects stdout to /dev/null. cout.txt
can easily run to hundreds of megabytes when using --silent.
If you think these changes suitable for the repo I will post the diffs.
Original issue reported on code.google.com by [email protected]
on 25 Nov 2009 at 10:50
Hi!
It is possible to use floating point numbers for order widths (as stated in
release notes for version 0.3).
Lets consider the input:
425
46.99 67
63.5 9
82.55 38
90.17 36
67.95 20
And run calculation with default settings. We got output:
# Solution Report #
Best integer obj. func. value = 27
Pattern count = 3: 90.17 x 4, 63.5 x 1,
Pattern count = 2: 82.55 x 5,
Pattern count = 1: 63.5 x 2, 46.99 x 6,
Pattern count = 1: 46.99 x 9,
Pattern count = 4: 90.17 x 3, 82.55 x 1, 67.95 x 1,
Pattern count = 2: 82.55 x 4, 46.99 x 2,
Pattern count = 12: 90.17 x 1, 82.55 x 1, 67.95 x 1, 46.99 x 4,
Pattern count = 2: 82.55 x 2, 67.95 x 2, 63.5 x 2,
The problem is with pattern "90.17 x 1, 82.55 x 1, 67.95 x 1, 46.99 x 4".
It exceedes the maximum width (pattern width=428,63; max width=425).
The same problem is with last pattern - its width is 428.
Original issue reported on code.google.com by [email protected]
on 4 Oct 2013 at 8:46
The data set below takes 384 secs to complete on Intel 1.83GHZ 2GB RAM.
The process consumes 2.19GB of memory.
6000
3000 16
2400 8
800 12
700 8
600 16
534 16
447 16
445 16
400 12
334 16
# Total runtime = 384 Secs (column generation at every node of BB tree)
# Solution Report #
Best integer obj. func. value = 21
Pattern count = 1: 600 x 1, 445 x 12,
Pattern count = 1: 600 x 1, 534 x 10,
Pattern count = 1: 600 x 10,
Pattern count = 6: 3000 x 2,
Pattern count = 4: 3000 x 1, 800 x 3, 600 x 1,
Pattern count = 4: 2400 x 2, 400 x 3,
Pattern count = 1: 534 x 1, 447 x 1, 334 x 15,
Pattern count = 1: 534 x 2, 447 x 11,
Pattern count = 1: 700 x 3, 447 x 3, 445 x 5, 334 x 1,
Pattern count = 1: 700 x 5, 534 x 3, 447 x 1, 445 x 1,
Restricting column generation to the root node only produces a less optimal
solution but the memory requirement
peaks at around 16MB.
# Total runtime = 2 Secs (column generation at root node only)
# Solution Report #
Best integer obj. func. value = 22
Pattern count = 1: 600 x 1, 447 x 12,
Pattern count = 1: 600 x 10,
Pattern count = 5: 3000 x 2,
Pattern count = 2: 700 x 1, 534 x 7, 447 x 2, 334 x 2,
Pattern count = 1: 700 x 1, 447 x 2, 445 x 9, 400 x 1,
Pattern count = 1: 700 x 1, 447 x 1, 445 x 1, 400 x 1, 334 x 12,
Pattern count = 1: 700 x 1, 534 x 2, 447 x 2, 445 x 6, 334 x 2,
Pattern count = 2: 3000 x 1, 2400 x 1, 600 x 1,
Pattern count = 4: 3000 x 1, 800 x 1, 700 x 2, 400 x 2,
Pattern count = 2: 2400 x 2, 600 x 2,
Pattern count = 2: 2400 x 1, 800 x 4, 400 x 1,
Original issue reported on code.google.com by [email protected]
on 16 May 2009 at 9:47
Hi all,
I would like to port cspsol to windows operating system. I have compiled and
generated GLPK yesterday with MinGW32 as described in their instructions. Is
there a possibilty to define a proceure for compiling the package with gcc on
windows (MinGW)?
Thank you,
Marko Bursic
Original issue reported on code.google.com by [email protected]
on 21 Aug 2010 at 10:52
What steps will reproduce the problem?
Solution is inexact. Is this to be expected in some cases?
1.
data set
5900
1294 12
1127 12
1059 2
What is the expected output? What do you see instead?
./cspsol --data /users/jonathan/cspsol-data-1.txt
# Solution Report #
Best integer obj. func. value = 6
Pattern count = 2: 1294 x 4,
Pattern count = 2: 1294 x 1, 1127 x 4,
Pattern count = 2: 1294 x 1, 1127 x 3, 1059 x 1,
which equates to a data set of
1294 12
1127 14
1059 2
./cspsol --cgroot --data /users/jonathan/cspsol-data-1.txt
# Solution Report #
Best integer obj. func. value = 6
Pattern count = 1: 1294 x 2, 1127 x 1, 1059 x 2,
Pattern count = 2: 1294 x 4,
Pattern count = 3: 1294 x 1, 1127 x 4,
which equates to a data set of
1294 13
1127 13
1059 2
What version of the product are you using? On what operating system?
cspsol-0.9 on OS X
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 27 Oct 2009 at 4:19
I have added crude XML output to cspsol, available with "--xml" -
parameter. If you are interested, where should I send patches or should I
join the project ?
We are aiming for developing an web-enabled frontend that will get data by
XML and feed them to cspsol and return XML-based answer. We will release
the code (most likely it will be written in Ruby) for this project if you
are interested. You can contact me with my username and by adding "joiner"
dot "fi" after it.
Original issue reported on code.google.com by [email protected]
on 15 Aug 2008 at 12:16
Dear Vijay,
first of all I'd like to thank you for the great job you've done with this
tool. I really appreciate it, the program works smoothly, documentation is
great!
I tried to compile with the last GLPK version 4.52 without any luck, because
there are some incompatible API changes in GLPK.
It works with GLPK 4.44.
Do you plan to upgrade? It would be nice to keep this project up to date.
Please do not let this project die!
Jiri
Original issue reported on code.google.com by [email protected]
on 18 Sep 2013 at 11:04
Simple HTML report to show:
+ Status of run
+ Results of a run in tabular & graphical format.
+ Debug information
Original issue reported on code.google.com by [email protected]
on 3 Apr 2012 at 2:01
Attachments:
While using cspsol to calculate window/door trim for a renovation project, I
err'd in some of my lengths so shortened some of the lengths in my input file
but the result required _more_ material than the previous input file. I
narrowed it down to one problematic line item.
The following transcript illustrates the problem:
./cspsol --data moldings.txt
Reading order data from file moldings.txt
Total orders read from file = 11
48 8
28 2
67 2
73 8
21 2
27 2
84 2
87 2
85 4
74 2
60.5 2
Add order demand constraints. Total rows, cols = 11, 0
Node 1: .......
Patterns: Current = 9, New = 7, Obj Func Value = 12 INTEGER ***
Branch and bound tree exhausted.
# Total runtime = 0 Secs
# Solution Report #
Best integer obj. func. value = 12
Pattern count = 2: 85 x 2, 21 x 1,
Pattern count = 3: 73 x 2, 28 x 1,
Pattern count = 1: 48 x 4,
Pattern count = 2: 84 x 1, 60.5 x 1, 48 x 1,
Pattern count = 2: 74 x 1, 67 x 1, 48 x 1,
Pattern count = 2: 87 x 1, 73 x 1, 27 x 1,
=================
./cspsol --data moldings.txt
Reading order data from file moldings.txt
Total orders read from file = 11
48 8
28 2
67 2
73 8
21 2
27 2
84 2
83 2
85 4
74 2
60.5 2
Add order demand constraints. Total rows, cols = 11, 0
Node 1: ..........
Patterns: Current = 9, New = 10, LP worse than integer incumbent 12 >= 13.
Fathom node.
Branch and bound tree exhausted.
# Total runtime = 0 Secs
# Solution Report #
Best integer obj. func. value = 13
Pattern count = 2: 85 x 2, 21 x 1,
Pattern count = 1: 84 x 2, 21 x 1,
Pattern count = 1: 83 x 2,
Pattern count = 1: 74 x 2, 28 x 1,
Pattern count = 4: 73 x 2, 28 x 1,
Pattern count = 1: 67 x 2, 48 x 1,
Pattern count = 1: 60.5 x 2, 48 x 1,
Pattern count = 1: 48 x 4,
Pattern count = 1: 48 x 2, 27 x 2,
Other than the above issue, cspsol is exactly what I needed... Thank you!
Original issue reported on code.google.com by [email protected]
on 24 Feb 2012 at 12:30
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.