1 Introduction

Several Four-bar linkage applications are found in Robotics. Han et al. [8], suggest the six degree-of-freedom robot leg using the four-bar linkage mechanism with high rigidity to minimize the actuators weight in a bipedal walking robot. Additionally, robot end-effector, that actually interacts with the object, design is of high importance. Some end-effector are grippers based on Four-bar linkages [20]. Some surgical and field robots based on Four-bar linkage, that no require actuators which are attached directly to driving joints and that may be independently controlled, are presented in Hoyul and Youngjin [9].Displacement analysis for Four-bar linkages, has been extensively reported in the technical literature [6, 7, 12, 15, 21].

With regard to optimization bio-inspired techniques have been increased considerably in the last two decades. One of the earliest works in evolutionary algorithm applied to the optimal synthesis of four-bar path generator is reported by Cabrera et al. [3] . The authors developed a genetic algorithmic to solve three study cases with and without prescribed timing and considering different target points. In Nariman-Zadeh et al. [22] a path synthesis procedure to generator linkages using a neural network is proposed, it consists of a learning stage where a large number of kinematic simulation are generated with random dimension, and in the second stage the neural network is applied to approximate a synthesis problem solution. Bulatović and Dordević [1] describe the process of optimal synthesis of a four-bar linkage using the controlled deviations method of the variables with the differential evolution algorithm application. In [16] authors deals the Pareto optimal synthesis of four-bar mechanisms for path generation considering tracking error and transmission angle error, it is solved using a multi-objective hybrid genetic algorithm. A hybrid evolutionary algorithm for path synthesis of four-bar linkage is presented in [13], here the hybridization between a genetic algorithm and a differential evolution algorithm is proposed. The authors state that the main advantages of this algorithm are the simplicity and ease to implement and solve complicated real-world optimization problems, with no need of deep knowledge of the search space. In [10] authors present a novel approach to the multi-objective optimal path synthesis of four-bar linkages and applying it to the traditional problem with one, two and three objective function . A novel algorithm called Malaga University Mechanism Synthesis Algorithm for path synthesis of mechanisms is successfully applied to six cases of path and function synthesis of four-bar and six-bar mechanisms [4]. Related subjects, see the title of the papers [2, 5, 11]. In the literature, the kinematic and optimization formulation of the four-bar path generator is very similar. The kinematic formulation in these works are based on the traditional closed-loop condition and the goal function is the sum of the square of the Euclidean distances, where the main difficulty is the penalization needing when the kinematic does not have solution in the two-dimensional real space. For this reason, the formulation here proposed is based in the use of the natural coordinates and the Hermitian conjugate operator in order to build an objective function whose output is always a positive real number. It should also be noted that the formulation proposed here can be extended to any problem of planar mechanisms synthesis with closed solution. The paper is organized as follows: Chapter 2 deals about the analytical position solving using natural coordinates. In chapter 3 the optimization problem is formulated using the Hermitian conjugate operator. Chapter 4 shows the mathematical description of teaching learning based optimization algorithm. In chapter 5 a result for three path synthesis problem is shown and compared with the literature. Finally, chapter 6 content the paper conclusions.

2 Position analysis of the four-bar mechanism

The Fig. 1 shows a schematic four-bar mechanism, where P is the coupler point and \(\varphi\) is the input angle. Here the position problem is solved using natural coordinates [17, 19].

The vector of natural coordinates is

$$\begin{aligned} q=\left[ \begin{matrix} C \\ D \\ P \\ \end{matrix} \right] =\left[ \begin{matrix} {{x}_{C}} \\ {{y}_{C}} \\ {{x}_{D}} \\ {{y}_{D}} \\ {{x}_{P}} \\ {{y}_{P}} \\ \end{matrix} \right] \end{aligned}$$
(1)

where the point C can be computed as,

$$\begin{aligned} C=\left[ \begin{matrix} {{x}_{A}}+a\cos \varphi \\ {{y}_{A}}+a\sin \varphi \\ \end{matrix} \right] \end{aligned}$$
(2)

and from mechanism’s geometry it is derived the following relationships:

$$\begin{aligned} s&=\left\| B-C \right\|&{{l}_{1}}&=\dfrac{{{b}^{2}}+{{s}^{2}}-{{c}^{2}}}{2s}&{{h}_{1}}&={{t}_{1}}\sqrt{{{b}^{2}}-{{l}_{1}}^{2}} \\ \end{aligned}$$

where \(t_{1} \in \left\{ -1,1 \right\}\). The geometric variable can be written in compact form as

$$\begin{aligned} {{N}_{1}}=\left[ \begin{array}{ll} \frac{{{l}_{1}}}{s} &{}\quad -\frac{{{h}_{1}}}{s} \\ \frac{{{h}_{1}}}{s} &{}\quad \frac{{{l}_{1}}}{s} \\ \end{array} \right] \end{aligned}$$

therefore the point D is determined by

$$\begin{aligned} D=C+{{N}_{1}}\left( B-C \right) \ \end{aligned}$$
(3)
Fig. 1
figure 1

Kinematic modelling of the four-bar mechanism through natural coordinates

Moreover, the geometric variables in the coupler are related by the equations

$$\begin{aligned} {{l}_{2}}&=\frac{{{d}^{2}}+{{b}^{2}}-{{e}^{2}}}{2b}&{{h}_{2}}&={{t}_{2}}\sqrt{{{d}^{2}}-{{l}_{2}}^{2}} \end{aligned}$$

where \(t_{2} \in \left\{ -1,1 \right\}\). The geometric variables are grouped in the matrix

$$\begin{aligned} {{N}_{2}}=\left[ \begin{array}{ll} \frac{{{l}_{2}}}{b} &{}\quad -\frac{{{h}_{2}}}{b} \\ \frac{{{h}_{2}}}{b} &{}\quad \frac{{{l}_{2}}}{b} \\ \end{array} \right] \end{aligned}$$

thereby the point P is computed as

$$\begin{aligned} P=C+{{N}_{2}}\left( D-C \right) \ \end{aligned}$$
(4)

The values of variables \(t_{1}\) and \(t_{2}\) determine the configurations or the assemble modes of the mechanism. The Fig. 2 shows four possible configuration for the mechanism, where \(t_{1}=1\) and \(t_{2}=1\) represent the configuration showed in the Fig. 2a, \(t_{1}=-1\) and \(t_{2}=1\) represent the configuration showed in the Fig. 2b, \(t_{1}=1\) and \(t_{2}=-1\) represent the configuration showed in the Fig. 2c and \(t_{1}=-1\) , \(t_{2}=-1\) represent the configuration showed in the Fig. 2d.

Fig. 2
figure 2

Possible configuration of a four-bar mechanism

In general the points D and P belong to the two-dimensional complex space, thus the mechanism’s assembles only is possible if all the components of and are real numbers. The principle approach in this paper is to work in field of the complex numbers in order to make the optimization method robust.

3 Optimization problem formulation

3.1 The Hermitian conjugate

If Z is an \(m\times n\) matrix with complex entries, then the Hermitian conjugate of Z, denoted by \({{Z}^{*}}\) , is defined by

$$\begin{aligned} {{Z}^{*}}={{\left( \overline{Z} \right) }^{T}}\ \end{aligned}$$
(5)

that is, if \(Z=\left( {{z}_{ij}} \right)\) , then \(\overline{Z}=\left( \overline{{{z}_{ij}}} \right)\) and \({{Z}^{*}}={{\left( \overline{Z} \right) }^{T}}\) [14]. In this work the Hermitian conjugate is used to define the synthesis error in the following way

$$\begin{aligned} \varepsilon ={{\left( {}^{d}P-P \right) }^{*}}\left( {}^{d}P-P \right) \ \end{aligned}$$
(6)

where \({}^{d}P\) is the desired point and P is the coupler point reached by the mechanism.

3.2 Goal function and constraints

The goal function is defined as the sum of the synthesis error determined by Eq. (6). In the Fig. 3 the computing of the goal function is illustrated. The design parameters are real values, thus with this parameter the position problem is solved, where the natural coordinates belong to the two-dimensional complex space and finally the goal function is computed yielding a real value.

Fig. 3
figure 3

Illustration of computing of the goal function

The optimization problem is formulated as

$$\begin{aligned}&\min f(X)=\sum \limits _{j=1}^{n}{{{\left( {}^{d}{{P}_{j}}-{{P}_{j}} \right) }{*}}\left( {}^{d}{{P}_{j}}-{{P}_{j}} \right) } \end{aligned}$$
(7)
$$\begin{aligned}&{\text {s}}{\text {.t: a) } }2\left[ \min \left( a,b,c,f \right) +\max \left( a,b,c,f \right) \right] -\left( a+b+c+f \right) <0 \end{aligned}$$
(8)
$$\begin{aligned}&{\text { b) } }{{\varphi }_{j}}-{{\varphi }_{j+1}}<0 \end{aligned}$$
(9)
$$\begin{aligned}&{\text { c) }}\min \left( a,b,c,f \right) -a=0 \end{aligned}$$
(10)
$$\begin{aligned}&{\text { d) } }{{x}_{k}}\in \left[ L{{i}_{k}},L{{s}_{k}} \right] \forall {{x}_{k}}\in X \end{aligned}$$
(11)

where \(f=\left\| B-A \right\|\) and the design variables are

$$\begin{aligned} X=\left[ \begin{array}{cccccccccccccc} a &{} b &{} c &{} d &{} e &{} {{x}_{A}} &{} {{y}_{A}} &{} {{x}_{B}} &{} {{y}_{B}} &{} {{t}_{1}} &{} {{t}_{2}} &{} {{\varphi }_{1}} &{} \cdots &{} {{\varphi }_{n}} \\ \end{array}\right] \end{aligned}$$
(12)

In the Eq. (7) the constraint a) guarantees the Grashof condition, the constraint b) guarantees a crescent angle sequence, c) warrants that input link be the shortest and d) is the lower and upper bound of the design variables. For solving the optimization problem using an evolutionary technique in this work a penalty function is used, thus the optimization problem is reformulated as

$$\begin{aligned} \min f(X)= & {} \sum \limits _{j=1}^{n}{{{\left( {}^{d}{{P}_{j}}-{{P}_{j}} \right) }{*}}\left( {}^{d}{{P}_{j}}-{{P}_{j}} \right) }+P\left( X \right) \end{aligned}$$
(13)
$$\begin{aligned} P(X)= & {} {{\rho }_{1}}\cdot {{g}_{1}}\left( X \right) +{{\rho }_{2}}\cdot {{g}_{2}}\left( X \right) +{{\rho }_{3}}\cdot {{g}_{3}}\left( X \right) \end{aligned}$$
(14)
$$\begin{aligned} {{g}_{1}}\left( X \right)&= {} \left\{ \begin{array}{ll} &1 {\text { if} }\,\,{{\varphi }_{j}}-{{\varphi }_{j+1}}=0 \\ &{{\left[ \max \left( 0,({{\varphi }_{j}}-{{\varphi }_{j+1}}) \right) \right] }^{2}} \\ \end{array} \right. \end{aligned}$$
(15)
$$\begin{aligned} {{g}_{2}}\left( X \right)&= {} {{\left[ \max \left( 0,{{r}_{2}}\left( X \right) \right) \right] }^{2}}\end{aligned}$$
(16)
$$\begin{aligned} {{g}_{3}}\left( X \right)= & {} {{\left[ \min \left( a,b,c,f \right) -a \right] }^{2}} \end{aligned}$$
(17)

where P(X) is a penalty function, \({{\rho }_{1}},{{\rho }_{2}},{{\rho }_{3}}\) are constants of a very high value that penalize the goal function when the associated constraint fails and

$$\begin{aligned} {{r}_{2}}\left( X \right) =2\left[ \min \left( a,b,c,f \right) +\max \left( a,b,c,f \right) \right] -\left( a+b+c+f \right) \end{aligned}$$

4 Optimization implementation

4.1 Teaching learning based optimization algorithm

A teaching learning based optimization (TLBO) is a teaching-learning process inspired algorithm proposed by Rao et al. [18]. This algorithm consists of two phases, Teacher phase and Learner phase.

In the teaching phase a teacher tries to increase the mean result of the class in the subject taught by him depending on his capability, it is written mathematically as

$$\begin{aligned} X_{j,k,i}^{'}={{X}_{j,k,i}}+Difference\_Mea{{n}_{j,k,i}}\ \end{aligned}$$
(18)

where \({X}_{j,k,i}\) is the result of the k learner in subject or design variable j in the iteration i, \(X_{j,k,i}^{'}\) is the updating of \({X}_{j,k,i}\) and

$$\begin{aligned} Difference\_Mea{{n}_{j,k,i}}={{r}_{i}}\left( {{X}_{j.kbest,i}}-{{T}_{F}}{{M}_{j,i}} \right) \ \end{aligned}$$
(19)

where \({{r}_{i}}\) is a random number in the range \(\left[ 0,1 \right]\) , \({{X}_{j,kbest,i}}\) is the result of the best learner in subject j, \({{T}_{F}}\) is a value that can be either 1 or 2 and computed as

$$\begin{aligned} {{T}_{F}}=\lfloor 1+rand\left( 0,1 \right) \left\{ 2-1 \right\} \rceil \end{aligned}$$
(20)

finally \({{M}_{j,i}}\) is the mean result of the learners in subject j.

In the learning phase the interaction among learners increases their knowledge. The interchanging of knowledge between two learners is computed as

$$\begin{aligned} X_{j,P,i}^{''}&= {} X_{j,P,i}^{'}+{{r}_{i}}\left( X_{j,P,i}^{'}-X_{j,Q,i}^{'} \right) {\text { if }}\,\,X_{total-P,i}^{'}<X_{total-Q,i}^{'}\end{aligned}$$
(21)
$$\begin{aligned} X_{j,P,i}^{''}&= {} X_{j,P,i}^{'}+{{r}_{i}}\left( X_{j,Q,i}^{'}-X_{j,P,i}^{'} \right) {\text { if} }\,\,X_{total-Q,i}^{'}<X_{{{total}}-P,i}^{'} \end{aligned}$$
(22)

where P and Q are randomly selected, \(X_{total-P,i}^{'}\) and \(X_{total-Q,i}^{'}\) are the updated function values of \({{X}_{total-P,i}}\) and \({{X}_{total-Q,i}}\) , respectively, at the end of teacher phase.

The Fig. 4 shows the flowchart of TLBO that is a population-based algorithm which simulates the teaching-learning process of the class room. his algorithm requires only the common control parameters such as the population size and the number of generations and does not require any algorithm-specific control parameters [18].

Fig. 4
figure 4

Flowchart of TLBO algorithm. Adapted from [18]

4.2 Treatment of design variables

The TLBO here descripted works with real variables, but the vector of design variables Eq. (12) contain integer variables that determine the configuration of the mechanism. Therefore, to deal with integer design variables the follow auxiliary vector design is used

$$\begin{aligned} X^a=\left[ \begin{array}{cccccccccccccc} a &{} b &{} c &{} d &{} e &{} {{x}_{A}} &{} {{y}_{A}} &{} {{x}_{B}} &{} {{y}_{B}} &{} {{t}_{1}^{a}} &{} {{t}_{2}^{a}} &{} {{\varphi }_{1}} &{} \cdots &{} {{\varphi }_{n}} \\ \end{array}\right] \end{aligned}$$
(23)

where \(t_{1}^{a}\) and \(t_{2}^{a}\) are the auxiliary variables of the \(t_{1}\),\(t_{2}\) respectively and limited to the interval \(\left[ 0,1 \right]\). The auxiliary variables are transformed using the equation

$$\begin{aligned} {{t}_{i}}&={{\left( -1 \right) }^{\lfloor t_{i}^{a} \rceil }} \qquad i \in \lbrace 1,2 \rbrace \end{aligned}$$
(24)

5 Results

In this section three problem proposed in the literature are solved using the procedure developed in the previous sections. A processor Intel i5-4300U CPU @ 2.5 GHz was used to program the solutions implemented in Matlab® and the solutions found are showed and compared with the literature.

5.1 Problem 1

This problem was taken from [3] which considers six-point path synthesis aligned without prescribe timing.

Design variables are:

$$\begin{aligned} X=\left[ \begin{array}{cccccccccccccc} a &{} b &{} c &{} d &{} e &{} {{x}_{A}} &{} {{y}_{A}} &{} {{x}_{B}} &{} {{y}_{B}} &{} {{t}_{1}} &{} {{t}_{2}} &{} {{\varphi }_{1}} &{} \cdots &{} {{\varphi }_{6}} \\ \end{array}\right] \end{aligned}$$

Target points are:

$$\begin{aligned} {}^{d}{{P}_{j}}=\left[ \left( 20,20 \right) ,\left( 20,25 \right) ,\left( 20,30 \right) ,\left( 20,35 \right) ,\left( 20,40 \right) ,\left( 20,45 \right) \right] \ \end{aligned}$$

Limits of variables:

$$\begin{aligned} \begin{array}{l} a,b,c,d,e\in \left[ 0,60 \right] \\ {{x}_{A}},{{y}_{A}},{{x}_{B}},{{y}_{B}}\in \left[ -60,60 \right] \\ {{t}_{1}},{{t}_{2}}\in \left\{ -1,1 \right\} \\ {{\varphi }_{1}},{{\varphi }_{2}},{{\varphi }_{3}},{{\varphi }_{4}},{{\varphi }_{5}},{{\varphi }_{6}}\in \left[ 0,360{}^\circ \right] \\ \end{array} \end{aligned}$$

The Fig. 5 shows the mechanism obtained with the approach here proposed as well as the mechanism found by Cabrera et al. [3].

Fig. 5
figure 5

Solution to the problem 1

The values of design variables are:

$$\begin{aligned} a=8.9169 \ b=32.6786 \ c=60 \ d=45.4871 \ e=16.2315 \ x_{A}=53.9887 \ y_{A}=4.9096 \ x_{B}=-29.5025 \ y_{B}=2.9867\ t_{1}=-1 \ t_{2}=-1 \\ \left\{ {{\varphi }_{i}} \right\} =\left\{ 0.0006, 22.0215, 37.3841, 53.3718 , 71.6155 , 95.6007 \right\} \end{aligned}$$

5.2 Problem 2

This problem is about twelve-point path synthesis without prescribed timing, it was taken from [2].

Design variables are:

$$\begin{aligned} X=\left[ \begin{array}{cccccccccccccc} a &{} b &{} c &{} d &{} e &{} {{x}_{A}} &{} {{y}_{A}} &{} {{x}_{B}} &{} {{y}_{B}} &{} {{t}_{1}} &{} {{t}_{2}} &{} {{\varphi }_{1}} &{} \cdots &{} {{\varphi }_{12}} \\ \end{array}\right] \end{aligned}$$

Target points are:

$$\begin{aligned} {}^{d}{{P}_{j}}=\left[ \begin{matrix} \left( 4.15,2.21 \right) ,\left( 4.5,2.18 \right) ,\left( 4.53,1.83 \right) ,\left( 4.13,1.68 \right) \\ \left( 3.67,1.58 \right) ,\left( 2.96,1.33 \right) ,\left( 2.67,1.06 \right) ,\left( 2.63,0.82 \right) \\ \left( 2.92,0.81 \right) ,\left( 3.23,1.07 \right) ,\left( 3.49,1.45 \right) ,\left( 3.76,1.87 \right) \\ \end{matrix} \right] \ \end{aligned}$$

Limits of variables:

$$\begin{aligned} \begin{array}{l} a,b,c,d,e\in \left[ 0,50 \right] \\ {{x}_{A}},{{y}_{A}},{{x}_{B}},{{y}_{B}}\in \left[ -20,20 \right] \\ {{t}_{1}},{{t}_{2}}\in \left\{ -1,1 \right\} \\ {{\varphi }_{1}},{{\varphi }_{2}},{{\varphi }_{3}},{{\varphi }_{4}},{{\varphi }_{5}},{{\varphi }_{6}},{{\varphi }_{7}},{{\varphi }_{8}},{{\varphi }_{9}},{{\varphi }_{10}},{{\varphi }_{11}},{{\varphi }_{12}}\in \left[ 0,360{}^\circ \right] \\ \end{array} \end{aligned}$$

The optimized mechanism found by Bulatović et al. [10] and the optimized mechanism obtained with the approach here proposed is showed in the Fig. 6.

Fig. 6
figure 6

Solution to the problem 2

The values of design variables are:

$$\begin{aligned}&a=1.1481\ \ b=8.753\ \ c=4.9843 \ \ d=4.5143\ \ e=8.008 \\&x_{A}=0.2256\ \ y_{A}=-1.5728\ \ x_{B}=5.4858 \ \ y_{B}=-1.003 \ \ t_{1}=-1 \\&t_{2}=1\\&\left\{ {{\varphi }_{i}} \right\} =\left\{ \begin{matrix} 13.0309, 35.9183 , 66.1241, 94.3757, 117.3105, 157.358 \\ 185.143 , 217.588 , 263.420 , 291.349 \ 316.623 , 341.74 \\ \end{matrix} \right\} \end{aligned}$$

5.3 Problem 3

The Fig. 7 shows the mechanism obtained with the approach here proposed as well as the mechanism found by Cabrera et al. [4]. Design variables are:

$$\begin{aligned} X=\left[ \begin{array}{cccccccccccccc} a &{} b &{} c &{} d &{} e &{} {{x}_{A}} &{} {{y}_{A}} &{} {{x}_{B}} &{} {{y}_{B}} &{} {{t}_{1}} &{} {{t}_{2}} &{} {{\varphi }_{1}} &{} \cdots &{} {{\varphi }_{10}} \\ \end{array}\right] \end{aligned}$$

Target points are:

$$\begin{aligned} {}^{d}{{P}_{j}}=\left[ \begin{array}{lll} \left( 20,10 \right) ,\left( 17.66,15.142 \right) ,\left( 11.736,17.878 \right) ,\left( 5,16.928 \right) \\ \left( 0.60307,12.736 \right) ,\left( 0.60307,7.2638 \right) ,\left( 5,3.0718 \right) \text { } \\ \left( 11.736,2.1215 \right) ,\left( 17.66,4.8577 \right) ,\left( 20,10 \right) \text { } \\ \end{array} \right] \end{aligned}$$

Limits of variables:

$$\begin{aligned} \begin{array}{l} a,b,c,d,e\in \left[ 0,80 \right] \\ {{x}_{A}},{{y}_{A}},{{x}_{B}},{{y}_{B}}\in \left[ -80,80 \right] \\ {{t}_{1}},{{t}_{2}}\in \left\{ -1,1 \right\} \\ {{\varphi }_{1}},{{\varphi }_{2}},{{\varphi }_{3}},{{\varphi }_{4}},{{\varphi }_{5}},{{\varphi }_{6}},{{\varphi }_{7}},{{\varphi }_{8}},{{\varphi }_{9}},{{\varphi }_{10}}\in \left[ 0,360{}^\circ \right] \\ \end{array} \end{aligned}$$
Fig. 7
figure 7

Solution to the problem 3

The values of design variables are:

$$\begin{aligned}&a=9.9864\ \ b=63.93\ \ c=33.7178 \ \ d=11.304\ \ e=53.8921 \\&x_{A}=-1.4159\ \ y_{A}=10.5839\ \ x_{B}=58.532 \ y_{B}=1.358\ \ t_{1}=1 \\&t_{2}=-1\\&\left\{ {{\varphi }_{i}} \right\} =\left\{ \begin{matrix} 1.1317 , 38.6537 \ 77.7545 , 118.224 ,158.8833 \\ 198.7785 , 239.8071 , 281.6572 , 320.3808 , 360 \\ \end{matrix} \right\} \end{aligned}$$

5.4 Discussion of the method

The proposed procedure is focused on the formulation of the optimization problem and not on the optimization method. Where the main difference of the proposed procedure with the methods known to the authors is that the synthesis error is always a real number independent of the values of the design variables, this allows that individuals potentially close to the global optimum are not eliminated. The results of the optimization of the three problems are comparable with those of the literature and moreover with different dimensions and configurations.

It should also be noted that the proposed procedure encompasses a greater number of potential solutions unlike other procedures in the literature. This is due to the fact that the objective function is never penalized with values too large when the mechanism assembly is impossible even if the dimensions are close to their optimal values.

6 Conclusion

This paper presents a new approach for the optimal path synthesis of a four-bar linkage. Where the robustness of the procedure is based on the analytical solution of the mechanism’s position through the use of natural coordinates and their operation under the field of the set of complex numbers. Further to the construction of the objective function using the Hermitian conjugate operator that allows defining define a synthesis error that is always a real value.

As an optimization method, a Teaching Learning Based Optimization Algorithm was modified due that originally the algorithm only worked with continuous variables. The modified TLBO was implemented in Matlab®for three trajectory synthesis problems with six, twelve and ten precision points respectively.

The proposed procedure can be used for the synthesis of any planar mechanism whose position can be obtained analytically, and using any method of evolutionary optimization.