# Study on Optimal Path Changing Tools in CNC Turret Typing Machine Based on Genetic Algorithm

Min Liu, Xiaoling Ding, Yinfa Yan, Xin Ci

► To cite this version:

Min Liu, Xiaoling Ding, Yinfa Yan, Xin Ci. Study on Optimal Path Changing Tools in CNC Turret Typing Machine Based on Genetic Algorithm. 4th Conference on Computer and Computing Technologies in Agriculture (CCTA), Oct 2010, Nanchang, China. pp.345-354, 10.1007/978-3-642-18369-0_39 hal-01564875

HAL Id: hal-01564875

https://inria.hal.science/hal-01564875

Submitted on 19 Jul 2017

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Study on Optimal Path Changing Tools in CNC Turret
Typing Machine Based on Genetic Algorithm

Min Liu¹, XiaoLing Ding*¹, YinFa Yan¹, Xin Ci²

1 College of Mechnical and Electronic Engineering, Shandong Agricultural University,
DaiZong Street NO.61, Tai’an City, China. E-mail:a881127,@126.com
2 Tai’an Falcon CNC Machine Co., Ltd ,.Tai’an City, China

**Abstract.** This paper is aimed to find the optimum path of CNC turret typing system to reduce the changing tools times and optimize tool movement routes to make up for the deficiency of CNC Turret Typing machine production efficiency. An uncertainty polynomial model is raised based on the asymmetric traveling salesman problem. And genetic algorithm (GA) is used to solve the path optimization problem. The optimization of path can minimize the moving tools times. Furthermore, the optimization problem is simplified to shortest distance between points. Fitness function, selection operator, crossover operator, mutation operator and other genetic operations are studied in this paper. In addition, the greedy crossover operator, the elite preservation strategy and the self-adaption strategy are imported in GA, which enhance the ability of finding the optimum and speed the efficiency. Finally, MATLAB simulation testifies that the algorithm is valid. The experiment result shows that the GA can shorten processing time and can reduce the air travel effectively without changing the machine’s hardware through reasonable arrangement of the changing and moving tools path. As a result, the efficiency and precision of CNC turret typing system was improved availably.

**Key words:** CNC turret, Genetic algorithm, Path optimization

# 1 Introduction

To meet the demands of tracking and controlling the product quality for steel
structure producers and understanding the products information for users, steel
structure information identification has been paid more and more attention. In our
country, engraving, stylus printing and typing are three main ways of steel structure
information identification. Among them, engraving mainly adopts NC milling cutter
engraving, laser mark and EDM shaping technology. For NC milling cutter engraving,
the words, fonts and stroke can be adjusted by NC. But there are still some problems,
for example, huge investment, short tool life and high expense. Laser mark, this
technology is widely used in marking the small workpieces. However, when the word
depth call for larger, the technology is very difficult to achieve and high cost [1].

* Corresponding author. Tel.: 0538-8249833.
E-mail address: xiaolingd@sdau.edu.cn (XiaoLing Ding)
EDM shaping is a mature and high precision technology, which demands greater
coordinate travel, high efficiency and larger cost for the large steel structure [2].
Another stylus printing using dotmatrix marking method has higher printing speed
and lower cost, but the lower print recognition rates and poorer visual effects, which
is prone to cause mark misunderstand [3]. Steel structure typing, which make
stamping characters more clear, is a kind of technique using ramjet power to impact
the characters. Besides, the typing depth is easy to control, the tool is long life and
low cost. At present, CNC turret typing is an advanced typing technology. The
meachine with CNC turret typing can achieve a two-way rotary and nearby change
tools anywhere [4]. The generation and optimization of the tools path in stamping
process plays an important role. Efficient tool path optimization algorithm can reduce
the tool traveling distance and can improve production efficiency. In the process of
generating numerical code, the point is optimized by shortening the changing and
moving path to reduce idle travel time, then can improve processing efficiency.
Therefore, it is worth studied to select the reasonable processing path.

The CNC turret typing system is characterized by high speed, high precision and
wide moving range. The specific location and methods of the relative motion between
tool and workpiece were described via tools path, including the effective stamping
locus and the auxiliary locus [5]. The auxiliary locus which cost some processing time
is mainly used for turret rotating positions and tool orientation, although they are not
directly involved in shaping the workpiece. So optimize the auxiliary locus is needed.
Due to the large auxiliary locus, the arrangement sequence is closely related with the
processing path. It is very difficult to use the traditional method to search optimal path.
In this paper, the path optimization based on the evolutionary algorithm is used to
plan the auxiliary locus. On the basis of the reduction of the changing tools amount
and optimization tools locus, The problem of optimal path changing tools is discussed
and solved from another perspective. This assumption, not considering the machine
fault and tool wear, permit us to believe only one same specification tool in CNC
turret machine.

## 2 Basic principle of optimal path changing tool and modeling

The changing tools time is longer than fast moving tools in CNC Processing, so it
is very important to reduce the tools changing times to improve the processing speed.
For the above reasons, the combinatorial optimization system is called for the least
tools changing times firstly. The steps are as follows. Firstly, each tool changing one
time must process the same characters completely without repeat and miss. Secondly,
the tools change through turret nearby rotating to process others characters. How to
arrange the processing paths to assure the least spare travel bring on a problem, which
can be come down to the asymmetric traveling salesman problem (TSP) with
additional constraint (that is, the least tool changing times). For example, a
businessman wants to sell goods in n cities. How to choose a shortest path make the
businessman go through the whole cities only once and return starting point [6]. TSP
is a typical NP complete problem, which is easy to describe but difficult to handle.
The classical and improved GA is an effective method for solving TSP so the method
has been widely used. GA is a global search capability algorithm and is derived from evolutionism based on genetic selection and nature elimination of Darwin ism and genetics. The algorithm is leaded in selection, crossover and mutation, etc. Genetic processing is repeatly application in the population which contains all possible solutions. In the process, offspring groups adapt to the environment more than previous. The optimal individual can be viewed as the near optimal solution by decoding [7].

In CNC turret typing system, processing code is analyzed firstly. Then the paths after the tool changing once are as a path group. After changing the correspondence tool, the tool moves along the shortest air travel paths begaining with a given character. The next character is processed until all the same characters are processed, so circulates. Here, tools play a TSP role in fact, and character points play the role of cities. Furthermore, the goal is the shortest of tool's air travel in processing.

# 3 Optimal path changing tools based on GA

## 3.1 About GA

GA is a predominant all-round optimizing method in species evolution processin nature. GA makes question's solution into a certain amount of initial chromosomes (initial solution) firstly. Secondly, the chromosomes are put into the problem environment. The well-adjusted chromosomes will be selected by the "survival of the fittest" principle. Then the above chromosomes take the selection, crossover and mutation operation. Thus a new generation and more adapt to the environment of chromosomes will appear. So following evolution, the optimal solution will converge to an individual which most adapts to the environment finally. GA searches from one group to another and the method does not easily fall into the local optimal solution. In addition, the search process only depends on individual fitness function, so the method is very good robustness and extensive adaptability.

## 3.2 Overall design of optimal path changing tool

In this paper, GA is used to optimize the CNC turret changing tools path. Path optimization was simplified as the optimization from point to point by an encoding method based on path. The greedy crossover operator is designed, which has advantage of inheriting good chromosome from parent individuals and improving search capability. Furthermore, this algorithm uses norm geometry selection method and the elite preservation strategy to protect the outstanding individual structures of group, and the algorithm adopts the adaptive strategy to adjust the mutation probability dynamically, so the efficiency of the algorithm is improved greatly. The path optimization program of CNC turret typing system includes coding module, selection, crossover and mutation module, GA controls parameter module, initialization module, decoding module, fitness calculation module and so on. The overall design flowchart is shown in Fig.1.
<figure><img src="image_2.png" /><figcaption>Fig.1 Flow diagram of the program</figcaption></figure>

## 3.3 Realization of GA

The working process of the GA mainly includes three types of operation, such as the chromosome coding and structure primitive group, the fitness calculation method and the selection, crossover, mutation operation method. The maximum number of generations termination criterion is adopted in GA and selected the viable path with the best fitness.

### 3.3.1 Chromosome coding and structure primitive groups.
The path coding form includes binary representation, adjacency representation, ordinal representation, path representation, matrix representation, edge representation and so on. GA mostly use particular gene representation composed of binary code, but for TSP scheduling problem, path representation is used usually. This is the nature and simplest method in path coding and it is a real number coding.

Changing tools serve as the processing technology routing according to the combinatorial optimization goal. Tool is changed one time as a process group which is expressed as a chromosome group. Grefenstette path representation is adopted in coding chromosome which can ensure that any individual has practical significance [8]. The path representation describes as follows. The Nth changing tool consists one process group W. The processing sequence in W is assumed in formula (1).

$$o = (t_1, t_2, t_3, ..., t_n). \qquad (1)$$

The rule is that once the process completed must move away from the group. The corresponding operation sequence of the Ith process $t_i$ is $m_i(1 \le m_i \le n-i+1)$ in
all unprocessed groups $W - \{t_1, t_2, ..., t_{i-1}\}$. The operation sequence is as for the process group coding in the chromosome. So a list $M$ of chromosome is got after dealing with all steps in formula (2).

$$M = (m_1, m_2, m_3, ..., m_n). \qquad (2)$$

### 3.3.2 Fitness function.
The fitness is the only criterion to judge whether the individual is good or not in GA. Optimal path changing tools in CNC turret typing system uses minimum tool moving locus as target function on the premise of the least changing tools times. Therefore, the corresponding fitness is shown in formula (3) for any chromosome $T$.

$$F(t) = 1 / \sum_{i} \sum_{j} d_{ij} u_{ij}. \qquad (3)$$

In the above equation, $d_{ij}$ shows the distance between the character $i$ and $j$. $u_{ij}$ shows whether the tool travels from the point $i$ to $j$. If "yes", its value is 1, "no" is zero.

### 3.3.3 Design the GA operator.
GA operator includes selection, crossover and mutation operator. Reasonably choosing operator can prevent premature convergence and can accelerate the search speed. In the operation of GA, these operators make the group ceaseless evolving and move towards the optimal solution gradually.

①. *Selection operator.* The operator is used to perform the operation of selecting the superior and eliminating the inferior for the individuals in group. Then the operator can determine how to select some individuals to inherit from the father generations to child. Due to the best chromosome not always appear in the last generation, the best chromosome is preserved at the beginning. Once the new group finds a better chromosome which is used to replace the original. After completion of the evolution, the last chromosome can be regarded as the optimization result. Therefore, this algorithm uses norm geometry selection and elite preservation strategy which can protect the excellent individual structure in evolutionary process.

The selection mathematical model is described in formula (4). Suppose the number of individuals is $n$, the fitness value of one individual $i$ is $F(i)$, so the probability of $i$ selected is $P_{si}$.

$$P_{si} = F_i / \sum_{j=1}^{n} F_j. \qquad (4)$$

$P_{si}$ reflects the fitness value of individual $i$ occupying the proportion in the sum of fitness at the whole group.

②. *Crossover operator.* Due to use *Grefenstette* path coding, genotype individual from GA is able to correspond a practical processing sequence. So we can use usually single point or multi-points crossover operator which determines the global search ability of GA. Many kinds of crossover operators are combined use in the algorithm.
In particular, GA is characterized by poor convergence, so the greedy crossover operator is introduced to accelerate convergence speed.

③*Mutation operator*. The role of mutation operator is to maintain the population diversity and improve algorithm local searching ability. The mutation operation adopted in this algorithm random produces a character number as the first processing character. In this way, the typing path is changed according to the above method. Then the phenomena of premature convergence can be prevented by adaptively adjusting the mutation probability.

3.4 Operation parameter

The operation parameters selected in GA include group size, individual coding length, crossover probability, mutation probability, biggest evolutionary algebra, etc., which influence the GA performance greatly. For the specific problem, whether the parameter setting is fitting or not, is judged by multi-Processing convergence condition and the quality of solutions.

4 Application and sample

If one tool of the CNC turret center has 31 points, now we should optimize the
process coding to make the path shortest after processing the same characters under
the condition of not changing tool. The parameters of optimization path algorithm are
as following. The group size is 40, maximum evolutionary algebra is 500, crossover
probability is 0.6, mutation probability is 0.05, self-adapted mutation parameter k=1,
the elite number is 2. At last, using GA optimization toolbox (GAOT) to simulate the
whole trajectory. GAOT in MATLAB is used to verify the GA efficiency. GAOT's
genetic operations is very flexible and provide reliable, extensible exploration
platform for application and research GA.

Program is as following, then the optimized path is shown in Fig.3.

clear all
global distMatrix
t=[1300 2302;3659 1415;4107 2144;2712 1799;3688 1635;3826
1156;2238 1229;5196 1044;2312 790;3386 570;3007 2970;2562
3756;2688 1991;2361 1776;1332 2695;3715 2678;3918
2179;4061 2370;3780 2212;3676 2578;4029 2838;4263
2931;3429 1908;3507 2376;3394 2643;3439 3201;2935
3240;3140 3550;2545 2357;2778 2826;2370 2975];
sz=size(t,1);distMatrix=dists(t,t);
xFns ='cyclicXover uniformXover partmapXover';
xOpts=[2;2;2];
mFns ='inversionMutation adjswapMutation shiftMutation
swapMutation threeswapMutation';
mOpts=[2;2;2;2;2];termFns='maxGenTerm';
termOps=[500];selectFn='normGeomSelect';
selectOps=[0.08];evalFn='tspEval';
evalOps=[ ];
bounds=[sz];gaOpts=[1e-6 1 1];
startPop=initializeoga(80,bounds,'tspEval', [1e-6 1]);
[x endPop bestPop
trace]=ga(bounds,evalFn,evalOps,startPop,gaOpts,termFns
,termOps,selectFn,selectOps,xFns,xOpts,mFns,mOpts);
bestPop
trace
plot(trace(:,1),trace(:,2));
hold on
plot(trace(:,1), trace(:,3));
figure(2)
clf
A=ones.sz sz);
A=xor(triu(A),tril(A));[xg yg]=gplot(A,t);
clf
h=gca;hold on
ap=x;
plot(t(x(1:sz),1),t(x(1:sz),2),'r-');
plot(t([x(1),x sz]),1),t([x(1),x sz]),2),'g-');
plot(xg, yg,'b.', 'MarkerSize',24);

<figure><img src="image_3.png" /><figcaption>Fig.2 Tool path chart after using standard GA to optimize</figcaption></figure>

<figure><img src="image_4.png" /><figcaption>Fig.3 Tool path chart after using improved GA to optimize</figcaption></figure>
<figure><img src="image_5.png" /><figcaption>Fig.4 Tool path optimum and average value after using GA to optimize</figcaption></figure>

The simulation result is shown in Fig.3 and Fig.4. Fig.2 shows tool path after using standard GA to optimize, the total distance is 18572.231687. The tool path after using improved GA is shown in Fig.3, the total distance is 16116.820139. The air travel distance shorten 13.22% compared with the standard GA. Obviously, the import of the greedy crossover operator, the elite preservation strategy and the self-adaption strategy improved the standard GA very successfully in this paper. Furthermore, the ability of finding optimum is improved and the improved GA obtains the optimum at the thirtieth generation first time. From Fig.3 it can be seen that tool path is improved obviously after optimization. CNC turret path is optimized on the premise of minimum changing times, because changing tools will waste more time than fast moving. As a result, the redundant tool locus is reduced and the processing time is saved greatly. Optimal path changing tool in CNC turret typing machine based on GA obtained a good optimize effect.

# 5 Conclusions

In this paper, we describe the practical problems in CNC turret typing system and use the improved GA to find optimal tool path. According to give priority to change tools at the least number of path optimization, the problem is converted to TSP problem with constraint condition firstly. Then the selection, crossover and mutation operator and fitness value are studied separately. A view of the simulation results can be obtained from here. This method used GA succeeded in optimizing the CNC turret typing path. These operations can effectively solve the tools air travel problem in the multi-point processing. It can not only shorten the processing time but also make up for the deficiency of production efficiency of CNC Turret Typing machine. It can be seen that this method is effective, feasible on the path optimization problems and has laid a foundation for further research. But, by virtue of introducing special constraint, genetic algorithm generality is restricted which is the main emphasis of the future research.

**Acknowledgement.** The authors would like to acknowledge ShanDong Provincial Education Department Science & Technology Project for their financial support
(J09LD22). The authors also would like to acknowledge Tai'an Falcon CNC Machine
Co. for providing the excellent environment and the experiment facility.

References

1. Fang Qiang,Cai DaoSheng,Qian Bo: Marking Path Optimization Algorithm for Laser Marking and Application. APPLIED LASER. 8, pp. 290--293. China. (2009)

2. Xie ZhiJiang,Xiao Yi,Han ZhiHua: EDM Lettering Technology of Large-scale Workpiece's Surface. Journal of Chongqing University. 5, pp. 14--17. China. (2003)

3. Chen xinhua,Xu wanling: Design of Print Head of Steel Plate Pin-printer and Analysis on the Priciple of Its Print Sign Forming. METALLURGICAL EQUIPMENT. 4, pp. 53--56. China. (2003)

4. Luo HongBao, Dong HongZhao: GA-based Approach to Optimize Cutters Arrangement on the Turret Post of Turning Center [J]. Agricultural Machinery. 2, pp. 172--175. (2007)

5. Erkan Ülker, Mehmet Emin Turanalp, H. Selçuk Halkaci: An artificial immune system approach to CNC tool path generation[J]. J Intell Manuf. 20,pp. 67--77. US. (2009)

6. Zhou ZhengWu, Ding TongMei: Research on Holes Machining Path Planning Optimization with TSP and GA[J]. Design and Research. 7, pp. 30--32. (2007)

7. CHEN J C, ZHONG T X: A hybrid-coded genetic algrithm based optimisation of non-productive paths in CN machining [J].The International Journal of Advanced Manufacturing Technology. 20, pp. 163--168. (2002)

8. Yu WuJia,Fu JianZhong,Chen ZiJian: Approach optimizing tool paths arrangement based on genetic algorithm[J]. Journal of Zhejiang University (Engineering science). 40, pp. 2117--2121. China. (2006)

9. Zhang LiBing,Wu Ting: Path optimization on laser drilling based on genetic algorithm[J]. Mechanical & Electrical Engineering Magazine. 24, pp. 77--79. (2007)

10. Qu Jing,Xiao ShiDe: PCB drilling path optimization based on ant-colony algorithm[J]. Mechanical & Electrical Engineering Magazine. 24, pp. 56--58. (2007)

11. Ma ZhaoMin, Huang Ling: The Optimization Algorithm of Holes Machining Path With Datum Hole[J]. Machine Tool & Hydraulics. 36, pp. 28--32. (2008)

12. Du Xuan,Li ZongBin: Component Placement Process Optimization for Chip Shooter Machine Based on Genetic Algorithm[J]. Journal of XI'AN JiaoTong University. 42, pp. 295--299. (2008)

13. Rizauddin RAMLI, Jaber ABU QUDEIRI, Hidehiko YAMAMOTO: Tool Path of Lathe Machine in Flexible Transfer Lines by using Genetic Algorithms[J]. IESM 2007, BEIJING-CHINA, May 30-June 2.(2007)

14. Aybars UĞUR: Path planning on a cuboid using genetic algorithms[J]. Information Sciences 178, pp. 3275--3287.(2008)

15. Ling-Ning Xing, Ying-Wu Chen: A hybrid approach combining an improved genetic algorithm and optimization strategies for the asymmetric traveling salesman problem[J]. Engineering Applications of Artificial Intelligence. 21, pp. 1370--1380. (2008)

16. Alok Singh, Anurag Singh Baghel: A new grouping genetic algorithm approach to the multiple traveling salesperson problem[J]. Soft Compute 13, pp. 95--101. (2009)

17. S.S. Makhanova',*, D. Batanovb, E. Bohezb, K. Sonthipaumpoonc, W. Anotaipaiboona,
M. Tabucanond: On the tool-path optimization of a milling robot[J]. Computers &
Industrial Engineering 43, pp. 455--472. Thailand. (2002)

18. S.-G. Lee, S.-H.Yang: CNC Tool-Path Planning for High-Speed High-Resolution Machining Using a New Tool-Path Calculation Algorithm[J]. Int J Adv Manuf Technol 20, pp. 326--333. (2002)
19. C.Castagnetti, E.Duc*, P.Ray: The Domain of Admissible Orientation concept: A new method for five-axis tool path optimisation[J]. Computer-Aided Design. 40, pp. 938--950. France. (2008)

20. Cuneyt Oysu, Zafer Bingul*: Application of heuristic and hybrid-GASA algorithms to tool-path optimization problem for minimizing airtime during machining[J]. Engineering Applications of Artificial Intelligence. 22, pp. 389--396. Turkey. (2009)

21. LiMin Zhua<sup>a*</sup>, Gang Zheng<sup>a</sup>, Han Ding<sup>b</sup>, YouLun Xiong<sup>b</sup>: Global optimization of tool path for five-axis flank milling with a conical cutter[J]. Computer-Aided Design. 42, pp. 903--910. China. (2010)

22. Wei He & Ming Lei & Hongzan Bin: Iso-parametric CNC tool path optimization based on adaptive grid generation[J]. Int J Adv Manuf Technol. 41, pp. 538--548. Springer-Verlag London (2008).

23. T. MORIWAKI*, S. TANGJITSITCHAROEN, T. SHIBASAKA: Development of intelligent monitoring and optimization of cutting process for CNC turning[J]. International Journal of Computer Integrated Manufacturing, 19, pp. 473--480. Japan. (2006)