Download WPEssink CARV 2013 V4.2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Pattern recognition wikipedia , lookup

Computational phylogenetics wikipedia , lookup

Natural computing wikipedia , lookup

Mathematical optimization wikipedia , lookup

Algorithm characterizations wikipedia , lookup

Multiple-criteria decision analysis wikipedia , lookup

Factorization of polynomials over finite fields wikipedia , lookup

Dijkstra's algorithm wikipedia , lookup

Travelling salesman problem wikipedia , lookup

Expectation–maximization algorithm wikipedia , lookup

Algorithm wikipedia , lookup

K-nearest neighbors algorithm wikipedia , lookup

Genetic algorithm wikipedia , lookup

Transcript
Toolpath Generation for CNC Milled Parts Using Genetic Algorithms
Wesley P. Essink, Aydin Nassehi, Stephen T. Newman
Department of Mechanical Engineering, University of Bath, Bath, BA2 7AY, UK,
Tel.:+44 (0)1225-386131; E-mail: [email protected]
ABSTRACT
As manufactured products become increasingly more complex, generating machining toolpaths to manufacture these products
are also becoming more complicated. Toolpath generation algorithms struggle when dealing with large numbers of data points
due to the complex features on a design. In this research, a genetic algorithm is proposed to solve a variation of the travelling
salesperson problem to generate a machining toolpath. Genetic algorithms are a more flexible approach to generating
toolpaths as it is independent of the geometry of the part. Novel algorithms for the fitness function and mutation operator are
proposed to ensure an optimal toolpath is generated without the genetic algorithm converging prematurely.
Keywords:
Genetic Algorithm; Toolpath Generation; Traveling Salesman Problem
1. INTRODUCTION
As manufacturing industry is becoming increasingly more automated
with the industry’s shift from craft production to mass customisation,
several paradigm shifts have occurred for this to be possible. From the
use of machines to replace hand-made parts, through the use of
production lines to increase the volume of products being made, to the
use of robots to ensure repeatable quality in all of the products
produced.
In the manufacturing world today the main challenge is keeping up with
the fast pace of technology development and making sure
manufacturing technology is flexible enough to keep up. One of the
main issues that need to be tackled is the time taken between design
and manufacture. Every time a new prototype is designed or a design is
modified, a new CNC machining program needs to be developed to
manufacture the part. This can be very time consuming to do manually.
This paper proposes a method of generating the machining toolpaths
required to create a CNC machining program using a genetic algorithm.
Genetic algorithms are independent of part geometry and so can
generate toolpaths for many different types of parts. As designs are
becoming increasingly more complex, the number of data points
required to describe the product increases as well, hence making
analytical methods of generating toolpaths very time consuming.
2. TOOLPATH GENERATION
There is a wide variety of literature available on toolpath generation as
there are many methods of generating toolpaths. A pioneering survey
paper was written by Dragomatz and Mann [1] in 1997 which covers
many of the widely used methods used to generate toolpaths as well as
a few non-traditional methods.
Traditional methods of generating toolpaths usually involve drawing
parallel lines to the contours on the part [2]. This can be done in a
variety of ways; one method is to use Voronoi diagrams to segment the
space within a boundary into sections and then using offset curves to
generate the toolpaths in each space [3]. Toolpaths have also been
generated from large amounts of point cloud data by separating the
points into bands and drawing toolpaths along the band lines [4]. The
drawbacks to this method are the lack of a finishing cut toolpath and the
difficulty in verifying the accuracy of the finished product.
The problem with these methods is that they are not very flexible as
they are usually designed to generate toolpaths for specific types of
features or using a specific machining strategy. A universal algorithm is
required which can generate a machining toolpath for any feature as
defined by the ISO 10303-21 standard [5] and for any machining
strategy as defined by the ISO 14649-11 standard [6].
Heuristics have been used for path planning in several applications one
of them being spray forming [7]. A study was done comparing the use of
genetic algorithms and ant colony optimisation on path planning in
spray forming. It was found that genetic algorithms produced faster
results at the cost of lower quality solutions [7].
3. SHORT OVERVIEW OF GENETIC ALGORITHMS
A genetic algorithm is effectively a heuristic technique used to optimise
a problem to a specified goal. Genetic algorithms were inspired by the
biological method of natural selection which can be seen in evolution.
Genetic algorithms are used to optimise many different designs from
structural engineering [8], manufacturing [9], aerospace engineering
[10] as well as many more. Genetic algorithms were first used to solve
the travelling salesman problem in 1985 by Brady [11]. This was later
developed further by Goldberg and Linge [12]. A full review on using
genetic algorithms for the travelling salesman problem was done by
Larrañaga in 1999 [13].
To represent a solution for the travelling salesman in genetic form, each
gene will contain a city/point. The chromosome will then contain the
order in which all of the cities/points are visited. Each point can only be
visited once and all of the points have to be visited. An initial random
population is created and then assessed in terms of its fitness. The
fitness function will measure how well each species in a population is
performing with respect to a specific goal. A new population can then
be created by mating the fittest species of the previous generation
together to ensure the best patterns of genes are carried over into the
next generation. Mutation of genes can be applied at this stage to
ensure the search space of the genetic algorithm is wide enough to
converge on the optimal solution. There are many methods of crossing
over genes during mating as well as mutation algorithms for ordered
chromosomes which will be discussed later.
5th International Conference on Changeable, Agile, Reconfigurable and Virtual Production (CARV2013), Munich, Germany 2013
4.
TOOLPATH GENERATING GENETIC ALGORITHM
STRUCTURE
The genetic algorithm structure can be used to generate toolpaths for
machining by dividing the surface of a modelled part into a grid and
treating each coordinate of the grid as a city in the travelling salesman
problem. By comparing the starting billet surface to the end product
surface at each cut depth, a toolpath can be generated by solving the
travelling salesman problem for each cut.
Figure 3: Detailed view of the grid in Figure 2.
Figure 1: Example part.
Figures 1 and 2 illustrate how this grid system could be applied to an
example part. As the part is described using the STEP part 21 data
structure [5], all of the boundaries of the features on the part would be
known so that the grid would omit these points. In Figure 2 the white
points would indicate material that would have to be removed and
black points would be avoided by the machining toolpath to create the
required features. Figure 3 is a closer look at the grid in Figure 2. Each
point in the grid has a number as well as a coordinate. Each point can
be referenced either by its coordinates or by the point number (i.e.
0-35).
4.1. DEVELOPING THE GENETIC ALGORITHM
To design the genetic algorithm for generating toolpaths, the nature of
a toolpath has to be converted into a genetic structure. Each point that
the toolpath passes through can be seen as a city in the travelling
salesman problem. To represent a toolpath in a genetic form, each
point’s location can be stored as the genotype of a gene in a
chromosome. A chromosome in this context represents a particular
toolpath through all the available points. Each species in a population
will represent a possible solution to the problem of finding the most
efficient toolpath. A population represents a collection of toolpath
solutions in the current generation.
Figure 2: Grid of points for example part.
Figure 4: Example chromosome for grid in Figure 3.
Figure 4 illustrates the structure of the ordered chromosome. Each
number in the genotype refers to one of the points in the matrix shown
in Figure 3. To create a toolpath from the data in the chromosome, the
points have to be joined in a linear fashion in the order described by the
chromosome. The toolpath for the chromosome in Figure 4 can be
seen in Figure 5.
function to reward continuation of a previous direction. This will shorten
the path of movement through points while moving a constant
direction. Each subsequent point travelled in the same direction will
reduce that segment of the path by fifty %.
π‘‰π‘–π‘Ÿπ‘‘π‘’π‘Žπ‘™ π‘ƒπ‘Žπ‘‘β„Ž πΏπ‘’π‘›π‘”π‘‘β„Ž =
1
(4)
2π‘ƒβˆ’1
where p = number of consecutive points along same direction.
Table 1: Benefit to the path length for continued path direction.
Number of
Virtual
Percentage of
consecutive points
Length
Original Distance
Figure 5: Example toolpath for chromosome in Figure 4.
By separating the three dimensional model into multiple two
dimensional layers by the cut depth, the travelling salesperson problem
can be simplified. Instead of solving the travelling salesperson problem
on the whole model, the genetic algorithm can solve the problem for
each layer of the model. This greatly reduces the amount of time
required to solve the problem as can be seen by the following:
Number of Possible Solutions = (π‘‹π‘Œπ‘)!
(1)
where X = points along X axis, Y = points along Y axis, and Z = points
along Z axis.
𝑍
Number of Possible Solutions = ( )(π‘‹π‘Œ)!
𝐷
(2)
where X = points along x axis, Y = points along Y axis, Z = points along
Z axis, and D = cut depth.
A simple calculation can be done to show the benefit of separating the
model into layers. For example a cube with 5mm sides and a cut depth
of 1mm:
π‘π‘’π‘šπ‘π‘’π‘Ÿ π‘œπ‘“ π‘ƒπ‘œπ‘ π‘ π‘–π‘π‘™π‘’ π‘†π‘œπ‘™π‘’π‘‘π‘–π‘œπ‘›π‘  = (5 × 5 × 5)! = 1.88 × 10209
5
π‘π‘’π‘šπ‘π‘’π‘Ÿ π‘œπ‘“ π‘ƒπ‘œπ‘ π‘ π‘–π‘π‘™π‘’ π‘†π‘œπ‘™π‘’π‘‘π‘–π‘œπ‘›π‘  = ( ) (5 × 5)! = 7.76 × 1025
1
4.2. FITNESS FUNCTION
To assess the quality of each species, a fitness function is used. The
fitness function will compare one or more features in the species to one
or more specific goals. For this genetic algorithm, the goal is to
generate a toolpath with the shortest length possible while being as
straight as possible.
To measure the performance of a species, the length of the toolpath
needs to be calculated. This can be done using a simple calculation
which sums the distance between all of the ordered points in the
species’ toolpath.
𝑝
Total Path Length = βˆ‘π‘›=1 √(π‘₯𝑛 βˆ’ π‘₯π‘›βˆ’1 ) + (𝑦𝑛 βˆ’ π‘¦π‘›βˆ’1 )
(3)
where p = number of points, x = position in x axis, and y = position in y
axis.
At this point the fitness function can be modified to accomplish
secondary goals. As the secondary goal is to keep the toolpath as
straight as possible, a second equation can be inserted into the fitness
1
1.00
100.00%
2
1.00
50.00%
3
0.75
25.00%
4
0.50
12.50%
5
0.31
6.25%
Through using the virtual path length for the fitness function it will
ensure that it is always more beneficial for a species to have one more
consecutive point than the last species. This will ensure that a
straighter toolpath will be chosen over one with more turns.
4.3. GENE CROSSOVER
To create a new generation of species, a selection of the fittest species
from the previous generation need to share their genes with each
other. This allows the population to retain superior gene combinations
while discarding inferior combinations.
There are many algorithms for crossing over genes in an ordered
chromosome. There is the Partial Mapped Crossover (PMX) [12],
Ordered Crossover (OX) [14], Position Based Crossover (POS) [14],
Edge Recombination Crossover (ER) [15], Sorted Match Crossover
(SMX) [11] as well as many others. The chosen method will depend on
the computational effort required and the time required to reach an
optimal solution. According to Larrañaga et al., the methods which
require the least iterations are the PMX, POS and ER methods [13]. Of
these three, ER is said to generate the most optimal solutions [13].
While developing the genetic algorithm, all three crossover strategies
(PMX, POS and ER) will be tested to see which of three strategies
performs best in terms of time to converge as well as quality of the
solution given by the genetic algorithm.
4.4. MUTATION
To ensure the genetic algorithm converges on an optimal solution, it is
important to keep the available genes in the gene pool as diverse as
possible. One way to do this is to insert new gene combinations into the
gene pool by adding a mutation function into the genetic algorithm. As
the algorithm is dealing with an ordered chromosome, mutating a gene
value to a random number can cause a point to be visited twice and
another point not at all. To avoid this, a method of mutating the current
gene to one of the nearest neighbours of the previous gene is
proposed. This method calculates the nearest neighbours of the
previous gene and randomly selects one of the available neighbours.
The sequence of figures from Figure 6 to Figure 9 illustrates the
nearest neighbour mutation method. Figure 6 is an example of a
toolpath which is not completely optimal. In Figure 7 the gene targeted
for mutation is highlighted along with its nearest neighbours. The
genetic algorithm will then select one of these nearest neighbours at
random to become the next point in the toolpath order. In Figure 8 the
optimal nearest neighbour is selected and its position is then switched
with the original gene to ensure order is kept in the chromosome. The
result of the mutation can be seen in Figure 9 where the two switched
genes are highlighted. The toolpath is now of optimal length and
direction.
where, X = points along X axis, Y = points along Y axis, and N =
number of nearest neighbours.
π‘‹π‘Œβˆ’1
Therefore there is an
increase in probability of having a successful
𝑁
mutation when using the nearest neighbour method.
Figure 6: Non optimal toolpath.
Figure 9: Next gene location switched with nearest neighbour.
5. VALIDATING THE GENETIC ALGORITHM
To validate the genetic algorithm a test needs to be designed that will
ensure the solution provided by the genetic algorithm is the optimal
solution. This can be done by testing the genetic algorithm on a
standard part which can be analysed manually and an optimal toolpath
developed without the genetic algorithm. The part needs to be
described using the STEP data model to see if a toolpath can be
generated from a STEP model. The two solutions can then be
compared in terms of length and number of turns to see if the solution
generated by the genetic algorithm is valid. The solution can then be
run on CNC simulation software such as VERICUT® to ensure the
toolpath will create the specified part without any problems. Finally the
solution can be tested on an actual CNC milling machine to determine
whether the machined part is within tolerance and design
specifications.
Figure 7: First gene location with nearest neighbours.
The part to be used to validate the genetic algorithm will be the part
described in ISO14649 Part 11 Annex F.
Figure 8: Nearest neighbour selected.
The nearest neighbour (NN) method increases the probability of the
mutation being successful by minimising the available genes that the
selected gene can switch positions with. The following calculation
verifies the benefit of using this method.
π‘ƒπ‘Ÿπ‘œπ‘π‘Žπ‘π‘–π‘™π‘–π‘‘π‘¦ π‘œπ‘“ 𝑆𝑒𝑐𝑐𝑒𝑠𝑠𝑓𝑒𝑙 π‘€π‘’π‘‘π‘Žπ‘‘π‘–π‘œπ‘› π‘€π‘–π‘‘β„Žπ‘œπ‘’π‘‘ 𝑁𝑁 π‘€π‘’π‘‘β„Žπ‘œπ‘‘ =
1
π‘‹π‘Œ 2 βˆ’π‘‹π‘Œ
(5)
where, X = points along X axis and Y = points along Y axis.
π‘ƒπ‘Ÿπ‘œπ‘π‘Žπ‘π‘–π‘™π‘–π‘‘π‘¦ π‘œπ‘“ 𝑆𝑒𝑐𝑐𝑒𝑠𝑠𝑓𝑒𝑙 π‘€π‘’π‘‘π‘Žπ‘‘π‘–π‘œπ‘› π‘Šπ‘–π‘‘β„Ž 𝑁𝑁 π‘€π‘’π‘‘β„Žπ‘œπ‘‘ =
1
π‘π‘‹π‘Œ
(6)
Figure 10: STEP-NC ISO14649 Test part [6].
This part has several features which can be used to test the genetic
algorithm’s capabilities in handling non-uniform surfaces. This part is
also described using the ISO14649 standard and can be used to test
the genetic algorithms capabilities in understanding the boundaries of
the features from a STEP part 21 file.
6. DISCUSSION
As manufactured parts become more complex, the number of data
points required to describe the part accurately will increase. Therefore
to account for this the techniques used to generate toolpaths for these
parts will also become more complex. Genetic algorithms are a very
efficient method of converging on a solution where there are a very
large number of possible solutions.
There are a number of problems that can arise while developing a
genetic algorithm to tackle the toolpath generation problem. The first
problem that might be encountered is avoiding convergence on a
non-optimal solution. Care must be taken when designing the fitness
function to ensure that only species with the desired characteristics are
given a high fitness. Another problem is that the closer the population
gets to the optimal solution, the less chance there is of the population
improving. Therefore the mutation algorithm needs to be designed so
that an improvement in the species’ genes is statistically feasible. The
third major problem to be solved is how the genetic algorithm decides if
the solution at a given point is truly the optimal solution or if more
generations are required to provide a better solution. As the optimal
solution is not known, the fitness function will provide a relative
measure of the species performance. To overcome this problem, a
method of determining the rate of convergence needs to be developed
so that the genetic algorithm will stop once the rate of convergence
drops below a desired level.
Future developments which would be useful to toolpath generation
problem would be to have an algorithm that would reduce the number
of data points required to describe a part feature. Points could be
clustered around boundaries and features with fewer points in spaces
between these boundaries and features. This would greatly increase
the efficiency of the genetic algorithm as fewer data points would mean
fewer possible solutions and hence less time to converge on an optimal
solution. Another useful area of research is to develop the fitness
function in such a way to generate toolpaths with specific machining
strategies (e.g. bidirectional milling or spiral milling). This could be
achieved by rewarding or penalising certain path patterns.
7. CONCLUSION
This paper provides a framework for developing a genetic algorithm
which can generate a machining toolpath for a part described by the
STEP data structure. This has been realized by having a novel
algorithm for the fitness function that will allow the genetic algorithm to
converge on an optimal solution from which a CNC machining toolpath
can be easily written. A new mutation algorithm has been developed
which will increase the probability of successful mutations by using the
nearest neighbours method. This will in turn also increase the
likelihood of the genetic algorithm generating an optimal toolpath.
8.
ACKNOWLEDGEMENTS
The research leading to these results has received funding from the
European Union's Seventh Framework Programme managed by REA
Research Executive Agency (FP7/2007-2013) under grant agreement
n286962.
9. REFERENCES
[1] Dragomatz, D.; Mann, S. (1997): A Classified Bibliography of
Literature on NC Milling Path Generation, in: Computer-Aided
Design, vol. 29, no. 3, pp. 239-247.
[2] Held, M.; Lukács, G.; Andor, L. (1994): Pocket machining based
on countour-parallel tool paths generated by means of proximity
maps, in: Computer-Aided Design, vol. 26, no. 3, pp. 189-203.
[3] Jeong, J.; Kim, K. (1998): Tool Path Generation for Machining
Free-Form Pockets Using Voronoi Diagrams, in: International
Journal of Advanced Manufacturing Technology, vol. 14, no. 12,
pp. 876-881.
[4] Chui, K.; Yu, K.; Lee, T. (2002): Direct tool-path generation from
massive point input, in: Proceedings of the Institution of
Mechanical Engineers, Part B: Journal of Engineering
Manufacture, vol. 216, no. 2, pp. 199-206.
[5] ISO 10303-21:2002 - Industrial automation systems and
integration -- Product data representation and exchange -- Part
21: Implementation methods: Clear text encoding of the exchange
structure.
[6] ISO 14649:2002 - Data model for Computerized Numerical
Controllers - Part 11: Process Data for Milling.
[7] Tewolde, G.S.; Sheng, W.; (2008): Robo Path Integration in
Manufacturing Processes: Genetic Algorithm Versus Ant Colony
Optimization, in: IEEE Transactions on Systems, Man, and
Cybernetics - Part A: Systems and Humans, vol. 38, no. 2, pp.
278-287.
[8] Jenkins, W. (1991): Structural optimisation with the genetic
algorithm, in: Structural engineer London, vol. 69, no. 24, pp.
418-422.
[9] Phanden, R.; Jain, A.; Verma, R. (2012): A genetic
algorithm-based approach for job shop scheduling, in: Journal of
Manufacturing Technology Management, vol. 23, no. 7, pp.
937-946.
[10] Crispin, Y. (1994): Aerospace conceptual optimization using
genetic algorithms, in: Proceedings of the Artificial Neural
Networks in Engineering Conference, St. Louis, MO, USA, pp.
333-338.
[11] Brady, R. (1985): Optimization Strategies Gleaned from Biological
Evolution," Nature, vol. 317, p. 804-806.
[12] Goldberg, D.; Lingle, R. (1985): Alleles, Loci, and the Traveling
Salesman Problem, in: Proceedings of the First International
Conference on Genetic Algorithms and Their Application,
Hillsdale, NJ, USA, pp. 154-159.
[13] Larranaga, P.; Kuijpers, C.; Murga, R.; Inza, I.; Dizdarevic, S.
(1999): Genetic Algorithms for the Traveling Salesman Problem: A
Review of Representations and Operators, in: Artificial
Intelligence Review, vol. 13, no. 2, pp. 129-170.
[14] Syswerda, G. (1991): Schedule optimization using genetic
algorithms," in Handbook of genetic algorithms, New York, pp.
332-349.
[15] Whitley, D.; Starkweather, T.; Fuquay, D. (1989): Scheduling
Problems and Travelling Salesman: The Genetic Edge
Recombination Operator, in: Proceedings on the Third
International Conference on Genetic Algorithms, Palo Alto, pp.
133-140.