Intention modelling and inference for autonomous collision avoidance at sea

—The open wording of the trafﬁc rules of the sea, COLREGS, and the existence of unwritten rules, make it essential for an autonomous ship to understand the intentions of meeting trafﬁc. This article uses a dynamic Bayesian network (DBN) to model and infer the intentions of other ships based on their observed real-time behavior. Multiple intention nodes are included to describe the different ways a ship can interpret and conﬂict with the behavioral rules outlined in CORLEGS. The prior distributions of the intention nodes are adapted to the current situation based on observable characteristics such as location and relative ship size. When a new observation is made, the probability distributions of the intention variables are updated by excluding all combinations of intention states that conﬂict with the observed behavior. This way of modeling makes the intention probabilities independent of how often observations are made. The resulting model is able to identify situations that are prone to cause misunderstandings and infer the state of multiple intention variables that describe the behavior. Different collision avoidance algorithms can use the resulting intention information to better know if, when, and how to act.


I. INTRODUCTION
When navigating at sea, understanding the intentions of other ships can be crucial for avoiding accidents [1]. Blindly assuming that the other ship will follow the traffic rules put forth by the Convention on the International Regulations for Preventing Collisions at Sea (COLREGS) [2] is insufficient as shown in [3]. They demonstrated the existence of local unwritten rules and agreements between captains that went contrary to the rules specified by COLREGS. Furthermore, COLREGS is open to disagreements making it unsafe to act only based on your own interpretation of the situation [4], [5]. For an autonomous ship to safely operate in these conditions, it is essential that the ship can pick up on the intentions of meeting traffic.
A large variety of ship collision avoidance algorithms exists in the literature [6], [7]. Most algorithms that consider COLREGS handle ships that do not fulfill the traffic rules by always executing evasive actions when the ships get close Manuscript submitted for possible publications. The work is sponsored by the Research Council of Norway through the Center of Excellence funding scheme, project-number 223254, AMOS, throught the FRINATEK funding scheme, project-number 274441, UNLOCK, and through the MAROFF funding scheme, project-number 295033 The authors are with the Center for Autonomous Marine Operations and Systems (AMOS), Department of Engineering Cybernetics, Norwegian University of Science and Technology, Trondheim, Norway (e-mail: sverre.v.rothmund@ntnu.no; trym.tengesdal@ntnu.no; edmund.brekke@ntnu.no; tor.arne.johansen@ntnu.no). enough. In [8] this is handled by having a separate shortterm controller, in addition to their COLREGS compliant controller, which disregards COLREGS when the ships are close enough. A different approach is taken in [9] where they have a separate collision risk and COLREGS compliance penalties. The collision risk penalty increases when the ships get closer, ensuring that an evasive action will be taken even if it conflicts with COLREGS.
A different approach is taken in [10] where they instead simulate multiple possible future trajectories the meeting traffic can take. The probabilities of the different trajectories are based upon the likelihood that the meeting traffic has different intentions, such as being COLREGS compliant. This enables the collision avoidance module to take early and substantial actions if the intentions are uncertain or if it becomes apparent that the other ship does not act according to the rules. [10] does not consider how these intentions can be identified.
Different methods exist for identifying the intentions of other ships [5], [11], [12]. [11] presents a method to identify whether the give-way ship is doing an evasive action or not. [12] presents a Bayesian model that evaluates the probability that the other ship follows its obligations as specified by COLREGS based on its observed motions. [5] develop a scoring system to evaluate to what degree different ships follow COLREGS. This method is designed to evaluate different collision avoidance algorithms but can also be used online to evaluate how well other ships are acting in accordance with the rules.
These articles [5], [11], [12] evaluate whether the other ship is acting as expected based on the own-ships interpretation of the situation. They do not model the underlying causes making the ship not act as expected. These underlying causes could, for example, be a disagreement of the situation or one of the ships having priority over the other.
Works on intention modeling exist for air traffic [13], [14], road traffic [15], and for robot pedestrian interactions [16], [17]. These works show different ways of inferring the goal, behavior, or trajectory of the other agents in the encounter. Only [17] consider underlying causes that affect how an agent acts. They use information on whether a pedestrian is alone or in a group to affect the prior probability that it will hurry over at a flashing green light.
The present article uses a dynamic Bayesian network (DBN) to model and infer the intentions of other ships at sea. Different intention variables are defined based on the different ways ships can interpret and conflict with the behavioral rules specified by COLREGS. The DBN combines these intention variables with a behavioral model based on COLREGS Rule t=0 t=1 t=2 The contribution of this article and novelty compared to earlier literature is the ability to model the underlying causes for how a ship acts and the ability to identify the state of multiple different intention variables. Modeling the underlying causes enables the model to identify situations that can cause misunderstandings, making it possible to take early actions to avoid a potentially dangerous situation. Furthermore, it enables the model to adapt to the current situation by letting situational information, such as relative ship size and location, affect the intentions. Being able to infer the state of multiple intention nodes enables the model to describe the future motion of meeting traffic with higher accuracy. The resulting intention probabilities can be used for collision avoidance with algorithms that explicitly consider the intentions [10] or as decision criteria replacing the static distance deciding when to always act to avoid collision [8].
The rest of the article is structured as follows. Section II give background information on Bayesian networks. Section III presents the proposed DBN which is demonstrated in section IV. The results are discussed in section V and a conclusion is given in section VI.

II. BACKGROUND
Bayesian belief networks are directed acyclic graphs (DAG) that model probabilistic relations. These networks consist of nodes that can be in a discrete set of states and arcs that define dependencies between nodes. An arc points from a parent node to a child node. Conditional probability tables (CPT) are supplied for all nodes and define the probability of the node being in a particular state as a function of the states of its parent nodes. If the nodes do not have a parent node, then the CPT defines the prior distribution of that node.
The different Bayesian probability laws are used to evaluate a node's probability distribution, given some evidence. Evidence is the set of knowledge about the state of one or more nodes. If this knowledge is uncertain, then virtual evidence can be used. Virtual evidence specifies the probability of observing this particular observation, given the state of the node. A state unlikely to result in the observation will be given a low probability, while one likely to result in the observation will be given a high probability. A thorough explanation of virtual evidence can be found in [18].
BBNs can be made dynamic by repeating some or all of the nodes for each time step. Figure 1 shows an example of the resulting dynamic Bayesian network (DBN). DBNs make it possible to model how a system develops over time. The DBN can consist of time-independent nodes as well as timedependent nodes. Time-dependent nodes can depend on nodes in previous time-steps, nodes in the current time-step, and time-independent nodes. Time-independent nodes can only depend on other time-independent nodes.
Software libraries such as [19] include different general solvers for evaluating DBNs and natively support the use of virtual evidence. More information on BBNs and DBNs can be found in [20] and [21].

III. METHOD
This section presents a Dynamic Bayesian Network (DBN) used to model and infer the intention of meeting ships. The term intentions will be used for a ship's internal states that determine its behavior in different situations. Examples of different intention variables are what the ship considers a safe distance, what priority it thinks it has relative to the other ships, and what it thinks the COLREGS situation is.
The DBN model takes the perspective of a single ship, which will be called the reference ship, and models its relation to all other ships in the area. To model multiple ships, the model must be run independently for each ship. How to run the model is described in section III-A.
Each of the intention variables are modeled as nodes in the DBN. These nodes are stochastic variables as the intention is unknown. The intention nodes are modeled as timeindependent nodes as it is assumed that the intentions do not change within one collision encounter. The prior distribution of the intention nodes describes how often the different intentions are encountered in situations similar to this one. How these priors are designed is described in more detail in section III-D.
The DBN evaluates the probability that a particular combination of behavior and intention node states are compatible. Which combinations that are compatible are based on COLREGS and are described in section III-B using logic statements. How these can be translated into CPTs is described in section III-C.
When a behavior is observed, it is inserted as evidence on different measurement nodes in a new time-step of the DBN. These measurement nodes are time-dependent, thereby enabling the system to combine information over time. The  probability distribution of the intention nodes are updated to take these observations into account by inserting further evidence specifying that the intentions and observed behavior are compatible at this time step. Evaluating the network with this evidence eliminates all combinations of intention node states that contradict the observed behavior. How to use the updated probability distribution of the intention nodes for collision avoidance is discussed in section III-E. Modeling whether a particular combination of behavior and intention node states are compatible enables the system to gradually infer the reference ship's intentions without considering how often observations are given to the system. Giving the same observation multiple times to the system will not affect the probability distribution of the intention nodes, as the first observation has already eliminated all combinations of states that the second observation eliminates.
A simplified example can illustrate this procedure. Fig. 2 shows a simplified network with two intention nodes, one indicating what time until closest point of approach (CPA) the reference ship considers as ample time to give way, the other whether the reference ship is planning to follow its obligation to give way. When an observation is made, the following evidence is inserted: time until CPA, which role the reference ship has according to COLREGS, and whether the reference ship has given way. The intention probabilities can then be updated by inserting further evidence stating that the "Behavior compatible with intentions" node is in the state "true". If it is observed that the time until CPA is 10 minutes, the reference ship has a give-way role, and has not given way, then the model can exclude the possibility that the ship intends to follow its obligation to give way and that it considers ample time to be more than 10 minutes. It is left with the possibility that it will not follow its obligations at all or that it considers ample time to be shorter than 10 minutes. For this example, the network evaluates the probability that the reference ship does not intend to give way to be 47%. This is due to the prior likelihood that the reference ship will give way at a short distance (0.01 + 0.05 = 0.06) is similar to the prior likelihood that it will not fulfill its obligations (0.05). This simplified example is unable to model the underlying causes defining how a ship should act. The rest of this section handles this by building a model based on the behavior specified in COLREGS.

A. Basic procedure
For every new observation: 1) Insert information from the observed behavior as evidence on the measurement nodes 2) Insert evidence stating that the observation must be compatible with the intention states 3) Evaluate the updated probabilities for the different intention states 4) Expand the network with a new time-step

B. Course applicability logic
This section presents a series of logic statements that define which combinations of intentions and behavior that are compatible. These statements are based on the behavioral rules specified by COLREGS Rule 7, 8, 11, and 13 to 18. Rules regarding traffic separation schemes (Rule 10), narrow channels (Rule 9), and sailing vessels (Rule 12) are not considered in this article.
The different intention variables of the reference ship are given in What COLREGS situation the reference ship thinks it has towards ship i "OT ing"/"OT en"/ "HO"/"CR PS"/ "CR SS" I GS Whether the reference ship acts according to good seamanship binary I P i Relative priority the reference ship has to ship i "higher"/"similar"/ "lower" Current COLREGS situation reference ship has towards ship i "OT ing"/"OT en"/ "HO"/"CR PS"/ "CR SS" Current distance between the reference ship and ship i real valued Distance between reference ship and ship i at CPA assuming both will keep their current course and speed real valued How far the reference ship crosses in front on ship i. This value is set to ∞ if the ship does not cross in front of ship i real valued Distance at CPA to the current midpoint between the reference ship and ship i assuming constant course and speed real valued Whether reference ship has passed ship i binary Time until CPA between reference ships and ship i assuming both will keep their current course and speed real valued Whether the reference ship will pass aft or in front of ship i if both keep their current course and speed "Aft"/"Front" Change in course towards ship i "starboard"/ "straight"/"port" Change in speed towards ship i "higher"/ "none"/"lower" Good seamanship towrads ship i binary Gives way correctly towards ship i binary Initial course when the situation started towards ship i. Course is given in the NED frame.
real valued Initial speed when the situation started towards ship i real valued There has been a port action to- There is currently a risk of colli- It is a risky situation towards ship i binary Stands on correctly towards ship i binary The reference ship will cross at a safe distance towards ship i -Compatible towards ship i: A behavior is compatible with the intention states towards ship i if either of the following is true: • The collision avoidance situation has not started yet. • The ships have passed each other safely • The ships will pass each other in such a manner that it is not a risky situation.
• If the reference ship has a give-way role and gives way correctly. • If the reference ship has a stand-on role and stands on correctly.
SS i [t] -Situation started: According to COLREGS Rule 11, the behavioral rules only apply for ships in sight of each other. COLREGS Rule 3 specifies that a ship is in sight if it can be seen visually. At what distance the reference ship sees ship i is unknown and modeled with the intention variable I SS . The situation starts whenever the distance between the ships is shorter than the situation start intention.
-Risk of collision: Actions to avoid collision are only needed if the reference ship considers that there is a risk of collision (COLREGS Rule 7, 12, and 14). According to COLREGS Rule 7(i), a risk of collision exists if the compass bearing from the reference ship to ship i "does not appreciably change" [2]. How much change that is sufficient would depend on the distance between the ships, as one would experience a quicker bearing change once the ships get closer. To simplify this requirement, the expected crossing distance assuming both ships will keep their current course and speed is used to evaluate whether there is a risk of collision. The acceptable distance when crossing in front can be lower than what is acceptable to the side of the ship. This is handled by defining two different intention variables, one specifying how far in front of a ship the reference ship considers it risky to cross (I RCF ) and one specifying the distance at CPA that is considered risky (I RC ).
-Risky situation: If there is a risk of collision at one point of time after the situation starts, then the situation should be considered as risky until the ships have safely passed each other.
P i [t] -Safely passed: If ship i is passed and is at a safe distance, then the reference ship does not need to consider the ship any longer.
-Stands on correctly: The reference ship stands on correctly if it does not change its course or speed, or if it is forced to change its course or speed by another ship it has a give-way role for (Rule 17).
GWC i [t] -Gives way correctly: The reference ship gives way correctly if it is executing a correct evasive maneuver. According to COLREGS Rule 8, the ship must take evasive actions in what it considers "ample time". The ship is allowed to keep its course and speed and to evade other ships before what it considers "ample time". The ship must give way after "ample time" has passed.
-Correct evasive maneuver: For an evasive maneuver to be correct, it must comply with "good seamanship" (COLREGS Rule 8) if the reference ship has an intention to act with "good seamanship" (I GS ). Additionally, the maneuver must fulfill the requirements specified by COLREGS if the reference ship has an intention to follow COLREGS (I C ). COLREGS specify a set of scenarios and how to act in each scenario. These consist of overtaking (OT ing, Rule 13) another vessel, being overtaken (OT en, Rule 17), head-on (HO, Rule 14), crossing with the other ship on the starboard side (CR SS, Rule 15), and crossing with the other ship on the port side (CR PS, Rule 17).
-Safe distance: According to COLREGS Rule 8, actions to avoid collision shall result in the ships passing at a safe distance. Whether the reference ship and ship i will pass at a safe distance is evaluated by assuming that both ships will keep their current course and speed. This assumption holds for ship i if it has a stand-on role, as stand-on ships are required to keep their course and speed (COLREGS Rule 17). If the reference ship has a give-way role, then it is expected to mark its intent by substantially changing its course or speed (COLREGS Rule 8) and then gradually return to the initial course. Assuming that it will keep its course and speed should result in passing at a safe distance if the ship has started to act to avoid collision. As with risk of collision (RC i [t]), different intention nodes are included for a safe distance when crossing in front and safe distance at CPA.
-Correct overtaking evasive maneuver: COL-REGS Rule 13 specifies that an overtaking vessel shall keep out of the way of the vessel being overtaken. Checking that the ships are crossing at a safe distance is therefore sufficient.
C HO i [t] -Correct head-on evasive maneuver: For headon situations, COLREGS Rule 14 specifies that the ships must pass each other on the port side. Both ships have to give way in this situation, making the assumption that ship i will keep its current course unrealistic. Instead, a new measurement is used that evaluates the closest distance the reference ship will have to the current midpoint between the ships, assuming the reference ship will keep its current course and speed. Only the distance to the midpoint from the ship's port side is considered. This makes this measurement equal to 0 if the ship passes the midpoint on the wrong side. Requiring the ships to keep a safe distance to their current midpoint force both ships to make an evasive action, even though the other ship has already started to act.
C CR SS i [t] -Correct crossing starboard-side evasive maneuver: In a crossing situation, Rule 15 of COLREGS specifies that a ship should, in addition to cross at a safe distance, avoid crossing in front of another ship it has on its starboard side.
C CR PS i [t] -Correct crossing port-side evasive maneuver: If a ship with the other on its port side is forced to take action, then COLREGS Rule 17(c) specifies that it should avoid altering its course to port.
M CS i [t] -COLREGS situation: According to COLREGS Rule 13(b), a ship is overtaking another when it is coming up on the ship "from a direction more than 22.5 degrees abaft her beam" [2]. Uncertainty in the heading of the other ship can lead to different interpretations of the situation. Uncertainty in whether it is an overtaking situation is modeled by using the classifier as shown in Fig. 3.
A head-on situation is defined by COLREGS Rule 14(a) to be when two vessels are meeting on "nearly reciprocal courses", while Rule 14 (b) specifies when a head-on situation exists based on the visibility of different lights of the other ship. This opens up for disagreements from different definitions of "nearly reciprocal" and how the ships observe each other. With the presence of current and winds, a ship observing the course of the other by radar or AIS might come to a different conclusion than one observing the heading of the other ship based on the visibility of lights [5]. Furthermore, measurement uncertainties in the course of the other ship can lead to misunderstandings. The classifier shown in Fig. 4 is used to accommodate this uncertainty. The probability that the reference ship evaluates the current situation as an overtaking or head-on situation is based on the two classifiers given in Figs. 3 and 4. The remaining probability gives the probability that the reference ship evaluates the situation to be a crossing situation. Whether the reference ship is in front or back of the other ship when the situation starts defines whether it is overtaking ("OT ing) or being overtaken ("OT en"). Whether the other ship is on the port or starboard side defines whether it is a crossing port side ("CR PS") or crossing starboard side ("CR SS") situation. This information is inserted as virtual evidence on the measured COLREGS situation node, M CS i According to COLREGS Rule 13(d), subsequent alterations in bearing do not change the situation. The situation is therefore defined when the situation starts, which can lead to misunderstandings as the different ships may define that the situation starts at different time points [4]. This is modeled by making the situation measurement node (M CS i ) equal to the situation intention node (I CS i ) at the time-step when the situation starts. At all other time-steps, the measurement is independent of the intention node. This is modeled by giving the measurement an equal probability of producing all measurements. As there are five possible measurements, a probability of 20% is specified.
R i -Role: A ship must give way if it has lower priority, either as specified in COLREGS Rule 18 or due to unwritten rules [3]. If the ship has higher priority, it must stand on. If the priority is similar, then the role is given by COLREGS Rule 13 to 15. In a head-on situation, then both ships must give way (Rule 14). In an overtaking situation, the overtaking vessel must give way (Rule 13). In a crossing situation, the one with the other ship on its starboard side must give way (Rule 15).
if I Pi == "lower" ∨ I Pi == "similar" ∧ (I CS i == "HO" ∨ I CS i == "CR SS" ∨ I CS i == "OT ing") "SO" otherwise (15) GS i [t] -Good seamanship: Good seamanship is difficult to define and can contain many different behaviors. In this article, good seamanship restricts the ship from changing which side it turns towards to avoid collision. The ship is not allowed to have made both a starboard action (SA) and a port action (PA) during a collision encounter.
CIC i [t] -Change in course: A change in course is evaluated by comparing the initial course with the observed course. The initial course is saved when the situation starts. If the change in course is less than P CIC then it is considered as keeping the course.
CIS i [t] -change in speed: The initial speed and change in speed are evaluated in the same manner as for the course.

C. Translation into DBN
A DBN is made from the logic statements given in section III-B. A node is introduced for each intention variable, measurement variable, and model variable. Arcs are introduced based on the dependencies given by the equations in section III-B. The resulting topology can be seen in Fig. 5.
The logical statements given in section III-B need to be translated into CPTs to be used by the DBN. This can be done by evaluating whether the output is "true" or "false" for all combinations of inputs. This results in CPTs consisting of 0/1 probabilities. Nodes that according to tables II, III, IV are real-valued must be discretized. A suitable range and discretization step must be defined. Some software for building and evaluating Bayesian models, such as the software GeNIe [22], allows the user to specify equations and to use realvalued nodes. The software can then automatically discretize and translate these equations into CPTs.

D. Priors
Information from the current situation, such as ship types and the type of environment, can improve the prior distributions of the intention nodes. Examples of different factors that could be considered are shown in Table VI. These influencing factors can be included as time-independent nodes that affect the intention states. Different approaches can be followed to identify factors that affect the intentions. One way is to have a workshop with experts in the field, such as experienced captains. This workshop can be similar to risk analysis workshops such as [23] and [24]. Another option is to study captains during operation as done in [3]. This has the advantage of being more correct than a workshop, but some factors might not show up during the study. A last option is to analyze historical data logged with the automatic identification system (AIS) that larger vessels are required to be equipped with [25].  This method would be more general as much more data from different ships and situations could be analyzed. It will, however, be limited to the information that is logged with the AIS, which does not necessarily include all factors that could be of interest. A combination of the three approaches is preferable to maximize correctness and completeness. The same methods can be used for quantifying how the intention nodes are affected by the identified factors. AIS data could be used to build prior distributions on, among others, how far before CPA different types of ships tend to give way and how close they tend to be at CPA. This information could be supplemented with data from operation studies and expert judgment to model how factors not included in the AIS affect the distribution. Different methods for building CPTs based on expert information are analyzed in [26].
Performing a thorough identification and quantification is outside the scope of this article. For simplicity, all of the influencing factors, except for relative ship size, are limited to be in a single state. Relative ship size is allowed to vary to demonstrate the effect priors have on the intention model. Which states the influencing factors can be in are shown in bold font in table VI. Table VII shows the quantification used to produce the results presented in section IV.

E. Using the intentions
This section presents two different ways of using the evaluated intention probabilities for collision avoidance.
Decision criteria: The first approach considers whether the own-ship should consider the reference-ship in the collision avoidance algorithm. Collision avoidance algorithms similar to [8] do not need to consider the reference ship if the ownship has a stand-on role, and the reference ship is planning to give way. A new node can be introduced into the network to evaluate whether the reference ship is planning to give way  or not. A threshold can be proposed that defines how likely it must be that the reference ship will give way for it to be safely ignored by the collision avoidance algorithm. The node representing whether the reference ship is planning to give way depends on whether the reference ship has a give-way role and if its definitions of ample time and safedistance are acceptable. Additionally, the reference ship is assumed not to give way if it acts in an unmodeled manner. Equation 24 shows the logic statement that defines whether the ship will give way towards ship i (WGW i ).
Candidate trajectories: The second approach evaluates whether a candidate trajectory for the reference ship is compatible with its intentions. Measurements can be evaluated based on the candidate trajectory and inserted into the network. Evaluating the network with these measurements will give the probability that this trajectory is compatible with the reference ship's intentions (C[t]). These candidate trajectories with corresponding probability can be used in collision avoidance algorithms similar to [10] Minor alterations are needed to evaluate the measurements based on trajectories. The distance at CPA to another ship (M DCPAi ), distance at CPA to their current midpoint (M DM i ), crossing in front distance (M DF i ), and the crossing side (M Si ) is evaluated by using the candidate trajectory of the reference ship while assuming that all other ships in the encounter will keep their course and speed. The current course (M C ) and speed (M S ) must be evaluated a bit into the candidate trajectory so that the ship has time to execute the potential evasive action. If the situation has not started, then a trajectory keeping the course and speed will be wrongly given a high probability. This is avoided by setting the current distance (M Di [t]) to zero. The time until CPA (M TCPAi ) is not relevant for the candidate trajectories as the entire future motion of the ship is considered as known. Instead, this measurement is set to the minimum acceptable time (AT min ). An intention to give way at a shorter time than acceptable will evaluate a high probability for trajectories that keep the course and speed. This makes the collision avoidance algorithm take evasive actions if it is likely that the reference ship will give way at an unacceptable short time before CPA. The rest of the measurements can be evaluated as usual.
There are many different ways of generating candidate trajectories. This article generates trajectories based on lineof-sight guidance, as proposed in [9]. These trajectories are generated by simulating a simple ship model that uses a line-of-sight guidance rule to evaluate a reference course that gradually converges towards the intended path [27]. Adding different constant offsets to the reference course generates different trajectories that quickly move away from and then align parallel to the original course. Figs. 6 to 12 shows the resulting trajectories with a constant offset in speed or course. All the trajectories assume that evasive actions are done at the current time-step and not at future time-steps. This assumption can be acceptable for collision avoidance, as it is enough to know if the other ship will give way in time and to what side it will give way.

IV. RESULTS
This section presents different simulation scenarios that demonstrate the capabilities of the intention model. For each scenario, the probabilities of the different candidate trajectories being compatible with the reference ship's intentions (C [t]) are presented. The probabilities for all trajectory candidates do not need to sum to 1 as there can be multiple trajectory candidates that are compatible with the intentions of the reference ship. The DBN is in each scenario evaluated using the SMILE [19] library for C++. A separate instance of the model is run for all ships in the encounter.

Scenario 1 -Gradual inference
This scenario demonstrates an ability to identify the intentions based on observations. Fig. 6 shows two ships meeting on a collision course. The situation is a clear crossing situation where, according to COLREGS Rule 15, the blue ship is responsible for giving way while the red should stand on. The model evaluates a 93% chance that the blue ship will give way (WGW ) and a 6% chance that the red ship will give way. The blue ship can give way either by reducing its speed or making a starboard turn. Fig. 7 show the same situation at a later time-point. As the blue ship has not yet done any action to avoid collision, it becomes more likely that it believes it has a higher priority making it not give way at all. The model, therefore, evaluates a 68% chance that the blue ship will give way. As the red ship has not changed its course or speed, it becomes less likely that it thinks it has lower priority, which results in a 1% chance that it will give way.
When the red ship starts to make an evasive maneuver, as shown in Fig. 8, it becomes more likely that the red ship acts to avoid collision. As the time until CPA is very short, it is unlikely that the red ship has such a short definition of ample time. The model, therefore, evaluates a 32% chance that the red ship acts in an unmodeled manner. The probability that the red ship will give way is evaluated to be 29%.

Scenario 2 -Uncertain COLREGS situation
This scenario demonstrates that the model identifies uncertainty in the COLREGS situation. Fig. 9 shows a scenario where the red ship is approaching the blue ship from an angle that is close to the border between an overtaking and crossing situations. The situation metric evaluates a 54% chance of it being an over-taking situation, in which case the red ship should give way to either side. The remaining 46% is evaluated as a crossing situation, in which case the blue ship should give way behind the red ship. This results in a substantial probability for both keeping the course and speed and taking evasive actions. For the blue ship, none of the candidate trajectories where course alone was changed made the blue ship cross behind the red ship at a safe distance. The only option among the candidate trajectories that gave way behind the red ship was for the blue ship to reduce the speed.

Scenario 3 -Risk of collision
This scenario demonstrates uncertainties that arise from whether there is a risk of collision (RC i ). Fig. 10 shows two ships meeting in a head-on situation. The model evaluates a 61% chance that there is a risk of collision, and a 86% chance that either ship will give way. If there is no risk of collision, then all actions that keep the ships at a risk-free distance are acceptable. Either way, making a large starboard turn is acceptable as it results in crossing as specified in COLREGS Rule 14. Fig. 11 shows the same scenario as Scenario 1 but utilizes information that the blue ship is significantly larger than the red ship. The model, therefore, evaluates a substantially larger probability that the blue ship has priority over the red, which results in a 58% chance that the blue ship will give way and a 40% chance that the red ship will give way.    Scenario 5 -Multi-ship encounters Fig. 12 shows an encounter with three ships, where the red and green ship have a head-on encounter, while the blue ship has an overtaking encounter with the red ship and a headon encounter with the green ship. If the blue ship had only considered the red ship, then it would be allowed to cross on either side of the ship. As the evasive maneuver has to be correct towards both ships, it can only change its course towards starboard.

Scenario 4 -Effect of priors
V. DISCUSSION Scenario 1 demonstrates that the model is able to infer the intentions of a ship based on its observed behavior. The blue ship did not change its course as it approached. This behavior could be explained by the blue ship having high priority or by having a short ample time. Once the ships came closer, the probability that the blue ship had a definition of ample time that was lower than the remaining time until CPA decreased. This increased the probability that the blue ship had higher priority. The red ship changed its course and speed shortly before CPA to avoid collision. Before this point in time, the model did not increase the chance that the red ship would give way as it did not give any indications of giving way. When the red ship finally changed course, the time until CPA was very short, making it quite unlikely that the red ship had such a short definition of ample time. As this behavior does not fit very well with the model, a high chance was evaluated that the red ship acts in an unmodeled way. A collision avoidance algorithm using this intention inference module should display conservative behavior when unmodeled behavior is observed. This will be the case when evaluating candidate trajectories, as all trajectories will have an increased probability of being compatible. When using the intentions as decision criteria, unmodeled behavior will count as not giving way, thereby making the own-ship give way. Scenarios 2 and 3 show different ways uncertainty in the other ships' behavior can arise. In Scenario 2, the COLREGS situation is uncertain, while in Scenario 3, the uncertainty stems from whether there is a risk of collision. Scenario 3 gives an example of a scenario where it is insufficient to consider a single parameter for collision avoidance, such as if the ship will give way. In most other situations, the own-ship must give way if the other ship does not fulfill its obligation. In this situation, the opposite is true; if the other ship fulfills its obligations, then both ships must give way. If the other ship keeps its course, then the own-ship can turn a safe situation into a potentially dangerous one by giving way with a significant starboard action, as specified in COLREGS rule 14.
Scenario 4 shows that situation information, such as the relative ship size, can be used to affect the intention probabilities. What can be considered a safe distance or ample time will vary greatly based on the location and ship size. This makes it crucial for collision avoidance algorithms to adapt their behavior to the current situation. The proposed intention model presented in this article is a step towards this ability as it gives the collision avoidance algorithm an understanding of how the other ship will act in the current situation.
Scenario 5 demonstrates that the model can consider encounters with multiple ships. The model considers whether a behavior is compatible with the intention towards all vehicles. The model does not consider that the reference ship has an idea of what the other ships plan to do. This could be that the blue ship in figure 12 predicts that the red ship will make a starboard turn and therefore takes an even larger starboard turn.
Evaluating different candidate trajectories has some advantages, such as being able to better portray situations such as the one shown in scenario 3. For the trajectories to realistically portray the other ship's behavior, there must be a candidate trajectory that adequately describes the other ship's trajectory. The candidate trajectory and actual trajectory must be close enough to result in the correct collision avoidance behavior for a collision avoidance algorithm utilizing these intentions. Choosing suitable candidate trajectories is not a trivial task. The ones used in this article cannot handle more complicated situations, such as those where the ship is unable to act at the initial time-step but can act at a later one and where the reference ships make more drastic or complicated changes in course or speed.
This article has not considered grounding risk or the COLREGS rules regarding traffic separation schemes (rule 10), narrow channels (rule 9), and sailing vessels (rule 12). Regarding traffic separation schemes and grounding risk, generating candidate trajectories will be more challenging as the trajectories must cover the ship's different options, such as following and leaving the traffic separation scheme correctly. In these situations, it might be necessary to generate the trajectories based on the current circumstances dynamically. An additional challenge arises in narrow channels due to standon vessels being allowed to change their course to follow the channel [5].
The model assumes all initial changes in course are large enough to avoid collision in themselves. This assumption does not hold if the model is fed an observation in the middle of a course change. The model can then evaluate that the ship is not standing on correct (as it changed its course), nor is it giving way correct (as the course change is too small to avoid collision). This can be handled by having a separate system that only feeds the model observations when course changes are completed or by introducing a measurement node indicating whether the other ship is currently changing its course.
The model does not explicitly consider measurement uncertainties in the course or speed of the different ships in the encounter. This should not be a problem as long as the noise is less than P CIC and P CIS . If the noise is substantial, then measurement uncertainty should be modeled as well. This can be achieved by having separate nodes representing the measured state and the measurement itself. The measurements themselves should be child nodes on the measured state, and their CPTs should describe the measurement uncertainty. This way of modeling is called the measurement idiom [20].
To have acceptable computational time, the number of timesteps in the DBN must be limited. This can be achieved with a sliding window approach where only the last couple of observations are considered. The priors for the intention nodes must be updated to represent the information that is no longer inside the window. This is done by setting the intention priors equal to what the posterior was at the last time-step that is no longer in the window. With a limited window, the frequency of new observations inserted into the model must be considered. Feeding information more often makes the window consider a shorter time span which will contain more similar observations. This will reduce the inference capabilities of the model. Feeding information less often makes the model respond to changes slower. Not all measurements need to be saved as a time-step in the DBN. The newest time-step of the DBN could be updated at a quick frequency and then only saved as a new time-step if it contained substantial new information relative to the previously saved time-steps. This should make the DBN respond quickly and keep a high inference quality with a limited window.

VI. CONCLUSION
This article presents a novel approach for modeling and inferring the intentions of other ships in a collision encounter at sea. The simulation study shows that the method is able to infer the state of different intention nodes, identify situations that are likely to lead to misunderstanding, and adapt the intention probabilities to the current situation. This opens up for new possibilities for collision avoidance algorithms. It could enable collision avoidance algorithms to act more safely and predictably as they will better understand the future motion of meeting traffic. They could become able to take early actions to turn a situation prone to misunderstandings into a clear situation where all ships agree on how to act. Lastly, it opens up for collision avoidance algorithms to adapt to the current situation, such as relative ship size and locations. This is an essential feature for collision avoidance algorithms working in multiple different situations where different tuning parameters are needed.
Possibilities for future work consist of utilizing the proposed method for collision avoidance, modeling how the situation affects the priors of intention states, expanding the model to handle land and traffic separation schemes, and practical implementation and experimentation.