Genetic Algorithm Optimisation of a Ship Navigation System

The optimisation of the PID controllers' gains for separate propulsion and heading control systems of CyberShip I, a scale model of an oil platform supply ship, using Genetic Algorithms is considered. During the initial design process both PID controllers have been manually tuned to improve their performance. However this tuning approach is a tedious and time consuming process. A solution to this problem is the use of optimisation techniques based on Genetic Algorithms to optimise the controllers' gain values. This investigation has been carried out through computer-generated simulations based on a non-linear hydrodynamic model of CyberShip I.


Introduction
In order to ensure the safe navigation of surface vessels their motion has to be controlled accurately.This control can be provided through the application of control theory.In general, control theory provides design strategies that allow a better understanding of the system being controlled and a mechanism to regulate the way it operates.There are various control theories or methodologies that have their own structure.Unfortunately, not all these methods perform their controlling duties satisfactorily due to inherent limitations imposed by the controller structure.In addition, the performance of these controllers depends on the values of the controller's parameters.Conventionally, the designer manually tunes these parameters to find an acceptable solution.However, this relies on an ad hoc approach to tuning, which depends on the experience and qualitative judgement of the designer.This process can be very slow and there is no guarantee that the designed solution will perform satisfactorily.
A solution to this problem is to use optimisation techniques that tune such parameters automatically.The most powerful of these techniques is based on Genetic Algorithms (GAs) [1], [2], [3].GAs are stochastic search methods that mimic the way species evolve in nature.They operate on a population of potential solutions applying the Darwinian principal of "survival of the fittest" to produce better and better possible solutions to a given problem.At each generation, a new set of candidate solutions is created by the process of selecting solutions that are better than others and breeding them together using operators borrowed from natural sexual reproduction in order to get populations of solutions that are better than the solutions they were created from, just as in natural adaptation.
This paper covers the optimisation of control systems for the propulsion and navigation of an oil platform supply ship using a GA.The particular vessel used in this study is a scale model called CyberShip I [4], [5], which is the test vehicle for the Guidance, Navigation and Control Laboratory at the Norwegian University of Science and Technology in Trondheim.Computer-generated simulations based on a non--linear hydrodynamic model of CyberShip I are used in the optimisation studies.These simulations have proven to be sufficiently representative of the full-scale manoeuvring dy-namics of such a vessel.Hence the optimised controllers could be used to control the actual scale model without the need for further modification.
The investigation presented in the paper will represent part of a study into the optimisation of controller designs based on a number of different control methodologies.In this case the particular methodology considered is classical PID, a very simple and widespread controller.PID control is used to provide the structure for both propulsion and navigation controller.The goal of this study is to obtain controller solutions that satisfactorily track the desired heading and propulsion response while keeping actuator usage to a minimum.
The results obtained from this study illustrate the benefits of using GAs to optimise propulsion and navigation controllers for surface ships.The accuracy of the resulting simulations allows meaningful evaluation of the optimised controllers' performance.

Supply ship mathematical model
The dynamics of the vessel can be represented by the kinetics and kinematics equations.When kinetic and kinematic equations are combined together the following matrix equation is produced [4] ( ) which corresponds to a form of state space equation (i.e.

( )
Here M, C, D and J are the mass/inertia, Coriolis, damping and Euler matrices, n = [u, v, r] T is the body-fixed linear and angular velocity vector, h = [x, y, y] T denotes the position and orientation vector in the earth-fixed frame and t = [t 1 , t 2 , t 3 ] T is the input force vector, given that t 1 is the thrust vector along the body fixed X-axis, t 2 is the thrust vector along the body fixed Y-axis and t 3 is the thrust vector along the Z-axis.These three force vectors relative to the body-fixed axis that constitute the inputs to the vessel model are provided by four thrusters.Two of them are placed at the stern, symmetric with respect to the body-fixed X-axis, while the other two are placed at the bow, along the body-fixed X-axis [4].Each thruster is represented by the force (f i ) it produces and the angle (a i ) defining its direction.And the amplitude limit values for each of the thrusters' force and angle are ±0.9N and ±p radians respectively [4].The three input force components (t) can be related to the individual forces produced by the thrusters (f i ) using trigonometric relationships [5].
Hence, the ship's model has 6 states (i.e.u, surge velocity; v, sway velocity; r, yaw rate; y, yaw angle; x p , x-position on earth and y p , y-position on earth) and 3 inputs (i.e.t 1 , t 2 and t 3 , thrust forces along the body fixed X, Y and Z-axis respectively) [4].
Since Cybership I is a scale model of an actual type of supply vessel the simulations performed are scaled in order to generate results comparable to the response of full-scale ships.

Automatic control system
For most surface vessels there are two main sets of dynamics: propulsion and heading.Two classical PID controllers [6] have been used to provide the structure for the propulsion controller (for governing surge velocity) and the navigation controller (for governing heading).These controllers operate on the error signal, which is the difference between the desired output and the actual output, and generate the actuation signal (i.e.t 1 and t 3 ), which drives the plant (i.e. the vessel).They have three basic modes of operation: proportional action, in which the actuation signal is proportional to the error signal, integral action, when the actuation signal is proportional to the time integral of the error signal, and derivative action, where the actuation signal is proportional to the time derivative of the error signal, and their transfer function is given by: These "three-term controllers" have been found to be so effective that PID is the standard control method used in the process industries.To design a particular control loop the three parameters (K, proportional gain, K I , integral gain, and K D , derivative gain) have to be "tuned" to arrive at acceptable performance.

Genetic Algorithm optimisation
GAs are optimisation techniques that mimic the way species evolve in nature.In natural evolution many organisms evolve by means of two mechanisms: natural selection and sexual reproduction.The concept of natural selection is described by the Darwinian theory of survival of the fittest.Sexual reproduction allows the offspring to inherit features from both its parents.
GAs emulate this process by evolving a population of parameter solutions through a number of generations.They initiate this process by randomly generating an initial population of possible parameters (suitably encoded).The performance of each solution is evaluated and a new generation is produced according to the three main operators of the GA: selection, crossover and mutation.Selection determines which solutions are chosen for mating according to the principal of survival of the fittest (i.e. the better the performance of the solution, the more likely it is to be chosen for mating and the more offspring it produces).Crossover allows an improvement in the species in terms of the evolution of new solutions that are fitter than any seen before, and mutation reintroduces values that might have been lost through selection or crossover, or creates totally new features.The cycle is performed until a predetermined number of generations is met [1], [2].
In order to search the space of possible solutions the GA uses a string (called chromosome) of digits as a representation of the elements of the space of possible solutions (i.e. the possible solutions are suitably encoded).
In this study, the encoding of the parameters has been chosen to allow a range of possible solutions from 0.001 10 -2 to 9.999 10 3 .Each controller parameter value is encoded as a string of five genes.As there are three parameters to optimise in the controller (i.e.K, proportional gain, K I , integral gain, and K D , derivative gain), each possible solution is represented by a chromosome that is a string of 30 genes (i.e. 15 genes represent the propulsion controller and 15 represent the heading controller).These genes, instead of being binary bits (as they used to be in the traditional GA), are integers included within the interval [0, 9], in order to allow a wider range of possible solutions in smaller chromosomes [4].

ParameterE ncoding abcde
ParameterV alue Once an initial population of chromosomes is generated at random, the chromosomes are decoded to get the corresponding parameters and these are introduced in the controllers.A simulation is run and the result obtained for each set of controller's parameters of the population is evaluated, using the cost function to be minimized.
Based on this cost function the selection procedure, used to draw chromosomes from the evaluated population, takes place.There are three main types of algorithms for this (i.e.roulette wheel selection, tournament selection and rank--based selection [4]), but they all share the feature that the probability of selecting a chromosome for reproduction is a decreasing function of the chromosome's cost score.
Roulette wheel selection allows sub-optimal solutions to have a chance of being accepted.It ensures a good mix of good and bad solutions and prevents premature convergence to a local minimum, however it also leads to a very slow convergence rate.Therefore, to avoid this slow convergence, the selection scheme chosen for this study is a variation of roulette wheel selection.The population is sorted according to the actual cost and a new cost value is assigned to each chromosome depending only on its position in the chromosome's rank and not on the actual cost value.
Consider Nchrom the number of chromosomes in the population, Pos the position of a chromosome in this population and SP the selective pressure (i.e. the probability of the best chromosome being selected compared to the average probability of selection of all chromosomes).The new cost is calculated as [7]: Then a biased roulette wheel is created where each chromosome in the population has a roulette wheel slot sized in proportion to its cost.To reproduce, the roulette wheel thus defined is spinned as many times as chromosomes are in the population [3].
The fact of assigning this new cost value to each chromosome (instead of creating a biased roulette wheel straight from the actual cost values obtained after the simulation) allows a bigger differentiation among the chromosomes.In a even population where most chromosomes have approximately the same cost value, assigning new cost values depending only in the position of the chromosome once the population has been ranked, increases the chances of the fittest chromosomes being chosen for reproduction.This way the convergence to the minimum is faster [7].
Once the new population has been obtained, chromosomes are ready for mating and mutation.The crossover operator combines the features of two parents to create new solutions.One or several crossover points are selected at random and then complementary fractions from the two parents are spliced together to form a new chromosome [4].In this study two-point crossover has been used because multi-point crossover encourages a greater amount of variation in the new chromosomes produced and two points do not greatly increase the complexity of the algorithm.
The mutation operator alters a copy of a chromosome.One or more locations are selected on the chromosome and replaced with new randomly generated values.Mutation is used to help insure that all areas of the search space remain reachable.The mutation probability chosen has been 5 % [4].

Manual tuning results
This investigation has been carried out through simulation studies in MATLAB.The accuracy of computer-generated simulations based on this mathematical model permits the use of such simulations as a method for evaluating the performance of the controllers.
In the vessel simulation two PID controllers have been integrated: one for the heading subsystem (i.e.generates the input t 3 ), and other for the propulsion subsystem (i.e.generates the input t 1 ).The parameters of both controllers (i.e.K, proportional gain, K I , integral gain, and K D , derivative gain) need to be tuned in order to get a response of the system as accurate as possible.The manual tuning yields the parameters shown in Table 1.
The resulting controller generates the simulated results shown in Figure 1 when a 45 o overdamped second order step input is applied in the heading and a 0.4 m/s overdamped second order step input in the propulsion.
Although the results obtained in this case are considered to be quite good, manual tuning is a tedious job and not very reliable, since sometimes the values of the controller's gains can be particularly difficult to obtain.Therefore a GA has been used to optimise these gains.

Genetic Algorithm optimisation results
The results presented in this section are best cases obtained from several runs (i.e. 10 runs) of the GA.The rest of the runs converge to the same minimum area and the control- Since it is desirable that the population size is approximately equal to the number of genes in each chromosome and that the generation size doubles this [4], in every run the population consisted of 60 chromosomes and the number of generations the optimisation cycle performed was 120.Thus, the GA initialisation is carried out by generating an initial population matrix of uniformly distributes random integers, whose size is 60 × 30 (i.e.number of chromosomes × number of genes in a chromosome).
The optimisation design criterion is defined by the cost function.In addition to this there is a desired response that the controller must track.The desired heading and propulsion manoeuvres used in the GA optimisation is the same than the one used in the manually tuned controller so that both studies can be compared (see Figure 1).
Since the objective of the controllers is to make the vessel track desired dynamic responses with the minimum actuator effort, the cost function will have two terms for each controller [4]: Here Dy i is the ith heading angle error between the desired and obtained heading, t 3i is the ith yaw thrust force, Du i is the ith surge velocity error between the desired and obtained surge velocity, t 1i is the ith surge thrust force, tot is the total number of iterations and l 1 and l 2 are scaling factors.Since the optimisation processes attempt to minimise the value of this function it is easy to see that Dy, Du, t 3 and t 1 will be minimised too.Therefore, the quantities Dy and Du give an indication of how well the controllers are operating by showing the tracking between the actual and the desired heading and surge velocity and the input components t 3 and t 1 are used to keep the actuators movement to a minimum so that they can operate well within their operating limits.
As the input force and torque are always larger than the output errors near the optimum, they dominate the cost values in this area.This leads to solutions that provide very small thruster effort, but a very poor tracking of the desired responses.In order to avoid this, t 3 and t 1 are scaled by two constants, l 1 and l 2 , so that an equally balanced trade-off between the elements is obtained and the four terms of the cost function are equally optimised.Several scaling factors have been considered, resulting in choosing l 1 and l 2 equal to 0.001 as the most appropriate.
In Figure 2 the fast convergence of the GA for these scaling factors is shown.The best solution converges to a solution very close to the minimum in less than 20 generations.The total cost is shown to converge to a low cost region within 5 generations, although after that there are some peaks of higher cost due to the mutation operator.
In the final generation there are 52 chromosomes that have similar cost functions (i.e.86.6 % of the population).This means that the amount of saturation is high and provides confidence in the final solution being near optimal.
The parameters shown in Table 2 are typical of those obtained as a solution by this optimisation.As can be seen from the figure, the tracking of the desired overdamped response in both subsystems, propulsion and heading, is excellent, although the surge velocity response shows a very small steady state error (0.01 m/s approximately).Obviously, t 1 increases while the ship is accelerating and stays constant once the ship has reached the desired surge speed.On the other hand, t 3 shows initially a positive peak, corresponding with the beginning of the manoeuvre and tends to zero as the ship completes the turn.Both input signals, t 3 and t 1 , are well kept within the operational limits, although t 3 shows a very oscillating behaviour.This leads to an unnecessary wearing and tearing of the actuators that shortens their life.A new cost function has been considered to try to reduce the oscillations in the actuators: These two new terms introduce a measurement of the inputs increasing or decreasing rates.In the minimization process these two terms will also be minimized, leading to a smoother input response.Both terms are scaled by two coefficients, m 1 and m 2 .
After several trials, the coefficients m 1 and m 2 that seem to fulfil the role of reducing the wear and tear in the actuators without worsening the tracking are: m 1 equal to 0.01 and m 2 equal to 0. This value of m 1 gives a good trade-off between good tracking of the desired heading and a significant reduction in the oscillations of the input t 3 .Also, any value for m 2 different to 0 leads to a very slow response, often with a big steady-state error, caused by the slowing down of t 1 .This is to be expected since the previous optimised controller did not present oscillations in the input t 1 .Hence, although the inclusion of the input rate term has provided a less oscillatory response for the input t 3 keeping a good tracking, in the case of t 1 it leads to a much worse tracking with slight improvements in the input response.It seems necessary to have a prior knowledge of the actuators behaviour in order to include the input rate term in the cost function.Introducing the input rate term in the cost function if there is no wearing and tearing of the actuator will just result in a slower input and less accurate tracking.
Considering the convergence of the GA method through the total and best cost, the total cost converges to a low cost region within 3 generations and the best cost converges to a solution close to the final cost value in the 10 th generation.Hence, the convergence in this case has been faster than in Figure 2. Also, observing the amount of saturation in the final generation it can be verified that the final solution is near optimal due to the high number of similar individuals in the final solution (i.e. 45 individuals, 75 % of the population).When the PID controllers are optimised using (6) the values shown in Table 3 are typical of those obtained.
The results obtained for the PID controller gains using this latter cost function ( 6) differ quite a lot from the ones got with the previous one (5), especially K I .As it has been included a new term in the cost function (6) to reduce the oscillations in the input signal generated by the heading controller (i.e.t 3 ), the GA has done so by decreasing K and K D to reduce the gain of the system and the noise amplification.Also, in order not to get a poorer tracking response after reducing K, K I has been increased to improve the tracking.Although the terms of the cost function ( 6) concerning the propulsion controller have not changed, the reduction of oscillation in t 3 affects t As can be seen from these plots the tracking of the surge velocity desired response is again excellent, and even the slight steady state error has disappeared.The tracking of the heading desired response is a bit worse than it was with the previous controller, especially in the transient (i.e. the first 10 seconds), but thanks to this the goal of this new optimisation, which was to reduce the wearing and tearing in the yaw thrusters, has been accomplished.

Execution Time
Comparing the execution time for both methods, manual tuning and GA optimisation, it can be seen in the Table 4 below that the time spent tuning the controller was longer that the time it takes to run a GA simulation.It is quite difficult to reckon the time a designer will spend doing a manual tuning because it highly depends on his experience, engineering judgement and luck.Although it may seem that the simulation time is quite long and there is no real advantage in it, we must take into account that while the optimisation is running the designer does not need to be there.

Conclusions
This paper has presented the findings of a study of PID controller gains optimisation for an oil platform supply ship's propulsion and heading dynamics.
The GA process has performed well as optimisation technique.It has obtained optimal solutions for both propulsion and navigation PID controllers without a-priori knowledge of the optimal region.As this a-priori knowledge is not necessary, GA techniques are very suitable when the designer is unfamiliar with the plant to control.
The key factor in the GA optimisation is the choice of the cost function.As the objective of the optimised controller is to make the vessel follow as accurately as possible the desired track while avoiding excessive wear and tear in the actuators, these two terms (i.e.difference between desired response and Acta Polytechnica Vol.41 No. 4   actual response and thrust forces) must be included in the cost function in order to be minimised.Numerous simulations considering different scaling factors show that there is a trade-off between the accuracy following the desired track and the actuators, usage and one of them cannot be improved without making the other worse.This leads to the necessity, of a balance so that the overall performance is good.
In addition, the inclusion in the cost function of a term considering the rate of variation of the thrust forces along the Z-axis leads to a significant reduction in the oscillation of this input keeping a good tracking of the desired heading.This is a considerable advantage since it avoids unnecessary wear and tear of the actuators, which could shorten their operational lifespan.
The results obtained illustrate the benefits of using GAs to optimise propulsion and navigation controllers for surface ships.The accuracy of the obtained simulations allows confidence in the good performance of these controllers once they are used to control the manoeuvring of the actual scale model.

Fig. 3 :
Fig.3: GA controllers response using cost function(5) 1 and this deals to a different propulsion controller.Once implemented the simulated responses shown in Figure 4 are obtained.

Table 1 :
Manually tuned controllers parameters Fig.1: Manually tuned controllers response lers obtained show similar characteristics, although they do not perform as well as the best case.

Table 2 :
GA controllers parameters

Table 4 :
Execution time