Improved genetic algorithm for parameters identification of cart-double pendulum
Yuanhong Dan1 , Peng Xu2 , Wei Zhang3 , Zhi Tan4
1, 2, 3, 4Chongqing University of Technology, Chongqing, China
Journal of Vibroengineering, Vol. 21, Issue 6, 2019, p. 1587-1599.
Received 17 March 2019; received in revised form 2 June 2019; accepted 10 June 2019; published 30 September 2019
Cart-double pendulum is a typical nonlinear under-actuated mechanical device, and highly sensitive to modeling error and external disturbance. Motion control of double pendulum is a very complex and difficult task, especially when it turns to real-time situation because a minor difference between kinetic model and actual device could lead to the necessity of significant adjustments according to control laws comparing to the usage of simulation controller. The use of accurate kinetic model is the key factor for fast transition from simulation to real-time operation. An improved genetic algorithm (IGA), which includes orthogonal experiment design, feedback mutation, pairing operation based on Hamming distance, and variable precision crossover operation, is introduced to identify the physical parameters of a double pendulum. The improved genetic algorithm (IGA) can overcome the shortcomings of the traditional genetic algorithm (TGA), for instance, premature convergence, and get results closer to the global optimal solution. The results of experiments demonstrate the effectiveness of the proposed method.
Keywords: cart-double pendulum, improved genetic algorithm, feedback mutation, variable precision crossover.
Multi-inverted pendulum is a typically nonlinear, multi-variable, strongly coupled, under-actuated mechanical system, which has been recognized as a classical platform for validating a new control method and control algorithm. Because of the properties of simple structure, low cost, and high control difficulty, multi-inverted pendulum related research has always been one of the hotspots in the control field. The researches of multi-inverted pendulum can be classified into 3 categories: (a) balance control in the neighborhood of inverted equilibrium point; (b) swing-up control from downward equilibrium to inverted equilibrium; (c) arbitrary transfer control from one equilibrium state to another. Balance control has been achieved from single pendulum to four-inverted pendulum [1-3], however, most researches on swing-up control and arbitrary transfer control still focus on the simulation [4-7], and few real-time researches are reported [8-10]. One obstacle is under-actuation characteristic, because rods can be controlled only indirectly through the movement of cart, that makes inverted pendulum be very sensitive to disturbance, and the controllability is very low. Another challenge is that a simulation result cannot be directly applied to the real-time control, because the mathematic model is not equivalent to the device. Owing to the sensibility and low-controllability of rods, a minor difference of controlled object between simulation and real-time control can lead to the necessity to make major adjustments of control parameters, even to redesign the controller configuration.
So, the accurate kinetic model is the key to speed up the process of transition from simulation control to real-time control. Traditional method to build up a kinetic model is to set up the model structure by applying a physics law (such as energy conservation law and momentum conservation law), and then get the values of physical parameters by direct measurement. It is difficult to obtain an accurate model with the help of the traditional method, because of the following reasons:
(1) Some idealized assumptions lead to a structural model error. Such as, all components of mechanical system are treated as a homogeneous rigid body, small volume parts are simplified as particles. There also could be unmodeled dynamics, as the manufacturing, assembling, and operating environments of a mechanical system always include unknown factors.
(2) Some physical parameters (such as mess, length, etc.) can be measured directly, while some parameters (such as moment of inertia, centroid position, friction coefficient, etc.) are difficult to be measured directly. Because of unmodeled dynamics, even for the parameters that can be measured directly, the appropriate adjustments shall be made to narrow down the difference caused by the unmodeled dynamics.
It is impractical to try to figure out all the unmodeled dynamics and to find out the real values of each parameter manually. This paper introduced a more effective and realistic modeling method which combined the idea of quasi-equivalent modeling  with the improved genetic algorithm. The main ideas of the proposed method include:
(1) If a mathematic model can reflect the main characteristics of actual device, then we can say the simulation environment is equivalent to the real-time environment, which means the controller effective in simulation will be also effective in the real time.
(2) The main characteristics are always contained in typical response data, such as step response, zero input response, etc. The difference between two systems can be quantized by the typical response data of those two systems. The smaller the difference is, the closer those two systems approach to the appropriate result.
(3) The improved genetic algorithm is used to search equivalent physical parameters for a kinetic model. Fitness function is established with the idea the same as in (2), feedback mutation is used to enhance the diversity of population, so the orthogonal experiment is applied to increase the searching efficiency; the variable-precision crossover is introduced to improve the searching accuracy, and the hamming distance is introduced to avoid inbreeding.
Genetic algorithm (GA) is a heuristic scientific method based on the Darwin’s biological evolution theory , which has been widely applied to solve the high dimensional optimization problem for parameter optimization in engineering and science areas. However, because of the contradiction between the high dimension of the population and the limited settlement space, the traditional genetic algorithm has the problems of inbreeding and premature convergence, and easily falls into local optimal solution . The proposed improved genetic algorithm in (3) can greatly overcome these defects. The experimental results of manual trial, traditional genetic algorithm, and improved genetic algorithm are provided to validate the effectiveness of the proposed method.
The rest of this paper is organized as follows: Section 2 describes the structure and mathematic model of CDP; In Section 3, the methods are proposed for the improvement to traditional GA; Section 4 shows the experimental results and the discussion; Section 5 addresses the conclusions of the note.
2. Physical structure and mathematic model of cart double pendulum
A typical cart double pendulum device is shown in Fig. 1; its physical structure is shown in Fig. 2. The degree of freedom of Cart-Double Inverted Pendulum is 3 (cart, inner rod, and outer rod), while only one servo motor is applied to drive the cart move back and forth within a limited straight track. The joint between cart and inner rod, and the joint between inner rod and outer rod, are passive links which can only be under the influence of the coupling effect of the joints. The angles of joints are detected by encoders which are on each link.
The cart displacement is , the angle of inner rod is , the angle of outer rod is . The generalized variables are taken as , then . The kinetic model of cart double pendulum can be derived by dynamic analysis method as follows :
Fig. 1. Experimental facilities of cart double pendulum
Fig. 2. Physical structure of cart double pendulum
Physical meaning of each variable is shown in Table 1.
Among these physical parameters in Table 1, the length () and mass (, , ) can be easily measured directly; while the centroid position (, ) and moment of inertia (, ) are not so easy to be measured. If we take the rod as a homogeneous rigid body, the centroid position and moment of inertia can be calculated according to the mass and length of each rod. The rotational friction coefficients (, ) are very hard to be measured, and they can only be estimated according to experience or factory parameters of the bearing. The estimated values for physical parameters of cart double pendulum are shown in Table 2.
Table 1. Physical parameters of cart double pendulum
Mass of inner rod, outer rod, and encoder
Length of inner rod and outer rod
Moment of inertia of inner rod, and outer rod
Centroid position of inner rod, and outer rod
Rotational friction of cart-inner rod axis
Rotational friction of inner rod-outer rod axis
Table 2. Estimated values for physical parameters of cart double pendulum
It is required to confirm how much the estimated values in Table 2 can represent the actual device. Like the idea shown in Section 1, both simulation model and actual device in the same initial state (shown in Table 3) are made, and the zero input response data of simulation and real-time are recorded. The contrast cures are shown in Fig. 3 and Fig. 4.
Table 3. Initial state of cart double pendulum
Fig. 3 and Fig. 4 respectively show the contrast curves of inner rod and outer rod. As it can be seen from Fig. 3 and Fig. 4, the basic trend of zero input response between simulation and real time is the same, but also there are obvious differences in swing period and vibrating amplitude. This means the values in Table 2 have certain representativeness, but not the accuracy enough to equivalent to actual device. In order to make simulation environment equivalent to the real time environment, we need to find out more accurate parameters for kinetic model (Eq. (1)).
Fig. 3. Contrast of inner rod angle between real time and simulation
Fig. 4. Contrast of outer rod angle between real time and simulation
3. Improved genetic algorithm
As mentioned in Section 1, the genetic algorithm is introduced to search for the optimal physical parameter values, and some improvements are put forward to overcome the defects of the traditional genetic algorithm (such as inbreeding and premature convergence). Details are shown bellow.
3.1. Pairing operation based on Hamming distance
Hamming distance is introduced to calculate the difference between two individuals (chromosomes). Considering that two chromosomes are and , the hamming distance of and can be calculated as follows:
If , then and are forbidden to pairing and crossover to produce offspring, and chromosome is regenerated by the following method:
where and are respectively the lower limited value and upper limited value of the th gene (parameter), . The introduction of hamming distance can increase the diversity of population and avoid inbreeding.
3.2. Variable precision crossover
The traditional crossover operation only involves genetic exchange of parental chromosomes according to the crossover point; this is an obstacle for searching precision. Considering two chromosomes and , the offsprings of and are generated with variable precision crossover operation as follows:
where: , , is the index of crossover point, is a random number and . This method of dynamically expanding precision allows searching for a feasible solution from a low-precision solution space to a high-precision solution space, to further enhance chromosome diversity.
3.3. Orthogonal experiments in crossover operation
Orthogonal experiments are adopted to speed up the evolutionary process of genetic algorithm. Orthogonal experiment is a kind of efficient and economical experimental method which deals with multiple factors and multiple levels by means of orthogonal table. The best offspring of two ancestor chromosomes can be obtained through lesser experiments if the orthogonal experiment method is adopted .
Here, two-level orthogonal experiments are used. When the orthogonal table is selected, if the column number of orthogonal table is greater than the number of variable, then the spare columns are just abscised. Each factor has two levels (the number of value fetch choice), which respectively correspond to the two values of the corresponding gene in a chromosome. A new table with the same dimension of selected orthogonal table is filled with another value according to the value in the orthogonal table and the value range of relevant gene, and the number of experiments is equal to the row number of orthogonal table. The optimal combination of multiple variables can be obtained by means of experiment arrangement method of orthogonal table.
Two chromosomes are selected randomly to perform the orthogonal experiment after the crossover operation, so as to find out the optimal level (parameter value) for each factor, and the optimal chromosome can be formed with these optimal levels for each factor. Then, the best offspring of ancestor chromosomes is produced.
3.4. Feedback mutation
As the evolutionary process continues, more and more offsprings are generated by good individuals, and the individuals in population tend to be the same, so this leads to the lack of genetic diversity. Then the evolutionary process becomes very slow, even stops, especially at the later stage of evolution, population falls into premature convergence. By replacing highly similar individuals with randomly generated new individuals, the diversity of population will increase, but the evolutionary process will also become a random process and will have no possibility of convergence to global optimal solution.
Feedback mutation is performed according to the population fitness: if the population fitness is bigger than a given consistent , then feedback mutation is activated; otherwise feedback mutation is disabled. Population fitness is calculated as follows:
where, is the fitness of the best individual; is the size of population; is the fitness of the th chromosome in population.
The new individual is generated by the following method:
where, is the th gene of new generated individual; and are given consistent less than 1; is the th gene of the best individual in population; is a random number, and .
Feedback mutation is intended to overcome fundamentally the premature convergence of the population. In the later stage of population optimization, the replacement of the individuals that have been eliminated by mutation with new randomly generated individuals can greatly improve the population diversity while maintaining the stability of the population size.
3.5. Nonlinear transformation of fitness function
Fitness function is used to evaluate the quality of an individual in the genetic algorithm; the fitness value directly determines the reproductive opportunities of a certain individual. So, the fitness function is very important for the genetic algorithm and needs targeted design according to a specific question. Considering two situations, individuals with low fitness may be eliminated before they have a chance to perform the genetic operation; while the offspring generated by individuals with high fitness will fill up the whole population. This is bad for population diversity, and the fitness function shall be transformed to give a certain survival chance to a low fitness individual. The solution is to reduce the difference between the chromosomal fitness values by a logarithmic function. The nonlinear transformation of the fitness function is as follows:
where, is the new fitness function, is the original fitness function, and are consistent to make sure that is positive, and to regulate the possibility of poor chromosomes and better chromosomes being selected for the crossover or mutation operation.
3.6. Process of improved genetic algorithm
Step 1: randomly generate initial population according to the given solution space.
Step 2: calculate the fitness of each individual in population, then sort descending the population according to the fitness values.
Step 3: calculate the fitness of population. If , then activate feedback mutation, otherwise only the normal mutation operation is used.
Step 4: roulette selection operation.
Step 5: variable precision crossover.
Step 6: orthogonal experiments.
Step 7: repeat steps 5-7 until ×/2 individuals of the next generation are generated.
Step 8: combine the ancestor population and the offspring population, then sort descending the new population according to the fitness values.
Step 9: choose individuals to form a new population of next generation.
Step 10: finish if the terminal conditions are met, otherwise repeat steps 3-10.
Fig. 5 contains a flow chart of the improved genetic algorithm.
Fig. 5. Flow chart of improved genetic algorithm
4. Experimental results
In this section, the kinetic parameters identification of cart double pendulum will be performed with both the traditional genetic algorithm (TGA) and the improved genetic algorithm (IGA). For the comparative purpose, we use the same gene coding method (real coding) and fitness function for both TGA and IGA.
4.1. Chromosome and fitness function
The physical parameters of cart double pendulum are shown in Table 1, and the estimated values are shown in Table 2. The length of rods () is assured, and shall not be optimized; mass parameters (, , ) can be measured directly, but shall be adjusted to compromise the unmodeled dynamics; the other parameters (, , , , , ) cannot measured directly. So, the genes in chromosome can be selected as follows:
where is a chromosome in the genetic algorithm, which contains the physical parameters to be identified, each parameter is coded with double-precison real number. defines the solution space of parameters, is lower limit, and is upper limit. The estimated value in Table 2 are not accuracy enough to represent the actual device, but the basic trend is in the line with actual situation, so the solution space can be expanded based on the values from Table 2:
The main characteristics of cart double pendulum (such as swing frequency, amplitude size, and energy decay process) can be reflected in the zero response data. So, physical parameters are adjusted to make zero-input response simulation in order to approach the real-time zero-input response. Their usage is an effective method to build up an equivalent kinetic model, so the fitness function can be set up as follows:
where, is simulated zero-input response data of the th rod at moment (1 means the inner rod, 2 means the outer rod); is the real-time zero-input response data of the th rod at moment . is the fitness function, which allows calculating the difference between simulation response and real-time response, while the target of parameter identification is to find the appropriate parameter values at which can get minimum value. The real-time zero-input response reference trajectory of inner rod and outer rod () is shown in Fig. 6, and the initial states of this reference trajectory is given in Table 3.
Fig. 6. Real-time zero-input response curves
Table 4. Some identification results of kinetic parameters with TGA
4.2. Experimental results of traditional genetic algorithm
The chromosome is chosen as shown in Eq. (8), the solution space is defined by Eq. (9), and the fitness function is set up with Eq. (10). In all these cases, the traditional single point crossover is applied, the initial population is randomly generated, and the roulette selection operation is performed. Population size 200, crossover rate 100 %, mutation rate 10 %, max generation is 500, and 4 steps of the Runge-Kutta method are adopted as a numerical algorithm, the step size is 0.005 s, the simulation duration is 10 seconds. Table 4 shows some identification results of kinetic parameters. Fig. 7 shows the evolutionary process of the best individual, and Fig. 7 shows the contrast curves of the inner and outer rods.
As it can be seen from Fig. 7, the convergence rate of traditional genetic algorithm is fast at the first 80 generations, the rest 420 generations tend to be stable, and the fitness of the best individual is 2.13894. There are totally 2000 data points, so the average error per point is 0.00106947, that is why the simulation curves (inner rod and outer rod) coincide with the reference trajectory shown in Fig. 8. The identification result of traditional genetic algorithm is much better than the estimated values in Table 2.
Fig. 7. Evolution curve of best chromosome with TGA
Fig. 8. Contrast curves of real time and simulation for both a) inner rod and b) outer rod
4.3. Experimental results of improved genetic algorithm
Using the improved genetic algorithm mentioned in Section 3, the chromosome is shown in Eq. (9), the fitness function is shown in Eq. (10) and be further transformed with Eq. (7), population size 200, crossover rate 20 %, mutation rate 2 %, max generation is 500. The IGA parameters are 0.95, 5, 0.95, 0.10, 32. Simulation environment: 4 steps of the Runge-Kutta methodwith the step size of 0.005 s, simulation duration of 10s, Windows 10, Visual C++ 6.0.
Table 5 shows some results of IGA, Fig. 9 shows the evolutionary process of the best chromosome. Fig. 10 shows the difference between simulation (with optimal kinetic parameters of IGA) and reference trajectory.
Table 5. Some identification results of dynamic parameters with IGA
Fig. 9. Evolution curve of best chromosome with IGA
Fig. 10. Contrast curves of real time and simulation for both a) inner rod and b) outer rod
As it can be seen from Table 5 and Fig. 9, the IGA tends to converge at about 70 generations, the fitness of the best chromosome is 0.8515, which is much better than the result of the traditional genetic algorithm (2.13894). This proved that the global searching ability of the improved genetic algorithm is better than the traditional genetic algorithm. Because the application of orthogonal experiments, the search efficiency of IGA has been greatly improved, this leads to the convergence rate of IGA faster than TGA. The error between simulation curves (with optimal parameters of IGA) and reference trajectory is so small (0.8515), that the curves almost overlapped as shown in Fig. 10.
4.4. Contrast between TGA and IGA
Both IGA and TGA achieved a remarkable improvement, the best individual of IGA is much better than TGA. Here we calculate the error between reference trajectory and simulation with optimal parameters for both TGA and IGA (), Fig. 11 and Fig. 12 respectively show the angular error of inner rod and outer rod.
Fig. 11. Angular error of inner rod between reference trajectory and simulation with optimal parameters
Fig. 12. Angular error of outer rod between reference trajectory and simulation with optimal parameters
In Fig. 11 and Fig. 12, the vibration amplitude of dash line is obviously bigger than solid line in both Fig. 11 and Fig. 12, this means the optimal parameters obtained with the improved genetic algorithm is much closer to the actual device.
Fig. 13. Contrast of evolution process of best individual between IGA and TGA
Fig. 13 shows the evolutionary process of the best chromosome for both the improved genetic algorithm and the traditional genetic algorithm. The TGA curve is always above the curve of IGA, which means IGA convergence faster than TGA, and the result of IGA is more accurate than that of the IGA.
An improved genetic algorithm is introduced to solve the problem of kinetic parameter identification for a cart double pendulum, which includes paring operation based on the hamming distance, variable precision crossover, orthogonal experiment, feedback mutation, and nonlinear transformation of the fitness function. The hamming distance guarantees the effectiveness of crossover operation. Variable precision crossover can search for a feasible solution from a low-precision to a high-precision solution space. Orthogonal experiment can find the optimal combination of parameters through fewer experiments. Feedback mutation fundamentally avoids the premature convergence of the genetic algorithm. Nonlinear transformation of the fitness function promotes the evolution to search the optimal generation. The error between the real-time response and simulation response as the fitness function, the contrast experimental results of empirical parameter, TGA optimized parameter, and IGA optimized parameter are provided. The result with IGA is obviously better than that with TGA and practical values, which verify the effectiveness of the proposed method.
This work was supported by the Chongqing Science and Technology Commission’s Technology Personnel Training Program (cstc2013kjrc-qnrc40010) and the Chongqing City Board of Education’s Science and Technology Research Project (KJ1709196).
- Hung T. H., Yeh M. F., Lu H. C. PI-like fuzzy controller implementation for the inverted pendulum system. Proceedings of the IEEE International Conference on Intelligent Processing System, Beijing, China, 1997, p. 218-222. [Search CrossRef]
- Yang Yawei, Zhang Minglian Stability of numerical control of triple inverted pendulum. Journal of Beijing University of Aeronautics and Astronautics, Vol. 26, Issue 3, 2000, p. 311-314. [Search CrossRef]
- Li Hongxing, Miao Zhihong, Wang Jiayin Adaptive fuzzy control of fourfold inverted pendulum based on variable universe. Science in China (Series E), Vol. 32, Issue 1, 2002, p. 65-75. [Search CrossRef]
- Luis Alvarez Icaza Passivity-based swinging up of a pendulum. Proceedings of the 18th IFAC World Congress, Milano, Italy, 2011, p. 10667-10672. [Publisher]
- Pa Yee Tsai, Cha’o Kuang Chen Free vibration of the nonlinear pendulum using hybrid Laplace Adomian decomposition method. International Journal for Numerical Methods in Biomedical Engineering, Vol. 27, 2011, p. 262-272. [Publisher]
- Jian Huang, Zhi Hong Guan, Takayuki Matsuno, Toshio Fukuda, Kosuke Sekiyama Sliding-mode velocity control of mobile-wheeled inverted-pendulum systems. IEEE Transactions on Robotics, Vol. 26, Issue 4, 2010, p. 750-758. [Publisher]
- Li Zhijun, Luo Jun Adaptive robust dynamic balance and motion controls of mobile wheeled inverted pendulums. IEEE Transactions on Control Systems Technology, Vol. 17, Issue 1, 2009, p. 223-241. [Publisher]
- Li Z. S., Liang D. W. Human simulated intelligent controller with fuzzy online self-tuning of parameters and its application to a cart-double pendulum. Journal of Computers, Vol. 3, Issue 9, 2008, p. 67-76. [Publisher]
- Park M. S., Chwa D. Y. Swing-up and stabilization control of inverted-pendulum systems via coupled sliding-mode control method. IEEE Transactions on Industrial Electronics, Vol. 56, Issue 9, 2009, p. 3541-3555. [Publisher]
- Graichen K., Treuer M., Zeitz M. Swing-up of the double pendulum on a cart by feedforward and feedback control with experimental validation. Automatica, Vol. 43, Issue 1, 2007, p. 63-71. [Publisher]
- Li Zushu Zhou Qijian Ren Wei Identification of “quasi-equivalent” model and pade approximation with multi-adjustable parameters for dynamical systems. Acta Automatica Sinica, Vol. 11, Issue 1, 1985, p. 53-62. [Search CrossRef]
- Foster J. A. Evolutionary computation. Nature Reviews Genetics, Vol. 2, Issue 6, 2001, p. 428-436. [Publisher]
- Wu Mei, Lu Jingui Summary of research progress of genetic algorithms. Machine Tool and Hydraulics, Vol. 36, Issue 3, 2008, p. 176-179. [Search CrossRef]
- Li Zhushu, Tan Zhi, Wang Yuxin, Zhang Hua Real-time swing-up and handstand control of cart double pendulum on inclined rail. Proceedings of the 23rd Chinese Control Conference, Wuxi, China, 2004, p. 1645-1649. [Search CrossRef]
- Yin Wing Leung, Yuping Wang Orthogonal genetic algorithm with quantization numerical optimization. IEEE Transaction on Evolutionary Computation, Vol. 5, Issue 1, 2001, p. 41-53. [Publisher]
LangmuirMayssam Naji, Ecem Yelekli Kirici, Ali Javili, E. Yegan Erdem
Vibroengineering PROCEDIAWencong Fu, Chan Wang, Peng Xu, Yuanhong Dan