**Contents**

Reprinted from: *Mathematics* **2022**, *10*, 2403,


doi:10.3390/math10142403

...............

 **213**


## **Preface to "Applied Mathematics to Mechanisms and Machines"**

The science of mechanisms and machines has necessitated mathematics from the very moment of its birth. The much celebrated renaissance figure Leonardo da Vinci already pointed out how necessary mathematics is for the advancement of science, stating that "No human investigation can be called real science if it cannot be demonstrated mathematically". In fact, the first steps of the development of mechanisms occurred hand in hand with geometry. At first, graphic methods, of undoubted pedagogical value, provided results for the motion of mechanisms at a given instant, which involved the arduous task of determining its kinematics and dynamics for the trajectory over time; conversely, analytical methods were limited to simple case resolution. With the advent and development of computing, numerical methods have made their way into all areas of knowledge and technology. In recent decades, these methods have made possible a rapid development of the analysis, optimization and synthesis of mechanical systems, mechanisms and machines in the academic, scientific and industrial fields.

The 16 chapters of this book (all of them accepted and published articles in the Special Issue "Applied Mathematics to Mechanisms and Machines" of the MDPI's *Mathematics* journal) cover a wide variety of topics, including the synthesis, design and optimization of mechanisms, robotics, automotive, Maintenance 4.0, machine vibrations, control, biomechanics and medical devices, among others, that combine mechanisms and machine science with mathematics in synergy.

The Guest Editors of the Special Issue are very grateful to the authors of these works for their high quality contributions, as well as to their reviewers for the sharpness and insightfulness of their comments. We also want to sincerely thank the administrative staff of MDPI publications for their invaluable support throughout the process.

**Higinio Rubio Alonso, Alejandro Bustos Caballero, Jesus Meneses Alonso, and Enrique Soriano-Heras**

*Editors*

## *Article* **Hybrid Optimization Based Mathematical Procedure for Dimensional Synthesis of Slider-Crank Linkage**

**Alfonso Hernández 1, Aitor Muñoyerro 2, Mónica Urízar 1,\* and Enrique Amezua 1**

> **\***


Correspondence: monica.urizar@ehu.es (M.U.)

**Abstract:** In this paper, an optimization procedure for path generation synthesis of the slider-crank mechanism will be presented. The proposed approach is based on a hybrid strategy, mixing local and global optimization techniques. Regarding the local optimization scheme, based on the null gradient condition, a novel methodology to solve the resulting non-linear equations is developed. The solving procedure consists of decoupling two subsystems of equations which can be solved separately and following an iterative process. In relation to the global technique, a multi-start method based on a genetic algorithm is implemented. The fitness function incorporated in the genetic algorithm will take as arguments the set of dimensional parameters of the slider-crank mechanism. Several illustrative examples will prove the validity of the proposed optimization methodology, in some cases achieving an even better result compared to mechanisms with a higher number of dimensional parameters, such as the four-bar mechanism or the Watt's mechanism.

**Keywords:** path generation; dimensional synthesis; hybrid optimization; slider-crank mechanism

## **1. Introduction**

Dimensional synthesis consists of finding a geometry that enables a mechanism to generate certain motion characteristics, such as trajectories or positions of elements. It is tough to solve this problem intuitively and often requires the implementation of specific methods. Depending on the type and amount of prescribed motion characteristics, it is not always possible to obtain an exact solution to this problem, forcing us to use optimization methods to find an approximation with minimal error. The target most commonly addressed in bibliographies is the synthesis type, known as path generation, where a point of a single degree of freedom mechanism is sought to run through a sequence of prescribed positions. This motion may or may not be synchronized with the location of the input element, resulting in prescribed or unprescribed timing problems, respectively. It should be noted that there also exist two other goals that are frequently studied, these being beyond the scope of this paper. These are function generation, where the motion of two elements of the mechanism is synchronized, and motion generation, where a sequence of locations for a certain element of the mechanism is prescribed.

Most of the literature on dimensional synthesis focuses on individual cases, the fourbar hinged mechanism being the most widely studied. In the existing literature, both the exact synthesis, by means of graphic [1] or analytical methods [2], and the approximate synthesis, by means of dimensional optimization [3,4], have been studied. On the other hand, the slider-crank mechanism has been used to solve function generation problems [5–8], for dynamic synthesis [9,10], and to serve as an adjustable mechanism [11–14]. However, no publications on dimensional optimization for path generation have been found. It should be noted that, in addition to the usual kinematic objectives, some papers include more specific characteristics within the error function. For example, in [15] a formulation is

**Citation:** Hernández, A.; Muñoyerro, A.; Urízar, M.; Amezua, E. Hybrid Optimization Based Mathematical Procedure for Dimensional Synthesis of Slider-Crank Linkage. *Mathematics* **2021**, *9*, 1581. https://doi.org/ 10.3390/math9131581

Academic Editor: Raimondas Ciegis

Received: 31 May 2021 Accepted: 2 July 2021 Published: 5 July 2021

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

1

developed by using exact differentiation that allows for establishing the position of the instant center of rotation and the centrode.

An often-employed dimensional optimization procedure consists of minimizing the error function, formulated as the sum of squared differences between the points of the discretized prescribed path, and those belonging to the real generated path. The minimization process can be solved with different methods that can be classified into two main groups, these being local and global methods, which are mentioned below. On the other hand, there are also publications focused not so much on studying the mathematical optimization techniques, but on proposing new ways of describing the output generated by the mechanism. This may result in a more advantageous definition for the optimization error function or for the elaboration of atlases and databases. In relation to the path generation problems discussed in this paper, there exist different approaches to describe the trajectories, and probably the most typical ones are based on the Fourier series [16] or Haar Wavelet transform [17]. Similarly, reference [18] describes a unified theory of the harmonic characteristic parameter method for mechanism synthesis. Apart from the dimensional synthesis, other publications focus on the phase that precedes it, i.e., structural synthesis, the first step in the conceptual design of mechanisms. In this sense, there can be found some proposals of automatic algorithms intended for the structural synthesis of robots and closed-loop mechanisms [19].

In relation to the mathematical optimization techniques for dimensional synthesis, the most effective and widely used local methods consist of applying the null gradient condition, which leads to a non-linear system of equations. This system often includes some passive variables that cannot be eliminated. To solve it, the function is linearized and an iterative method, such as Gauss–Newton, is used, starting from an approximate initial solution provided by the designer. The original reference for this type of method is a paper published in 1966 by Chi-Yeh [20], which was dedicated to the four-bar linkage. From then on, several papers related to dimensional synthesis of this mechanism by means of gradient methods have been published, exploring different ways to improve the effectiveness of optimization. As part of these alternative approaches, in [21] the authors proposed modifying the set of variables to be optimized, considering the nodal coordinates instead of the usual dimensional parameters, thereby allowing the elimination of some constraints that were present in the original problem. It is also noteworthy that other publications focus on reformulating the error function, such as [22,23]. The authors of those works proposed to minimize the strain energy originated when the mechanism is forced to run exactly through the prescribed trajectory. On the other hand, some authors have chosen to estimate the error by avoiding its sensitivity to translation and rotation effects, such as [24], where a system of relative coordinates between precision points is used. Following the same idea, the authors proposed to perform a prior and independent phase to optimize the translation, rotation, and scaling parameters [25]. In addition to the different alternatives to characterize the design parameters of the mechanism and to estimate the resulting error, a relevant aspect to achieve good performance in gradient methods is to carry out an exact calculation of the partial derivatives, avoiding the numerical derivation, since it increases the computational cost and results in a lower efficiency. Given the interest in solving this problem, reference [26] presents a general method for calculating the exact partial derivatives from the loop equations previously identified by the designer.

Despite the large number of existing publications devoted to optimal dimensional synthesis by means of gradient methods, and to the improvement of their performance, none of them are capable of solving the main limitation they have. Unfortunately, these methods are highly sensitive to the chosen starting approximation, since they are local in nature and hence converge to the nearest minimum, which will not necessarily be the optimal overall solution. To overcome this drawback, global methods make it possible to explore the entire space where solutions can be found. Metaheuristic methods are the most common ones, and they have been covered in several references. These include genetic algorithms [27–29], differential evolution [30–32], ant search [33], krill herd algorithm [34], imperialist competitive algorithm [35], or neural networks [36]. Nevertheless, the weakness of heuristic methods in comparison with gradient methods is their higher computational cost and a lower convergence rate. Furthermore, there is no guarantee that they will converge to a minimum, neither locally nor globally.

Hybrid optimization algorithms, such as [37], gain greater strength when a global method generating seeds for starting mechanisms is combined with a good local method. Normally, hybrid methods start by running a global method to obtain one or several designs that will later be used as initial approximations in a local method to quickly converge to the nearest relative minimum. In this paper, as described below, a hybrid optimization approach is proposed.

In the case of the slider crank mechanism analyzed in this paper, thanks to the simplicity of its kinematics, it is possible to express the synthesis variables directly as a function of the dimensional and input parameters, and thus completely eliminating the passive variables. A novel aspect of the proposed approach is the way in which the resulting system of equations is solved. Considering the more general case of unprescribed timing synthesis, the final system of equations associated with the null gradient condition can be divided into two subsystems with different characteristics. As will be explained, the procedure described in this article allows each subsystem to be solved separately within an iterative process that connects them together. This makes it possible, in some particularly simple cases, such as the two-parameter slider-crank, to solve all the equations analytically, while in more complex cases, numerical methods must necessarily be adopted. The optimum solution reached will be a relative minimum of the error function and will be influenced by the initial approximation used to solve the system of equations numerically. In this paper, reducing this dependency will be attempted by running the local optimization algorithm from different starting points previously selected by a genetic algorithm. The generation of the starting points could also be done by another type of heuristic method, or through a sweeping process that generates random points within the entire search space. Even so, the latter technique would not achieve the most promising regions as the genetic algorithm does, but it would only generate a wide grid of different starting points. Therefore, the genetic algorithm is the preferred choice.

It is important to highlight that the procedure described in this paper seeks to obtain reliable solutions, not only from a mathematical vision, but also from a practical point of view. For this reason, it will be stated how to avoid the circuit defect in the slider-crank mechanism, relying on the concept of branch index. This concept was introduced in reference [21] to analyze the kinematics of the four-bar hinged linkage. The incorporation of design constraints will be addressed by means of penalty functions included in the error function to be minimized. This is essential to impose the Grashof criterion and thus ensure that the input element is able to fully rotate (crank input).

Finally, the effectiveness of the proposed methodology will be illustrated through different examples. The final solutions obtained in this paper are as accurate as the ones reached in other papers when solving the same problem by using more complex designs, such as four-bar or Watt linkages.

The main novelties and highlights of this paper are:


• Solving and comparison of examples proposed by other authors in the literature dealing with the four-bar linkage. Thanks to the effectiveness of the method proposed in this work, the slider-crank mechanism, though being simpler and more limited, is able to provide similar performances (or even better in some cases) in path generation problems.

#### **2. Materials and Methods**

In this section, the basis of the optimum synthesis procedure as well as the functioning of the hybrid optimization strategy is presented.

#### *2.1. Bases of the Optimum Synthesis Procedure*

Before tackling the optimization process, the loop-closure equations of the mechanism and the position equations of the coupler point that traces the trajectory will be obtained. In addition, the variables that take part in the synthesis process and their functional dependence law will be described. This enables obtaining the partial derivatives that intervene in the minimization process.

#### 2.1.1. Synthesis Equations for a General Design

First, the kinematic problem of the slider-crank mechanism with five dimensional parameters, represented in Figure 1, is obtained.

**Figure 1.** Slider-crank mechanism with 5 dimensional parameters.

The loop-closure equations are the following:

$$a\_1 \cdot \sin \varphi = a\_5 - a\_2 \cdot \sin \theta \tag{1}$$

$$s = a\_1 \cdot \cos \varphi + a\_2 \cdot \cos \theta \tag{2}$$

From Equation (1) yields:

$$
\sin \theta = \frac{a\_{\overline{5}} - a\_1 \cdot \sin \eta}{a\_2} \tag{3}
$$

Then, *cosθ* is given by Equation (4), where *K* = ±1.

$$\cos \theta = K \sqrt{1 - \left(\frac{a\_5 - a\_1 \cdot \sin \varphi}{a\_2}\right)^2} \tag{4}$$

The synthesis equations are as follows:

$$\tan^{\prime} = s - (a\_2 - a\_3) \cdot \cos \theta + a\_4 \cdot \cos \left(\theta - \frac{3\pi}{2}\right) \tag{5}$$

$$y' = -(a\_2 - a\_3) \cdot \sin \theta + a\_5 + a\_4 \cdot \cos \theta \tag{6}$$

Using the loop equations to solve the passive variables *s* (Equation (2)) and *θ* (Equations (3) and (4)), and substituting them in Equations (5) and (6), the following expressions are obtained for the synthesis variables, referring to the local system O'X'Y':

$$\mathbf{x}' = a\_1 \cos \varphi + a\_3 \cdot \mathbf{K} \sqrt{1 - \left(\frac{a\_5 - a\_1 \sin \varphi}{a\_2}\right)^2} - \frac{a\_4 \cdot (a\_5 - a\_1 \sin \varphi)}{a\_2} \tag{7}$$

$$y' = \frac{(a\_3 - a\_2) \cdot (a\_5 - a\_1 \sin \eta)}{a\_2} \cos \eta + a\_5 + a\_4 \cdot K \sqrt{1 - \left(\frac{a\_5 - a\_1 \sin \eta}{a\_2}\right)^2} \tag{8}$$

Remark Regarding Branches and Circuits

The sign ± in Equations (7) and (8), which has been substituted for *K* = ±1 for simplicity, is related to the two possible positions of the coupler point *P* for the same input *ϕ*. This means that two branches exist, each one associated with the positive or negative value of *K*. This circumstance is illustrated in Figure 2, in which the two possible configurations of the mechanism, for a given value of the input *ϕ*, are represented.

**Figure 2.** Two possible configurations for the same input.

The two possible trajectories of point *P* associated with the different configurations of the coupler element, commonly known as *branches*, can be connected or unconnected, resulting in a unique circuit (a unicursal curve), or two circuits (a bicursal curve). In this work, designs where the crank input is able to perform a 360◦ full rotation are considered, meaning that the Grashof criterion must be fulfilled. Therefore, the two possible branches will be two unconnected circuits. To avoid branch defects, all the selected points must have the same value of *K*. This value will be the one corresponding to the branch that yields a minimum error with respect to the desired path.

In the most general case, represented in Figure 3, the local reference system O'X'Y' has a rotation relative to the global system OXY, defined by the parameter *a*6, and a translation in the plane defined by the parameters *a*7 and *a*8.

The equations that express the synthesis variables in the global reference system are the following:

$$\mathbf{x}\_{i} = \mathbf{x}\_{i}^{\prime} \cdot \cos(a\_{6}) - y\_{i}^{\prime} \cdot \sin(a\_{6}) + a\_{8} \tag{9}$$

$$y\_i = \mathbf{x}\_i^{\prime} \cdot \sin(a\_6) + y\_i^{\prime} \cdot \cos(a\_6) + a\_7 \tag{10}$$

**Figure 3.** Slider-crank mechanism with 8 dimensional parameters.

Now that all the variables involved in the synthesis problem have been defined, the following classification can be established:


#### 2.1.2. Optimal Design Based on the Error Function

The error function *E*, commonly used in synthesis problems, is defined as the sum of the squared Cartesian distances between the prescribed points and those actually generated:

$$E = \sum\_{i=1}^{N} \left[ \left( \mathbf{x}\_i - \mathbf{x}\_i^d \right)^2 + \left( y\_i - y\_i^d \right)^2 \right] \tag{11}$$

The error between prescribed and generated trajectory must be minimized to obtain the optimal mechanism. There are two options for carrying out this minimization. In the modality known as prescribed timing, only the dimensional parameters are optimized, requiring solving the system shown in Equation (12). In this case, the input parameters *ϕi* are not variables to be optimized, but constant values (prescribed values). However, in an optimization known as unprescribed timing, both the dimensional parameters *aj* and the set of input parameters *ϕi* are optimized, requiring solving the systems given by Equations (12) and (13). This last option is more complex but its potential to obtain precise solutions is greater, since the value of the input parameters is not being restricted.

$$\frac{\partial E}{\partial a\_j} = 0 \quad \rightarrow \sum\_{i=1}^{N} \left[ \left( \mathbf{x}\_i - \mathbf{x}\_i^d \right) \frac{\partial \mathbf{x}\_i}{\partial a\_j} + \left( y\_i - y\_i^d \right) \frac{\partial y\_i}{\partial a\_j} \right] = 0 \qquad \forall j = 1, 2, \dots, n \tag{12}$$

$$\frac{\partial E}{\partial \varphi\_i} = 0 \quad \rightarrow \sum\_{i=1}^{N} \left[ \left( \mathbf{x}\_i - \mathbf{x}\_i^d \right) \frac{\partial \mathbf{x}\_i}{\partial \varphi\_i} + \left( y\_i - y\_i^d \right) \frac{\partial y\_i}{\partial \varphi\_i} \right] = 0 \qquad \forall i = 1, 2, \dots, N \tag{13}$$

#### *2.2. Hybrid Optimization Procedure*

Thanks to the simplicity of its kinematics, in the slider-crank mechanism it is possible to eliminate the passive variables. In this way, the synthesis variables (*<sup>x</sup>*, *y*) are expressed as an explicit function of parameters *aj* and *ϕ*, facilitating the obtaining of the partial derivatives that appear in Equations (12) and (13). After performing the substitution, it can be verified that the system of Equations (12) and (13) is non-linear. This system can be decomposed into two subsystems of equations. On the one hand, Equation (12) is composed of 8 equations, as many as the dimensional parameters of the mechanism. Each of these equations has the form *g*(*<sup>a</sup>*1, *a*2 ... *a*8, *ϕ*1, *ϕ*2,... *ϕN*) = 0. On the other hand, Equation (13) is made up of *N* equations, as many as points of precision has the trajectory. Each of these equations has the form *h*(*<sup>a</sup>*1, *a*2 ... *a*8, *ϕi*) = 0. This circumstance is fundamental when establishing the procedure for solving the system of equations.

In addition, in order to find the optimal initial approximation, the one that will be the starting point of the local optimization process, and that plays a relevant role in the process, a multi-start approach will be implemented. In the following sections, the hybrid procedure proposed by the authors of this work will be explained.

#### 2.2.1. Solving the Equation System for Local Optimization

In this section, the iterative algorithm to solve the non-linear system of equations resulting from the null gradient condition is addressed. The procedure is based on the decoupling of the two subsystems (12) and (13), as described below.

#### • **First phase:**

This starts from a certain mechanism, coming from the multi-start procedure that will be explained in Section 3.2. The dimensions (*<sup>a</sup>*1, *a*2, ... , *a*8) of this mechanism are assumed constant in this phase. The values of these dimensions are substituted in each of the equations of subsystem (13), resulting in a total of *N* equations, each with a unique *ϕi*.

In the simplest case of the slider-crank mechanism, with 2 dimensional parameters (*<sup>a</sup>*1 = *a*2 = *a*3 and *a*5 = *a*6 = *a*7 = *a*8 = 0), and using the transformation of half-angle tangent, *ti* = tan *ϕi* 2, Equation (13) becomes a fourth degree polynomial:

$$\left(2a\_1a\_4 + x\_i^da\_4\right)t\_i^4 + \left(8a\_1^2 + x\_i^da\_1 + 2y\_i^da\_4\right)t\_i^3 - 12a\_1a\_4t\_i^2 + \left(-8a\_1^2 + 4x\_i^da\_1 + 2y\_i^da\_4\right)t\_i + 2a\_1a\_4 - x\_i^da\_4 = 0 \tag{14}$$

From the 4 possible values of *ti*(*ϕi*), the one that gives the minimum error is the selected one.

For a design with 3 dimensional parameters, Equation (13) becomes a polynomial of degree 10. Even so, it is easy to obtain the 10 roots and detect the correct one proceeding as in the previous case. However, with 4 or more dimensional parameters, it is no longer as easy to determine its corresponding univariate polynomial, nor is it really worth it. It is more practical to operate as explained next.

The Equation (13) is solved numerically, starting from an initial approximation, and arriving at a unique solution of the parameter *ϕi*. To guarantee that the global optimal value of *ϕi* is obtained, it will be necessary to start from an initial approximation obtained as follows: each sum of Equation (11), which represents the error made in each synthesis position *i*, is evaluated as a function of the input parameter *ϕi* along the discretized domain [0,2 π). In this way, a graph similar to the blue curve represented in Figure 4 will be obtained, where two minima of the error function appear, the one indicated on the right being the one with the lowest value. The latter value of *ϕi* is taken as a starting approximation to solve Equation (13) (in our case, using the MATLAB *fsolve* command).

**Figure 4.** Error function for a point *i* evaluated at [0,2π).

To illustrate this concept, in Figure 5 the prescribed point for a synthesis position *i* and the trajectory generated by the mechanism of dimensions *aj* in the current iteration are indicated. The effect of evaluating the sum of the error function (11) and choosing the absolute minimum is equivalent to traversing the generated trajectory and selecting the point of it (the black point) closest to the prescribed one (red point). In this example, the black point indicated in Figure 5 corresponds to the absolute minimum, *ϕ* = 5.88 rad, which is the one previously indicated in Figure 4.

**Figure 5.** Generated trajectory and prescribed point (red).

#### • **Second phase:**

In this phase, the values *ϕi* obtained in the previous phase will be assumed as constants, and the unknowns (*<sup>a</sup>*1, *a*2, ... , *a*8) will be calculated from the subsystem from Equation (12).

As an example, in the simplified particular case of the slider-crank mechanism with 2 parameters, Equation (12) becomes the following linear system:

$$\begin{Bmatrix} 4\sum\_{i=1}^{N} \cos^2 \varrho\_i & \sum\_{i=1}^{N} \sin 2\varrho\_i \\ \sum\_{i=1}^{N} \sin 2\varrho\_i & N \end{Bmatrix} \begin{Bmatrix} a\_1 \\\\\\ a\_4 \end{Bmatrix} = \left\{ \begin{array}{l} 2\sum\_{i=1}^{N} \cos \varrho\_i \cdot \mathbf{x}\_i^d \\\\ \sum\_{i=1}^{N} \left( \sin \varrho\_i \cdot \mathbf{x}\_i^d + \cos \varrho\_i \cdot \mathbf{y}\_i^d \right) \end{Bmatrix} \tag{15}$$

However, in the design cases with 3 or more dimensional parameters, the subsystem of equations turns out to be non-linear, making it necessary to apply numerical solving

methods. As a starting approximation, the values (*<sup>a</sup>*1, *a*2, ... , *a*8) that were assumed as constants in the previous phase will be taken.

## •**Next steps:**

With the new values of *aj* obtained in the second phase, we go back to the first phase, and thus continue iteratively until convergence. The chosen stopping criterion consists of comparing the current values of the optimization variables (*<sup>a</sup>*1, *a*2 ... *a*8, *ϕ*1, *ϕ*2,... *ϕN*) with those of the previous iteration, so that when the difference is less than a specified tolerance, the iterative process will stop.

#### 2.2.2. Implementing a Multi-Start Strategy

The method proposed in Section 3.1 has the disadvantage of being very sensitive to the starting approximation. To avoid this drawback, a multi-start approach based on a genetic algorithm will be used to guide the local optimization method towards a search for the global optimal solution.

The proposed multi-start approach obtains a sufficiently large set of starting approximations, representative of a global sweep of the design space *aj* . In this article, a genetic algorithm is used to locate 100 candidate solutions that serve as initial approximations. It is decided to use the genetic algorithm incorporated in MATLAB, assigning as arguments of the *fitness function* the values for the 8 dimensional parameters. The latter function assigns the optimal correspondence of input parameters, according to the procedure outlined in the first phase of Section 3.1, and returns a scalar value that quantifies the individual's fitness as the quadratic sum of the distances between generated and prescribed points.

It is important to bear in mind that, considering the way the fitness function is posed, each starting solution for the unprescribed timing problem will not depend on 8 + *N* variables (8 dimensional + *N* inputs), but only on the 8 dimensional parameters, which facilitates the exploration of the search space by the genetic algorithm without the need to restrict the input parameters.

The complete scheme of this hybrid procedure is shown in Figure 6. As can be seen, it consists of executing a local optimization from the different starting points obtained in the scan of the space of the dimensional parameters *aj* . In this way, different local minimums will be obtained and the best of them will be selected.

To avoid excessive computational cost, the execution time of the genetic algorithm is limited to an acceptable value (i.e., 1 min). Bear in mind that it will not be necessary to obtain the optimal solutions, but that it will be enough to be close to them. On the other hand, the execution time of the local method to be applied later will depend on the number of iterations performed, but it generally consumes a few seconds for each starting point used.

#### 2.2.3. Incorporation of Design Constraints

Searching for an optimal design usually implies adapting the generated trajectory to a prescribed one. In addition, some design requirements must be fulfilled. These design constraints are related to several aspects, such as the maximum size of the mechanism, the maximum and minimum lengths of certain bars, the Grashof criterion, the transmission angle limits, and so on.

**Figure 6.** Flowchart of the hybrid optimization scheme.

In general, the optimization problem with certain inequality constraints can be formulated as the minimum error subjected to

$$\{g\_k(a\_1, \ldots, a\_n)\} \ge 0 \,\forall k = 1, 2, \ldots, l$$

A typical constraint equation, *gk*, is expressed as follows:

$$\sum\_{j=1}^{m} a\_j \mathbb{C}\_j \ge \mathbb{C}\_0 \tag{16}$$

When an inequality constraint, such as Equation (16), is included in the process, the error function yields

$$E = \sum\_{i=1}^{N} \left(\mathbf{x}\_i - \mathbf{x}\_i^d\right)^2 + \sum\_{i=1}^{N} \left(y\_i - y\_i^d\right)^2 + \lambda \cdot \left(\sum\_{j=1}^{m} a\_j \mathbf{C}\_j - \mathbf{C}\_0\right)^2 \tag{17}$$

If, on the one hand, Equation (16) is not fulfilled during the iterations of the optimization process, it is necessary to amplify the value of the error to invalidate the corresponding design *aj* . This can be done by means of the *λ* parameter, which acts as a penalty factor, proceeding as follows:

$$\begin{aligned} \text{If } \sum\_{j=1}^{m} a\_j \mathbf{C}\_j - \mathbf{C}\_0 &< 0 \qquad \text{then} \qquad \lambda = Predicted \text{ value} \\ \text{If } \sum\_{j=1}^{m} a\_j \mathbf{C}\_j - \mathbf{C}\_0 &\ge 0 \quad \text{then} \quad \lambda = 0 \end{aligned}$$

If, on the other hand, the condition to be imposed is an equality constraint, then *λ* will always be a certain predefined value. In this paper, after reviewing similar works in the literature and conducting several trials with different values, the value *λ* = 50 was established, insofar as it provides good results for all the analyzed design cases.

## **3. Results**

The following examples will demonstrate the validity of the proposed methodology, showing the results of each design case.

#### *3.1. Demonstrative Example 1*

The desired trajectory, shown in Figure 7, is formed by two straight lines and two circumference arcs tangent to these lines. Considering the simplicity of the slider-crank, achieving a design that traces this trajectory is challenging. Moreover, this example is interesting because the trajectory combines both straight lines and arcs, which are trajectories commonly used in the path planning synthesis of planar mechanisms. The coordinates of the desired points, *xd i*, *yd i*, are given in Table 1. A total of 16 points are defined.

**Figure 7.** Example 1. Desired trajectory.

The eight dimensional parameters and the 16 input parameters (unprescribed timing) will be optimized, that is, the most complete case possible. Following the previously described technique, this example is solved using the proposed multi-start method, starting from 100 different starting mechanisms. The conditions of the crank-input (based on Grashof's criterion) and a maximum 3:1 ratio between the longest and shortest bar are imposed by means of penalty functions.



The best solution, shown in Figure 8, leads to an error equal to 0.0073. The corresponding design parameters are included in Table 2. In the Supplementary Materials, a video showing the motion of this optimum mechanism can be found.

**Figure 8.** Example 1: best multi-start solution for slider-crank, E = 0.0073.

To illustrate the influence that the starting point has on the final solution obtained, Figure 9 shows, by way of example, the optimal mechanism obtained from another starting point, which does not reach a solution as good as the one shown above, so it would be excluded.



**Figure 9.** Example 1: comparison to other multi-start solution (multi-start no. 10), E = 0.0227.

This same example has been used by the authors of this work in a recent work, in particular reference [38], making use of another optimization method and applying it to the four-bar mechanism. It should be taken into account that the four-bar mechanism has an additional dimensional parameter with respect to the slider-crank and thus, in principle, a greater potential to adjust to the prescribed trajectories. Nevertheless, comparing the results of both achieved optimal mechanisms (the error in [38] with the four-bar was 0.0089), it can be seen that they are almost of the same value, even having a slightly smaller error in the current case.

#### *3.2. Demonstrative Example 2*

Figure 10a shows the results obtained by other authors [30,34,39,40] for an example of path generation synthesis of a closed path formed by 25 points marked in red. Each of the authors uses a different optimization method, but all of them use the four-bar mechanism. On the other hand, Figure 10b shows the results obtained when solving the same example with the slider-crank under the methodology proposed in this paper.

The comparison is made with other studies that analyze the four-bar because, as mentioned in the introduction, the vast majority of path generation synthesis works make use of the four-bar. Even so, as it has been shown in the previous example and it will happen in this one, the method that we propose achieves very similar (or even better) results, despite making use of a more limited mechanism such as the slider-crank.

The optimal solution obtained in this paper with the slider-crank mechanism (Figure 10b) corresponds to an error of 0.103 and is of similar quality to Bulatovi´c et al. [34]. They obtained an error of 0.0392, which is slightly lower than the one we found, but is of the same order of magnitude. On the other hand, in [34] they also indicated the error achieved by Laribi et al. [39] and Smaili and Diab [40], these being 0.9022 and 0.5504, respectively, so they would be considerably higher. On the other hand, the error obtained by Kafash and Nahvi [30] is not directly comparable with the rest because they use a different error function. However, the trajectory generated by the authors in [30] is graphically represented in Figure 10a. The corresponding optimal design parameters for the more general case of slider-crank are shown in Table 3. As in the previous example, a video showing the motion of this optimum mechanism is included as Supplementary Materials.

**Figure 10.** Example 2: optimal solution for: (**a**) four-bar and (**b**) slider-crank mechanism.


**Table 3.** Example 2: Optimum design parameters and inputs.

#### *3.3. Demonstrative Example 3*

On this occasion, a path generation problem, previously solved in reference [41] for the Watt mechanism, is presented. Their optimal solution is represented in Figure 11a, together with the set of prescribed points represented in red. The optimal solution obtained with the slider-crank mechanism, represented in Figure 11b, has an equal, and, it could be said, even higher precision, despite being a simpler mechanism that has fewer design parameters involved.

The optimal design parameters of the slider-crank mechanism are listed in Table 4. Yet again, a video showing the motion of this optimum mechanism is included as Supplementary Materials.

**Figure 11.** (**a**) Watt's mechanism optimal solution from [41]; (**b**) optimal solution for slider-crank mechanism.


**Table 4.** Example 3: Optimum design parameters and inputs.

## **4. Discussion**

In this paper, a hybrid optimization procedure has been presented to address the dimensional synthesis of path generation using the slider-crank mechanism. On the one hand, a novel approach has been proposed to solve the non-linear equations corresponding to the null gradient condition, which is based on the decoupling of two subsystems of equations, and which simplifies the resolution procedure without prejudice to the precision obtained. On the other hand, the incorporation of the multi-start method manages to give the local optimization method a global character, carrying out a previous sweep of the total space of the dimensional variables to find the most promising starting approximations. To carry out this search, a genetic algorithm is used where only the eight dimensional parameters are involved, thanks to the fact that the fitness function has been programmed to select the optimal input parameters based on the dimensions.

In addition, it should be noted that this methodology is aimed at achieving designs that are valid from a practical point of view. Therefore, the non-existence of branch defects is ensured, and different design restrictions can be incorporated in a simple way through the use of penalty functions. In this way, it can be ensured that the crank input mechanism does not exceed a maximum ratio between bar lengths or other additional design requirements at the discretion of the designer.

Finally, the effectiveness of the method has been proved by verifying, through various examples, that the slider-crank mechanism allows us to achieve solutions with a precision comparable to other one degree of freedom mechanisms that have a greater number of dimensional parameters, such as the four-bar or the Watt's mechanism, with the additional advantage of having simpler kinematics.

**Supplementary Materials:** The following are available online at https://www.mdpi.com/2227-739 0/9/13/1581/s1. The three videos corresponding to the motion of the optimum mechanisms are available.

**Author Contributions:** Conceptualization, A.H., A.M., M.U. and E.A.; methodology, A.H., A.M. and M.U.; software, A.M.; validation, A.H., A.M., M.U. and E.A.; formal analysis, A.H.; investigation, A.H., A.M., M.U. and E.A.; resources, A.H. and A.M.; data curation, A.M.; writing—original draft preparation, A.H. and A.M.; writing—review and editing, M.U. and E.A.; visualization, A.M.; supervision, A.H.; project administration, A.H. and M.U.; funding acquisition, A.H., M.U. and E.A. All authors have read and agreed to the published version of the manuscript.

**Funding:** The authors wish to acknowledge financial support received from the Spanish governmen<sup>t</sup> through the Ministerio de Economía y Competitividad (Project DPI2015−67626-P (MINECO/FEDER, UE)), the support for the research group through Project Ref. IT949−16, provided by the Departamento de Educación, Política Lingüística y Cultura from the regional Basque Government, and the Program BIKAINTEK 2020 (Ref. 012-B2/2020) provided by the Departamento de Desarrollo Económico, Sostenibilidad y Medio Ambiente from the regional Basque Government.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Not applicable.

**Conflicts of Interest:** The authors declare no conflict of interest.
