Hybrid Optimization Approach for the Design of Mechanisms Using a New Error Estimator

A hybrid optimization approach for the design of linkages is presented. The method is applied to the dimensional synthesis of mechanism and combines the merits of both stochastic and deterministic optimization. The stochastic optimization approach is based on a real-valued evolutionary algorithm EA and is used for extensive exploration of the design variable space when searching for the best linkage. The deterministic approach uses a local optimization technique to improve the efficiency by reducing the high CPU time that EA techniques require in this kind of applications. To that end, the deterministic approach is implemented in the evolutionary algorithm in two stages. The first stage is the fitness evaluation where the deterministic approach is used to obtain an effective new error estimator. In the second stage the deterministic approach refines the solution provided by the evolutionary part of the algorithm. The new error estimator enables the evaluation of the different individuals in each generation, avoiding the removal of well-adapted linkages that other methods would not detect. The efficiency, robustness, and accuracy of the proposed method are tested for the design of a mechanism in two examples.


Introduction
The mechanical design of modern machines is often very complex and needs very sophisticated tools to meet technological requirements.The design of linkages is no exception, and modern applications in this field have increasingly demanding requirements.The design of linkages consists in obtaining the best mechanism to fulfil a specific motion characteristic demanded by a specific task.In many engineering design fields there are three common requirements known as function generation, path generation, or rigid-body guidance 1, 2 .Dimensional synthesis deals with the determination of the kinematic parameters of the mechanism necessary to satisfy the required motion characteristics.measure the difference between the desired parameters and the generated ones.However, this formulation has proven to be ineffective when seeking the optimal solution 15 .In many cases the MSD misleads the direction of the design and good linkages generated by the algorithm can be underestimated.Therefore, error estimation is of the utmost importance for deterministic and stochastic optimization.In EA the error estimator must be evaluated for each individual in each generation and for this reason the lack of accuracy could lead to poor efficiency in the optimization process.To avoid these problems Ullah and Kota 15 proposed the use of Fourier Descriptors that evaluate only the shape differences between the generated and desired paths.However, the proposed formulation is limited to closed paths in path generation problems.An energy-based error function is used in 16 where the finite element method is used to assess the synthesis error.This formulation reduces the drawbacks of MSD, but problems with the relative distance between desired and generated parameters remain.
The aim of this work is to propose a new hybrid algorithm that combines an evolutionary technique with a local search optimization approach.Some of the fundamentals in mechanism synthesis studied in this paper have been extensively discussed in the literature.However, the originality of this work lies in two aspects: the first one is the introduction of a new error estimator which accurately compares the function generated by the candidate mechanism with desired function.The second one is a novel approach based on the combination of deterministic and stochastic optimization techniques in the so-called hybrid methods.The flowchart for the optimization process is presented in the paper together with the results and conclusions.

Objective Function and Deterministic Optimization Approach
In optimal synthesis of linkages the optimization problem is defined as follows: minimize F q w , w subject to Φ q w , w 0, g q w , w ≤ 0,

2.1
where the objective function F q w , w formulates the technological requirements of the mechanism to be designed.The equality constraints Φ q w , w formulate the kinematic restrictions during the motion, and the inequality constraints g q w , w establish the limitations in the geometrical dimensions.Vector q w is the vector of dependent coordinates and w is the n-dimensional vector of design variables.
To illustrate the formulation the scheme of a four-bar mechanism in a path generation synthesis problem is shown in Figure 1.The proposed method can be applied effortlessly to any type of planar mechanism; however, the example in Figure 1 enables the formulation to be easily understood.The equality constraints are formulated as follows:

Generated path
Desired path where the vector of design variables contains the geometrical dimensions of the link.That is and dependent variables are defined as q T θ 3 θ 4 x g y g .

2.4
An important aspect in dimensional synthesis of linkages is the formulation of the goal or objective function.The objective function is capable of expressing the difference between the desired and generated paths see Figure 1 , providing an estimation of the error between the two curves irrespective of location, orientation, and size.The minimization of this function obliges the design variables to be changed and leads to the optimal dimensions of the linkage which can be expressed as w * .The generated and desired paths can be either open or closed curves.Figure 2 shows the two paths for the case of two closed curves.In this work the definition of both curves is assumed to be specified by a number of points named precision points.The precision points are selected by the designer by using vector notation and Cartesian coordinates as follows: where subscript d stands for desired points, g stands for the generated ones and p is the number of precision points.Most of the works in dimensional synthesis propose the Mean Square Distance to assess the error between the two curves.That is The deterministic approach used in this paper is based on a local search procedure which uses first-order differentiation to obtain the search direction.In the synthesis problem the generated precision points depend on the vector of design variables and 2.6 should be rewritten as follows: which is the objective function that must be minimized subject to the equality and inequality constraints to obtain the optimal dimensions of the mechanism.Differentiating 2.7 with respect to the design variables and equating it to zero provides ∇F q w , w J T g{q w , w} − d 0, 2.8 where J is the Jacobian that can be expressed as, J ∂g q w , w ∂w ∂g q w , w ∂q w ∂q w ∂w .

2.9
With the aim of greater clarity hereafter the dependence on the variables is omitted.The term between brackets in 2.8 can be expanded using Taylor series expansion as ∇F ≈ J T g − J T d J T JΔw 0.

2.10
From 2.10 a recursive formula can be obtained as follows: In this formula the stepsize α has been included in order to control the distance along the search direction.In 6 the determination of the stepsize and the exact Jacobian is described.Differentiation of equality constraints given in 2.1 using the chain rule yields ∂Φ ∂q ∂q ∂w ∂Φ ∂w 0. Thus, 2.9 can be rewritten as

2.12
All terms in 2.13 can be easily obtained from the objective function and constraints, and they enable the exact Jacobian to be determined for use in the deterministic optimization method.
If there are inequality constraints in the optimization problem, they can be converted to equality constraints through the addition of so-called slack variables.That is 2.14 In this way, each inequality constraint adds a new variable that must be included in the formulation.

New Error Estimator for EA Algorithms
In EA, lack of accuracy in the error estimation could lead to overestimation of the error and removal of good individuals from the optimization process.On the other hand, underestimation of the error could lead to selecting individuals who are not better adapted than others in fulfilling the goal.Equation 2.7 is used in many works as the objective function 4-9 .It has been widely used in deterministic approaches, but it is also used in probabilistic optimization.However, the function itself is an estimator of the error, not a representation of the actual error.This function depends on the relative position of the two curves and under certain circumstances the approximation may not be good enough.For instance, in the case shown in Figure 2 the error given by 2.7 can be increased or decreased if the generated curve is translated closer to the desired one or away from it, respectively.Moreover, rotation and scaling can be added to the transformation in order to reduce the error.For practical applications in engineering the translation of the curve only entails the translation of the linkage even as the rotation only needs to change the mechanism orientation.The lack of accuracy of 2.7 can be reduced by selecting the appropriate initial guess linkage in local optimization.However, in EA this option is not available and it should be solved using other strategies.Thus, one can say that the error between two curves is minimum if they are compared by the translation, rotation, and scaling.Therefore, 2.7 could underestimate the error unless some transformations are introduced.The first transformation consists of the translation of the generated curve towards the desired one.To do that, the geometric centroids of both curves are determined by using the precision points as follows: where d c and g c are the coordinates of the geometric centroids for desired and generated curves, respectively.The new coordinates of the precision points for the two paths are obtained by translating the geometric centroids to the origin of the reference frame.That is

3.2
Figure 3 shows the translation of both curves.Thus, the error estimation can be reformulated in the following way:

3.3
Obviously, 3.3 reduces the error and is more accurate than 2.7 .However, it should be pointed out that it still depends on the order chosen for numbering the precision points.In other words, 3.3 provides a comparison of the precision points with the same superscript, which depends on the arbitrary choice previously made by the designer.Therefore, it could be possible to reduce the error when the order of numbering is changed.Therefore, removing the effect of the numbering requires the formulation of p error estimators.For the case of two closed curves, as shown in Figure 3, the following matrix can be written:

3.4
Each column of 3.4 gives the terms of the error estimator for each possible combination.Thus, each error estimator can be formulated as the summatory function defined by ; j 1, 2, . . ., p, where subscript j stands for the estimator index.Therefore, F j is a single-valued function providing the estimation of the error.A vector can be formulated with all the values given by 3.5 Only one of the terms in this vector provides the minimum error and will be selected to form the objective function.That is The matrix given by 3.4 and the summatory given by 3.5 are only valid for the comparison of closed-closed curves.However, it is possible to have two other situations: open-open or open-closed paths.The former case is shown in Figure 4, while the latter is shown in Figure 5.
In both cases the number of precision points may be different for the desired and generated curves.Thus, the precision points are redefined as follows: where c is the number of precision points for the generated curve.Similarly to the closedclosed case, the centroid of the precision points is determined and the curves are translated  to the origin of the reference frame.The possible combinations that allow the estimation of the error are given by the following matrix:

3.9
The sum of the squared elements of each column in 3.9 leads to ; j 1, 2, . . ., c − p 1.

3.10
Equation 3.10 provides the different error estimators and the minimum value given by this formula is selected as the objective function.

Mathematical Problems in Engineering
When the desired path is an open curve and the generated path is a closed curve see Figure 5 , the aforementioned process can be used.However, the error estimator should be adapted to this situation.That is

3.11
Thus, the error estimators can be formulated as follows:

3.12
Equations 3.5 , 3.10 , and 3.12 provide a better comparison because they remove the effect of the translation and avoid the influence of the numbering.However, the error estimation can be enhanced by rotation and scaling.Indeed, if the generated curve is rotated and scaled with respect to the desired one, the difference between the two curves could be reduced.To do this, two new parameters must be introduced.The first one is a reference angle which provides the orientation of each curve.In Figure 2 the orientation angles are given by β d and β g .In practical design of mechanisms the modification of β g implies the rotation of the whole linkage in the plane, which is allowed for most of the cases.The second parameter is the scaling factor s.This parameter allows the generated curve to be expanded or contracted to reduce the difference with respect to the desired path.For the case of closed-closed curves the introduction of the rotation and scaling factor in the formulation modifies equations as follows: ; j 1, 2, . . ., p,

3.13
where 14 is the rotation matrix and provides the rotation of the generated precision points.
The error estimator given by 3.13 is now the objective function in a local optimization subproblem with two variables, β g and s.This optimization subproblem attempts to find the best orientation and size of the generated curve and also the linkage in order to reduce the error with respect to the desired path.The objective functions for the open-open curves may be readily derived as

3.16
These expressions might suggest that the problem must be solved as an optimization with two variables.However, the authors' experience shows that better results are obtained when the problem is solved independently for each variable.In other words, the results obtained are very accurate when the rotation optimization problem is solved before the scaling problem.In summary, the aforementioned transformations are the core of the comparison between the desired curve and the candidate, avoiding the influence of location, orientation, and size all at once.This provides an important contribution that improves the efficiency in the exploration of the search space when using evolutionary algorithms.

Hybrid Approach for the Synthesis of Mechanisms
The design space of linkages contains a large number of local minima.Deterministic approaches based on local optimization start from a random point converging to the nearest local minimum.Thus, the solution may be an unsatisfactory solution because the design space is not sufficiently explored.The strength of stochastic optimization approaches lies in searching the entire design space of the design variables in order to locate a region with the lowest values of the objective function.This region probably contains the global minimum.However, the cost of the computational time required to achieve the convergence by using EA could be very expensive when an accurate solution is demanded.Local search approaches need less time to achieve solutions, but the accuracy depends on the quality of the initial guess.To ensure convergence and enhance its ratio hybrid methods combine the benefits of both techniques.The main advantages expected from this approach are the generality and total independence of the initial guess.The evolutionary process for searching among the optima is briefly outlined below.

Evolutionary Strategy
It should be highlighted that the efficiency of an evolutionary algorithm is given by both the quality of the objective function and the structure of the chromosomes and their genes.In this work the objective function is formulated as was described in the previous section.The chromosomes are encoded using real-valued genes instead of a binary code because several works 9, 13 have demonstrated the advantages of this procedure in the design of linkages.Thus, each gene gives the real value of a design variable in the mechanism to be synthesized and all genes are grouped in a chromosome which in classical optimization is known as the vector of design variables.That is where m represents the dimensionality of w r,g , g is the generation subscript, and r max is the number of individuals in each generation.The dimension of w is given by the type of mechanism to be synthesized and the kind of coordinates used in their definition.In this work natural coordinates are used for this purpose, as well as in the definition of the generated and desired paths.The starting and successive populations are randomly generated: where g max is the number of generations.In this work r max does not change during the optimization process so the population neither increases nor decreases.After a generation has been created, the fitness of each individual is evaluated in order to sort them for the selection.The evaluation of the fitness depends on the type of curves involved in the problem, selecting 3.13 , 3.15 or 3.16 according to the case.The algorithm uses an elitism strategy in order to preserve the best individuals for the next generation.To obtain the number of best individuals an elitism factor, ef, is used as follows: where nE is the number of individuals whose genetic information is preserved for the following generation.After that, the tournament selection starts and the parents are chosen for reproduction.The first step in reproduction is to establish the number of offspring generated by the crossover, whose valued is given by the following formula: where nC is the number of offspring generated by the crossover operator and rf is the reproduction factor.Mutation is another operator used to change the genes randomly during the reproduction.The number of offspring affected by mutation is given by nM r max − nE − nC.

4.5
Thus, the number of parents is twice the number of offspring selected for crossover plus the number of individuals selected for mutation.To decide whether or not it should become a member for reproduction, the roulette wheel method 8 is used for the selection of parents from the complete population.The number of slots in the roulette is equal to the number of individuals and the size of the slots is equal to their expectation.Once the parents are selected, crossover is used to increase the diversity of the individuals in the complete population.
Crossover generates the offspring by taking genetic information from the two parents.The chromosomes of the descendents are obtained using the arithmetic mean of the same genes taken from each parent using a random coefficient with normal distribution.The mutation operator is controlled by two coefficients.The first one is the scale, sM, which controls the range of the variation allowed in the genes.The second one is the shrink coefficient, hM.This coefficient allows mutations with a wider interval of variation in the first generations but gradually reduces this interval in the following generations.In this way the algorithm provides exploration and exploitation of the global optimum and maintains a suitable balance during the optimization process.The authors have verified that the control of the shrink coefficient is fundamental to obtain the optimal solution when the range of the design variables is very different.
After the reproduction has finished for one generation, the new generation is evaluated by using the fitness value for every individual and the same process is repeated until the convergence of the evolutionary algorithm is achieved.Different convergence criteria may be used to stop the algorithm.The first one is based on the accuracy obtained for the best individual in the last generation, but a limit in the number of generations is also established to stop the process.Once the convergence is achieved, the fitness of the last generation is evaluated and a family of best individuals is obtained.The family of best individuals is selected from those linkages whose fitness value is below a threshold.This family of linkages is used as the initial guess for the deterministic approach to form the hybridization process which is described in the following subsection.

Hybrid Algorithm
Figure 6 shows the flowchart of the hybrid algorithm including the stochastic and deterministic optimization.On the left-hand side of Figure 6, the scheme of the evolutionary technique is shown.The right side in the same figure shows the deterministic part of the hybrid algorithm.The algorithm starts with the definition by the designer of the desired function based on the required motion for the linkage.The designer also establishes the EA parameters that will be used in the algorithm e.g. the operators for selection, crossover, etc. .After that the optimization process starts with the generation of the first population.The fitness evaluation of this first generation requires the estimation of the error by using deterministic optimization to obtain the orientation angle, β g , and scaling factor, s.If the fitness value is below a threshold, a family of linkages is selected to be optimized by the deterministic approach.This rarely occurs in the first generation and several generations are necessary to cross from the probabilistic approach to the deterministic optimization as is shown in Figure 6.The deterministic approach uses the best individuals selected from the evolutionary algorithm which are called Family 1.These individuals are optimized irrespective of their fitness values because local optimization could lead to obtaining better individuals among those with worse initial expectation.The deterministic approach optimizes each individual independently to obtain a second family called Family 2. The solution is selected as the best linkage of this second family.

Numerical Examples
In this section two examples are presented in order to demonstrate the capacity of the hybrid algorithm.In the first example a four-bar mechanism is selected to be synthesized to generate a right angle path.The example does not correspond to any actual implementation in engineering design, but this type of path is a challenging objective and demonstrates the accuracy, robustness, and efficiency of the proposed approach.The second example is a practical application in the design of an actual machine.The results in these examples are divided into two stages.The first one is the result obtained by the evolutionary algorithm and the second one is the result obtained by the complete hybrid algorithm which includes the local optimization approach in the dimensional synthesis.

Four-Bar Linkage Generating a Right Angle Path
In this example the methodology is applied to the synthesis of a four-bar mechanism.The scheme of the mechanism is the same as that used in Section 2 see Figure 1 .Likewise the constraints and design variables are given by 2.2 and 2.3 , respectively.The aim of the problem is that the coupler point, P, of the synthesized linkage describes a right angle path during the motion.The path is defined by 11 prescribed points whose coordinates are shown in the first two rows in Table 1.Table 2 shows the values of the operator factors used in the evolutionary algorithm.It is important to highlight the small size of the population and the maximum number of generations.The best resulting mechanism and the path followed by the coupler point in the evolutionary part of the algorithm is shown in Figure 7 a , in addition to the desired precision points.The evolutionary algorithm takes 189.59 seconds to achieve the convergence with an error of 2.439 mm 2 using an Intel Core I5 PC.As can be observed in this figure, the generated path approximates well to the desired one; however, there is clearly a lack of accuracy.In order to compare the result with the desired path, the third and fourth rows of Table 1 show the coordinates of the generated points.The solution for the hybrid algorithm is shown in Figure 7 b where the path followed by the coupler point fits very well with the desired one.
In the last two rows of Table 1 the coordinates of the generated path are shown and the last row of Table 3 shows the values for the design variables.The error at convergence is 0.2025 mm 2 and the time necessary to achieve the convergence was 212 seconds, which is a very reasonable computational cost in this kind of problem.
Since it is stochastic, the results differ each time the algorithm runs.In order to evaluate the robustness, the algorithm was run 30 times and the sample mean error obtained at convergence was 0.309 mm 2 with a sample standard deviation of 0.211 mm 2 .The sample mean CPU time to achieve the convergence was 215.05 seconds with a standard deviation of 19.031 seconds.

Application to a Mechanism for Injection Machine
In this example the methodology has been applied to the design of a mechanism for die-cast injection machine.Figure 8 a shows the scheme of such a machine, where the system for the injection of zamak alloys is shown at the top.The mould is located below the injection system not shown in the figure .The system for the displacement of the mould is shown on the left-hand side of the figure.Figure 8 b shows the detail of the injection system where it is possible to see the linkage used for this purpose.The mechanism selected for this application is a combination of a four-bar linkage together with a slider-crank mechanism connected by the coupler link.The motion of the slider follows a straight line pushing the zamak alloy through the entrance to fill the mould.This motion must be controlled in order to fill the mould adequately.To obtain good quality in the manufacturing process a rapid, motion of the slider is necessary initially, then a slower motion, and finally a fast backward motion when the mould has been filled.This motion of the slider is coordinated with the input link which is driven by an electric motor with constant velocity see Figure 8 b .The precision points are set every 18 deg of the motor rotation, or in other words, 20 precision points are selected for a full rotation of the motor.The coordinates of the precision points are shown in Table 4 and the desired motion is dotted in Figure 9.The scheme of the mechanism to be synthesized is shown in Figure 10 together with the twelve design variables.Figure 9 compares the results for the evolutionary algorithm and the hybrid optimization approach and Table 4 gives the values of the coordinates generated in all cases.Finally, Table 5 shows the values of the design variables at convergence for the evolutionary algorithm and the hybrid algorithm.
Despite of the difficulty of the problem, the graphical results in Figure 9 show that the evolutionary algorithm provides good accuracy in general; however, in the central part of the curve the accuracy is lower.The hybrid algorithm enhances the accuracy in this zone and provides a very good solution.
The sample mean error obtained by the hybrid algorithm is 357.70 mm 2 with a standard deviation of 14.07 mm 2 .The mean CPU time to achieve the convergence is 623.17 seconds with a standard deviation of 46.40 seconds.

Concluding Remarks
In this paper a hybrid optimization approach has been presented with application to the optimal dimensional synthesis of planar mechanisms.The objective function is selected using a new error estimator defined by means of the precision points.This error estimator enables the evaluation of the fitness of the function without influence of translation, rotation, and scaling effects.The error estimation is done using a local optimization procedure  The examples show that the proposed method not only achieves the convergence but also demonstrates how the accuracy is improved by the combination of the two procedures.To do this, the examples depict the solution for the case of the evolutionary algorithm working alone, and then the solution improved by the hybrid algorithm.This shows how the evolutionary algorithm provides an approximation to the solution and then the local optimization improves the accuracy.In both examples the solution provides good designs and the generated curves fit very well with the desired ones.In summary, the hybrid algorithm is a valuable tool for the design of mechanisms when highly demanding requirements are imposed.Thus, the conclusion we draw is that the appropriate combination of stochastic and deterministic algorithms has an enormous potential in the more effective solution of optimization problems in the design of mechanisms.This work will be further developed for the solution of other mechanism design problems by adapting the algorithm.Furthermore, another future task in this field aims to improve the efficiency of the hybrid optimizer by using the most recent developments in metaheuristic approaches such as Particle Swarm Optimization and Differential Evolution.

Figure 1 :
Figure 1: Scheme of the four-bar linkage.

Figure 2 :
Figure 2: Desired d and generated g closed paths.

Figure 3 :
Figure 3: Translation of the desired d and generated g paths.

Figure 4 :
Figure 4: Desired d and generated g open paths.

Figure 5 :
Figure 5: Desired open path d and generated closed path g .

Figure 6 :
Figure 6: Flowchart of the hybrid algorithm.

Figure 7 :
Figure 7: a Solution with the evolutionary algorithm and b with the hybrid algorithm.

Figure 8 :
Figure 8: a Injection moulding machine and b detail of the injection system.

Table 1 :
Desired path and the path generated at the convergence with the proposed algorithm.

Table 2 :
Values of the different factors used in the evolutionary algorithm.

Table 4 :
Desired path and the path generated at convergence with the proposed algorithm.efficient hybrid algorithm.The hybrid algorithm combines the advantages of both stochastic and deterministic approaches to improve the robustness and accuracy.Two examples have been presented in the paper to demonstrate the capacity of the method.