Browse Subject Areas

Click through the PLOS taxonomy to find articles in your field.

For more information about PLOS Subject Areas, click here.

  • Loading metrics

Research on Laser Marking Speed Optimization by Using Genetic Algorithm

Research on Laser Marking Speed Optimization by Using Genetic Algorithm

  • Dongyun Wang, 
  • Qiwei Yu, 
  • Yu Zhang


Laser Marking Machine is the most common coding equipment on product packaging lines. However, the speed of laser marking has become a bottleneck of production. In order to remove this bottleneck, a new method based on a genetic algorithm is designed. On the basis of this algorithm, a controller was designed and simulations and experiments were performed. The results show that using this algorithm could effectively improve laser marking efficiency by 25%.


Laser marking machines (LMMs) have become the most common coding equipment on product packaging lines. These machines are commonly used for their tamper-resistance and environmentally friendly characteristics. However, the speed of LMMs cannot keep up with the speed of the pipeline and affect production. Currently, studies of methods for improving marking efficiency generally focus on Laser Travelling Path Optimization (LTPO). Qiwei Yu and Dongyun Wang [1] [2] changed the LTP when a basic marking unit was completed. These methods could help improve the product line’s speed, which is usually limited by the size of marking area. However, the efficiency of the basic marking unit could not be improved. Xin Sun [3] transformed the contour’s cutting sequence problem into a TSP problem, which resulted in a significant improvement in coding of closed contour lines. It could help improve the laser’s travel efficiency to some extent. Nini Li[4] extracted the nodes from the contour, then optimized the path nodes using a local search optimization algorithm, and eventually obtained an approximate optimal solution. To further improve laser marking efficiency, a new method based on GA is proposed in this paper.

Materials and Methods

Principles of LMM and description of LTPO problem

In galvanometric scanning system, a laser beam is deflected by two mirrors, and then focused by an f-theta lens. At last, the focused beam is projected on the marking plane [5]. Fig 1 shows the general principles of LMM. The position of the marking point is determined by the rotating angles of X, Y galvanometers [6]. If the point should be marked, the laser will be turned on. Otherwise it will be shut down. Through combination control of laser power switch and galvanometer angles, any two-dimension contents could be marked.

There are two factors that affect marking speed, one is the response frequency of galvanometer and another is the length of LTP. Marking contents are composed of points, lines and closed contours. The length of the LPT is determined by the sequence that the laser travels through the content. As all points must be marked exactly once and the laser has to return back to its initial position, the target of LPTO is to find the shortest path.

LTPO by using genetic algorithm

In the computer science field of artificial intelligence, a genetic algorithm (GA) is a search heuristic that mimics the principle of natural selection and “survival of the fittest” [7].This heuristic is routinely used to generate useful solutions to optimization and search problems [8]. In a genetic algorithm, a population of candidate solutions (called individuals or chromosomes) to an optimization problem is evolved toward better solutions. Each candidate solution has a set of properties which can be mutated and altered [9][10]. GA is great for finding solutions to complex search problems. They're often used in fields such as engineering to create incredibly high quality products. It has the ability to search through a huge combination of parameters to find the best match [11]. The basic steps of GA are shown below [7].

  1. Step1: Generate an initial population
  2. Step2: Evaluate fitness of individuals in the population
  3. Step3: Repeat
    1. ①. Select individuals from the population to be parents
    2. ②. Recombine parents to produce children
    3. ③. Mutate the children
    4. ④. Evaluate fitness of the children
    5. ⑤. Replace some or all of the population by the children


Decide to stop whereupon report the best solution encountered

Gene and chromosome representation for LTPO

Various representation methods are used in GA, such as binary representation, path representation, matrix representation, adjacency representation, ordinal representation [11]. The LTPO problem is to find a shortest path for a given set of marking content. So it is natural to using path representation. The chromosome corresponding to a LPT is an array of n integers which is a permutation of (1, 2,…, n), where an entry i in position j indicates that point i is visited in the j th time instant. The first step in using a genetic algorithm is to set up the relationship between the solution Space and the chromosome’s coding space.

A gene refers to a point to be marked and gene encoding which is a part of chromosome encoding, refers to describing the marking points with natural numbers. Therefore chromosome P(1,2,3,4) expresses a path that the laser will take when it marks an object, as shown in Fig 2.

Each contour’s start point and end point are considered the index points of the closed contour in the gene encoding. Now each gene expresses a closed contour composed of a group of points, but stepping along the closed contour should be conducted when marking each indexed point. As described in Fig 3, chromosome encoding is to compose a gene sequence for the marking contents.

Fig 4 shows the shape of an open line which consists of lines connected end to end. Each line has start and end points between which is a continuous path. The marking process could select to begin from either the start point or the end point. Therefore, positive and negative signs are introduced indicate the marking direction. A positive sign means that a line is processed from its start point to end point, while a negative sign means the contrary. A description of each open line by the natural number that expresses the marking sequence of the strokes, in this case the relationship between the solution space of the LTPO and the positive and negative integers representing the path in coding space is set up.

The fitness function

Let {1,2,3,4 … n} be the labels of the points and D = d[i,j] be an n × n cost matrix where d[i,j] denotes the distance from i to j. The LTPO problem is to find the shortest path for the laser to travel through all the points. The length of the path is given by


The objective is to find a permutation of the n points, which has the shortest path.

As the coordinates for point i are given as (xi,yi), the length of the path can be further calculate as


So the fitness function can be given by


Initializing the population

Many individual solutions are randomly generated to form an initial population. The population size depends on the nature of the problem, but the initial population typically contains several hundreds or thousands of possible solutions. Traditionally, this population is generated randomly, allowing the entire range of possible solutions (the search space). In LTPO, the size of the population is determined by the complexity of the marking contents. To keep the group’s diversity and calculating complexity, the initial population is randomly generated.

The genetic operators

Genetic operators include selection, crossover and mutation. The genetic operators could ensure better convergence for GA.

The basic part of selection process is to stochastically select from one generation to create the basis of the next generation. The requirement is that the fittest individuals have a greater chance of survival than weaker ones. This replicates nature in that fitter individuals will tend to have a better probability of survival and will go forward to form the mating pool for the next generation. Weaker individuals are not without a chance. In nature such individuals may have genetic coding that may prove useful to future generations. There are a few different selection methods such has roulette wheel, tournament, linear normalization [11]. Here, the roulette wheel selection is used. And the probability of each individual is based on the fitness value. It is given by (4)

As the LTPO is a permutation problem, it is natural to encode a path by enumerating the point indices in order. Here, the position of a point is not fixed and only the sequence is meaningful. A valid solution would need to represent a path where every point is included at exactly once. This would mean adjusting the crossover function so it doesn't just add a random point to the path, possibility causing a duplicate. In order to avoid invalidation, the order crossover approach was used. It has been found to be one of the best in terms of quality and speed [11][12]. Fig 5 indicates one example of order crossover. In real application, 2 children were produced.

As for mutation operator, the simple inversion mutation (SIM) approach is used. It has been found effective in TSP solution[12].In SIM, we only need to select two objects at random then simply swap their positions. This could also avoid invalidation.

Fig 6 shows an example of SIM function.

Setting the parameters

Crossover probability (CP) and mutation probability (MP) should be set before optimization process. CP indicates a ratio of how many couples will be picked for mating. The higher of CP would increase the possibility that an excellent individual would be damaged. But a too small one may cause the GA stagnant. In our application the CP was set to 0.8.

MP determines how often will be parts of chromosome mutated. If there is no mutation, offspring is taken after crossover without any change. If mutation is performed, part of chromosome is changed. Mutation is made to prevent falling GA into local extreme, but it should not occur very often. Otherwise GA will in fact change to random search. Here the MP is set to 0.01.

Simulations and experiments

An open line model is universal for LTPs. A point is the special case that occurs when the line length is zero and start and end points coincide, while a closed contour occurs when the line length is greater than zero and the two points coincide. The algorithm takes the start point as the representative point, while marking to this point, related strokes are also required to be marked. A smaller sum of the length of the paths between the representative points corresponds with a better marking efficiency.

The genetic algorithm for LTPO was implemented using the M language and simulated using Matlab. In the simulation, the 70 points shown in Fig 7 (A) were selected for marking. Once started, the GA continued its calculations. And the optimization process was recorded. Fig 7 (B) shows the recommended path for the LTP which has a total length of 122.9279. Fig 7(C) shows the iterative optimization process by recording the route length.

To further verify the proposed algorithm, experimental studies were performed. The key components of the LMM are listed in Table 1. Fig 8 shows the picture of the test bench.

To mark the contents of Zhejiang Normal University in both Chinese and English fonts, the first point of each stroke was taken as a representative marking point. The experiment data was recorded in Table 2.The total path length was 8161.67 when the traditional LTP method described in reference [1] was used, and the length of the path found by the GA was 5876.42, which represents a reduction of 28%. Then, the contents were marked twice using the two LPT control methods. Fig 9 shows the marking results. The time required to mark the same content was 3.1s and 2.32s. The efficiency has been improved by approximately 25%.

Fig 9. The results of marking using two LTP methods.

(a)Marked using traditonal LPT methods. (b) Marked using GA.


In this paper, a new laser traveling path optimization method using GA was introduced and discussed. It was designed by M language and implemented on the test bench. The initial population was chosen randomly. The selection approach was roulette wheel selection. And the CP and MP were set to 0.8 and 0.01 respectively. Simulations and experiments have shown that the new method could achieve more than 25% over the traditional methods. We can conclude that more complex marking contents will produce better optimization effects.


We thank colleagues in college of engineering of Zhejiang Normal University. Many of them helped us to build up the experiment bench.

The funders played no part in this study nor the decision to publish the findings and there are no relevant conflicts of interest to disclose.

Author Contributions

Conceived and designed the experiments: DYW. Performed the experiments: QWY YZ. Analyzed the data: DYW QWY. Contributed reagents/materials/analysis tools: DYW YZ. Wrote the paper: DYW QWY.


  1. 1. Yu QW, Wang DY, Jie Y. Research on the speed optimization of laser marking. Opto-Electronics Engineering and Materials Research. 2012; 571: 411–415.
  2. 2. Wang DY, Yu QW, Ye XP. Correction of the field distortion in embedded laser marking system. Optics &Laser Technology. 2014; 57:52–56.
  3. 3. Xin S. Research on Path Optimization of Two Dimension Laser-Cutting [Dissertation]. Huazhong University of Science and Technology; 2012.
  4. 4. Nini L, Zhangwei C, Shize C. Optimization of laser cutting path based on local search and genetic algorithm. Computer Engineering and Applications. 2010; 46(2):234–236.
  5. 5. Chen MF, Chen YF, Hsiao W, Wu SY, Hu CW, Gu ZP. A scribing laser marking system using DSP controller. Optics and Lasers in Engineering, 2008; 46: 410–418.
  6. 6. Dongyun W, Xinpiao Y. An embedded laser marking controller based on ARM and FPGA processors. The Scientific World Journal, 2014; 2014:1–7.
  7. 7. Panos M, Pardalos MGC. Resende. Handbook of applied optimization. In: Beasley John E. Population Heuristics. Oxford University Press, 2002. p. 138–157.
  8. 8. Mohammad T, Mahsa P, Mehran Y. An efficient algorithm for function optimization: modified stem cells algorithm. Central European Journal of Engineering, Vol. 3 (1): 36–50.
  9. 9. Akbari Z. A multilevel evolutionary algorithm for optimizing numerical functions. International Journal of Industrial Engineering Computations, 2011; 419–430.
  10. 10. Rego C, Gamboa D, Glover F, Osterman C. Traveling salesman problem heuristics: leading methods, implementations and latest advances, European Journal of Operational Research, 2011; 211 (3): 427–441.
  11. 11. Larranaga P, Kuijpers C, Murga R, Inza I, Dizdarevic S. Genetic algorithms for the traveling salesman problem: a review of representations and operators. Artificial Intell Rev, 13:129–170.
  12. 12. Ray SS, Bandyopadhyay S, Pal SK. Genetic operators for combinatorial optimization in TSP and microarray gene ordering. Appl Intell, 2007; 26:183–195.