Inference Engine in an Intelligent Ship Course-Keeping System

The article presents an original design of an expert system, whose function is to automatically stabilize ship's course. The focus is put on the inference engine, a mechanism that consists of two functional components. One is responsible for the construction of state space regions, implemented on the basis of properly processed signals recorded by sensors from the input and output of an object. The other component is responsible for generating a control decision based on the knowledge obtained in the first module. The computing experiments described herein prove the effective and correct operation of the proposed system.


Introduction
The importance of maritime transport in the global economy is expressed primarily by the quantity of cargoes carried by sea, currently estimated at 80%. If we assume the transport performance as a criterion, the share of maritime transport in global trade exceeds 90% [1]. The actual competitiveness of maritime transport in relation to other modes results in increasingly larger seaborne trade. Consequently, traffic intensity, tonnage, and speeds of vessels also increase. This in turn affects the level of safety of people, vessels, cargo, and the environment. In order to improve safety and increase the efficiency and competitiveness of marine transport services, more and more advanced navigational systems and equipment are installed on board ships and in land-based vessel traffic control centers. The benefits are as follows: (i) Material benefits associated with the reduction of losses and damage to and sinking of vessels (ii) Economic benefits due to lower operating costs and shorter voyage (iii) Environmental protection and prevention of environmental disasters caused by collisions of vessels carrying dangerous goods One of the typical tasks related to the safety of navigation is the problem of automatic course stabilization, consisting in automatic maintenance of the ship on a preset course under conditions of external disturbances, as well as bringing the ship automatically back on a preset course after its previous alteration. The ship's course-keeping capability is crucial, because nonoptimal control of the rudder involves the loss of average speed, covering a longer track, lengthened time of the voyage, and more fuel consumption, which in consequence raises total operating costs. The associated problem is steering gear overload that may lead to a critical breakdown. Most importantly, uncontrollable yawing, especially on waterways with increased traffic, affects the level of safety, increasing a risk of collision [2].
The history of automatic ship movement control devices dated back to the early 20th century. The invention of gyrocompass (1908, H. Anschutz), a device capable of indicating north with high accuracy, also on ships made of steel (unlike the compass), enabled the development of autopilots (1911, E. Sperry). Initially, such devices were simple mechanisms, transforming proportionally a signal from the gyrocompass into a control decision, so their designs were mostly based on the concept of the P regulator. From this period the publications [3,4] are worth noting, regarded as pioneer works in the field.
The helmsman's actions on the bridge are similar to the operation of PID controller, that is, it proportionally accounts for deviation from ship's course (term P: a proportional component), action of factors causing permanent deviation from the course (term I: an integral component), and speed of deviating from the course (term D: a derivative component). It is therefore natural that designs of subsequent autopilots usually were based on the PID controller concept, sometimes on PD controllers. Till the 1990s, the PID control method was a dominant solution, and specific examples can be found in the works [5][6][7]. Because dynamic properties of a ship are not constant (they depend on vessel type and sailing conditions), the PID/PD controller setpoints should also change, especially if the autopilot is to serve for maintaining the ship on course, as well as for course alteration to a new value. This requirement has initiated a whole range of new concepts based on the notion of space states and stochastic control theory. These solutions often make use of Kalman filter or reference model methods. Examples of adaptive autopilot designs can be found in works [8][9][10][11][12][13][14][15].
The simplest adaptive autopilots based on the PID (PD) controller concept have higher quality of control than previous solutions. However, their idea is based mainly on the linear model of object dynamics. Developments of the control theory included attempts to design autopilots operating on the basis of nonlinear control techniques. Some examples can be found in the publications [16][17][18][19][20][21][22][23][24][25].
Another solution bypassing the problem of nonlinearity is the use of computer technologies and artificial intelligence methods. The number of publications on this subject is constantly on the rise. Example references are [26][27][28][29][30][31][32][33][34][35][36]. The system herein described fits into that area of research. It is not a classic expert system, where expert knowledge is recorded in the form of rules. In the proposed solution, the knowledge is represented by properly processed signals recorded by sensors from the object input and output. The inference engine is crucial for the proposed expert system of ship's course stabilization. It consists of two functional components or modules. One of them is responsible for the construction of space states, a basis for the other module to generate a control decision.
In this original method, it is possible to overcome difficulties that occur in developing typical control algorithms for a complex and nonlinear model affected by strong external disturbances (wind, waves), while providing high quality control.

The Design of an Intelligent System of Ship Course Stabilization
The circulation of signals in the proposed expert system of ship course stabilization (course autopilot) is shown in Figure 1. In the inference engine, for a given object output y = [ , , ] (r: angular velocity, : deviation from course, and : rudder angle), a control decision is generated, that is, the preset rudder angle , on the basis of quantities retrieved from the knowledge base B . It is so determined as to stabilize the defined quantity, that is, ship's course. This process is repeated at time unit intervals Δ . Let the symmetric, closed interval ⟨ min , max ⟩ be a set of all angular velocities that the object may assume. After discretization, we obtain this set: where Δ is discretization unit, is number of elements in the set (1).
Similarly, as a result of discretization of possible values of rudder angle (i.e., the interval ⟨ min , max ⟩), we get a set: Computational Intelligence and Neuroscience 3 where Δ is discretization unit, is number of elements in the set (2).
The knowledge base contains object output signals recorded in an ordered manner (resp., angular velocity, deviation from the course, and rudder angle), depending on the discretized state of the object and discretized control decisions. The output signal is here to be understood as measurement of object state after one time unit Δ . For practical reasons, the signals may be replaced by data obtained from any complex hydrodynamic model describing the object and the impact of the environment. However, to avoid a system with an open loop, a hydrodynamic model has to be adapted by a parametric or structural method to changing conditions, on the basis of real signals recorded from the object output. An ordered record of signals may be implemented in the form of multidimensional arrays with these values: where [ , , ] is value of object angular velocity after one time unit Δ ; when at a current instant the angular velocity of the object is min + Δ , rudder angle is min + Δ , and the control decision has the form min + Δ , [ , , ] is value of object course deviation after one time unit Δ ; when at a current instant the object angular velocity is min + Δ , rudder angle is min + Δ , course deviation is equal to zero, and the control decision has the form min + Δ , [ , ] is value of rudder angle after one time unit Δ ; when at a current instant the rudder angle is min + Δ , and the control decision has the form min + Δ .
Array values (3) and linear interpolation used allow determining an object output for any initial state and any control decision in the form as elements of the set (2).
The following sections describe the inference engine of the proposed expert system, the crucial component in generating a control decision. The last section provides a proof of control system stability.

The Construction of State Space
Regions. The first of two functionally important components of the inference engine of the proposed expert system is responsible for the construction of state space regions. A proper classification of state space regions will be a basis for the control algorithm described in the next section.
The zero region 0 is therefore a cuboid with the boundary. Parameters 0 , 0 , and 0 should be arbitrarily selected so that their values are close to zero. They are thus established because the problem of ship course stabilization consists in bringing simultaneously the values of the angular velocity, course deviation, and rudder angle close to zero.
The closed th region ( Figure 2) where ∈ + is a set of object states for which there exists a sequence of control decisions not longer than , generated at time unit intervals, bringing the object state to zero region 0 .
The first region 1 will be a set of such object states for which there exists a control decision that when executed results in the object state after one time unit Δ getting to the zero region 0 . The second region 2 is the sum of the first region 1 and a set of object states for which there exists a control decision, leading to the state transition to the first region 1 after one time unit Δ . In the same way, further regions are determined. It should be noted that the so-defined process of determining regions of state spaces is finite, because a set of all possible states is a cuboid with the boundary (angular velocity, deviation from the course, or rudder angle may only take values from a certain range). So there is some max ∈ + , such that the region with this index will be a set of all possible states of the object (space of states): The boundaries of state space regions are determined ascendingly starting from the first region 1 , to the region max . It can be noticed that for preset angular velocity and rudder angle, based on the values from the arrays (3), we can determine the ranges of course deviations for which there exist a control decision that after execution will result, after one time unit Δ , in the object state being moved to the region with an index lower by one than the region under consideration. With that relationship used iteratively, we get The determination of state space region boundaries (6) should take place for each change in the array values (3). Such procedure assures the adaptation of the system under consideration to changing conditions of ship movement. min + Δ ≤ ( ) < min + ( + 1)Δ ), depending on the discrete control decisions. It should be noted that for sufficiently small time increments Δ the system will respond differently for some, not all, control decisions. This will limit the set of further analyzed cases.
The next step, made on the basis of array values (6), and with use of linear interpolation, defines the minimum indexes of regions where the object states will be found in the first step, depending on the analyzed control decisions (those, for which the system response was different after one time unit Δ ).
The generated control decision should correspond exactly with the smallest index determined in the previous step. However, this condition may prove to be inadequate, because it will be met by more than one of the analyzed control decisions. Let the set Δ mean all such control decisions. In this case, the most appropriate seems to be the decision that fulfils the condition: Condition (8), on the one hand, ensures uniqueness of the algorithm; on the other hand, it minimizes the load of the steering gear, because it minimizes the absolute difference between the current rudder angle and the control decision being generated.
The control algorithm can therefore be described in three steps: (1) Determination of the future object states depending on the discretized control decisions (2) Determining possible regions for an object state (3) Determination of the control decision satisfying condition (8) All the steps in the algorithm are sequential. The convergence of the algorithm is guaranteed by the feasibility of each step.
The idea behind the proposed control process is that at successive instants the generated control decisions will result in the object state getting to a region with a lower index. It follows that when at the instant zero the object state will be in the th region, such a control decision will be generated that at 1st instant the state object was in − 1st region, until finally in th instant the object state should be found in the zero region and remain there, which is equivalent to bringing the ship's course to the set value (9).
The idea behind the proposed control process is as follows: The automatic control algorithm is required to guarantee the stability of the system. The relevant proof concerning the presented method of control is given in the next section.

The Control System
Stability. The control system is called stable (in the Lyapunov sense) then and only then, if for every positive number we can select such a number (generally dependent on ) that a trajectory starting in a state x(0) lying inside the sphere with radius will remain inside the sphere with radius for any instant . In addition, if the condition occurs (i.e., for a time tending to infinity the control system returns to the state of equilibrium that had been disturbed), the control system is asymptotically stable. The stability of the control system near the point of equilibrium is called local stability, and the stability at any large initial conditions x(0) is called the global stability. In order to show the global stability of the control system under consideration, let for any meeting the condition (2 ≤ ≤ max , due to the definition of zero region, max (1) is any small value, which can be considered approximately as zero) where max ( ) is the maximum distance (in the sense of Euclidean metric) of the boundary of th region from the point of equilibrium of the control system (0 ≤ ≤ max ).
will be selected as follows: where min ( ) is the minimum distance (in the sense of Euclidean metric) of the boundary of th region from the point of equilibrium of the control system (0 ≤ ≤ max ).
Then the initial state of the control system, lying inside the sphere with radius , must remain inside the sphere with radius , because in accordance with the control algorithm discussed in the previous section, it cannot leave the region it was previously found in, which completes the proof of stability in the Lyapunov sense of the proposed control system.
The operating principle of the control process described in the previous section was that in the subsequent instants such control decisions are generated that, when out of equilibrium, the system returns to the zero region, that is, the point of equilibrium, which fulfils condition (10), proving the asymptotic stability of the control system.

Computing Experiments
The experiments have been made in the MATLAB/Simulink environment. A de Wit-Oppe model [37] was used as an object (vessel), incorporating the dynamics of the steering gear [5]:̇1 = 5 cos 3 − 6 sin 3 , 2 = 5 sin 3 + 6 cos 3 , where (  In order to take account of disturbances, simulations included a signal characteristic of wind-induced sea waves [5].
There were two computing experiments. Each of them consisted of simulation series comparing the operation of the proposed system to the control performed by an LQR controller. For comparison, an LQR regulator was chosen, as it is an optimal regulator for a linear stationary object. A Nomoto model was used as a ship's model for the synthesis of the LQR regulator [5]:̇3 As a quality criterion, this functional was taken: where is a coefficient greater than zero, which is interpreted as a compromise between the deviation from the course (angle of yaw) and the rudder angle (steering gear load), arbitrarily adopted here as 1.
Then the control law for LQR can be described by this formula: where = − 1 √ , 6 Computational Intelligence and Neuroscience The first computing experiment was aimed to compare the values of quality control indicator (15) measured (for a time span of 0-250 seconds) for different types of waves, for a ship with the course set on zero radians. Figure 3 presents an example simulation result for sea state 4. The charts, respectively, depict the trajectory of ship movement, the indicator of quality control, the rudder angle, and the deviation from the course in the simulation. The values of quality control indicator should be interpreted accordingly as 0.1993% and 0.0171% decrease in ship's operational speed caused by additional resistance associated with disturbances. By using the proposed method, the decrease in speed was much smaller. These results clearly confirm high quality of the proposed system operation.
In all the cases examined, the quality indicator value for a ship controlled by the proposed system was lower than in the system using an LQR controller (even if the latter is optimal for linear stationary object). The developed method allowed reducing the decrease in ship's operational speed by 0.1%-0.5%, depending on wave height. It was also observed that the control quality was improving, compared to the LQR controller, with increasing wave height.
The other computing experiment was to examine how much time it takes for the object to reach the zero region (i.e., vessel is brought on a new course), if at instant zero the course is altered from 0 radians to a new course other than zero. In other words, the test included the time of course stabilization (control time) and overshoot, in a situation of an abrupt change of the setpoint. Figure 4 presents an example simulation result obtained during the tests. The charts illustrate the trajectory of ship movement, the indicator of quality control, the rudder angle, and the deviation from the course in the simulation. In this situation, the course was changed from 0 to /4 radian. We can observe a shorter transitional period in the proposed control method. These results, like in the first experiment, confirm high quality of the proposed system.
In all the cases examined, the time to reach the zero region by a ship controlled by the proposed system was less than in case of the control involving an LQR controller. Owing to the developed method, course stabilization time was shortened Computational Intelligence and Neuroscience approximately from 5% to 40%, depending on the value of the newly defined course.
The computing experiments presented in this section clearly confirm high quality of control (ship course stabilization) of the proposed expert system. This refers to the minimization of control criterion value (15), control time, and the magnitude of overshoot at a step alteration of the ship's course. In all the cases examined, the control quality of the proposed system was higher than that of an LQR controller.

Conclusions
One of the important tasks in maritime transport, which has an impact on the reduction of transport costs and enhancement of navigation safety, is the problem of automatic ship's course stabilization. However, the main difficulties that appear in the design of efficient navigational devices are problems with developing effective algorithms implementing desired functionalities. Designing solutions that will be sufficiently effective and based on few simplifications leads to complex systems that are hard to be analyzed in a traditional manner. Hence, it seems necessary to apply computational mathematics for solving problems of marine navigation, or, in a broader perspective, maritime transport. Computational mathematics is understood here as a combination of traditional mathematical tools, characterized by strict reasoning (strict evidence) and artificial intelligence methods, additionally supported by technical capabilities of modern computers [38]. The expert system discussed herein, tasked to automatically stabilize ship's course, fits well into that area of research. By using the data on the system hydrodynamics and the original inference engine, we could bypass difficulties that occur in developing typical control algorithms for complex and nonlinear model affected by strong external disturbances (wind, waves), while providing high quality of control. This was confirmed by computing experiments.
The proposed system will be implemented in the executive module of the navigational decision support system NAVDEC [39][40][41]. The executive module combined with other modules (e.g., module of data fusion [42][43][44][45] and 8 Computational Intelligence and Neuroscience prediction module [46,47]) is part of the navigational decision support system in the process of safe ship conduct (invention [48]).
The developed system has a function of automatic ship's course stabilization. However, the methodology can be easily extended and used for solving problems of automatic ship steering along a preset trajectory. It seems that in the context of the proposed approach it is possible, for further considerations, to extend tasks and include other objects of control. Hence, the proposed methodology represents a new branch of intelligent control systems.

Conflicts of Interest
The author declares no conflicts of interest.