## 3 Traffic Model and Knowledge Discovery
```
0:\(v,WPs\) (\(i.e.,ENs,EXs,POs\)), \(Rs\)
1:// if the vessel has passed through at least two waypoints
2:if\(length(v.wps)>1\)then
3:\([wp_{a},wp_{b}]\leftarrow\)\(v.wps(end-1:end)\)
4:if\(not(Rs\{wp_{a}\_to\_wp_{b}\})\)then
5://the route from \(wp_{a}\) to \(wp_{b}\) does not exist: it is added to the \(Rs\) list
6:\(Rs\gets add(Rs\{wp_{a}\_to\_wp_{b}\})\)
7:endif
8:// update the relevant route by adding the track portion between \(wp_{a}\) and \(wp_{b}\)
9:\(timestamp_{wp_{a}}=v.timestamp_{wp_{b}}(v.wps=wp_{a})\)
10:\(timestamp_{wp_{b}}=v.timestamp_{wp_{b}}(v.wps=wp_{b})\)
11:\(Rs\{wp_{a}\_to\_wp_{b}\}.params(end+1)\leftarrow(v.track(timestamp\in[timestamp_{wp_{a}},timestamp_{wp_{b}}]))\)
12:// update the vessel list of routes
13:\(v.routes\gets add(\)'\(Rs\{wp_{a}\_to\_wp_{b}\}\)')
14:endif
15:return\(v,Rs\)
```  
**Algorithm 3**\(Route\ Objects\ Manager\)  
Differently from centroid-based clustering, DBSCAN does not require the number of clusters _a priori_, while arbitrarily shaped clusters can be easily found as often observed within the maritime traffic context. For instance, centroid-based methods can fail in discriminating different ports whose centroids are close to each other, when they are located along the coast line, as shown in Figure 2. Moreover, DBSCAN introduces a way to classify noise points, which can be used to detect and filter outliers, as will be shown hereafter. The on-line learning enables an incremental density-based clustering of waypoints. The waypoints clusters are either created, expanded and merged, following the typical procedure of incremental DBSCAN, as introduced in [37]. In Algorithm 2, the on-line clustering of \(WPs\) is illustrated, showing how the vessel object features are updated accordingly. The cluster parameters (_i.e._, the radius, \(Eps\), of the neighborhood of the event of interest and the minimum number, \(N\), of points to be detected in the \(Eps\)-neighborhood of the vessel) are tuned, based on the specific nature of the \(WPs\) (_i.e._, whether they are \(POs\) or \(ENs/EXs\) objects) and on the specific features of the monitored area. Topographically, port and offshore platform objects are represented via a spatial distribution given by the coordinates of the vessels, which contribute to create or update them. As a consequence, such objects are automatically described via a list of vessel objects and a volume of traffic. In this way, a frequency plot based on the type of vessels can be associated to each port and offshore platform object in order to help characterize the activities in the stop zones. Entry and Exit Points Manager:Another class of waypoints useful for describing the motion patterns within a selected area is represented by entry (\(ENs\)) and exit (\(EXs\)) points. Whenever a vessel object enters (leaves) the area under analysis, it generates \"birth\"/\"death\" events (corresponding to vessel status transition \"transmitting\"/\"lost\" and _vice versa_), and the relevant entry/exit point is created or updated. As in image processing and visual surveillance (see, e.g., [16]), entry and exit points are related to the monitored scene and may change depending on the bounding box area, while port or offshore platform objects are fixed reference points. Similarly to the stationary points, entry and exit points are learned through the incremental DBSCAN method and described with a list of transiting vessel objects and a volume of traffic. Algorithm 2--_On-Line WPs Clustering_ in Annex A summarizes the main steps. Figure 3 shows the results of the unsupervised waypoints detection and characterization over the North Adriatic Sea, where many routing systems are present (such as traffic separation schemes), because of the intense traffic and oil drilling activities. Route Objects Manager:Once the waypoints are learned, route objects, \(Rs\), can be built by clustering the extracted vessel flows, which connect two ports (_i.e._, local routes), an entry point to a port, a port and an exit point or an entry point and an exit point (_i.e._, transit routes).