Neuro-Knowledge Model Based on a PID Controller to Automatic Steering of Ships Neuro-Knowledge Model Based on a PID Controller to Automatic Steering of Ships

Despite this upward pace of discovery of different possibilities, it has been impossible up to now to derail relatively popular techniques, such as the "traditional" PID control. Since the discovery of such regulators by Nicholas Minorsky in the area of automatic steering of ships [3, 4] since 1922 by now, many studies on this regulator are made. It should be noted that there are numerous usual control techniques for the process in any field, where innovations were introduced, for example thanks to the inclusion of artificial intelligence in this area, [5]. Despite this, the vast majority of its implementation uses PID controllers, raising the utilization rate up to 90% [6], according to different authors. Their use continues to be very high for different reasons such as ruggedness, reliability, simplicity, error tolerance, etc.


Introduction
In the area of control engineering, it is necessary to work in a continued form in obtaining new methods of regulation to remedy deficiencies that already exist, or to find better alternatives to which they were used previously, for example [1,2]. This dizzying demand of applications in control, is due to the wide range of possibilities developed until this moment.
Despite this upward pace of discovery of different possibilities, it has been impossible up to now to derail relatively popular techniques, such as the "traditional" PID control. Since the discovery of such regulators by Nicholas Minorsky in the area of automatic steering of ships [3,4] since 1922 by now, many studies on this regulator are made. It should be noted that there are numerous usual control techniques for the process in any field, where innovations were introduced, for example thanks to the inclusion of artificial intelligence in this area, [5]. Despite this, the vast majority of its implementation uses PID controllers, raising the utilization rate up to 90% [6], according to different authors. Their use continues to be very high for different reasons such as ruggedness, reliability, simplicity, error tolerance, etc.
In the conventional PID control [6,7] there are many contributions made by scholars as a result of investigations conducted on the subject,. There are many expressions among them, for obtaining the parameters that define this control, achieved by different routes and operating conditions specific for the plant that tries to control.
Emphasize that formulas developed to extract terms, which are sometimes empirical, always go out to optimise a particular specification. On the other side often happens that when one of the parameters is improved, other gets worse. We need to indicate that the parameters obtained applying the formulas of different authors are a starting point for setting the regulator. Usually it is necessary to proceed afterwards to a finer tuned test-error.
The vast majority of real systems are not linear. This occurs notably in the steering of ships, from which long time ago emerging models as the first or second order Nomoto model [8], the Norbbin model [9] or the Bech model [10]. Nowadays this feature remains a cause for study [11,12] according to their working point, certain specifications will be required to be equal in all areas of operation. Thus different values of the regulator parameters will be needed in each of these areas. Having this in mind, self and adaptive PID regulators [5,[13][14][15] are a good solution to reduce this problem. Though it should be noted that its implementation is quite difficult, expensive and closely linked to the type of process which purports to regulate, being sometimes difficult to establish a general theory in this type of PID controllers.
To alleviate these difficulties it can be applied the well-known Gain Scheduling method, which is easier to implement, and with which are obtained highly satisfactory results. The concept of Gain Scheduling arises at the beginning of the 90t's [16], and it is considered as part of the family of adaptive controllers [13]. The principle of this methodology is to divide a non-linear system in several regions in which its behaviour is linear. Thus we obtain parameters of the controller that allow having some similar specifications around the operating range of the plant.
To implement the Gain Scheduling at first it is necessary to choose the significant variables of the system according to which it is going to define the working point. Then it is necessary to choose operating points along the entire range of operation of the plant. There is no systematic procedure for these tasks. Often at first step are taken those variables that can be measured easily. The second step is more complicated because of the points that have to be selected. The system can be stable at them for the parameters of the controller deducted, but it does not have to be stable between the selected points. This problem has no simple solution, and when it exists, there is usually particularized, that is why a subject has been studied by researchers, see for example [17][18][19].
A way to solve the problem is using artificial neural networks, which is a known side of the Artificial Intelligence that is in general difficult and uses other techniques. There are some similar cases where their work is to be resolved by this technique [20,21], as well as other techniques of artificial intelligence [22,23]. As it will be shown throughout this document, the use of the proposed method may be feasible in many cases.
This document is structured starting with a brief introduction of the topology of PID controller, which it is used to show an explanation of the method proposed above. Then is exposed a description of its application to the model of a ship, which is a non-linear system, to carry out the steering control with the proposed methodology. That is applicable in different steering models of existing ships regardless of the complexity. It ends with the validation of the method, making simulations under different conditions.

The PID controler
There are multiple representation forms of PID controller, but perhaps the most widespread and studied is the one given by the equation 1 where u is the control variable and y is the control error given by e = YSP − y (difference between the reference specified by the input and the output measured in the process). Thus, the control variable is a sum of three terms: the term P, which is proportional to the error, the term I, which is proportional to the integral error, and the term D, which is proportional to the derivative of error. The controller parameters are: the proportional gain K, the integral time Ti and the derivative time T − d.
There are multiple ways for the representation of a PID controller, but to implement the PID controller used and defined in the formula above, and more commonly known as the standard format [6,7], shown in representation bloc, it is shown in Figure 1. There are infinite processes that exist in industries whose normal function is not adequate for certain applications. The problem is often solved by using this controller, by which the system is going to obtain certain specifications in the process control leading them to optimal settings for the certain process. The adjustment of this controller is carried out by varying the proportional gain, and the integral and derivative times commented in its different forms.

Adjustament methods of parameters controller with gain scheduling
On many occasions this method is known as the process dynamic changes with the process operating conditions. One reason for the changes in the dynamic can be caused, for example, by the well-known nonlinearities of processes. Then it will be possible to modify the control parameters, monitoring their operation conditions and establishing rules. The methodology will consists of first application of Gain Scheduling, analyzing the behaviour of the plant in question at different points of work and establishing rules to program gains in the controller, so that it will be possible to obtain certain specifications which remain, in the possible extent, constant throughout the whole range of operation of the process. This idea can be schematically represented as shown in Figure 2.
The Gain Scheduling method can be considered as a non-linear feedback of a special type; it has a linear controller whose parameters are modified depending on the operation conditions, with some rules extracted and previously programmed. The idea is simple, but its implementation is not easy to carry out, except in computer controlled systems. As it is shown in Figure 3, operating conditions that indicate the working point that is the process, with the specific rules learned, program in the controller, the parameters selected.

Implementation with neural networks instead of the knowledge base tuning rules
The replacement of the rules that define the gains of PID controller based on the working point system is raised by a neural network whose inputs are the operation conditions of the plant, and as outputs it will have the parameters of PID controller (K, Ti and Td). The neural network used is a network type MLP (Multi Layer Perceptron) with a similar topology to the one shown in Figure 3.  It is possible to raise several simple neural networks for each parameter instead of one, in which all of them have as input, the system conditions but the output is the controller parameter in each case.

Nomoto model of ship-steering process
To analyze a ship's dynamics as a Nomoto model it is convenient to define a coordinate system as indicate in figure 4.
From equation 2 is determinated the transfer function from rudder angle to heading in the equation 3. where, The parameters K 0 and T i0 are parameters of ship model. In many cases the model can be simplified to equation 5. where, This model is called the first order Nomoto model of a ship. Its gain 'b' can be expressed approximately as expression 7.
where ′ D ′ is the displacement (in m 3 ), ′ A ′ is the rudder area (in m 2 ) and ′ c ′ is a parameter whose empirical value is approximately 0.5. The parameter ′ a ′ will depend on trim, speed and loading and its sing may change with the operating conditions.

System used to verify the proposed method
To illustrate the method proposed in this document for the automatic steering of ships, it is going to be applied to a freighter with 161 meters of length, which displacement will range from 8,000 m 3 in the vacuum until the 20,000 m 3 full load. The velocity at which will be able to navigate will be more than 2 meters per second, for which is perfectly valid the model used, to 8 meters per second maximum velocity. It is necessary to specify that the Servo-rudder operates at a speed of 4 meters per second limited to ±30 degrees, according to this description the model shown in Figure 5.
It will be replaced the fixed values commented, where it should be pointed out for the case of the freighter, that the parameter a 0 has a value of 0.19 and the variable will be replaced in each case as necessary.
To carry out the simulations and to achieve the desired data for implementing the proposed model, it is used Matlab/Simulink. For which it is edited in the first place the following control scheme based on descriptions made previously, shown in Figure 6. The PID block houses, the scheme shown in Figure 7, whose structure is as the one explained at the beginning of the document, in which it should be noted for a better approximation to the real system, the congestion at the output of the block adder. The servo-rudder block has inside, the diagram of figure 8, which is neither more nor less than the diagram of the Servo of Figure 5 in Simulink format.

System operation conditions
The operation conditions of the system are infinite therefore certain values have to be chosen. It makes no sense to obtain parameters for multiple cases so it is necessary to make a coherent estimate to achieve good results. One approach is to choose a reasonable amount of equidistant values and observe the changes of the parameters for each case. If there are substantial changes from one value to another then an opportunity of taking new intermediate values between them will be provided.
There are own terms of the ship that will not vary as can be the area of the rudder. In this case, the only term that will define the operation conditions or gains adjustment rules of the controller, are the displacement and the velocity of the ship. It is necessary to highlight that the displacement is not going to be obviously a property that is constantly changing as can do the velocity, even if it is in a slow way. Taking into account the above and the ranges of values that can take each of the two parameters from which the model depends on, it is established the Table 1

Obtaining the controller parameters for each operation status
In the stage of obtaining the parameters of different working points, in the control implementation by the scheduling of the virtual controller instead of PID controller in parallel could be selected a hysteresis block. This is an attempt to obtain the controller parameters using the Relay Feedback method and it will be discussed in a summarized form.

Relay-feedback method
This is an alternative way to the chain closed method of Ziegler-Nichols [24][25][26][27][28], for the empirical location of the critical gain (K c ) and the period of sustained oscillation (T c ) of the system. It uses of the method of relay (Relay Feedback) developed by Aström and Hägglud [13,29], which consists in leading the system to the oscillation state by the addition of a relay as it is shown in Figure 9. This oscillation taken from the system has a period with approximately the same value as the period of sustained oscillation Tc (critical period). In the experiment it is recommended to use a relay with hysteresis which characteristics like the one shown in Figure 10 with an amplitude d and a width of the hysteresis window h.
After the assembly is done, it will proceed as follows to get the parameters mentioned: 1. Leading the process to put the process in steady state, with the system regulated by the PID controller, with any parameters that let us achieve that status. It will be taken note of the control signal values and the output of the process in those conditions.
2. Then the control is finished with the relay, instead of the PID controller. As a set point it is given the value read in the output of the process in the previous step. It is introduced in the input shown in Figure 7 as the Offset, the control signal value taken in the previous paragraph which is necessary to put the process in steady state.
3. The process is situated into operation with the indications made in the previous paragraph, and it is expected to become regular in the output (in practice it can be considered to have reached this state when the maximum value of the output repeats the same value for at least two consecutive periods).
4. It will be noted down the two parameters shown in Figure 11, where T c is the sustained oscillation period.
5. The critical gain of the process is determined by expression 9. The Relay Feedback has the advantage that adjustment can be made on the set point and it can be carried out at any time. However, a problem is that to tune, the process must exceed the set point on several occasions and there could be cases in which this is inadvisable because of the damage they can cause during the process.

Obtaining the parameters T c and K c
In the particular case shown in this paper, there is no need to implement the hysteresis mentioned in the explanation of Relay Feedback with a window, because works with a relatively slow system. Instead, a simple comparator as the one shown in Figure 12 will be sufficient. d -d Figure 12. Hysteresis for the plant tested Logically the value of h is zero and the value of d is 0.5. It is established as set point a value of 0.5, and the offset for this case is not necessary because it would be zero. Under these conditions the system becomes operational, and the result obtained is shown in figure 13.
It is necessary to pay attention to the final zone, where the oscillation is now stabilized and periodic, and with the expressions commented above for the Relay Feedback method, the extracted parameters are T c and K c .

Obtaining the PID controller initial parameters
With the parameters that have been obtained in the previous paragraph, it is possible to get the controller parameters applying direct formulas, achieving the three terms of the regulator.  In this case it will be necessary to obtain them for a criterion of changes in the load (for load disturbances rejection).
Taking this into account the expressions to tune controllers in closed chain of Ziegler-Nichols will be applied. They are the pioneer formulas for obtaining controller parameters, and they are good at changes in the load. The specification that it is trying to obtain is a list of overshoot of a quarter decay ratio, which means that in the face of the input of a disturbance, the successive overtopping of reference, are four times lower than the previous one (damping factor of 1/4) . Such expressions are shown in Table 2.

Fine tuning of the controller
The parameters obtained in the preceding paragraph would be necessary subject to a fine-tuning, because the results reached are not suitable.
In this most delicate task of adjustment it is necessary to indicate that it should not saturate the output controller at any time. It is necessary to reach a compromise, since an excess of proportional gain causes a fast response in the output and with little overshoot, which apparently is ideal, but under these conditions the servo is constantly fluctuating, which will cause it to deteriorate in a short period of time. As conclusion, it is going to search gradual outputs, without saturation or sudden changes such as the case shown in Figure 14. It is necessary to indicate that for this model the method of adjusting parameters Ziegler-Nichols is not the ideal, since the initial values of the parameters do not give good results, differing greatly from those achieved after fine-tuning.

Parameters obtained for each case
Taking all the comments above into account all the comments above we obtain the controller parameters fine-tuned for each of the cases discussed above, which seeks a criterion of minimum overshoot and maximum speed for the restrictions presented in the preceding paragraphs. In this way we reach the parameters of the table 3.

Implementation of the neural network
It has been designed a neural network type MLP (Multi Layer Perceptron) for scheduling of each one of the controller constants K, T i and T d . They all have two inputs, which are the displacement and the velocity of the ship, and one output that is the corresponding constant.
The neuronal network has an intermediate layer with 5 neurons for K and 6 for T i and T d . This structure has been adopted after many tests with different numbers of neurons in the middle layer (tests were made from 4 to 9 neurons in the middle layer) for each of the neural networks. The activation functions of neurons in the middle layer are a kind of hyperbolic tangent, except in the output layer, where one neuron is with a linear function.
Once this configuration is selected it is shown the different characteristics of the training carried out with backpropagation learning. It has been made the training of K, T i and T d at 531, 705 and 686 respectively epochs, with an average error at the end of the training less than 1%. The artificial neural networks have been trained off-line, although the checking of its proper operation has been performed on line.

System assembly and verification of results
It is implemented in Simulink ( Figure 15) the system diagram. If it is compared with the model used for obtaining the controller parameters in the different representative points of work, it is possible to observe that the relay block , has been eliminated, and the PID controller has been replaced for a block, which name is Neuro-PID.
The internal diagram blocks of the Neuro-PID controller, is shown in Figure 16 in the format that has been implemented in Simulink.
As it is shown in Figure 16 a PID controller is implemented where the earnings are the outputs of the artificial neural networks and which inputs are the displacement and the By this way, the implemented controller will choose the most appropriate parameters for the area in which it is working. It should be noted that more points could be obtained to train neural networks, but it would be more expensive. Furthermore, the neural network itself follows the tendency of data, already interpolates properly between them, showing one of the advantages of its use.
To validate the model created it is resorted to its simulation with different values of the parameters, on which depend the velocity model and displacement.
It has been made different tests at multiple points of work, and in Figure 17 is shown four representative examples in which in all cases is made a steering to -5ž and once stabilized to +10ž.The answer is satisfactory and similar in all cases with the only difference in velocity due to the different velocities. It should be noted that at small velocities to get an adequate response of the steering, similar to the one of the entire range, it is necessary to saturate the After the results achieved, it is pointed a satisfactory behaviour of the implemented system, in which the desired results of uniformity are achieved in the operation, regardless of conditions, from which depends the model of the ship.

Conclusion
Obviously, in non-linear systems, such as the case of the steering a ship studied in this document, and also working across a wide range of operation, and that could be divided in zones with a linear behaviour, in which the control is also feasible using a type PID controller, the option of its use with the method proposed in this paper is an option to take into account.
As an alternative to the different types of autotuning PID's one of the easiest solutions is the one developed in this article. It is necessary to accentuate that it is not an easy solution to adopt, especially with continuous controllers, but with the addition of programmable control devices this labour becomes comparatively simple.
Emphasize that difficulties in the use of PID controllers working with Gain Scheduling, have the problem of taking those points which are significant, interpolation between them and also could happen that the system is stable at selected points but not between them. With the use of artificial neural networks all these drawbacks are softened to a large extent, since all of them are solved with the use of this aspect of artificial intelligence.
This methodology provides a uniform response of the system throughout the whole operating range of the ship, regardless of displacement, or the velocity, parameters of which the model depends on. If this depends on other factors, the methodology could be applied equally to them.