1 Introduction

The problem of determination and optimization of joint reactions as well as minimization of shaking forces and shaking moment in different types of mechanisms represents a big challenge for researchers and designers. Mechanisms are required to operate uniformly even at high speeds. In order to accomplish it, it is necessary to reduce the forces and the moment which are the results of inertia. The minimization of shaking forces and shaking moment leads to improved dynamics, while noise and vibrations decrease. Besides, the determination of joint reactions plays an important role in stress analysis and dimensioning of mechanisms. Šalinić [1] proposed an algorithm for determination of joint reactions in a symbolic form in planar and spatial rigid multibody systems.

Mechanisms can be balanced either statically or dynamically. The condition for achieving static balance is that the sum of all forces during motion must equal zero [2]. In order to achieve the balance of forces, it is necessary to have the stationary mass center. Static balancing is accomplished by using the method of counterweights [3] or the method of mass redistribution [4]. Berkof and Lowen [5] proposed the method of linearly independent vectors, which requires redistribution of masses of members in such a way that the total center of mass becomes stationary. Arakelian and Dahan [6] introduced a method for complete balancing of the shaking force and partial balancing of the shaking moment which is applied for any planar or spatial mechanism. The method is based on the principle of minimization of the mean value of the shaking moment.

Dynamic balancing implies simultaneous balancing of shaking forces and the moment [7, 8]. In order to satisfy dynamic balance, the sum of all forces and the sum of all moments must be equal to zero. The use of counterweights and counter-rotations for shaking force and shaking moment balancing leads to the increase in mass and inertia of the mechanism. Since recently, several optimization techniques have been used for minimization of shaking moment only, or, in combination with the minimization of shaking force, and/or driving torque. In addition to conventional optimization techniques which are applied for optimal balancing of planar mechanisms [9], modern evolutionary optimization techniques, which are biologically inspired, are often applied. Dynamic balancing of a planar mechanism in which shaking forces and shaking moment are minimized by using the Genetic Algorithm, GA, is considered in [10]. Minimization of shaking forces and the moment by finding the optimal distribution of mass of mechanism members by using an equivalent system of point-masses is described in [10, 11]. Chaudhary et al. [11] solved the multi-objective optimization problem by using the teaching-learning-based optimization (TLBO) algorithm. Farmani et al. [12] considered the problem of dynamic balancing in a four-bar mechanism by using two evolutionary algorithms called non-dominated sorting Genetic Algorithm and multi-objective particle swarm optimization. The objective functions were derived from the concept of inertia counterweights and physical pendulum that permit complete balance of all mass effects.

For the purpose of obtaining as good results as possible and as effective algorithms as possible, and in addition to the modification of standard optimization algorithms, several authors also combined two and more different optimization algorithms.

A certain number of papers deal with the problem of balancing and optimization of dynamic parameters of a four-bar mechanism. Guo et al. [13] proposed a new method which represents a combination of the mass redistribution method and the counterweight method for a planar four-bar mechanism. For the purpose of reducing shaking forces, shaking moment and driving torque, the proposed method used the Genetic Algorithm. Erkaya [14] presented a practical method for reducing shaking forces and fluctuation of the moment in a four-bar mechanism, which is based on the Genetic Algorithm. It was shown that the structure of the objective function and the values of weighting factors have an important role in the optimization process.

The problem of minimization of joint reactions was discussed in [15, 16]. Šalinic et al. [15] presented two ways for minimization of joint reactions of a planar serial manipulator. The first way is based on the optimal selection of the angular rotation laws of manipulator links, and the second one on attaching counterweights to the manipulator links. Harl, Oblak and Butinar [16] considered the minimization of joint reactions of planar kinematic chains by means of a multi-objective approach. The attention is directed toward the formulation of the problem of nonlinear programming for the purpose of minimization of generalized forces.

In several papers, there is a reference to the research done so far, with an overview of the literature in this field and the summary of results obtained by different methods of balancing of mechanisms. Arakelian and Smith [17] presented an overview of methods for dynamic balancing of mechanisms based on the generation of different movements of counterweights. Complete shaking force and shaking moment balancing are demonstrated using the pantograph copying properties. Wijk and Herder [18] presented the balancing principles which are obtained from a survey of the literature and applied them to a representative mechanism. They summarized and compared the existing balancing principles concerning the addition of mass and the addition of inertia. Zhang and Wei [7] provided a detailed description of modern technologies and principles of dynamic balancing of mechanisms based on the minimum increase in mass and inertia. Also, they explained the synthesis of parallel robots on the basis of decomposition and the concept of integration. Several chapters of the book are devoted to the discussion and presentation of optimization processes which are applied in balancing of mechanisms.

This paper considers the problem of dynamic balancing of a four-bar mechanism which is presented in Fig. 1. The masses of the links are \(m_1\), \(m_2\) and \(m_3\), while the lengths of the links are \(L_1,\,L_2\) and \(L_3\). The four-bar mechanism is placed in the vertical plane \(O_1 xy\). The positions of the mass centers \(C_p \left( {p=1, 2, 3} \right) \) are defined by \(\alpha _p [{\mathrm{rad}}]\)i\( d_p [m]\), \(\left( {p=1, 2, 3} \right) \).

Fig. 1
figure 1

A general four-bar mechanism

Firstly, the joint reactions were determined at all joints by using the new method which can be applied to rigid planar closed-loop kinematic chains. The problem of dynamic balancing of mechanisms was then solved as an optimization problem. Unlike some papers [10, 14, 15] in which one objective function was formed by using weighting factors, the optimization problem in this paper is solved by using a multi-objective approach.

In this paper, two biologically inspired algorithms, Cuckoo Search—CSA (Yang in [19]) and Firefly Algorithm—FA (Yang and Deb in [20]), i.e., their hybridization, are used for solving the problem of multi-objective optimization. Almost all biologically inspired algorithms are of recent origin, and they look simple and their main characteristics are most often derived, directly or indirectly, on the basis of observations of systems from nature. The success and popularity of these algorithms can be attributed to the following factors: simplicity of algorithm, simplicity of application and diversity of solutions they generate.

Several biologically inspired algorithms are capable of achieving convergence toward a global optimum of an optimization problem after a relatively small number of iterations. This characteristic practically recommends them for solving problems of global optimization. To be efficient, biologically inspired algorithms must have certain specific characteristics. They must generate new solutions which are better than the previous ones. The second characteristic is that a metaheuristic algorithm must recognize a trap of entering a local optimum and have a mechanism which will take it out of that search space. A good combination of these characteristics results, under certain conditions, in a good efficiency of the algorithm, which, again, requires good balance of two main components: intensification and diversification [21]. Diversification means that different solutions which search the space on a global scale are generated, whereas intensification means to focus on the search in a local region using the information about good solutions found in it. Intensification often uses randomization, which enables the algorithm to leave any local minimum. It can also be used for local search around the currently best solution if the step is restricted to a local region. If the step is sufficiently big, randomization can explore the search space on a global scale.

The number of biologically inspired algorithms has been rapidly rising recently, so that the short research by Fister in [22] shows that there are more than 40 kinds of these algorithms with the tendency of appearance of new ones inspired by nature. It is simply impossible to mention all the existing types of biologically inspired algorithms, as well as their modifications and hybridizations. Readers can find a detailed overview of the existing algorithms in the paper written by Yang [23].

The application of biologically inspired algorithms in the design of mechanisms can be seen in the following papers: [24,25,26,27,28,29,30,31,32,33].

Except biologically inspired algorithms, gradient-based methods can effectively lead to a global optimum. However, gradient-based methods involve determination of the first and the second derivative of the objective function and that is not always easy in real engineering problems. In addition, the use of gradient-based methods to a complex optimization problems is limited because it is necessary to set the initial values of the design variables in such a way to make them close to the desired (optimum) values. In some cases, the gradient must be approximated numerically which is not at all an easy task because it requires several additional calculations of the objective function in each iteration. Due to the above facts, the authors did not deal with the application of this algorithm, leaving the space for future research.

As aforementioned, this paper shows how a multi-objective optimization problem was solved by using a new algorithm created by hybridization of two biologically inspired algorithms—Cuckoo Search and Firefly Algorithm, i.e., H-CS-FA. The selected algorithms have different approaches and optimization flows, but what they have in common is that both of them use the mechanism of Lévy flights for obtaining solutions. [34, 35]. The main difference between these two algorithms is that in the CS algorithm there is a mechanism for elimination of a ”bad“ nest, which represents a danger that the algorithm may, at a point, leave the good direction while searching for an optimum solution, which can lead to the increased time of finding the optimum.

In the H-CS-FA algorithm, a new approach for solving the problem of multi-objective optimization is introduced where simultaneous, i.e., parallel search is used. After starting the initial solution for each objective function, it is checked whether the optimality criterion is satisfied for every pass. If the optimality criterion is not satisfied for all objective functions, the algorithm starts checking from the beginning, in a new iteration. Otherwise, i.e., when the optimality criterion is satisfied for all objective functions, that solution is proclaimed the best one and the values of the objective function are compared with it in the next iterative cycle. The risk of wrong estimation of the values of weight factors for each objective function is thus avoided, i.e., the search time is reduced—the cycle of searching for the best values of each objective function is avoided because everything is done in one iterative cycle of searching.

The paper is organized as follows: Section 2 provides a detailed description of the new method for determination of joint reactions. Solving of the problem of dynamic balancing by applying multi-objective optimization and the new hybrid algorithm H-CS-FA is presented in Sect. 3. The efficiency of the new hybrid algorithm was tested on the example of optimization of dynamic parameters of a four-bar mechanism and the obtained results are shown in Sect. 4. Finally, the conclusions and notes are presented in Sect. 5.

2 A new method for determination of joint reactions of a four-bar mechanism

This section will present a new method for determination of joint reaction forces in rigid planar closed-loop kinematic chains in which rigid bodies are interconnected by revolute joints. This new method is based on the approach for determination of joint reaction forces in tree structure rigid multibody systems described in [1]. Namely, in our paper the method from [1] will be modified and extended to the case of rigid planar closed-loop multibody systems. The modification of the method from [1] relates to the use of absolute angles of rotation of bodies in the kinematic chain instead of relative angles of rotation between neighboring bodies connected by a revolute joint. In terms of calculation, the use of absolute angles of rotation considerably simplifies the procedure of determination of joint reaction forces in comparison with the procedure from [1] based on relative joints coordinates.

According to [36], after cutting off the joint \(O_{3}\) (see Fig. 1), the motion of the considered four-bar mechanism can be divided into simultaneous motions of two mechanisms denoted with I and II and shown in Fig. 2, where the links of the mechanism II are massless.

The driving torques \(M_1^*,\, M_2^*\) and \(M_3^*\) act in the joints \(O_1 ,\,O_2\) and \(O_4\) of the mechanism I, while in the mechanism II the corresponding driving torques are \(M_1^{**},\,M_2^{**}\) and \(M_3^{**} \), respectively. Since the joints \(O_2,\,O_3 \) and \(O_4\) of the four-bar mechanism shown in Fig. 1 are passive (not actuated), the following conditions must be satisfied [36]:

$$\begin{aligned} M_2^*+M_2^{**}= & {} 0 \end{aligned}$$
(1)
$$\begin{aligned} M_3^*+M_3^{**}= & {} 0 \end{aligned}$$
(2)
Fig. 2
figure 2

The four-bar mechanism equivalently represented through two subsystems I and II

External force systems exerted on the links \(\left( {V_p } \right) \left( {p=1, 2, 3} \right) \) of the mechanism I are represented by equivalent force systems consisting of forces \(\mathbf{F}_p^*\left( {p=1, 2, 3} \right) \) determined by:

$$\begin{aligned} \mathbf{F}_p^*=\left[ 0\quad {-m_p g}\quad 0 \right] , p=1, 2, 3 \end{aligned}$$
(3)

passing through the mass centers \(C_p \left( {p=1, 2, 3} \right) \), respectively, together with the couples with torques \(\mathbf{M}_p^*\left( {p=1, 2, 3} \right) \) given by:

$$\begin{aligned} \mathbf{M}_1^*= & {} \left[ 0 \quad 0 \quad {M_1^*-M_2^*} \right] , \end{aligned}$$
(4)
$$\begin{aligned} \mathbf{M}_2^*= & {} \left[ 0 \quad 0 \quad {M_2^*} \right] , \end{aligned}$$
(5)
$$\begin{aligned} \mathbf{M}_3^*= & {} \left[ 0 \quad 0 \quad {M_3^*} \right] , \end{aligned}$$
(6)

where g is the gravitational acceleration.

Similarly, for the mechanism II one has:

$$\begin{aligned} \mathbf{F}_1^{**}= & {} \left[ 0 \quad 0 \quad 0\right] , \end{aligned}$$
(7)
$$\begin{aligned} \mathbf{F}_2^{**}= & {} \left[ {X_{O_3 } } \quad {Y_{O_3 } } \quad 0 \right] , \end{aligned}$$
(8)
$$\begin{aligned} \mathbf{F}_3^{**}= & {} \left[ {-X_{O_3 } } \quad {-Y_{O_3 } } \quad 0 \right] , \end{aligned}$$
(9)
$$\begin{aligned} \mathbf{M}_1^{**}= & {} \left[ 0 \quad 0 \quad {M_1^{**} -M_2^{**} } \right] , \end{aligned}$$
(10)
$$\begin{aligned} \mathbf{M}_2^{**}= & {} \left[ 0 \quad 0 \quad {M_2^{**} +X_{O_3 } \left( {d_2 \sin \left( {\theta _2 +\alpha _2 } \right) -L_2 \sin \theta _2 } \right) +Y_{O_3 } \left( {-d_2 \cos \left( {\theta _2 +\alpha _2 } \right) +L_2 \cos \theta _2 } \right) }\right] , \end{aligned}$$
(11)
$$\begin{aligned} \mathbf{M}_3^{**}= & {} \left[ 0 \quad 0 \quad {M_3^{**} +X_{O_3 } \left( {-d_3 \sin \left( {\theta _3 +\alpha _3 } \right) +L_3 \sin \theta _3 } \right) -Y_{O_3 } \left( {-d_3 \cos \left( {\theta _3 +\alpha _3 } \right) +L_3 \cos \theta _3 } \right) }\right] , \end{aligned}$$
(12)

where \(X_{O_3}\) and \(Y_{O_3}\) represent the components of reaction force in the joint \(O_3 \) along the x and y axes, respectively. In accordance with [37, 38], introducing now redundant coordinates \(s_1 ,\ldots , s_6 \) (also known as open-constraint coordinates), the motions of the mechanisms I and II can be described by the generalized coordinates \(q_1 ,\ldots , q_9 \) where \(q_i \equiv \theta _i\, \left( {i=1,2,3} \right) \) and \(q_{3+r} \equiv s_r \left( {r=1,\ldots , 6} \right) \) and where the following constraints hold (see Fig. 3):

$$\begin{aligned} f_r \equiv q_{3+r} =0 ,\quad r=1,\ldots , 6. \end{aligned}$$
(13)
Fig. 3
figure 3

The introduction of redundant coordinates in the mechanisms I and II

Note that the coordinates \(s_1 ,\ldots , s_6 \) represent the prohibited relative motions in the joints \(O_1 ,\,O_2\) and \(O_4 \). In addition, the constraints (13) may be written at velocity and acceleration levels, respectively, as follows:

$$\begin{aligned} \dot{q}_{3+r} \equiv 0 , \quad \ddot{q}_{3+r} \equiv 0 , \quad r=1,\ldots , 6. \end{aligned}$$
(14)

Applying Kane’s equations with undetermined multipliers [39] for the mechanism I, one has:

$$\begin{aligned}&Q_{i\left( *\right) }^a +Q_{i\left( *\right) }^{in} =0 , \quad i=1,2,3 \end{aligned}$$
(15)
$$\begin{aligned}&Q_{3+r\left( *\right) }^a +Q_{3+r\left( *\right) }^{in} +\lambda _{r\left( *\right) } =0 , \quad r=1,\ldots , 6 \end{aligned}$$
(16)

and for the mechanism II:

$$\begin{aligned}&Q_{i\left( {**} \right) }^a +Q_{i\left( {**} \right) }^{in} =0 , \quad i=1,2,3 \end{aligned}$$
(17)
$$\begin{aligned}&Q_{3+r\left( {**} \right) }^a +Q_{3+r\left( {**} \right) }^{in} +\lambda _{r\left( {**} \right) } =0 , \quad r=1,\ldots , 6 \end{aligned}$$
(18)

where \(Q_{j\left( *\right) }^a \left( {j=1,\ldots , 9} \right) \) and \(Q_{j\left( {**} \right) }^a \left( {j=1,\ldots , 9} \right) \) represent generalized active forces corresponding to the generalized coordinates \(q_1,\ldots , q_9\) determined by the following expressions:

$$\begin{aligned} Q_{j\left( *\right) }^a= & {} \sum _{p=1}^3 {\left( {\mathbf{M}_p^*\frac{\partial {{\varvec{\upomega }} }_p }{\partial \dot{q}_j }+\mathbf{F}_p^*\frac{\partial \mathbf{V}_{C_p } }{\partial \dot{q}_j }} \right) }, \quad j=1,\ldots ,9 \end{aligned}$$
(19)
$$\begin{aligned} Q_{j\left( {**} \right) }^a= & {} \sum _{p=1}^3 {\left( {\mathbf{M}_p^{**} \frac{\partial {{\varvec{\upomega }} }_p }{\partial \dot{q}_j }+\mathbf{F}_p^{**} \frac{\partial \mathbf{V}_{C_p } }{\partial \dot{q}_j }} \right) } , \quad j=1,\ldots ,9 \end{aligned}$$
(20)

\(Q_{j\left( *\right) }^{in} \left( {j=1,\ldots , 9} \right) \) and \(Q_{j\left( {**} \right) }^{in} \left( {j=1,\ldots , 9} \right) \) are the generalized inertia forces corresponding to the generalized coordinates \(q_1 ,\ldots ,q_9 \) determined by:

$$\begin{aligned} Q_{j\left( *\right) }^{in}= & {} -\sum _{p=1}^3 {\left( {m_p \mathbf{a}_{C_p }^T \frac{\partial \mathbf{V}_{C_p } }{\partial \dot{q}_j }+J_{C_p } {{\varvec{\upvarepsilon }} }_p^T \frac{\partial {{\varvec{\upomega }} }_p }{\partial \dot{q}_j }} \right) } , \quad j=1,\ldots , 9 \end{aligned}$$
(21)
$$\begin{aligned} Q_{j\left( {**} \right) }^{in}= & {} 0, \quad j=1,\ldots , 9 \end{aligned}$$
(22)

In the expressions (19)–(21), \({{\varvec{\upomega }} }_p =\left[ 0 \quad 0 \quad {\dot{\theta }_p }\right] ^{T}\) and \({{\varvec{\upvarepsilon }} }_p =\left[ 0 \quad 0 \quad {\ddot{\theta }_p } \right] ^{T}\) are the angular velocity and the angular acceleration of the link \(\left( {V_p } \right) \), respectively, \(\mathbf{V}_{C_p } =\left[ {\dot{x}_{C_p } } \quad {\dot{y}_{C_p } } \quad 0 \right] ^{T}\) and \(\mathbf{a}_{C_p } =\left[ {\ddot{x}_{C_p } } \quad {\ddot{y}_{C_p } } \quad 0 \right] ^{T}\) are the linear velocity and the linear acceleration of the mass center \(C_p \), respectively, where the Cartesian coordinates \(x_{C_p } \left( {p=1,2,3} \right) \) and \(y_{C_p } \left( {p=1,2,3} \right) \) are given in Appendix, and \(J_{C_p } \) is the mass moment of inertia about centroidal axis of the link \(\left( {V_p } \right) \).

Solving now Eqs. (15) and (17) for \(M_2^*,\, M_2^{**} ,\, M_3^*\) and \(M_3^{**}\) and substituting the obtained quantities into Eqs. (1) and (2) yield the following expressions for the components of the reaction force in the joint \(O_3\):

$$\begin{aligned} X_{O_3 }= & {} -\frac{1}{2L_2 L_3 \cos \left( {\theta _2 -\theta _3 } \right) }\,\left[ {d_2 L_1 L_3 m_2 \left( {\cos \left( {\alpha _2 -\theta _1 +\theta _2 -\theta _3 } \right) +\cos \left( {\alpha _2 -\theta _1 +\theta _2 +\theta _3 } \right) } \right) \ddot{\theta }_1 } \right. \nonumber \\&+\,2\left( {d_2^2 L_3 m_2 +J_{C_2 } L_3 } \right) \ddot{\theta }_2 \cos \theta _3 +2L_2 \left( {J_{C_3 } +m_3 d_3^2 } \right) \ddot{\theta }_3 \cos \theta _2 \nonumber \\&+\,d_2 L_1 L_3 m_2 \dot{\theta }_1^2 \left( {\sin \left( {\alpha _2 -\theta _1 +\theta _2 -\theta _3 } \right) } \right. \nonumber \\&\left. {+\,\sin \left( {\alpha _2 -\theta _1 +\theta _2 +\theta _3 } \right) } \right) +d_2 gL_3 m_2 \left( {\cos \left( {\alpha _2 +\theta _2 -\theta _3 } \right) +\cos \left( {\alpha _2 +\theta _2 +\theta _3 } \right) } \right) \nonumber \\&\left. {+\,d_3 gL_2 m_3 \left( {\cos \left( {\alpha _3 -\theta _2 +\theta _3 } \right) +\cos \left( {\alpha _3 +\theta _2 +\theta _3 } \right) } \right) } \right] \end{aligned}$$
(23)
$$\begin{aligned} Y_{O_3 }= & {} -\frac{1}{2L_2 L_3 \cos \left( {\theta _2 -\theta _3 } \right) }\,\left[ {d_2 L_1 L_3 m_2 \left( {\sin \left( {\alpha _2 -\theta _1 +\theta _2 +\theta _3 } \right) -\sin \left( {\alpha _2 -\theta _1 +\theta _2 -\theta _3 } \right) } \right) \ddot{\theta }_1 } \right. \nonumber \\&+\,2\left( {d_2^2 L_3 m_2 +J_{C_2 } L_3 } \right) \ddot{\theta }_2 \sin \theta _3 +2L_2 \left( {J_{C_3 } +m_3 d_3^2 } \right) \ddot{\theta }_3 \sin \theta _2 \nonumber \\&+\,d_2 L_1 L_3 m_2 \dot{\theta }_1^2 \left( {\cos \left( {\alpha _2 -\theta _1 +\theta _2 -\theta _3 } \right) } \right. \nonumber \\&\left. {-\,\cos \left( {\alpha _2 -\theta _1 +\theta _2 +\theta _3 } \right) } \right) +d_2 gL_3 m_2 \left( {\sin \left( {\alpha _2 +\theta _2 +\theta _3 } \right) -\sin \left( {\alpha _2 +\theta _2 -\theta _3 } \right) } \right) \nonumber \\&\left. {+\,d_3 gL_2 m_3 \left( {\sin \left( {\alpha _3 +\theta _2 +\theta _3 } \right) -\sin \left( {\alpha _3 -\theta _2 +\theta _3 } \right) } \right) } \right] \end{aligned}$$
(24)

where the constraints (14) are taken into account. In addition, from Eq. (16) it follows that:

$$\begin{aligned} \lambda _{1\left( *\right) }= & {} m_1 \left( {\ddot{x}_{C_1 } } \right) _0 +m_2 \left( {\ddot{x}_{C_2 } } \right) _0 , \end{aligned}$$
(25)
$$\begin{aligned} \lambda _{2\left( *\right) }= & {} \left( {m_1 +m_2 } \right) g+m_1 \left( {\ddot{y}_{C_1 } } \right) _0 +m_2 \left( {\ddot{y}_{C_2 } } \right) _0 , \end{aligned}$$
(26)
$$\begin{aligned} \lambda _{3\left( *\right) }= & {} m_2 \left( {\ddot{x}_{C_2 } } \right) _0 , \end{aligned}$$
(27)
$$\begin{aligned} \lambda _{4\left( *\right) }= & {} m_2 g+m_2 \left( {\ddot{y}_{C_2 } } \right) _0 , \end{aligned}$$
(28)
$$\begin{aligned} \lambda _{5\left( *\right) }= & {} m_3 \left( {\ddot{x}_{C_3 } } \right) _0 , \end{aligned}$$
(29)
$$\begin{aligned} \lambda _{6\left( *\right) }= & {} m_3 g+m_3 \left( {\ddot{y}_{C_3 } } \right) _0 , \end{aligned}$$
(30)

and from Eq. (18):

$$\begin{aligned} \lambda _{1\left( {**} \right) }= & {} \lambda _{3\left( {**} \right) } =-X_{O_3 } , \end{aligned}$$
(31)
$$\begin{aligned} \lambda _{2\left( {**} \right) }= & {} \lambda _{4\left( {**} \right) } =-Y_{O_3 } , \end{aligned}$$
(32)
$$\begin{aligned} \lambda _{5\left( {**} \right) }= & {} X_{O_3 } , \end{aligned}$$
(33)
$$\begin{aligned} \lambda _{6\left( {**} \right) }= & {} Y_{O_3 } \end{aligned}$$
(34)

where the notation \((\cdot )_{0}\) means that the quantity \((\cdot )\) is calculated for \(q_4 =\cdots =q_9 =0\).

Finally, the components of reaction forces in the joints \(O_1 ,\,O_2\) and \(O_4\) along the x and y axes, respectively, read:

$$\begin{aligned} X_{O_1 }= & {} \lambda _{1\left( *\right) } +\lambda _{1\left( {**} \right) } =m_1 \left( {\ddot{x}_{C_1 } } \right) _0 +m_2 \left( {\ddot{x}_{C_2 } } \right) _0 -X_{O_3 } \end{aligned}$$
(35)
$$\begin{aligned} Y_{O_1 }= & {} \lambda _{2\left( *\right) } +\lambda _{2\left( {**} \right) } =m_1 \left( {\ddot{y}_{C_1 } } \right) _0 +m_2 \left( {\ddot{y}_{C_2 } } \right) _0 +\left( {m_1 +m_2 } \right) g-Y_{O_3 } \end{aligned}$$
(36)
$$\begin{aligned} X_{O_2 }= & {} \lambda _{3\left( *\right) } +\lambda _{3\left( {**} \right) } =m_2 \left( {\ddot{x}_{C_2 } } \right) _0 -X_{O_3 } \end{aligned}$$
(37)
$$\begin{aligned} Y_{O_2 }= & {} \lambda _{4\left( *\right) } +\lambda _{4\left( {**} \right) } =m_2 \left( {\ddot{y}_{C_2 } } \right) _0 +m_2 g-Y_{O_3 } \end{aligned}$$
(38)
$$\begin{aligned} X_{O_4 }= & {} \lambda _{5\left( *\right) } +\lambda _{5\left( {**} \right) } =m_3 \left( {\ddot{x}_{C_3 } } \right) _0 +X_{O_3 } \end{aligned}$$
(39)
$$\begin{aligned} Y_{O_4 }= & {} \lambda _{6\left( *\right) } +\lambda _{6\left( {**} \right) } =m_3 \left( {\ddot{y}_{C_3 } } \right) _0 +m_3 g+Y_{O_3 } \end{aligned}$$
(40)

In Eqs. (23), (24) and (35)–(40), the quantities \(\theta _2\) and \(\theta _3\) and their time derivatives can be eliminated using the following relations [2]:

$$\begin{aligned} \theta _2= & {} 2\tan ^{-1}\left( {\frac{-b_2 \pm \sqrt{b_2^2 -4a_2 c_2 }}{2a_2 }} \right) \end{aligned}$$
(41)
$$\begin{aligned} \theta _3= & {} 2\tan ^{-1}\left( {\frac{-b_3 \pm \sqrt{b_3^2 -4a_3 c_3 }}{2a_3 }} \right) \end{aligned}$$
(42)

where

$$\begin{aligned} a_2= & {} \cos \theta _1 -\frac{L_4 }{L_1 }+\frac{L_4 }{L_2 }\cos \theta _1 +\frac{L_3^2 -L_4^2 -L_1^2 -L_2^2 }{2L_1 L_2 }, \end{aligned}$$
(43)
$$\begin{aligned} b_2= & {} -2\sin \theta _1 , \end{aligned}$$
(44)
$$\begin{aligned} c_2= & {} \frac{L_4 }{L_1 }+\left( {\frac{L_4 }{L_2 }-1} \right) \cos \theta _1 +\frac{L_3^2 -L_4^2 -L_1^2 -L_2^2 }{2L_1 L_2 }, \end{aligned}$$
(45)
$$\begin{aligned} a_3= & {} \cos \theta _1 -\frac{L_4 }{L_1 }-\frac{L_4 }{L_3 }\cos \theta _1 +\frac{L_1^2 -L_2^2 +L_3^2 +L_4^2 }{2L_1 L_3 }, \end{aligned}$$
(46)
$$\begin{aligned} b_3= & {} -2\sin \theta _1 , \end{aligned}$$
(47)
$$\begin{aligned} c_3= & {} \frac{L_4 }{L_1 }-\left( {\frac{L_4 }{L_3 }+1} \right) \cos \theta _1 +\frac{L_1^2 -L_2^2 +L_3^2 +L_4^2 }{2L_1 L_3 }, \end{aligned}$$
(48)

At the end, it should be added that the presented approach for determination of joint reactions in planar closed-loop multibody systems is based on the technique of introducing prohibited relative motions in the joints, as in the approach described in [40]. However, our approach in terms of calculation is advantageous over the approach in [40] because it does not require the formation of constraint Jacobian matrices and their pseudo-inverse matrices, as in [40]. In this paper, this is allowed by using one absolute coordinate (absolute angle of rotation), and not three as in [40], for determination of the position of links of the mechanism.

3 Optimization process

3.1 Hybrid Cuckoo Search and Firefly Algorithm (H-CS-FA)

The algorithm used in this paper was created by hybridization of two biologically inspired algorithms: Cuckoo Search and Firefly Algorithm.

Cuckoo Search (CS) represents a new optimization metaheuristic algorithm, which is also biologically inspired by the cuckoos’ manner of looking for nests where they could lay eggs. This algorithm, as already said, was proposed by Yang and Deb in [19]. The Cuckoo Search algorithm is a biologically inspired algorithm which is widely applied in solving very complex optimization problems in various fields of engineering, industry, etc. In the existing literature, there are a large number of papers where this algorithm was used in its original form, or as its various improvements or hybridizations with other algorithms. A detailed presentation of application of the standard Cuckoo Search algorithm can be seen in the review articles [41,42,43].

The Firefly Algorithm (FA) was introduced for the first time by Yang, in [20]. The Firefly Algorithm is also a biologically inspired optimization algorithm which idealizes some characteristics of the flashing light of the firefly. A comprehensive review of the literature where the Firefly Algorithm was applied for solving different optimization problems was given by Fister et al. in [44] and Yang and Xingshi in [45].

In this paper, the authors will not remain on a detailed explanation of these algorithms.

The hybrid algorithm applied in this paper represents a combination of the Cuckoo Search algorithm, CS, and the Firefly Algorithm, FA. In both algorithms, generation of new solutions takes place according to the Lévy flight mechanism. The main difference between these two algorithms is that in the CS algorithm there is a mechanism of elimination of a “bad” nest, which represents a danger that the algorithm may, at a point, leave the good direction while searching for an optimum solution. It can lead to the increased time of finding the optimum.

The proposed hybrid algorithm is based on the CS algorithm which incorporates a part of the FA, which is shown in Algorithm 1.

figure a
figure b

MOO is used for solving optimization problems which include two or more complex, nonlinear, opposed objective functions, which should be simultaneously optimized: \({\mathrm{min}} \left\{ {F_1 \left( {\varvec{X}} \right) , F_2 \left( {\varvec{X}} \right) ,\ldots ,F_m \left( {\varvec{X}} \right) , } \right\} \) where \({\varvec{X}}\) is the vector of design variables: \(\mathbf{X}=\left( {x_1 ,x_2 ,\ldots ,x_d } \right) ^{T}\). In single-criterion optimization, i.e., optimization with one objective function, the optimization algorithm generates a new solution looking for it in the search space defined by the boundaries of design variables. During the iterative process, worse solutions are eliminated and replaced with better ones. The solution found for that iterative cycle is also the best one for the given optimization problem. However, in nontrivial, MOO problems, there is no unique solution which will at the same time optimize each objective function. The optimum solutions found cannot be improved by one criterion without being worsened by another, which makes the search and finding of the optimum solution by all criteria considerably difficult.

In the literature, the method of weighting factors or the Pareto front is used for solving the problems of multi-objective optimization. In the method of weighting factors, all objective functions are transformed through weighting factor into one objective function and the problem of multi-objective optimization is reduced to the problem of single-criterion optimization. In the application of the Pareto front, instead of weighting factors, the best values for each objective function are used and those best values have the role of the weighting factor during the linearization of problems, i.e., transformation of multi-objective optimization into single-criterion optimization.

In this paper, simultaneous, i.e., parallel search is used for solving the problem of multi-objective optimization. After starting the initial solution for each objective function, it is checked whether the optimality criterion is satisfied for every pass. If the optimality criterion is not satisfied for all objective functions, the algorithm starts checking from the beginning, in a new iteration. Otherwise, i.e., when the optimality criterion is satisfied for all objective functions, that solution is proclaimed the best one and the values of the objective function are compared with it in the next iterative cycle (Algorithm 2). The risk of wrong estimation of the values of weight factors for each objective function is thus avoided, i.e., the search time is reduced—the cycle of searching for the best values for each objective function is avoided because everything is done in one iterative cycle of searching.

The shaded rows in Algorithm 2 show that from the matrix of solutions \(n\times d\) where n—the number of nests and d—the number of design variables, only the solution in which all elements of the newly generated row of the matrix of solutions are smaller than the corresponding elements of the previous best solution is selected.

figure c

3.2 Objective function

There are two different approaches in multi-objective optimization. The first one uses specially structured algorithms whose goal is obtaining the best set of non-dominated solutions in terms of Pareto fronts. The second one is usually defined as multi-objective optimization, which consists of one optimization goal when different objective functions are linearly combined in a unique objective function using weighting factors. The authors of this paper follow the approach which differs from the above-mentioned two, where optimizations of several objective functions are performed simultaneously. Multi-objective optimization is applied for the minimization of joint reaction forces, shaking force, shaking moment and driving torque of a four-bar mechanism. Based on the above expressions, the problem is defined as follows:

$$\begin{aligned} {\mathrm{min}} \left\{ {F_1 \left( {\varvec{X}} \right) , F_2 \left( {\varvec{X}} \right) ,\ldots ,F_m \left( {\varvec{X}} \right) } \right\} \end{aligned}$$
(49)

Subject to: \(g_j ({\varvec{X}})\le 0, j=1,\ldots ,k\) where \(F_i \left( {\varvec{X}} \right) , (i=1,2,\ldots ,m)\) is the objective functions, \(g_j ({\varvec{X}})\le 0, \) are the constraint functions and k is the number of constraints. The design variables vector is denoted by \(\mathbf{X}=\left( {x_1 ,x_2 ,\ldots ,x_d } \right) ^{T}\), and d is the number of design variables.

The upper and lower boundaries are defined for each design variable. Sixteen design variables are considered, and thus, \({\varvec{X}}\) is defined as:

$$\begin{aligned} {\varvec{X}}= \left\{ {L_1 , L_2 , L_3 , L_4 , \alpha _1 , \alpha _2 , \alpha _3 , m_1 , m_2 , m_3 , J_{C_1 } , J_{C_2 } , J_{C_3 } , d_1 , d_2 , d_3 } \right\} \end{aligned}$$
(50)

and the boundaries of design variables are shown in Table 1.

4 Numerical results

In this paper, the problem of dynamic balancing of a four-bar mechanism is considered as a multi-objective optimization problem. The new algorithm, (H-CS-FA), is used for solving the optimization problem. The driving member 2 rotates with a constant angular velocity of 300 rpm.

Table 1 Original and optimized parameters of the four-bar mechanism

The following three cases are considered:

Case 1—In this case, reactions are optimized at all four joints of the given mechanism, i.e., simultaneous minimization of eight objective functions is performed. Unlike numerous examples in the available literature in which only joint reactions in fixed joints, i.e., ground joint reaction forces, are optimized, the relations below show that the objective functions are selected in such a way to cover the reactions at all joints of the observed four-bar mechanism.

$$\begin{aligned} F_j= & {} \frac{1}{\delta }\sqrt{\sum _{i=0}^\delta {f_j^2 \left( {t_i } \right) } }, \quad j=\left( {1,2,\ldots ,8} \right) ,\quad \hbox { where }\delta =200,\quad \hbox { and }t=0{:}0.01{:}0.2; \end{aligned}$$
(51)
$$\begin{aligned} f_1= & {} X_{O1} , f_2 =Y_{O1} , f_3 =X_{O2} , f_4 =Y_{O2} , f_5 =X_{O3} , f_6 =Y_{O3} , f_7 =X_{O4} , f_8 =Y_{O4} , \end{aligned}$$
(52)

Case 2—In this case, all joint reactions and the driving torque are optimized. In other words, nine objective functions are minimized simultaneously:

$$\begin{aligned} F_j= & {} \frac{1}{\delta }\sqrt{\sum _{i=0}^\delta {f_j^2 \left( {t_i } \right) } }, \quad j=\left( {1,2,\ldots ,9} \right) ,\quad \hbox { where }\delta =200,\quad \hbox { and }t=0{:}0.01{:}0.2; \end{aligned}$$
(53)
$$\begin{aligned} f_1= & {} X_{O1} , f_2 =Y_{O1} , f_3 =X_{O2} , f_4 =Y_{O2} , f_5 =X_{O3} , f_6 =Y_{O3} , f_7 =X_{O4} , f_8 =Y_{O4} ,\,\, , f_9 =M_1 \end{aligned}$$
(54)

Case 3—By applying the H-CS-FA algorithm in this case, three objective functions which cover the shaking forces in the direction of x and y axes, as well as the shaking moment, are simultaneously minimized:

$$\begin{aligned} F_j= & {} \frac{1}{\delta }\sqrt{\sum _{i=0}^\delta {f_j^2 \left( {t_i } \right) } }, \quad j=\left( {1,2,3} \right) ,\quad \hbox { where }\delta =200,\quad \hbox { and }t=0{:}0.01{:}0.2; \end{aligned}$$
(55)
$$\begin{aligned} f_1= & {} F_{\mathrm{sh}x} , f_2 =F_{\mathrm{sh}y} , f_3 =M_{\mathrm{sh}} , \end{aligned}$$
(56)

The control parameters of the algorithm used in the optimization process for all three cases are:

\(n=25\)—the number of nests; \(p_a =0.25\)—the discovery rate of alien eggs; \(\mathrm{iter\max } =500\)—the maximum number of iterations, \(n_f =40\)—the number of fireflies, \(\alpha =0.5\)—the randomization parameter, \(\gamma =1\)—the absorption coefficient, \(\beta _0 =0.2\)—the attractiveness, \(d=16\)—the number of design variables.

Design variables are defined for the proposed mechanism. The non-optimized (original) values (taken from [14]) and the optimized values of design variables (obtained by using FA, CS and H-CS-FA), as well as the boundaries of design variables, are given in Table 1.

For Case 1, the ground joint reaction forces of the original and optimized mechanisms are given in Fig. 4. After the optimization process, the values of these forces are considerably lower in comparison with the initial values. The use of the above-mentioned optimization algorithm resulted in the reduction by 97.834%, 71.329%, 80.633% and 53.898%, in the values \(X_{O_1 } , Y_{O_1 } ,\,X_{O_4 }\) and \(Y_{O_4}\), respectively.

Fig. 4
figure 4

Original and optimized values of ground joint reaction forces (Case 1)

Figure 5 presents the initial and optimized values of joint reactions at the movable joints \(O_{2}\) and \(O_{3}\). The reactions at these joints, \(X_{O_2 } ,\,Y_{O_2 } ,\, X_{O_3 }\) and \(Y_{O_3 }\) are reduced by 61.586%, 23.615%, 84.641% and 1.919%, respectively. On the other hand, Fig. 6 presents the change of values of the shaking forces, the shaking moment as well as the driving torque, before and after the optimization process, for Case 1.

Fig. 5
figure 5

Original and optimized values of reaction forces in the joints \(O_{2}\) and \(O_{3}\) (Case 1)

Fig. 6
figure 6

Original and optimized values of shaking force components, shaking moment and driving torque (Case 1)

In Case 2, the values of ground joint reaction forces which are considerably lower in comparison with the initial values are obtained by applying the H-CS-FA algorithm in the optimization process. In other words, the application of the hybrid algorithm results in the reduction by 90.293%, 69.216%, 84.639% and 72.665%, in the values \(X_{O_1 } ,\, Y_{O_1 } ,\, X_{O_4 } \) and \(Y_{O_4 } \), respectively. Figure 7 presents the initial and optimized values of ground joint reaction forces for Case 2.

Fig. 7
figure 7

Original and optimized values of ground joint reaction forces (Case 2)

Similarly, the reactions at the movable joints \(X_{O_2 } ,\, Y_{O_2 },\, X_{O_3 } \) and \(Y_{O_3 }\) are reduced by 62.992%, 36.711%, 89.406% and 61.962%, respectively, while the optimized value of the driving torque is reduced by 92.546% in relation to the original value. The joint reactions at the movable joints \(O_{2}\) and \(O_{3}\) for Case 2 are presented in Fig. 8. The change of values of shaking forces along the axes x and y, the shaking moment as well as the driving torque, before and after the optimization process, for Case 2, is shown in Fig. 9.

Fig. 8
figure 8

Original and optimized values of reaction forces in the joints \(O_{2}\) and \(O_{3}\) (Case 2)

Fig. 9
figure 9

Original and optimized values of shaking force components, shaking moment and driving torque (Case 2)

The values of joint reactions, shaking forces, shaking moment and driving torque are considerably reduced by applying the proposed H-CS-FA algorithm in Case 3. The values of ground joint reaction forces \(X_{O_1 } , \,Y_{O_1 } ,\, X_{O_4 }\) and \(Y_{O_4 }\) are reduced by 90.92%, 75.654%, 76.029% and 77.687%, respectively, in relation to the initial values. Figure 10 presents the original and optimized values of these reactions for Case 3 in the observed four-bar mechanism.

Fig. 10
figure 10

Original and optimized values of ground joint reaction forces (Case 3)

The joint reactions at the movable joints \(O_{2}\) and \(O_{3}\) in the original and optimized mechanisms are shown in Fig. 11. The application of the optimization process in Case 3 resulted in a considerable reduction of the values of these reactions, which is shown in Fig. 11. Also, after the optimization process and the application of the proposed algorithm, the values of shaking forces in the direction of x and y axes are reduced by 99.186% and 77.396%, while the value of the shaking moment \(M_{\mathrm{sh}}\) is reduced by 76.383% in relation to the initial value. Figure 12 presents the original and optimized values of shaking forces, shaking moment and driving torque for Case 3.

Fig. 11
figure 11

Original and optimized values of reaction forces in the joints \(O_{2}\) and \(O_{3}\) (Case 3)

Fig. 12
figure 12

The original and optimized values of the shaking force components, the shaking moment and the driving torque (Case 3)

Based on the optimal values of design variables given in Table 1, Figs. 4, 5, 6, 7, 8, 9, 10, 11 and 12 are obtained.

Observing Table 1, it can be noticed that several optimized values of design variables \(\left( {L_1 , L_2 , L_3 , m_2 , J_{C_3 } , d_3 } \right) \) coincide with the lower or upper bounds of these variables. For this reason, the search space has been expanded, i.e., the boundaries of these design variables are expanded in order to test the sensitivity of the proposed algorithm.

The optimized values of design variables along with the expanded boundaries of these design variables are shown in Table 2. It should be noted that the expansion of the search space was done only for Case 3 in order to test the applied algorithm in terms of the speed of convergence and the sensitivity of the boundaries.

Table 2 Original and optimized parameters of the four-bar mechanism for expanded search space

The italics values in Table 2 indicate the boundaries for the initial values of design variables with expanded range. As it can be seen from Table 2 by expanding the search space, i.e., by setting wider limits, the optimized values of design variables do not coincide with the lower or upper bounds of these variables.

The diagrams of convergence in this paper are given in Figs. 1314 and 15, only for Case 3. The diagrams of convergence in Figs. 13a, 14a and 15a correspond to the situation where the search space is within the boundaries of Table 1, while the diagrams of convergence in Figs. 13b, 14b and 15b correspond to the case where the search space is expanded (the boundaries of the design variables taken from Table 2). The other diagrams of convergence are not shown in order not to exceed the usual size of the paper.

Fig. 13
figure 13

Diagram of convergence in Case 3 for \(F_{\mathrm{sh}x}\)

Fig. 14
figure 14

Diagram of convergence in Case 3 for \(F_{\mathrm{sh}y}\)

Fig. 15
figure 15

Diagram of convergence in case 3 for \(M_{\mathrm{sh}}\)

It can be seen from the previous figures that the expansion of the search space does not significantly affect the speed of convergence. In gradient-based methods, by narrowing the search space, or by setting the initial values of the design variables in such a way to make them close to optimal, the speed of convergence is rapidly increasing. However, it should be noted that in H-CS-FA applied in this paper, the expansion of the search space does not significantly affect the speed of convergence. On the contrary, for one of the objective function \((M_{\mathrm{sh}} )\) the speed of convergence is better in the case of expanded boundaries (Fig. 15).

The percentage decreases of the values of joint reactions, the driving torque, the shaking force, and the shaking moment for all three considered cases are presented in Table 3. Note that two variants have been considered for Case 3: the search space with the boundaries from Table 1 and the expanded search space with the bounds from Table 2. By expanding the boundaries of design variables for Case 3, the percentage decrease in values of objective functions \((F_{\mathrm{sh}x},\,F_{\mathrm{sh}y}\hbox { and }M_{\mathrm{sh}})\) remains almost at the same level.

Table 3 The decreasing ratios for the cases considered

Note that the italics values presented in Table 3 represent the results obtained by individual application of the FA and CS algorithms, which are better in comparison with the corresponding results obtained by applying the H-CS-FA algorithm. Finally, by analyzing the data in Table 3, it can be concluded that for all three considered cases (Case 1, Case 2, and Case 3), the application of H-CS-FA results in the reduction of all optimization values. Also, for Case 1 and Case 2, in comparison with FA and CS, the H-CS-FA algorithm provides, for most optimization values, a higher degree of reduction in values of these quantities. In Case 2, in comparison with CS and FA, the use of the H-CS-FA algorithm results in a considerable reduction of all optimization values. From the aspect of minimization of reaction forces in the inner joints (joints 2 and 3) for the considered type of planar mechanism, it is best, for practical calculations, to use the objective function (49) composed of the particular functions defined in Case 2

5 Conclusions

This paper considers the problem of minimization of joint reactions, shaking forces, shaking moment and driving torque in a four-bar mechanism. Firstly, the joint reactions are determined by using a new method based on the use of absolute angles of rotation of the links. The problem of minimization of joint reactions is solved by using multi-objective optimization. Unlike the conventional approaches to multi-objective optimization which imply the use of weighting factors or the Pareto front, this paper presents a new algorithm created by means of hybridization of two biologically inspired algorithms in order to accomplish simultaneous minimization of several objective functions. Three cases in which eight, nine and three objective functions are simultaneouly minimized by optimization of the distribution of mass of each link of the mechanism are considered. The new biologically inspired algorithm, named Hybrid Cuckoo Search and Firefly Algorithm (H-CS-FA), is applied for the purpose of minimization of joint reaction forces, shaking force, shaking moment and driving torque. The results obtained show considerable reduction of values of these dynamic quantities in comparison with the original (non-optimized) ones. By analyzing the results shown in Table 3, it can be noticed that the greatest reduction in the value of the shaking force along the x and y axes, the shaking moment as well as the driving torque is in Case 3. Hence, in Case 3, when \(F_{\mathrm{sh}x}\), \(F_{\mathrm{sh}y}\) and \(M_{\mathrm{sh}}\) are chosen for objective functions, the results show that their percentage decrease is also the highest. By expanding the search space, this result does not change significantly. In other words, by expanding the boundaries of design variables in Case 3, a percentage reduction in values \(F_{\mathrm{sh}x}\)\(F_{\mathrm{sh}y}\) and \(M_{\mathrm{sh}} \) remains at the same level. In Case 1, where joint reactions at all joints are selected as objective functions in the optimization process, it can be noticed that there is the greatest reduction in the values of joint reactions in the stationary support \(O_{1}\). In Case 2, where all joint reactions and the driving torque are optimized, it is noticed that the highest percentage decrease in joint reactions is in the joints \(O_{2}, O_{3}\) and \(O_{4}\). The imposed conclusion is that an adequate selection of objective functions can influence the degree of reduction in the corresponding dynamic quantities. Also, the results obtained show that the use of the proposed H-CS-FA in the process of multi-objective optimization results in obtaining considerably reduced values of the optimized quantities, which proves its efficiency. Also, by comparing the results obtained using the hybrid algorithm (H-CS-FA) and the results obtained by applying the basic algorithms (CS and FA), the efficiency of the proposed optimization procedure and justification of the application of the proposed algorithm have been proved. While solving the problem of dynamic balancing of the four-bar mechanism in this paper, the joint reactions at all four joints are taken into account, which is not the case in the previous approaches in the literature which have considered only reaction forces at the ground joints, \(O_{1}\) and \(O_{4}\). Further research of the authors of this paper will be directed toward the extension of the proposed hybrid algorithm to other types of planar mechanisms.