# Data Fusion Analysis and Synthesis Framework for Improving Disaster Situation Awareness
## 7 Algorithms for Synthesizing the Optimal Data Fusion Configuration
### Best-Fit
```
1:functionCALCULATE_BEST_FIT(instance, time_limit, cost_limit) returns list of data sources
2:functionCALCULATE_BEST_FIT(instance, time_limit, cost_limit)
3:\(\mathit{cost}\gets 0\)
4:\(\mathit{ds\_tree}\leftarrow\) empty tree
5:\(\mathit{time,cost}\leftarrow\mathit{ds\_tree.add\_root}(BEST\_APPLICABLE\_SOURCE(\mathit{ds\_tree}, \mathit{instance},\mathit{time\_limit},\mathit{cost\_limit}))\)
6:while constraints are met do
7:\(t,c\gets\mathit{ds\_tree.add\_child}(\mathit{prev\_element},BEST\_APPLICABLE\_SOURCE(\mathit{ds\_tree}, \mathit{instance},\mathit{time\_limit},\mathit{cost\_limit}))\)
8:if new data_source attached then
9:\(\mathit{time}\leftarrow t\)
10:\(\mathit{cost}\mathrel{+=}c\)
11:else
12:break
13:endif
14:endwhile
15:return\(\mathit{ds\_tree}\)
16:endfunction
17:functionBEST_APPLICABLE_SOURCE(\(\mathit{ds\_tree}\), instance, time_limit, cost_limit)
18:\(\mathit{best\_data\_source}\leftarrow\) empty data_source object
19:\(\mathit{found}\leftarrow\) false
20:\(\mathit{data\_sources}\leftarrow\) available data sources for the instance, length \(N\)
21:\(\mathit{effectiveness\_values}\leftarrow\) empty list with length \(N\) used for comparison
22:for index from 0 to \(N\)do
23:\(\mathit{effectiveness,time,cost}\leftarrow\mathit{CALCULATE\_EFFECTIVENESS}( \mathit{ds\_tree},\mathit{data\_sources}[N])\)
24:if\(time<\mathit{time\_limit}\) and \(\mathit{cost}<\mathit{cost\_limit}\)then
25:\(\mathit{effectiveness\_values}[\mathit{index}]\gets\mathit{effectiveness}\)
26:\(\mathit{found}\leftarrow\) true
27:endif
28:endfor
29:if found then
30:\(\mathit{best\_data\_source}\leftarrow\mathit{data\_sources}[\mathrm{argmax}( \mathit{effectiveness\_values})]\)
31:endif
32:return\(\mathit{best\_data\_source}\)
33:endfunction
```  
**Algorithm 1** CALCULATE_BEST_FIT(instance, time_limit, cost_limit) returns list of data sources  
The effectiveness values of the available data sources are estimated as follows:  
1. Smart home (\(e=0.717\));
2. Face recognizer (\(e=0.5\));
3. Collapse detector (\(e=0.233\));
4. Camera of face recognizer(\(e=0.22\));
5. Seismic detector (\(e=0.133\));
6. People counter (\(e=0.133\)). For brevity, the cost and timing values of these data sources are not shown here. In the first iteration, smart home is selected since it has the highest estimated effectiveness value. The total cost is calculated as 2.5 K units of currency and the total time value is 0.1 s. In the second iteration, the contributions of the remaining data sources are calculated. The face recognizer is selected because it has the highest contribution value: \((0.717+(1-0.717)\times 0.5=0.8585)\). The total cost is estimated as 15 K and the total time as 0.655 s. The algorithm reaches its cost limit and therefore terminates. In this example, we assume that only one data source of the same type can be attached to an residence. For illustration purposes, to explain the algorithm, a relatively simple example is chosen. In a real case, however, there may be many geographical elements to be considered with a large number of alternatives and variations of data sources. The running time of the algorithm can be calculated as follows: If the number of data sources in the output is \(N\), and the number of available data sources is \(M\), then the running time can be computed by (4), where t represents the running time in each allocation step (corresponds to the function \(BEST\_APPLICABLE\_SOURCE\)). \[ \begin{split} T_{best}=t\times(\sum_{k=1}^{M}M-k+1)\\ T_{best}=t\times N\times(M-N+\frac{1}{2})\end{split}  \tag{4}\]