Skip to main content
. 2021 Oct 23;21(21):7035. doi: 10.3390/s21217035
Algorithm 2: STDF IoT-based Data Fusion Manager.
Input: HashMap ‘HC’ of key: source id and value: Arraylist of data units
Output: HashMap ‘Final-HC’ of key: source id and value: 2D Arraylist of location ID & data unit
 1
 2
 3
 4
 5
 6
 7
  
 8
 9
 10
 11
  
 12
 13
  
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
  
 25
 26
 27
 Begin
  Initialize Clustered_HC as an empty HashMap//the HashMap to retain location IDs clustering results
  For each key in HC//loop for all received source IDs
  Initialize Centroids_List as an empty Arraylist
  Initialize data_units_List with the current source ID’s data units
  For each data unit ‘D’ in data_units_List//loop for all data units of the current source ID
  If (location ID of ‘D’ is not in Centroids_List) then//check if the location ID of the current
  data unit exists in the centroids list
  {Add locationID of ‘D’ to Centroids_List}//add location ID if it does not exist}
  End if
  End for
   Cluster with K-means using the current Centroids_List and data_units_List//apply clustering on
   the current source ID’s data units using its current centroids
   Add key to Clustered_HC//retain the current source ID in the HashMap
   Add clustered data units to Clustered_HC//retain the resultant clustered data units for the
   current source ID in the HashMap
  End for
  Initialize Final-HC as an empty HashMap//the HashMap used for data fusion
  For each key in Clustered_HC//loop for all source IDs
  Initialize ArrayList Updated-Tree as an empty Arraylist
  Initialize ArrayList TAG-Tree with the clustered data units of the current source ID
  For each locationID ‘loc’ in TAG-Tree//loop for all location IDs of current source ID
  Initialize data_units_List with the data units of the current ‘loc’
  Get the ‘Freshest data unit’ with the minimum generation time in data_units_list
  Add the current ‘loc’ and its ‘Freshest data unit’ in Updated-Tree
  End for
   Add the current key and its Updated-Tree to Final-HC//retain the aggregated results on all location
   IDs of the current source ID in the final HashMap
  End for
  Return Final-HC//return a HashMap of key: source ID and values: location IDs and freshest data units
  End