Application of genetic algorithm for the synthesis of path-generating compliant mechanisms

This study demonstrates a significant achievement in using the Genetic Algorithms technique to design compliant mechanisms capable of tracking a predetermined non-linear output path. The main objective of this research is to develop a computational optimization framework for generating mechanisms that satisfy the specified input requirements with the highest precision. The authors present a tool that incorporates a Python interface and ANSYS MAPDL software for modeling, solving, and optimizing compliant mechanisms. The optimization objective and algorithm are outlined, followed by a report of the results and recommendations for future research directions.


Introduction and motivation
Mechanical devices used for lifting, handling, and transporting objects are of great interest in the fields of robotics and automation.Such systems typically comprise complex planar or spatial mechanisms, consisting of multiple rigid links and joints to accomplish a specific task.However, these mechanisms are often subject to problems such as friction, backlash, and wear, which can adversely affect their accuracy and performance [1][2][3].These solutions are also characterized by relatively high weight, manufacturing cost, and production time.As a result, lightweight design has emerged as an important area of mechanical engineering that seeks to achieve a reasonable balance between energy and resource efficiency * Author to whom any correspondence should be addressed.
Original Content from this work may be used under the terms of the Creative Commons Attribution 4.0 licence.Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI. while minimizing the above drawbacks.In mechanisms, too, the materials commonly used in mechanical engineering are being replaced by innovative lightweight alternatives [4,5].Compliant mechanisms differ from rigid-body mechanisms in their ability to generate movement through the deformation of elastic links.They have a relatively small number of components compared to rigid-body mechanisms, allowing simpler manufacturing processes, reduced friction and lubrication requirements, and greater potential for miniaturization.For more advanced solutions, compliant mechanisms can incorporate actuators and sensors to form active compliant mechanisms [6,7].Integrating active elements into compliant structures can eliminate the need for separate actuator applications and increase the robustness of the system.
Despite the many advantages that compliant mechanisms offer over conventional mechanisms, the development of flexible structures is hampered by several drawbacks and challenges throughout the technology chain.Successful implementation of compliant mechanisms in complex systems requires a deep understanding of the behavior of individual components and their interdependencies.The main challenge lies in the design and analysis of the mechanisms.Unlike conventional solutions, compliant mechanisms experience large deformations, rendering linearized beam equations inapplicable.Instead, much more complex non-linear approaches have to be used [8].The wide range of potential applications requires the establishment of a systematic approach to the design and fabrication of compliant structures.Given the need for practical applications, a growing body of research has focused on the development of path-generating compliant mechanisms (PGCMs) -mechanisms that can follow a prescribed path [9][10][11][12][13][14][15].Despite the existence of robust computational tools for the analysis of flexible kinematic systems, only a handful of integral optimization software programs are currently available and suitable for use.
Several software tools are available for compliant mechanism design, including CoMeT, SPACAR, DAS-2D, FlexWorks, and CoMUI.CoMeT uses a Matlab GUI and performs various analyses, including deformation, stress, optimization, and sensitivity analysis [16].SPACAR uses nonlinear finite element theory for dynamic analysis [17], while DAS-2D integrates pseudo-rigid body models and kinetostatic analysis/synthesis theories [18].FlexWorks is a design solver developed to generate conceptual one-piece mechanisms [19], and CoMUI [20] is a promising tool for the rapid design of compliant mechanisms, with the ability to use any geometry for flexure hinges.Although several tools for optimization and synthesis of CM exist, they lack the ability to define a trajectory as input data.The purpose of those design tools is to study the behavior of deformation, while the path of movement remains undefined.
The main contribution of this study is the development of an optimization and computational environment for the systematic design of PGCMs.To achieve this, a state-of-theart population-based Genetic Algorithm (GA) method [21] was selected from a range of meta-heuristic methods.The developed tool incorporates a Python interface and ANSYS MAPDL software for modeling, solving, and optimizing compliant mechanisms.As opposed to previous scientific investigations, which have predominantly relied on topology optimization to analyze material distribution within user-defined domains, this study introduces a different approach.The main objective of this research is to carry out the synthesis of a fourbar mechanism, characterized by a predefined number of links and specific joint types.The developed tool provides outputs that include joint coordinates, which determine the link lengths and the rocker angle of rotation.

Research background
GAs are a class of metaheuristic algorithms that are widely used in optimization and search problems.They are inspired by Darwin's theory of natural selection and are part of a larger family of algorithms called Evolutionary Algorithms.GA uses a heuristic approach that allows optimization without prior knowledge of the relationship between input parameters and the output fitness value.By performing a global search using selection, mutation, and crossover operations, GA can effectively explore the search space and identify optimal solutions.Unlike Descent Methods (DM), which follow strict optimization rules and require computation of the objective gradient, GA performs a global search for an optimal solution using a selection method that does not require such computation.While DM is suitable for mono-criteria optimization, GA is well-suited to multi-objective optimization tasks that involve navigating large search spaces.However, the computational time required for GA increases significantly with mesh refinement, which is a bottleneck in the optimization problem described in this study.
One of the earliest scientific efforts to synthesize compliant mechanisms using GAs was undertaken by Sharma et al [22].Their work describes the use of genetic programming to develop a design tool for optimizing compliant mechanisms in a multi-objective setting.Tai et al [23] introduced a morphological geometric representation approach that was combined with an evolutionary algorithm for mechanism synthesis.The design space is discretized into finite elements and divided into support, loading, and output regions.The representation method identifies the curves that connect one region to another.In another study, Saxena [9] used Nondominated Sorting in Genetic Algorithm to solve multiple objectives in the synthesis of compliant mechanisms for path generation.The proposed method simultaneously optimizes the topology, size, and shape of the mechanism, thus providing an efficient solution to the overall design problem.The topology optimization is derived by using the modulus of elasticity of the frame elements.Shape optimization is performed by varying the node positions, while size optimization is performed using in-plane width and uniform out-of-plane thickness as design variables.In another study, Saxena [10] presented a novel approach that extended the search algorithm to include multiple materials by treating the elastic moduli as design variables.Sharma et al [11] focused on solving a multiobjective optimization problem by minimizing the weight of the structure and the input energy, which were conflicting goal functions.
Based on the studies referenced above, it can be concluded that the GA is a widely used approach for the synthesis and optimization of large deformation compliant mechanisms.However, it should be noted that the optimization process often requires a significant number of function evaluations to obtain the optimal solution, resulting in high computational costs and long computation times.In addition, it is currently observed that there is a lack of available computing environments that are designed for the optimization of compliant mechanisms for path generation.

The optimization task
The optimization problem at hand concerns the synthesis of a planar-compliant four-bar mechanism which, when given a prescribed rotation, can be deformed so that one of its links follows a predetermined path.The mechanism consists of one compliant and two rigid links and is driven by a motion at the joint n 1 (as shown in figure 1).The links are anchored to the ground by two revolute joints n 1 and n 4 .Joint n 3 facilitates rotation between the two rigid links, while joint n 2 connects the compliant link to its adjacent link.When subjected to a given rotational input, the compliant link will deform, resulting in a curvilinear output, whose shape is determined by the position of node n 2 .The objective of the optimization algorithm is to determine the mechanism configuration that most closely approximates a given desired trajectory.
Assuming that the trajectory of such an arbitrary mechanism p mechanism can be described by: where (x 2,s |y 2,s ) denotes the position of n 2 at the current substep s, x i,0 , y i,0 the node coordinates of the mechanism in the initial position with i ∈ {1, 2, 3, 4} and ϕ s the rotation of n 1 at s, and the target path as: then a function f that measures the path deviations between target and output trajectory can be expressed by: The f represents the objective function to be minimized in the optimization problem: The system is subject to two different constraints.The first is a fixed angle of rotation, represented by ϕ const (4b).The second constraint relates to the dimensions of the design domain and is represented by (4c) and (4d).Together, these constraints limit the range of possible variations within the system and must be taken into account when analyzing its behavior.Further restrictions include a minimum distance of 20 mm between adjacent nodes, as well as a requirement that the links of the mechanism do not intersect in the initial position.These limitations are designed to ensure that the mechanism operates within functional parameters.The target path is, however, user input and can take any function that fits the target-specif demands of the compliant mechanism.In this work, the mechanism should follow the path defined by the given equation: The chosen target path, described by equations (5a) and (5b) represents a segment of a parabolic curve.Initial investigations have shown that the curvature of the target path is challenging, but not excessively difficult to find an optimum solution.Some research studies have focused on the optimization of local geometric parameters for specific mechanism designs.However, our work focuses on the synthesis of mechanisms capable of accommodating variable input data, including trajectory and rotation, without changing the material properties of the compliant and rigid links.This approach highlights the importance of designing mechanisms that are flexible and adaptable to a wide range of input conditions, without compromising the fundamental physical properties of the system.
As there is no known analytical solution to equation ( 1), the finite element analysis (FEA) software ANSYS was used to solve the equation numerically.The compliant link was discretized using beam elements, specifically ANSYS BEAM188, which are based on Timoshenko beam theory.A linear elastic material model based on the elasticity of steel (Young's modulus of 210 GPa and Poisson's ratio of 0.3) was selected for the flexible link.The area moment of inertia I = 0.79 mm 4 representing a value for a rod with a circular cross-section and a diameter of 2 mm was assigned.The influence of gravity was neglected in the analysis.

Objective function: measurement of the deviation between the target and the output path
To compare two paths and obtain a scalar value that reflects their similarity, it can be considered to discretize both paths into the same finite number of points equally distributed along the curves (see figure 2(a)).The FEA model generates a discretized path with one point for each substep of rotation ϕ s , up to the user-specified rotation ϕ max in the last substep m.However, if the coordinates of points in successive substeps show minimal change during optimization, the section with agglomeration (see figure 2(b)) will be given greater weight, leading to the biased similarity metric.To overcome this problem, the points used to determine similarity are uniformly distributed along a linear interpolation curve derived from the calculation points provided by the FEA, as shown in figure 2(c).This approach ensures that the similarity metric is not affected by local distortions.In this study, a penalty function f pen (see equation ( 6)) is used to increase the fitness value in situations where the length of the FEA curve, denoted as l FEA , differs from the target curve length, denoted as l target .The primary aim of this technique is to encourage the algorithm to explore not only paths of the desired shape but also those of the desired size.
With the pairwise calculated Euclidean distance (equation ( 7)), the mean squared error (equation ( 8)) with the penalty (equation ( 6)) subsequently can be used as a final metric for the similarity.
The FEA uses a default number of 100 substeps during its simulation.However, in cases where the simulation software encounters convergence problems, it may be necessary to reduce the substep size and a maximum number of substeps of 500 can be used.To improve the comparability of the two paths, the linear interpolation curve and the target curve are each discretized by 100 points.

Optimization algorithm: implementation of GA
The GA uses chromosomes as a means of storing a collection of parameters (variables) that define a proposed solution, also known as an individual, that the algorithm solves.To evaluate the performance of each individual, a fitness value is calculated.This is a measure of the individual's performance against a given objective, as shown in equation (8).Usually, a fitness value of zero demonstrates the optimal solution, whereas higher fitness values indicate that performance is deteriorating.
The GA optimization process consists of several steps.The first step is to create an initial population, which serves as the first generation of individuals.The initial population consists of individuals with random genes (variables x 1 , y 1 , x 2 , y 2 , x 3 , y 3 , x 4 , y 4 , ϕ s ), subject to constraints defined a priori (see equation (4b-4d)).The fitness of each individual in the initial population is calculated using a fitness function.To generate successive generations, the GA employs two genetic operators: crossover and mutation.This ensures that good solutions remain in the gene pool and helps the algorithm to achieve convergence.The crossover operator combines genetic information from two parents to produce offspring with a new set of genes.The mutation operator randomly alters a variable for one gene with a probability given by the mutation rate.Crossover and mutation operators maintain the diversity of the population in subsequent generations and mitigate the risk of convergence to a local optimum.The iterative process of generating new populations is performed repeatedly until either a predetermined maximum number of generations or a threshold of the desired fitness value is reached.A schematic representation of the GA's simplified workflow is presented in figure 3.
The optimization routines were implemented using Python programming language, facilitated by the DEAP package [24] for GA-related algorithms and the PyMAPDL package [25], which served as a communication interface with the ANSYS Mechanical APDL software.A detailed overview of the implemented optimization routine is presented in algorithm 1.
The selection process described in algorithm 1 line 1 with selectIndividuals implements the function selTournament from DEAP which randomly chooses individuals from the population and returns the best ones.During crossover (line 3-14) createTwoOffsprings uses the DEAP function cxOnePoint that splits the chromosome from both parents at the same random place and creates offsprings from those two parts.In the mutation process the DEAP function mutGaussian is utilized.It adds a random offset to a gene from a Gaussian normal distribution with the mean of MUTATE_MU and the scale MUTATE_SIGMA.Further explanation can be found in [24].

Hyperparameters and operators of GA
The selection of appropriate values for hyperparameters is of paramount importance as it can significantly influence the optimization performance.Several research studies [26][27][28] have shown that hyperparameters, such as the size of the initial population, can have a significant impact on other parameters, including the search space, fitness function, and diversity.The potential impact of these factors on the issue of premature convergence cannot be overlooked.Unfortunately, the lack of universally applicable parameter values poses a challenge in addressing this issue across different problem domains [29].The identification of problem-specific parameter values that facilitate optimal optimization results is imperative.Therefore, the hyperparameters used in this study were selected after preliminary investigations.The relevant hyperparameters used for the synthesis and optimization of compliant mechanisms are summarized in table 1.

Results
To assess the effectiveness of the optimization algorithm, a benchmark is presented in this section in addition to the actual optimization results.

Defining a benchmark
The implemented benchmark is similar to a random search optimization.Based on the fitness values of 120 000 random mechanisms, values of 2500 results were randomly collected.By iterating over the sample, the minimum fitness up to each iteration step is calculated.This process was repeated several times and the mean of the minimum fitness values is calculated, as shown in figure 4(a).After 2500 evaluations, the mean minimum fitness value is 1500.Any effective optimization algorithm must exceed this benchmark, i.e. it should return a mechanism with a fitness lower than 1500 after 2500 evaluations.The distribution of fitness values for all 120 000 mechanisms is depicted in figure 4(b).

Optimization results
Eight optimization runs were carried out to cover the statistical nature of GA. Figure 5(a) and its magnification figure 5(b) illustrate the fitness per number of total evaluations for each optimization run and the corresponding benchmark curve.Since some individuals are carried over to the next generation without modification, not all individuals need to be evaluated in a generation.Therefore, the total number of evaluations may be less than the product of the population size and the number of generations.For the chosen hyperparameters, approximately 1250 simulations had to be run for each optimization.At the beginning of the optimization process, the fitness values do not differ significantly from the benchmark, but after less than 500 evaluations the GA outperforms the benchmark in each run.The lowest fitness value found is 11.7, which is notably lower than the benchmark.The corresponding mechanism is illustrated in figure 6(a).For each optimization run, the path of the mechanism with the lowest fitness is plotted in figure 6(b).

Discussion
This paper presents the results of eight optimization runs using a GA for the synthesis of path-generating compliant mechanisms.The outperformed benchmark (section 5.1) after 500 evaluations clearly shows the effectiveness of the GA.However, a more in-depth analysis unveils that the best mechanisms of each run do not accurately follow the target path (see figure 6(b)).Initially, increasing the number of generations seems to be a straightforward approach.Preliminary studies have indicated that, for the chosen hyperparameters (table 1), the GA tends to populate the generation increasingly with similar individuals, with the effect that at a high number of generations i.e. 25-50, all individuals are similar except for small deviations.This phenomenon can be interpreted as a state of being trapped in a (local) optimum.The authors conclude that the GA is useful for identifying the overall shape of an appropriate mechanism, but is inefficient for fine adjustments.It is assumed that after finding the solution candidate with the GA, switching to a gradient-based algorithm would lead to better results in fewer evaluations.In this context, Particle Swarm Optimization seems to be a promising alternative as it combines the advantages of evolutionary algorithms and gradient-based ones.The results obtained are only applicable to the selected hyperparameters, and it cannot be excluded that the outcomes may be different for other hyperparameter settings without further investigation.Nevertheless, the tool developed to carry out the optimizations gives the possibility to design a compliant mechanism for arbitrary target paths.Ongoing efforts include the integration of self-adaptive parameters within the GA framework to balance exploration and exploitation at different stages of the search algorithm.These efforts are expected to lead to significant improvements in the accuracy of results.In the studies described here, the mutation and crossover probabilities are kept constant throughout the optimization process.In future research, the authors intend to investigate the influence of different hyperparameters on the speed of the optimization and the quality of the results, as well as for different target paths.In addition, a new optimization algorithm will be examined in which random mechanisms are modified by a Procrustes transformation.

Figure 1 .
Figure 1.Four-bar partially compliant mechanism and its constraints.

Figure 3 .
Figure 3. Simplified flowchart of the GA.

Figure 4 .
Figure 4. Fitness benchmarking: (a) expected minimum value with boxplot and (b) random individual fitness distribution.

Figure 5 .
Figure 5.Comparison of optimization results and benchmark: (a) medium magnification and (b) strong magnification.

Figure 6 .
Figure 6.FEA paths from the optimization (a) the best overall result (b) the results of all runs.

Algorithm 1 .
Formation of a new population.

Table 1 .
Values of selected GA hyperparameters used in the optimization.