# Robotic Cell Layout Optimization Using a Genetic Algorithm
## 2 Materials and Methods
### Genetic Algorithm  
A genetic algorithm is a search heuristic inspired by the principles of natural selection and genetics. It is commonly used to find approximate solutions to optimization and search problems and was used in this research to optimize the work cell area through functions that minimize the number of interferences between the workstations. Here is an overview of how genetic algorithms work [26]:  
* Population initialization: A set of candidate solutions (called individuals) is generated. Everyone represents a potential solution to the problem. Figure 3: Circular robotic cell. Figure 2: Linear or semicircular robotic cell. Selection: Each individual will be evaluated using a fitness function, which measures how well it solves the problem. Individuals are selected for reproduction based on their fitness scores. Higher fitness individuals have a higher probability of being selected. Common selection methods include roulette wheel selection, tournament selection, and rank-based selection. * Crossover: Selected individuals are paired to create offspring. The genetic material from two parent individuals is exchanged at the crossover point, producing two new offspring. * Mutation: With a low probability, individual bits in the offspring's chromosomes are flipped or altered. Mutation introduces genetic diversity and helps prevent premature convergence to local optima. * Replacement: The offspring replace some or all the old population, creating a new generation. The process of selection, crossover, and mutation is repeated for many generations. Figure 4 shows the typical cycle of the evolution of a genetic algorithm. Some recent examples of the use of the genetic algorithm in optimization applications for industrial robot problems are optimal movement trajectories in industrial robots, aiming to minimize the objective function of the manipulator's velocity rate, producing the highest possible speed at the end-effector while keeping the axis speeds at a minimum [27], with stochastic multi-modal processing times with multiple parallel-working robots per workstation. The objective is to minimize the number of workstations at a given production rate and the probability limit of violating the cycle time [28]. The proposed algorithm uses an uninformed initialization based on assigning random values to the genes of everyone. In this case, the representation is real, so each gene will take values in a defined interval with a uniform probability. \[\text{Station/Gen}=[(0,\text{Working area in long}),(0,\text{Working area in width})] \tag{1}\]  
The solution is a combinatorial optimization problem whereby each station location is a gene and, together with the other station locations, together form the \"genetic code of the individual\". \[Individual=\{Gen_{1},Gen_{2},Gen_{3},\dots,Gen_{n}\}\text{ where each }Gen_{n}\text{ is}\{x,y\} \tag{2}\]  
\[Robot\text{ base}=[\{x_{1},y_{1}\}\,,\{x_{2},y_{2}\}] \tag{3}\]  
With the initial population, the code generates the points that correspond to the corner or diagonal of the stations to have the complete area of each one of them, as shown in Figure 5.  
Figure 4: Cycle of the genetic algorithm. Obtaining the minimum and maximum values [\([X_{min},Y_{min}]\), \([X_{max},Y_{max}]\)], the area of each combination generated is calculated and then evaluated in the first fitness function to be minimized. The second fitness equation is to minimize the number of interferences between stations, since this would be considered a physical constraint for the solution. The fitness equations to be minimized in the genetic algorithm are shown below. \[f(area)=(X_{max}-X_{min})\;*\;(\;Y_{max}-Y_{min}) \tag{4}\]  
\[f(M_{i})=\sum(x1_{max}\geq x2_{min}\wedge x2_{max}\geq x1_{min}\wedge y1_{max} \geq y2_{min}\wedge y2_{max}\geq y1_{min}) \tag{5}\]  
where M\({}_{i}\) is a working station. With two objective functions to be minimized, it is considered a multi-objective problem.