Keywords

1 Introduction

The evolutionary algorithms are a stochastic search and optimization algorithms inspired from the Darwinian theory of evolution. This kind of computing started in the middle of twentieth century by means of the influence of several works [1, 2]. In the last decades this field have motivated many researchers and scientists who had contributed to its amazing progress. The evolutionary algorithms can be subdivided into four subfields: evolution strategies [3], evolutionary programming [4], genetic programming [5] and genetic algorithms [6]. As genetic algorithms imitate the process of natural selection of the survival of the fittest, they use a population of individuals that generates offspring by means of crossover and mutation operators. In each generation the algorithm selects the fittest individuals to survive for the next generation. Several variants have been developed and proposed in the literature [79]. The basic differences between them is in their representation of chromosomes, their crossover operators, their mutation operators and their selection strategy. In evolutionary algorithms, we are principally interested by the intensification and the diversification of the search process [10]. The crossover operator allows the transfer of genetic information between individuals, hence it helps for the intensification of the search. The mutation adds new information into genotypes and helps the algorithm to explore different regions of search space and to avoid local optimums. The mutations diversify the search process and are indispensable to guaranty the convergence of the algorithm [11]. On 1989, the British biologist Richard Dawkins reformulates the theory of evolution in terms of genes rather than individuals [12]. We call his theory: the selfish gene theory. Dawkins suggests that evolution of spaces is based on genes. The body that have the biological spaces is created by genes to assure their duplication (their own survival).

En 1998 Corno et al. developed a new genetic algorithm based on the theory of Richard Dawkins. The algorithm is called the Selfish Gene Algorithm (SGA) [13]. This algorithm is focalized on genes and uses a pool of genes called the virtual population rather than a population of individuals. As this algorithm is central for our study we give a formal precise definition. Its pseudo code is shown in Fig. 1.

Fig. 1
figure 1

The pseudo code of SGA [13]

In SGA, the alleles compete for loci. It has each one a probability of selection that measures the chances that has an allele to be selected to form one of the individuals used in the tournament selection. The algorithm uses tournament selection to compare two individuals between them. The alleles of the winner of the tournament are rewarded by incrementing their selection probabilities. And the alleles of the failed individual are penalized by decreasing their selection probabilities. If one of the individual selected is fitter than the best ever found, it replaces it.

In this paper we propose a novel selfish gene algorithm called the Replaces and Never Penalizes Selfish Gene Algorithm (RNP-SGA). This algorithm does not penalize the alleles. The idea behind this variant is to replace the alleles of the fit less individual by the alleles of the fittest (the winner of the tournament). The rest of this paper is organized as fallow. In the next section we introduce the proposed algorithm. In section three we analyze and compare the RNP-SGA and the SGA in terms of quality of convergence, accuracy, stability and the time consumption. The fourth section is devoted to studying, modeling and controlling of a gymnastic humanoid robot on the bar. We use the proposed algorithm to optimize an LQR controller designed to assure the movement of swing-up on the bar. Section five conclude this paper.

2 The Replaces and Never Penalize Selfish Gene Algorithm

In this section we introduce the algorithm called the Replace and Never Penalize Selfish Gene Algorithm (RNP-SGA). This algorithm is a variant of selfish gene algorithm. The RNPSGA uses also the tournament selection but it does not penalize alleles. It rewards the alleles of the winner of the tournament and replaces the alleles of the failed individual by the alleles of the winner. This action of replacing allows a duplication of the genes of the winner in the virtual population. Hence, the intensification of the search process is increased. Actually, the proposed algorithm by rewarding the “good” alleles through increasing their selection probabilities will automatically penalize the “bad” ones; their selection probabilities will be relatively less significant. To assure a good exploration of the search space we increment the mutation probability. The mutation in RNP-SGA occurs randomly and can affect any gene in the virtual population. The pseudo code of the proposed algorithm is shown in Fig. 2.

Fig. 2
figure 2

The pseudo code of the proposed RNP-SGA

The proposed algorithm uses a virtual population of genes. Each of them has a probability of selection that measures the chances of the given allele to be selected into the chromosomes of the individuals selected to compete in the tournament. The alleles of the winner (the fitter) are duplicated in the virtual population by overwriting (replacing) those of the failed. This action of overwriting ameliorates the intensification of the search. To avoid duplication of the same genes in the entire virtual population long before finding the optimal solution we increment the probability of mutation.

Generally, in evolutionary computing we are aimed to give a dynamic change to the parameters governing the algorithms [11]. So we propose the decreasing of the probability and step size of mutations to assure good accuracy and quality of convergence. Now we propose benchmarking of the proposed algorithm. The results of the simulation tests are shown in next section.

3 Benchmarking of the RNPSGA

3.1 Mathematical Functions

We propose in this section the benchmarking of the proposed algorithm under some famous benchmark functions. We choose from literature [8, 9] a set of seven functions. The Table 1 gives the mathematical form of the used benchmark functions. The value of the optimal of all those functions is zero and its position is on the origin of the D dimensions space.

Table 1 Mathematical form of the test functions

3.2 Simulation Settings

In order to compare the SGA and the proposed algorithm we give the parameters used in our experiments:

  • The maximum number of iteration N = 40000

  • Dimension: three case D = 10, D = 30 and D = 50

  • Dimension of VP is set to 50 × D (VP is a matrix)

  • Normal distribution mutation: \( x = x + \sigma \,N(0,\,1) \)

  • Probability of mutation μ = 0.01 for SGA and μ = 0.1 for RNPSGA

  • \( segma = 0.5(Max - Min) \)

  • \( segma\_dump\_initial = 1; \)

  • \( segma\_dump\_final = 0.992; \)

  • \( \begin{aligned} segma_{dump} = \left( {\frac{N - K}{N - 1}} \right)^{2} \times (segma\_dump\_initial \hfill \\ \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, - segma\_dump\_final) + segma\_dump\_final; \hfill \\ \end{aligned} \)

  • Dynamic of the standard deviation: \( segma = segma \times segma\_dump \)

  • Rewording of genes: additive function +0.01

  • Penalizing of the genes: subtractive function −0.01

The algorithms are implemented in Matlab 2014a code source. The computer used for our simulations is Intel® Core™ i5-2350M CPU 2.30 GHz and 8 GB of RAM. The results and the discussion are on the next subsection.

3.3 Results and Discussion

We experiment the two described algorithms with the functions listed above. The entire mathematical benchmarks are tested with dimensions 10, 30 and 50. Each function had been tested for 50 independent runs for the different dimensions shown above.

  1. 1.

    Convergence study: the algorithms used for comparison are stochastic. This means that their results differ from one run to another. Hence we need to repeat the same experiment for several times and then we compare the averaged values found. The detailed results are shown in Table 2. The results given in bold style mean that the corresponding algorithm has found a better solution, the averaged value of 50 independent runs, compared to the other. The table give the averaged optimal values found, the standard deviation and the processing time. It indicates also how many times the algorithm is executed for each instance (N). The results given in bold style mean that the corresponding algorithm performs the problem more than the other. We conclude from Table 2 that RNPSGA is batter that SGA. It gives 90.4762 % of good results. The proposed algorithm can be compared to more recent and efficient algorithms to measure objectively its quality (see the results shown in [1517]).

    Table 2 Average, standard deviation, number of success for each instance (N) and time processing of the best fitness values found by RNP-SGA and SGA
  2. 2.

    Algorithms’ stability: the standard deviation is the most used indicator of stability. It measures the distribution of the results found around the averaged value of 50 independent runs. We conclude through this measure the accuracy of the proposed algorithm.

  3. 3.

    Computational time: the time that makes an evolutionary algorithm to generate the solution is an important factor. In real word applications we search for fast algorithms. The evolutionary algorithms are not recommended for online problems in many applications. Add to this that real applications need high time for an algorithm to generate their solutions. If we compare the time processing of the proposed algorithm and the SGA, we can conclude that there are no difference between them. As SGA had been used in real-world applications, the RNP-SGA can be also used.

4 Realisation of Gymnastic Movement on the Bar by Humanoid Robot

In this section we propose the utilization of the RNPSGA to realize the swing-up movement on the bar by a humanoid robot. Firstly we need the dynamic model of the humanoid robot on the bar. Secondly, we derivate the linear model around the swing-up position. Then the RNPSGA can be applied to compute the matrix Q and R for the designing of the optimal LQR controller.

4.1 Virtual Model

We present here the virtual model designed using Solidworks 2014. The complete model of the humanoid robot hanging on a high bar is represented in Fig. 3. To control the humanoid robot, we combine between Solidwork and Simscape/Matlab. The model of the designed robot on Simmechanics/Matlab is shown in Fig. 4. Therefore, the exact mechanical properties of the humanoid are copied directly from Solidworks. The details are shown in Table 3.

Fig. 3
figure 3

Virtual model of the humanoid designed with Solidworks

Fig. 4
figure 4

The humanoid as a three link underactuated pendulum

Table 3 Parameters of the humanoid robot

4.2 The Nonlinear Dynamic Model of the Gymnastic Humanoid Robot

The Gymnastic humanoid robot can be seen as being compound of three main links [15, 18]. The first link represents the arms, the second represents the torso and a third represents the legs. The joints of the robot are therefore the hands, the shoulders and the hips. Both shoulders and hips are actuated by two servos in each side. The hands are not actuated indeed, and therefore the system can be approximated by a three link underactuated pendulum. The dynamic behavior of this multi-body robotic system can be derived from the classical Euler-Lagrange equations. The model is represented in Fig. 4.

We precise here the used notations:

  • \( \theta_{i} \) is the angle of joint i in respect to the previous link.

  • \( m_{i} \) is the mass of link i.

  • \( I_{i} \) is the inertia of link i.

  • \( \tau_{i} \) is the torque actuated on the active joint i.

  • \( L_{i} \) is the length between joint i and joint i + 1.

  • \( Lc_{i} \) is the length between joint i and the center of gravity of the mass i.

The direct cinematic model of the center of mass of each link is:

$$ x_{1} = Lc_{1}\,cos (\theta_{1}) $$
(1)
$$ y_{1} = Lc_{1}\sin \left( {{\theta}_{1}} \right) $$
(2)
$$ x_{2} = L_{1}\,cos (\theta_{1}) + lc_{2}\,cos(\theta_{1} + \theta_{2}) $$
(3)
$$ y_{2} = L_{1}\,sin\left( {\theta_{1}} \right) + Lc_{2}\,sin\left( {\theta_{1} + \theta_{2}} \right) $$
(4)
$$ x_{3} = L_{1}\cos \left( {\theta_{1}} \right) + L_{2}\cos \left( {\theta_{1} + \theta_{2}} \right) + Lc_{3}\cos \left( {\theta_{1} + \theta_{2} + \theta_{3}} \right) $$
(5)
$$ y_{3} = L_{1}\sin \left( {\theta_{1}} \right) + {\text{L}}_{2}\sin \left( {\theta_{1} + \theta_{2}} \right) + Lc_{3}\sin \left( {\theta_{1} + \theta_{2} + \theta_{3}} \right) $$
(6)

The Lagrangian of the system is given by:

$$ L = \mathop \sum \limits_{i = 1}^{3} (T_{i} - U_{i} ) $$
(7)

where the kinetic energy T and the potential energy U of links are given by:

$$ T_{1} = \frac{1}{2}\left[ {m_{1} \left( {\dot{x}_{1}^{\,\,\,2} + \dot{y}_{1}^{\,\,\,2} } \right) + I_{1} \dot{\theta }_{1}^{\,\,\,2} } \right] $$
(8)
$$ T_{2} = \frac{1}{2}\left[ {m_{2} \left( {\dot{x}_{2}^{\,\,\,2} + \dot{y}_{2}^{\,\,\,2} } \right) + I_{1} \left( {\dot{\theta }_{1} + \dot{\theta }_{2} } \right)^{2} } \right] $$
(9)
$$ T_{3} = \frac{1}{2}\left[ {m_{2} \left( {\dot{x}_{3}^{\,\,\,2} + \dot{y}_{3}^{\,\,\,2} } \right) + I_{1} \left( {\dot{\theta }_{1} + \dot{\theta }_{2} + \dot{\theta }_{3} } \right)^{2} } \right] $$
(10)
$$ U_{1} = m_{1} gy_{1} $$
(11)
$$ U_{2} = m_{2} gy_{2} $$
(12)
$$ U_{3} = m_{3} gy_{3} $$
(13)

The nonlinear model is then derived from Euler-Lagrange equations. We found the model given by Eq. 14

$$ \left[ {\begin{array}{*{20}c} {d_{11} } & {d_{12} } & {d_{13} } \\ {d_{21} } & {d_{22} } & {d_{23} } \\ {d_{31} } & {d_{32} } & {d_{33} } \\ \end{array} } \right]\left[ {\begin{array}{*{20}c} {\ddot{\theta }_{1} } \\ {\ddot{\theta }_{2} } \\ {\ddot{\theta }_{3} } \\ \end{array} } \right] + \left[ {\begin{array}{*{20}c} {{\text{G}}_{1} } \\ {{\text{G}}_{2} } \\ {{\text{G}}_{3} } \\ \end{array} } \right] + \left[ {\begin{array}{*{20}c} {C_{1} } \\ {C_{2} } \\ {C_{3} } \\ \end{array} } \right] = \left[ {\begin{array}{*{20}c} 0 \\ {\tau_{1} } \\ {\tau_{2} } \\ \end{array} } \right] $$
(14)

where the inertial terms are:

$$ \begin{aligned} d_{11} = {\text{A}}1 + & 2m_{2} L_{1} Lc_{2} \,cos\left( {\theta_{2} } \right) + 2m_{3} L_{1} L_{2} \cos \left( {\theta_{2} } \right) + 2m_{3} L_{2} Lc_{3} \cos \left( {\theta_{3} } \right) \\ & + m_{3} L_{1} Lc_{3} \,cos(\theta_{2} + \theta_{3} ) \\ \end{aligned} $$
$$ \begin{aligned} d_{12} = {\text{A}}2 + & m_{2} L_{1} Lc_{2} \,cos(\theta_{2} ) + m_{3} L_{1} L_{2} \,cos(\theta_{2} ) + 2m_{3} L_{2} Lc_{3} \,cos(\theta_{3} ) \\ & + m_{3} L_{1} Lc_{3} cos(\theta_{2} + \theta_{3} ) \\ \end{aligned} $$
$$ d_{13} \, = \,A_{3} + m_{3} L_{2} Lc_{3} \,cos(\theta_{3} ) + m_{3} L_{1} Lc_{3} \,cos(\theta_{2} + \theta_{3} ) $$
$$ d_{21} \, = \,d_{12} $$
$$ d_{22} \, = \,A_{2} + 2m_{3} L_{2} Lc_{3} \,cos(\theta_{3} ) $$
$$ d_{23} \, = \,A_{3} + m_{3} L_{2} Lc_{3} \,cos(\theta_{3} ) $$
$$ d_{31} = d_{13} $$
$$ d_{32} = d_{23} $$
$$ d_{33} \, = \,A_{3} \, + \,m_{3} L_{2} Lc_{3} \cos \left( {\theta_{3} } \right) $$
$$ A_{1} = m_{1} Lc_{1}^{2} \, + \,m_{2} L_{1}^{2} + m_{2} Lc_{2}^{2} + m_{3} L_{1}^{2} + m_{3} L_{2}^{2} + m_{3} Lc_{3}^{2} + I_{1} + I_{2} + I_{3} $$
$$ A_{2} = m_{2} Lc_{2}^{2} + m_{3} L_{2}^{2} + m_{3} Lc_{3}^{2} + I_{2} + I_{3} $$
$$ A_{3} = m_{3} Lc_{3}^{2} + I_{3} $$

The gravitational terms are:

$$ G_{1} \, = \,{\text{B}}_{1} cos(\theta_{1} ) + {\text{B}}_{2} cos(\theta_{1} + \theta_{2} ) + {\text{B}}_{4} \,cos(\theta_{1} + \theta_{2} + \theta_{3} ) $$
$$ G_{2} = {\text{B}}_{3} cos(\theta_{1} + \theta_{2} ) + B_{4} \,cos(\theta_{1} + \theta_{2} + \theta_{3} ) $$
$$ G_{3} = B_{4} \,cos(\theta_{1} + \theta_{2} + \theta_{3} ) $$
$$ {\text{B}}_{1} \, = \,(m_{1} lc_{1} + m_{2} l_{1} + m_{3} l_{1} )g $$
$$ {\text{B}}_{2} = (m_{2} lc_{2} + m_{3} l_{2} )g $$
$$ {\text{B}}_{3} = (m_{2} lc_{2} + m_{3} l_{2} )g $$
$$ B_{4} = m_{3} lc_{3} g $$

And the Corriolis:

$$ \begin{aligned} C_{1} = & {\text{F}}_{4} \left( {\dot{\theta }_{2} + \dot{\theta }_{3} } \right)\left( {2\dot{\theta }_{1} + \dot{\theta }_{2} + \dot{\theta }_{3} } \right)sin\left( {\theta_{2} + \theta_{3} } \right) \\ \quad \quad \quad & + {\text{F}}_{1} \dot{\theta }_{2} \left( {2\dot{\theta }_{1} + \dot{\theta }_{2} } \right)sin\left( {\theta_{2} } \right) + {\text{F}}_{2} \dot{q}_{2} \left( {2\dot{\theta }_{1} + \dot{\theta }_{2} } \right)sin\left( {\theta_{2} } \right) \\ \quad \quad \quad & + {\text{F}}_{3} \dot{\theta }_{3} \left( {2\dot{\theta }_{1} + 2\dot{\theta }_{2} + \dot{\theta }_{3} } \right)sin\left( {\theta_{3} } \right) \\ \end{aligned} $$
$$ \begin{aligned} C_{2} = & - F_{1} \dot{\theta }_{1}^{2} \,sin\left( {\theta_{2} } \right) - {\text{F}}_{2} \dot{\theta }_{1}^{2} \,sin\left( {q2} \right) + {\text{F}}_{3} \dot{\theta }_{3} (2\dot{\theta }_{1} + 2\dot{\theta }_{2} + \dot{\theta }_{3} )\,sin(\theta_{3} ) \\ \quad \quad \quad & - {\text{F}}_{4} \dot{q}_{1}^{4} \,sin\left( {\theta_{2} + \theta_{3} } \right) \\ \end{aligned} $$
$$ C_{3} = - \,{\text{F}}_{3} \left( {\dot{\theta }_{1} + \dot{\theta }_{2} } \right)^{2} sin(\theta_{3} ) - {\text{F}}_{4} \dot{\theta }_{1}^{2} \,sin\left( {\theta_{2} + \theta_{3} } \right) $$
$$ F_{1} = - m_{2} L_{1} Lc_{2} ,\,{\text{F}}_{2} = - \,m_{3} L_{1} L_{2} ,\,F_{3} = - \,m_{3} L_{2} Lc_{3} ,\,{\text{F}}_{4} = - \, m_{3} L_{1} Lc_{3} , $$

4.3 Linearization of the Model

We are interested by the realization of the gymnastic movement. In the literature we talk about the swing-up control problem [14]. The objective is to realize and to stabilize the humanoid at the vertical unstable equilibrium position. As the model derived from Euler-Lagrange equations is highly nonlinear, we derive here the linearized model around the vertical position.

$$ \theta = \left[ {\begin{array}{*{20}c} {\frac{\pi }{2}} & 0 & 0 \\ \end{array} } \right]^{T} \,{\text{and}}\,\,\dot{\theta } = \left[ {\begin{array}{*{20}c} 0 & 0 & 0 \\ \end{array} } \right]^{T} $$

The linearized model of the humanoid for the vertical unstable equilibrium is given by the fooling equations:

$$ D\mathop q\limits^{..} + Gq = T\tau $$
(15)
$$ \left[ {\begin{array}{*{20}c} {d_{11} } & {d_{12} } & {d_{13} } \\ {d_{21} } & {d_{22} } & {d_{23} } \\ { d_{31} } & {d_{32} } & {d_{33} } \\ \end{array} } \right]\left[ {\begin{array}{*{20}c} {\ddot{\theta }1} \\ {\ddot{\theta }2} \\ {\ddot{\theta }3} \\ \end{array} } \right] + \left[ {\begin{array}{*{20}c} {g_{11} } & {{\text{g}}_{12} } & {{\text{g}}_{13} } \\ {{\text{g}}_{21} } & {d_{22} } & {{\text{g}}_{23} } \\ {{\text{g}}_{31} } & {{\text{g}}_{32} } & {{\text{g}}_{33} } \\ \end{array} } \right]\left[ {\begin{array}{*{20}c} {\theta_{1} - \frac{\uppi}{2}} \\ {\theta_{2} } \\ {\theta_{3} } \\ \end{array} } \right] = \left[ {\begin{array}{*{20}c} 0 & 0 \\ 1 & 0 \\ 0 & 1 \\ \end{array} } \right]\left[ {\begin{array}{*{20}c} {\tau_{1} } \\ {\tau_{2} } \\ \end{array} } \right] $$
(16)

where:

$$ d_{11} = {\text{A}}_{1} + 2m_{2} L_{1} Lc_{2} + 2m_{3} L_{1} L_{2} + 2m_{3} L_{2} Lc_{3} + 2m_{3} L_{1} Lc_{3} $$
$$ d_{12} = {\text{A}}_{2} + m_{2} L_{1} Lc_{2} + m_{3} L_{1} L_{2} + 2m_{3} L_{2} Lc_{3} + m_{3} L_{1} Lc_{3} $$
$$ d_{13} = A_{3} + m_{3} L_{2} Lc_{3} + m_{3} L_{1} Lc_{3} $$
$$ d_{21} = d_{12} $$
$$ d_{22} = A_{2} + 2m_{3} L_{2} Lc_{3} $$
$$ d_{23} = A_{3} + m_{3} L_{2} Lc_{3} $$
$$ d_{31} = d_{13} $$
$$ d_{32} = d_{23} $$
$$ d_{33} = A_{3} + m_{3} L_{2} Lc_{3} $$
$$ g_{11} = B_{1} + B_{2} + B_{4} $$
$$ g_{12} = B_{3} + B_{4} $$
$$ g_{12} = {\text{B}}_{4} $$
$$ g_{22} = g_{21} = g_{12} $$
$$ g_{33} = g_{31} = g_{32} = g_{23} = g_{13} $$

4.4 The State Space Model of the Humanoid

The state vector is constituted by the position vector \( \varvec{q } \) and \( \dot{\varvec{q}} \), hence we have:

$$ X = [\begin{array}{*{20}l} {q_{1} - \frac{\uppi}{2}} \hfill & {q_{2} } \hfill & {q_{3} } \hfill & {\dot{q}_{1} } \hfill & {\dot{q}_{2} } \hfill & {\dot{q}_{3} } \hfill \\ \end{array} ] ^{T} $$
(17)

The state space model is given by:

$$ \dot{x}\left( t \right) = Ax\left( t \right) + Bu\left( t \right) $$
(18)
$$ y\left( t \right) = Cx\left( t \right) + Du\left( t \right) $$
(19)

The matrix A, B, C and D are given by:

$$ A = \left[ {\begin{array}{*{20}c} {0_{n \times n} } & {I_{n \times n} } \\ {D^{ - 1} G} & {0_{n \times n} } \\ \end{array} } \right],B = \left[ {\begin{array}{*{20}c} {0_{n \times m} } \\ {D^{ - 1} T} \\ \end{array} } \right],C = I_{n \times n} \,{\text{and}}\,D = 0 $$

The numerical values of the state space matrix A and B are:

$$ A = \left[ {\begin{array}{*{20}c} 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ { 18.8797} & { - 21.4186} & { - 5.1879} & 0 & 0 & 0 \\ { - 18.3221 } & {46.7787} & { 8.3809 } & 0 & 0 & 0 \\ { - 0.2202} & { - 10.0165} & { 6.1066 } & 0 & 0 & 0 \\ \end{array} } \right]B = \left[ {\begin{array}{*{20}c} 0 & 0 \\ 0 & 0 \\ 0 & 0 \\ { - 0.2169} & {0.0326} \\ {0.4124} & { - 0.1147} \\ {0.1147 } & { - 0.1410} \\ \end{array} } \right] $$

4.5 Realization of the Gymnastic Movement by the Humanoid Robot

We propose in this subsection the designing of an intelligent optimal controller to stabilize the humanoid robot on the vertical unstable position (swing-up control). Therefore, we design firstly the LQR controller and then we optimize its parameters (the Q and R) by the RNP-SGA algorithm proposed in this paper and we compare the results given by RNPSGA and the results found by SGA. The optimization criterion is derived from the error between the trajectory of the variables \( \varvec{X} \) and the position of the swing up movement. The mathematical formula of this criterion is:

$$ J = \sqrt {\int_{{t_{0} }}^{{t_{f} }} {\left( {X\left( t \right) - \hat{X}} \right)^{2} } } $$
(20)

where \( X\left( t \right) \) is the trajectory of the state is space and \( \hat{X} \) is the desired position. We note that \( \widehat{X} = \left[ {\begin{array}{*{20}l} {\frac{\pi }{2}} \hfill & 0 \hfill & 0 \hfill & 0 \hfill & 0 \hfill & 0 \hfill \\ \end{array} } \right]^{T} \). The matrix Q and R are assumed diagonal. We propose here to compute them using the SGA and the proposed RNPSGA. The Simscape model is shown in Fig. 5. The result are shown in the next subsection.

Fig. 5
figure 5

Simscape model of the gymnastic humanoid robot

4.6 Results and Discussion

We present here the results given by the SGA and the RNPSGA. The algorithms search for the diagonal elements of the matrix Q and R that minimize the criterion \( J \). Once Q and R are known, we calculate the feedback \( K \) that stabilizes the robot on the vertical position. In LQR control, we search for K that minimizes the cost function given by:

$$ C = \mathop \smallint \nolimits \left\{ {x^{{\prime }} Qx + u^{{\prime }} Ru + 2 *x^{{\prime }} Nu} \right\}\,dt $$
(21)

The feedback \( K \) is calculated using the algebraic Riccati equation. The low for the LQR controller is known to be: \( u\left( t \right) = - k\left( t \right)x \)

The results found by SGA and RNP-SGA are summarized in Table 4. The results found by RNPSGA are better than those found by SGA. The Fig. 6 gives the allure of the obtained gymnastic movement in virtual 3D space. The allures of the evolution of optimization process is shown in Fig. 7.

Table 4 The results found by SGA and RNP-SGA
Fig. 6
figure 6

The swing-up movement obtained

Fig. 7
figure 7

Optimization process

5 Conclusion

This paper purposes a new variant of selfish gene algorithm called the Replaces and Never Penalizes Selfish Gene Algorithm (RNP-SGA). The algorithm uses tournament selection and overwrites the genes of failed individual by the alleles of the winner of the tournament. As the algorithm duplicates the genes of the winners of the tournament in the virtual population, then it allows more intensification. The proposed algorithm is tested firstly for unconstrained optimization problem using unimodal and multimodal benchmark functions. A statistical study shows its high performance compared to standard SGA in terms of quality of convergence, accuracy, stability and processing time. Secondly we test the algorithm on a humanoid robot. The objective is to stabilize the movement of the swing-up control. The model of the humanoid robot is designed using Solidwork specifically to do the movements of the gymnastic on horizontal bar. The results given by RNP-SGA are compared to those found by SGA.