Sei sulla pagina 1di 8

An Algorithm for the positioning of two dimensional shapes minimizing free space.

S I Wattam1

Abstract

Manufacturing items, where the shapes are two dimensional and cut from larger sheets of
material is a ‘cutting stock problem’. There has been considerable interest in this
problem, because of the need to minimize waste, and increase optimisation of the sheet
material.
This paper introduces a suitable heuristic, which allows the assessment of optimum
layout.

Keywords: Cutting Stock, Heuristic, Hill Climb

Introduction

This paper examines a possible heuristic algorithm to layout shapes or patterns on a 2


dimensional surface or sheet. This problem is often met in industry when trying to
optimise the use of sheet material such as wood, cloth or metal. Which is essentially the
‘cutting stock' problem.

The algorithm was developed from a simple idea of placing shapes at random on the
surface, and examining ways of optimising that placement by using heuristics that have
been suggested in literature. Namely the largest first heuristic. However, what is also
critical to the efficiency of the algorithm is the pre processing of the shapes into size, and
the suggested placing of the shapes on the sheet automatically by the algorithm.

The efficiency of the suggested layout is then tested using a suitable ‘Hill Climb’
formulation to assess the amount of white space available. Thus by minimising white
space, the algorithm generates a suggested optimal fit for the given patterns.

Method

Both secondary and primary research were used to establish the results. The secondary
research consisted of previous work, and a literature search on suitable heuristic methods
for shape placement of 2D surfaces. (Wattam, 2004). These were then combined to
generate a suitable compound heuristic and an algorithm developed along with a
preliminary test of the suggested algorithm using suitable computer software.

Results and Discussion

The shape of each item is known, and of two dimensions (assuming sheet material).
There are a finite number of units to cut from a sheet. The assumption therefore is that the

1 Stuart Wattam MSc, C Eng Senior Lecturer at The Department of Mechanical Engineering, Gadjah Mada
University, Yogyakarta

1
shape and areas occupied by each shape can be laid out on a grid that comprises of
known interrelated tiles. A finer grid the more accurate the area and placement of the
shapes (Rooney,1987).
When cutting objects from a sheet allowance must be made for the width of any cutting
tool.

Error: Reference source not foundFigure 1 Seven items to be cut from a rectangular
sheet

Figure 1 shows a typical layout of items to be cut from a rectangular sheet, also showing
the allowance made for the cutting tool.

Initially we can simplify the layout by ignoring the allowance made for the cutting tool,
and making the grid course. The shapes are reflected in the relative number of grid tiles
occupied, and the allocation of a number.

1 1 1 1 1 2 2 2 2 3 3 3 3 3
1 1 1 1 1 2 2 2 2 3 3 3 3 3
1 1 1 1 1 2 2 2 2 3 3 3 3 3
1 1 1 1 4 4 4 4 4 3 3 3 3 3
1 1 1 1 4 4 4 4 4 3 3 3 3 3
1 1 1 1 4 4 4 4 4 3 3 3 3 3
5 5 5 5 4 4 4 4 4 7 7 7 7 7
5 5 5 5 6 6 6 6 6 7 7 7 7 7
5 5 5 5 6 6 6 6 6 7 7 7 7 7
5 5 5 5 6 6 6 6 6 7 7 7 7 7
5 5 5 5 6 6 6 6 6 7 7 7 7 7
Figure 2. Items laid on a rectangular sheet sowing relative size

Putting unit space around each item except at the edges allows the simulation of cutting
space.

1 1 1 1 1 2 2 2
1 1 1 1 1 2 2 2
1 1 1 1 1 2 2 2
1 1 1 1
1 1 1 1 4 4 4 4
1 1 1 1 4 4 4 4
4 4 4 4
5 5 5 5
5 5 5 5 6 6 6 6
5 5 5 5 6 6 6 6
Figure 3. Showing trimming or cutting space

The grid space needs to reflect the wastage, or trim / cutting allowance. The problem

2
therefore is to place the shapes in suitable order on the sheet, and then minimise the
amount of unused space.
In principle the simplest way of placement of items on a sheet is to generate every
possible layout, and then calculate the waste involved. This exhaustive generation
increases factorally with the number of items to be placed.

Table 1. Factorial expansion


n! n!
70
5040
40320
24 362880
120 10 362880
0

In the examples given earlier the number of items to be placed is 7 giving 5040 possible
layouts from Table 1. Obviously some will be mirror images of one another therefore, the
total number is nearer 1000. Thus when considering larger numbers of objects e.g. 11 the
number of possibilities would approach 40 million.

Figure 3 shows the layout with cutting space (Waste). The algorithm should minimise the
layout so that the packing of items on the sheet is optimised.

∑ Ai
The area of the sheet is S, and the are of the items is i =1
7

∑ Ai
The waste is therefore S - i =1 =W (1)
From equation (1) by packing the items Ai closer together, and in an optimum
configuration.

∑ Ai
S- i =1 >= W (2)

By initialising the grid pattern and summing the unused areas we can obtain a value for
W. The lowest value for W will be the best fit. So called ‘Hill Climb’ (Rooney, 1987),
has been used to fit space to areas and optimise fit. However, most successful algorithms
have a preliminary process to order the parts in some way. One successful heuristic has
been ordering the parts by size, fitting the parts on the sheet in size order. These are
widely discussed in literature (Coffman, 1984; Haesler, 1988; Burke, 2000).

Therefore to achieve this we must firstly size and sort the patterns prior to fitting on the
sheet. There are various ways of sizing the patterns. In CAD the usual process is to find
an enclosing polygon, and then calculate the area given the vertices of the ploygon. This

3
can be done in either vector notation, or by examining the raster properties of the shape in
question.

We look firstly at the vector representation of polygons. Regular polygons are tabulated.
(Avallone, 1996), alternatively they can be calculated knowing the number of vertices,
and the coordinates. (Mortenson, 1989).

El 2 π
A= Cot ( )
4 2E (3)

Where E is the number of vertices, and l is the perimeter of the polygon.

The perimeter l is calculated from the vertices equation (4), then substituting in (3) for the
area.

( x1 − x 2) 2 + ( y1 − y 2) 2 + ( x2 − x3) 2 + ( y 2 − y3) 2 + ...+ ( x n − x1) 2 + ( y n − y1) 2


(4)

The more general case of a convex irregular polygon can be calculated from calculating
the trapezoids and summing for all the trapeziums. (Foley, 1984; O’Rourke; 1995,
Gosper, 1998; Prashker, 1999). Equation (5) can be implemented by counting round the
polygons vertices.

N −1
A = 0.5∑ [( xi + 1 − xi )( yi + yi + 1)]
i =1 (5)

4
Figure 4. Vector polygon with each side subtending a trapezoid

Assuming a clockwise directed polygon as in figure 4 the area can be calculated using
equation (5).

The second method for obtaining the area of a random shape is by using the standard
raster patterns, and fitting these to the shape.(Prashker, 1999). There are 256 unique value
patterns, and the algorithm systematically applies the patterns to a moving window at
each pixel, and a running total of perimeter values is kept. This is then multiplied by the
length of the pixel edge to give the area of the polygon. For a large image, and many
pattern polygons this can take some time, and the vector method is preferred for speed.
Therefore, it is this method that is used in this paper to calculate the area of each
individual shape.

Once the area is calculated, the list of shapes, and the area is sorted in size order resulting
in a definition file.

Table 2. Definition file format

Item Code Item Number Area Vertices Coordinates

The left hand bottom corner of the pattern item is the first coordinate in the list of
coordinate vertices. The left hand bottom corner is chosen by convention in CAD
packages as the start point in polygon drawing. This shape table can then be used to
generate the layout on the sheet material. There will still be the necessity to try various
layouts to find the optimum layout, but the number of trials will be reduced by using the
heuristic of largest first.
Place this beginning at coordinate (0,0) for the left hand bottom most corner. And then
subsequently fitting the rest of the patterns.

In addition to the items included in Table 2 the shape can be given an orientation

5
(winding number) that indicates the top left most vertices and a flip logic switch.
Which will aid the speed of the algorithm. These additions are shown in Table 3.

Table 3.Improved Definition File Format

Item Code Item Number Area Winding Vertices Flip Coordinates

2 2 2 2 2 3 3 3
2 2 2 2 2 3
2 2 2 2 2 3
2 2 2 2 2 3 3 3

1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
Figure 5. Trial layout

The calculation of the white space for this layout (Waste) Figure 5 gives a value of 49.
Rotating shapes, and possibly flipping the shape, providing that the sheet is suitable, can
generate other possible layouts.

The algorithm

Outline basic Algorithm, which consists of three loops.

for every shape to be nested do


Temp_l := l
for every orientation of the shape do
for every corner of the layout do
for every corner of the shape do
Nest shape with layout
f := fitness(l);
if f > Max_f then
Max_f := f
Best_Shape := current shape
l := Temp_l

6
Nest Best_Shape with l
Display(l)

Without prior heuristic sorting on the definition table the timing of the above algorithm
suggests that it would be or the order of k*m*n where k is the number of possible
orientations of the shape, m is the number of possible corners of the sheets and n the
number of corners or vertices of the individual shapes.

Conclusions

Pre sorting a definition table using simple techniques such as hill climbing can save time
in a particular algorithm. It also allows a high level graphical interface which can be
manipulated further, prior to committing the layout on to a particular sheet.

The addition of cutting path allocation also allows the estimation of waste, or unused
sheet area to be minimized in addition to optimisation of the layout.

There are numerous other possible heuristics that could be tried. However, the literature
suggests that a simple heuristic coupled with a simple graphical interface produces
satisfactory results.

The work in the paper therefore needs extending to include a graphics display that will be
compatible for further processing, and machine control.

7
References

Avallone, E. A, Baumeister, T, Marks’ Standard Handbook for Mechanical Engineers,


Tenth Edition, Mc Graw Hill.

Burke E. and Kendall G. 2000.Comparison of Meta-Heuristic Algorithms for Clustering


Rectangles, Computers and Industrial Engineering, Vol. 37, Iss. 1-2, pp 383-386.

Coffman, Jr, E.G., M.R. Garey, and D.S. Johnson. 1984, Approximation Algorithms for
Bin-Packing -- An Updated Survey. In Algorithm Design for Computer System Design,
ed. by Ausiello, Lucertini, and Serafini. Springer-Verlag.

Foley, J.D., Van Dam, 1984, Fundementals of Computer Graphics, Addison Wesley.

Gosper, J. J., 1989, www.brunel.ac.uk/~castjjg/java/polygon.html.

Haessler, R.W. 1988, Selection and Design of Heuristic Procedures for Solving Roll
Trim Problems, Management Science,December.

Mortenson, M. E., 1989, An Introduction to the Mathematics and Geometry of Computer


Graphcs, Heinmann Newnes.

O’Rourke, J., 1995, Computational Geometry in C, Cambridge Press.

Prashker, S., 1999, An improved algorithm for calculating the perimeter and area of
raster polygons, Geocomputation

Rooney, J., 1987, Principles of Computer Aided Design, Pitman / Open University.

Wattam, S, (2004), Literature review of the 'Cutting Stock' algorithm, ????.

Potrebbero piacerti anche