Stabilization of nonlinear inverted pendulum system using MOGA and APSO tuned nonlinear PID controller

An inverted pendulum system (IPS) is a highly nonlinear dynamical open loop unstable system, typically used as a benchmark to verify the performance of controllers. The IPS emulates the behaviour of an altitude control of a space booster or rocket on take-off. The problem is to develop suitable controllers to maintain the stabilization and swing up of an inverted pendulum on a cart. This paper presents the evolutionary tuning methods of nonlinear PID (NL-PID) controller for IPS with the multi-objective genetic algorithm (MOGA) and adaptive particle swarm optimization (APSO) algorithm. The function of NL-PID controllers is to keep the pendulum in an upright position by maintaining the pendulum at same state and angle at zero degrees. The comparison of responses and performance of MOGA tuned NL-PID and APSO tuned NL-PID controllers for an IPS are described. The mathematical modeling and simulation analysis of the IPS is presented in detail to test the effectiveness of controller tuning algorithm. The APSO based tuning of the NL-PID controller has lesser chattering, noise and fast settling time than MOGA based tuning of the controller. *Corresponding author: Sudarshan K. Valluru, Department of Electrical Engineering, Delhi Technological University, Delhi 110042, India E-mail: sudarshan_valluru@dce.ac.in Reviewing editor: Mohammed Chadli, University of Picardie Jules Verne, France Additional information is available at the end of the article ABOUT THE AUTHORS Sudarshan K. Valluru has been an associate professor of Electrical Engineering since 2009 at Delhi Technological University, New Delhi, India. His area of interests is Meta-Algorithms Applications to Control of Dynamical Systems, Intelligent, and Soft Computing Techniques. He is Fellow Member of Institution of Electronics and Telecommunication Engineers, Life Member of Institution of Engineers (I), and Life Member of Indian Society for Technical Education and also a member of IEEE (USA). Madhusudan Singh has been working as Professor of Electrical Engineering since 2007 at Delhi Technological University, New Delhi, India. His research interests are in the area of modeling and analysis of Electrical Machines and Dynamical Systems, Voltage control aspects of Self-Excited Asynchronous Generator, Power Electronics, and Drives. He is a Fellow Member of Institution of Electronics and Telecommunication Engineers, Fellow Member of Institution of Engineers (I), and Life Member of Indian Society for Technical Education and also a Senior member of IEEE (USA). PUBLIC INTEREST STATEMENT It is interesting to watch the rocket launching at the space center, many of us watching on television the launching process of the rocket/ satellites and their establishment in the orbit of the earth. Sometimes our mind stuck on certain aspects while watching the scenario of rocket flight. The aspects include what force is controlling the launching rocket which is carrying the satellite, how the rocket of such huge weight is projected upright, how the satellite is placed into the space orbit. All these aspects for a budding control engineer are hard to understand initially, but once we start embracing the results obtained from control engineering, to learn and design dynamic controllers are becoming inevitable nowadays. The nonlinear inverted pendulum system(IPS) is a challenging benchmark control problem to design and test such new dynamic controllers. It resembles the many real-world dynamical systems, such as self-erecting rocket, missile launchers, Segway robotic platforms. Received: 08 May 2017 Accepted: 16 July 2017 First Published: 20 July 2017 © 2017 The Author(s). This open access article is distributed under a Creative Commons Attribution (CC-BY) 4.0 license.


PUBLIC INTEREST STATEMENT
It is interesting to watch the rocket launching at the space center, many of us watching on television the launching process of the rocket/ satellites and their establishment in the orbit of the earth. Sometimes our mind stuck on certain aspects while watching the scenario of rocket flight. The aspects include what force is controlling the launching rocket which is carrying the satellite, how the rocket of such huge weight is projected upright, how the satellite is placed into the space orbit. All these aspects for a budding control engineer are hard to understand initially, but once we start embracing the results obtained from control engineering, to learn and design dynamic controllers are becoming inevitable nowadays. The nonlinear inverted pendulum system(IPS) is a challenging benchmark control problem to design and test such new dynamic controllers. It resembles the many real-world dynamical systems, such as self-erecting rocket, missile launchers, Segway robotic platforms.

Introduction
Most of the physical systems are nonlinear dynamic systems which exhibit multiple equilibrium points. The stability analysis of the nonlinear system in the presence of unknown disturbances, uncertainties in system model and system parameter variations are more complex when compared to the linear systems (Sastry, 1999;Vidyasagar, 1993). The inverted pendulum system (IPS) is one of the established benchmark problems in control literature as well as one of the most complicated dynamical systems according to report of the International Federation of Automatic Control (IFAC) theory committee. It is a standard benchmark problem (Davison, 1990;How, 2015) to test controllers and their tuning algorithms due to the presence of higher order nonlinearities and instability problem (Aracil & Gordillo, 2004;Geva & Sitte, 1993). It has a resemblance to many complex practical engineering systems such as helicopter control, ballistic missile or space flight launching control and humanoid mobile robots, etc.
The IPS is an upright pendulum with its fulcrum fixed at the top of the cart that can move horizontally and controlled such that the pendulum is always balanced and upright. The cart is free to move in the horizontal plane in response to an externally applied force. Consider a situation that the pendulum is in an upright position on the cart without control action, now a slight position change of cart would destabilize the pendulum causing instability in the system. The objective of the controller is to regulate control input i.e. the torque on the cart and keep the pendulum in an upright position by maintaining pendulum angle at same state and zero degrees. Extensive research work on control of dynamical systems have been reported and available in three subgroups such as classical, adaptive and artificial intelligence based controllers. PI, PID, and LQR controllers are classical controllers and suggested for linear systems control. The classification of sliding mode and model predictive controllers belongs to adaptive controllers for nonlinear regimes. The artificial intelligence based controllers such as fuzzy controllers, neuro-controllers, hybrid neuro-fuzzy controllers and metaheuristic algorithm tuned PID controllers (Astrom & Kumar, 2014) are more suitable for nonlinear dynamical systems. Despite the advent of many controllers, PID controller is still one of the most simple and easy to implement in the stabilization of IPS. It offers simple structure, practicability, robustness, cost-effective solution with good performance and simple tuning methods. Most of the conventional tuning methods require tedious numerical computations to get appropriate PID parameters. Tuning of PID parameters are very critical, and it is anticipated to find optimal parameters to give satisfactory response for an inverted pendulum. In Recent past, besides the conventional tuning methods, several researchers have attempted for optimisation of PID gain parameters exclusively based on metaheuristic algorithms. The genetic algorithm (GA) (Liu & Daley, 1999;Shen, 2002) and particle swarm optimisation algorithm (Banks, Vincent, & Anyakoha, 2007Oi, Nakazawa, & Matsui, 2008;Zhao, Li, & Qian, 2005) tuning methods yields optimal results than conventional tuning techniques. These metaheuristic algorithms are highly robust since the efficiency does not depend upon the characteristics of the IPS. The application of GA and standard PSO for tuning of linear PID controller in the linear dynamical system has emerged significantly in last few decades. Chinichian and Kashani (1989) presented design and analysis of state variable feedback controller for a state space linear model of IPS mounted on a motor driven cart. Murata, Matsuno, Moran, and Hayase (1995) presented the dynamical modeling and nonlinear observer based controller with linear feedback gains to stabilize the inverted pendulum mounted on cart system. Tuning of PID controller is difficult due to parameters variations. Deris, Omatu, and Kitagawa (1995) and Omatu and Yoshioka (1998) have applied genetic algorithm tuned neuro PID controller to stabilize the pendulum mounted cart system. Medrano-Cersa (1999) illustrates the design of a robust digital controller with a blend of state space and frequency methods to balance the IPS on moving cart. An energy based control strategy is described by Åström and Furuta (2000) to control and swing up of an IPS on the cart. Patnaik and Behera (2008) have reported the design and implementation of a multiobjective genetic algorithm (MOGA) based classic quadratic regulator, standard H ∞ and mixed H 2 /H ∞ controllers for the inverted pendulum. The response of PID plus LQR has been compared to that of simple PID on a pendulum cart system by Prasad, Tyagi, and Gupta (2011). Aouaouda, Chadli, Khadir, and Bouarar (2012) consider the tracking problem of uncertain Takagi-Sugeno fuzzy continuous systems subject to unknown inputs. Bououden, Chadli, and Fouad Allouani (2013) introduced a new approach for designing an adaptive fuzzy model predictive control using standard particle swarm optimization algorithm. Durand, Guerrero-castellanos, and Marchand (2013) proposed energy control and event-based state feedback control strategies for unstable IPS on cart system and demonstrated the computational cost efficiency on real-time test bed. Chadli, Aouaouda, Karimi, and Shi (2013) presented a fault-tolerant tracking controller for a verticle take-off and landing aircraft flight in uncertain conditions. Aouaouda, Chadli, and Karimi (2014) described the design of a robust fault estimation and fault tolerant control for the vehicle lateral dynamics subject to external disturbance and unknown faults. Bououden, Chadli, and Karimi (2015) proposed ant colony optimization for designing an adaptive fuzzy model predictive control. Aouaouda, Chadli, Shi, and Karimi (2015) have designed a multi-objective H − /H ∞ sensor fault detection observer for a discrete-time nonlinear system subject to parameter uncertainties. An output feedback controller is proposed by Lee, Mukherjee, and Khalil (2015) to stabilize and trajectory control for inverted pendulum on cart system. Korkmaz, Aydoğdu, and Doğan (2012) disfavor the classical tuning of PID besides this, they proposed the design of nonlinear PID (NL-PID) and compared with GA tuned PID controller. Different PSO algorithms are stated by Menhas, Wang, Fei, and Pan (2012) to design optimal PI and PID controllers for a MIMO system. Valluru, Singh, Bhushan, and Sreevidya (2015) have made a comparative study of untuned PID, NARMA L-2, and standard PSO tuned linear PID for a nonlinear dynamical system. This paper presents a performance evaluation of the IPS with MOGA tuned NL-PID, and APSO tuned, NL-PID controllers instead of routine GA and standard PSO tuning of linear PID controller. The present study focuses on detailed investigations, and performance evaluation of the NL-PID controlled IPS for optimal gain tuning by new variants of metaheuristics i.e. MOGA and APSO based optimization of controller parameters. The simulation results validate the system performance index regarding chattering, noise and settling time.
The paper is organized in five sections commencing with the introduction followed by Section 2, which analyzes mathematical modeling of IPS and its control strategies. In Section 3 the design of NL-PID controller for an IPS is presented. Section 4 discusses pseudo codes of the MOGA, APSO algorithms and pendulum angle response of IPS is investigated with NL-PID controller. Section 5 presents the conclusion.

Mathematical modeling of IPS
The IPS (Chatterjee, Patra, & Joglekar, 2002) involves a cart which is capable of moving backward and forward with a pendulum fulcrum at the bottom of its limited length such that the pendulum can move along with cart in the same plane. The pendulum attached to the cart is free to fall along the cart axis of motion. The pendulum movement is constrained in a vertical plane while the cart can move only in the horizontal plane. The control input force F is used to control the motion and hence the displacement x of the cart in the horizontal plane while indirectly controlling the angular position of the pendulum angle θ p . The value of the input force depends upon control voltage (u) applied to DC motor, which drives the cart. The cart position and pendulum angle are monitored and used to change control signal so that the pendulum remains in stable region and upright at zero angles and does not affect even by small disturbance on the cart. A schematic representation combined with free body diagram is shown in the Figure 1.
The modeling of the IPS is challenging due to its inherent nonlinearities and instability. The mathematical modeling is based on the motion patterns through physical and mechanical means to set up the input-output relationship in the system. https://doi.org/10.1080/23311916.2017.1357314

IPS model equations
The nomenclature of the parameters and variables used in modeling of IPS are given in Table 1.
The dynamic equations (Guida, Nilvetti, & Pappalardo, 2010;Teixeira & Zak, 1999) of the system using Newton's second law described as: The Equations (1) and (2) denotes the nonlinear dynamic model of the IPS.

Control strategy and stability analysis
The nonlinear dynamic equations for ẍ and ̈p may be represented into a state space form by considering the four state variables as: x 1 = θ p = pendulum angle measured from vertical.
x 4 =ẋ = cart velocity. (1) x = −mal̈p cos p + mal̇2 sin p − af c + aF   According to direct Lyapunov method (Chadli & Borne, 2013;Khalil, 2002), the controller state can define as p x 1 , x 2 which is a function of the control is input F − f c . Now by assuming the system equilibrium at origin i.e. p 0, 0 and choosing positive definite matrix P as 1∕2 0 0 1∕2 the energy equation is 3 −m 2 l 2 a cos 2 x 1 ⎤ ⎥ ⎥ ⎦ Let V: → ℝ be a continuously differential function such that V < 0 verify the asymptotic stability. To prove this there exists a scalar > 0 (Khalil, 2002), then the asymptotic stability of the system satisfies the control input.
To ensure asymptotic stability, the control input of IPS must be as follows

Design of NL-PID controllers for IPS
The PID controllers are widely used to stabilize the unstable systems. The PID controllers for unstable systems are having the capability of self-tuning by either conventional or intelligent technique to attain the stability in the neighborhood of operating envelope. However, the conventional tuning requires tedious numerical computation to achieve best possible controller gains, during the change of parameter variations. Therefore, the PID controller may perform poorly if the unstable system operates at different operating points, which need that the controller to be repeatedly re-tuned. The system may lose the stability at that operating point if the re-tuning made through complex and slow tuning methods. In these situations, an alternate approach to eliminate the problem is to use NL-PID with intelligent tuning techniques such as bio-inspired meta-heuristics, which are suitable to achieve faster and precise computation with best controller gains. However, when the system structure is complex with parameter variations, the linear PID do not exhibit good efficacy compared to that of the NL-PID. The NL-PID controller changes its parameters quickly over time according to system error and can provide an additional degree of freedom to achieve improved performance. Currently, different variants of GA and PSO algorithms tuned PID controllers have shown renewed interest among the researchers to automate the tuning process in the design of the controller.

NL-PID controller design
Mostly the PID controllers are employed to control unstable systems. While linear PID controllers are often sufficient for stabilizing unstable systems during small linear operating envelope, however for more high precision control, the competency and robustness of linear PID remained insufficient. The major failure of linear PID controller comes due to the constraints in the mathematical model i.e. contradiction between increased gain and the faster response of the system. If a suitable law is formulated for the system, which removes this limitation leading to a better control action for the system (Han, 1994). A general NL-PID module is introduced (Chen, Ballance, Gawthrop, Gribble, & O' Reilly, 1999;Su & Dong Sun, 2005) as in Equation (13) where sign(e) = 1, e ≥ 0 −1, e < 0 where e is the error signal, δ describes the linear range of the function f, here function f can accommodate a greater range of nonlinear characteristics which is determined by α. Hence now control signal being generated by the NL-PID is given in Equation (14) The function f(e, α, δ) denotes the rate of error feedback, to compensate the nonlinearity of the systems considered the value of α p is taken in the range of p ∈ [0, 1] since it needs lower gain when the error is high and vice versa. The integral saturation problem of the integral term can be rectified by using α i in the range of i ∈ [−1, 0]. The value of differential term is chosen as α d > 1 so that when the steady state is reached the effect of the differential term is reduced. The systematic structure design of NL-PID is shown in Figure 2.

Metaheuristics tuned NL-PID controllers for IPS
Bio-inspired metaheuristic algorithms are dissimilar as compared to the traditional algorithms regarding a multi solid solution while later have a single point solution; metaheuristic algorithms can all together evaluate some points in the search space with lesser convergence time and converge to global optima rather than local optima. Further, the metaheuristic algorithms reproduce offspring to progress the search space in addition to solution. Many metaheuristic algorithms such as Genetic Algorithm, Ant colony algorithm, particle swarm optimizer algorithm, firefly algorithm, and artificial bee colony algorithm (Yang, 2010) and their advanced variants have been developed in recent past. These algorithms differ from each other by variables to be tuned, offspring generation, and replacement mechanism. Out of all these algorithms, the most familiar is a genetic algorithm and particle swarm optimization algorithm for PID tuning of several systems. The variants of MOGA and Adaptive Particle Swarm Optimization Algorithm (APSO) have been considered here for the tuning of NL-PID controllers for IPS. The advantage of these algorithms is a shortfall of system matrix eigenvalues.

MOGA tuned NL-PID controllers
The MOGAs were one type of combinatory optimized search algorithm, which require discretized search space to solve real decision variables of system optimization problems for both single objective and multi-objective functions. The MOGA selects individuals based on random selection from the population and consists of genetic transformations such as crossover, mutation to create a new set population. Hence initially there is no clue, regarding the best answer for an optimization problem. Over the successive generations, the best among the lot are selecting, operators are worked upon on them and evaluated again until they evolve to the global optimal or suboptimal solution. The objective of using MOGA (Valluru, 2011) here is to determine the optimal value of NL-PID parameters (K p , K i and K d ) such that the objective functions J(x) is minimized. The overall result of the finding of the optimal parameters would lead to fine tuning of the PID controller and simultaneously improvement in the transient as well as steady state response of the system under consideration.
The objective function J(x) becomes an instrument to evaluate the performance of NL-PID controller with the determined value of gain parameters, resulting in an optimized controller with the best individual is given in Equation (15) where r(n) is nth input of the system and y(n) the nth output of the system. A general block diagram of MOGA tuned NL-PID is shown in Figure 3 which uses the torque as reference signal to the inverted pendulum, the error between actual output and the reference signal along with proportional (K p ) integral (K i ) derivative (K d ) gains generate the control signal. The pseudo code of MOGA employing to tune NL-PID controllers for IPS can be summarized as follows: 1. Set the range of PID controller parameters as objective function J(x), x = (K p , K i , K d ) T .

Encode the solution into chromosomes as binary strings.
3. Define the fitness F ∝ J(x) for maximization. 4. Generate the initial population of size N for the NL-PID controller parameters.
5. Initial probabilities of crossover (p c ) and mutation (p m ).
6. Evaluate the initial population.

Decode the binary strings and visualize the new values of
The size of the population, dimension, mutation rate, selection rate, maximum iterations used in the MOGA process to find best optimizing tuning parameters of NL-PID controllers for IPS taken as 10, 3, 0.2, 0.3, 100 respectively. The estimated NL-PID controller gain parameters by MOGA, which is tabulated in Table 2 and shown in Figure 4.  The control signal u(t) for MOGA tuned NL-PID as shown in Figure 5. The pendulum angle response of IPS with MOGA tuned NL-PID as shown in Figure 6.

APSO tuned NL-PID controllers
APSO algorithm is effective for optimizing a broad range of objective functions, inspired from the swarming phenomena of fish schooling and bird flocking. The multiple agents known as particles, swarm around the search space starting from an initial guess. APSO has some similarities with MOGA, but APSO is much simpler because it uses real number randomness and global communications instead of mutation/crossover. The APSO algorithm starts with the initialization of group of arbitrary particles in the search space, and each particle represents a potential solution for the optimization of an objective function.
During each iteration, all the particles in the search space discover a feasible solution. After, the particle updates its position according to the present velocity vector which contains its previous value and decides to take into account the past local and global best solutions. By keeping the best solutions, the particle moves towards local best solution attained by its fellow particles but also the global best. Hence if a particle has discovered a new best solution, then all other particles would try to move toward it. The four important terms in APSO (Chen, Hu, Wang, Gao, & Li, 2016; Li, Zhan, Lin,   Zhang, 2015;Zhan, Zhang, Li, & Chung, 2009) for the particles in the swarm are p i position, v i (current velocity), Pb i (local best position), Gb j (global best position). Each particle is updated according to the above four features in each iteration, assuming an cost function J to be minimized. The innovative velocity of a particle is determined by the Equation (16) where n is the number of iterations, w is inertia weight, c 1 and c 2 are the acceleration co-efficients (called cognitive and social component respectively) and r 1 and r 2 are two quasi uniform random numbers between (0, 1). v i,j is the velocity of the jth dimension of the ith particle. The new position of the particle is updated by using Equation (17) The local best of every particle is updated by the Equation (18) Here the population size is denoted by s; then the optimized global best can be found by the Equation Tuning of NL-PID can be done efficiently by using particle swarm optimizer to find the values of optimal gain parameters (K p , K i and K d ) which will minimize the objective function (J). The block diagram of APSO tuned NL-PID for cart pendulum system is shown in Figure 7 which uses the step reference signal to the IPS, the error between actual output and the reference signal along with proportional (K p ), integral (K i ), derivative (K d ) gains generated the control signal u(t).
The APSO pseudo code to tune the L-PID and NL-PID controllers for IPS is summarized as follows: 1. Set the range of PID controller parameters J(x), x = (K p , K i , K d ) T 2. Initialize the locations of p i and velocity v i for swarm size n, acceleration factors c 1 and c 2 to the controller parameters K p , K i , K d each representing dimensions of particle position vector in real parameter space.
3. for each particle, i do, by testing each particle for fitness by evaluating the objective function

J(x)
4. Set the initial local best (Pb i ), and global best (Gb j ).

While stopping criteria is not reached do for every particle i do
Generate innovative velocity v i,j (n + 1) according to Equation (16) Generate new positions p i,j (n + 1) according to Equation (17) Evaluate objective functions at new positions Renew the current best of each particle end for Find the current global best end while 6. Output the final results of optimized global best Pb(n + 1) = Pb(n), J(p(n + 1)) ≥ J Pb(n) Pb(n + 1), otherwise (19) Gb(n + 1) = min Pb J Pb i (n + 1) , 1 ≤ i ≤ s The size of the swarm, dimension, maximum iterations, cognitive factor, social factor, constriction factor used in the adaptive particle swarm optimizer to find the best-optimized parameters for NL-PID controller for the IPS are 10, 3, 50, 2.05, 2.05, and 2 respectively. The best gain parameters of APSO tuned NL-PID controllers are given in Table 3 and gained evolution is shown in Figure 8.  The control signal u(t) for APSO tuned NL-PID as shown in Figure 9. The pendulum angle response of IPS with APSO tuned NL-PID as shown in Figure 10.

Performance comparison of MOGA and APSO tuned NL-PID controller for IPS
A comparison performance of the IPS for pendulum angle response using MOGA and APSO algorithm tuned NL-PID controllers are carried out through simulation studies in MATLAB and summarized in Table 4.

Conclusion
This investigation presents comprehensive tuning strategy and performance evolution of NL-PID controller in conjunction with MOGA and APSO to stabilize the pendulum angle of IPS. APSO based tuning of NL-PID gives lesser settling time, and lesser chattering in response than MOGA tuned NL-PID controller. In addition to this, it is observed that the utilization of an NL-PID controller improves the dynamic performance of IPS. The APSO tuned NL-PID controller provides the optimum performance of the IPS and stabilize the system in operating state quickly with less chattering in the initial response. In the present scope of work, efforts are made to validate the performance and stabilization of IPS with MOGA and APSO based tuning of NL-PID controllers. However, the authors are motivated to implement these control algorithms on real-time prototype IPS in the laboratory.