# An Indoor Smart Parking Algorithm Based on Fingerprinting
## 6 Indoor Parking Algorithm
### The Driver-Slot Association  
In order to complete the indoor parking process, we also need to take into consideration the set of drivers \(D\) ready to park. As previously said, each driver can express the terminal he wants to reach after leaving his car during the user profiling phase.  
By following the running example, let us consider \(D=\{d_{1},d_{2},d_{3},d_{4},d_{5},d_{6}\}\) the set of drivers and a function \(terminal:D\to T\) associating to each driver his favorite terminal.  
Table 5 provides an example with 6 drivers and their preferences.  
Algorithm 3 produces a set \(Result\subseteq D\times S\) made of pairs \((driver,slot)\) such that the slot has been associated with the driver, according to his preferences.  
\begin{table}
\begin{tabular}{c|c} \hline \(a_{1}\) & \(s_{1},s_{7},s_{8},s_{9},t_{1},t_{2}\) \\ \(a_{2}\) & \(s_{2},s_{3},s_{11}\) \\ \(a_{3}\) & \(s_{4},s_{6},t_{3},t_{4}\) \\ \hline \end{tabular}
\end{table}
Table 4: Area construction with \(\theta=0.4\).  
\begin{table}
\begin{tabular}{c|c} \hline \(a_{1}\) & \(s_{1},s_{7},s_{8},s_{9}\) \\ \(a_{2}\) & \(s_{2},s_{3},s_{11}\) \\ \(a_{3}\) & \(s_{4},s_{6}\) \\ \(a_{4}\) & \(t_{1},t_{2}\) \\ \(a_{5}\) & \(t_{3},t_{4}\) \\ \hline \end{tabular}
\end{table}
Table 3: Area construction with \(\theta=0.2\).  
\begin{table}
\begin{tabular}{c|c} \hline \(a_{1}\) & \(s_{1},s_{7},s_{8},s_{9}\) \\ \(a_{2}\) & \(s_{2},s_{3},s_{11}\) \\ \(a_{3}\) & \(s_{4},s_{6}\) \\ \(a_{3}\) & \(s_{4},s_{6},t_{3},t_{4}\) \\ \hline \end{tabular}
\end{table}
Table 4: Area construction with \(\theta=0.4\).  
\begin{table}
\begin{tabular}{c|c} \hline \(a_{1}\) & \(s_{1},s_{7},s_{8},s_{9}\) \\ \(a_{2}\) & \(s_{2},s_{3},s_{11}\) \\ \(a_{2}\) & \(s_{2},s_{3},s_{11}\) \\ \(a_{3}\) & \(s_{4},s_{6},t_{3},t_{4}\) \\ \hline \end{tabular}
\end{table}
Table 4: Area construction with \(\theta=0.4\).  
```
Input:\(D\), \(A\) Output:\(Result\) for\(d\in D\)do \(area=is(terminal(d))\) \(s=get\_available\_slot(area)\) if\(!s\)then \(area=get\_next\_available\_area(A)\) if\(!area\)then break endif \(s=get\_available\_slot(area)\) endif if\(!s\)then \(exit\) endif \(add(Result,(d,s))\) \(remove(s,area)\) endfor
```  
**Algorithm 3** Slot Association  
The function \(get\_available\_slot(area)\) gives a random available slot in the selected area. The function \(get\_next\_available\_area(A)\) simply returns the next area in \(A\) having at least one available parking slot (if any). The function \(add\) allows putting the new pair \((driver,slot)\) in the resulting set. The function \(remove(s,area)\) simply makes the slot \(s\) no longer available.  
The resulting set by applying Algorithm 3 to the running example is shown in Table 6. They are obtained by applying the algorithm to the areas obtained in Table 4.  
Since after this execution, \(a_{1}\) and \(a_{3}\) run out of available parking slots, what would happen if some other driver showed up? Let us suppose of having two additional drivers \(d_{7}\) and \(d_{8}\) whose preferences about the target terminal are \(t_{3}\) and \(t_{4}\) respectively. The area of terminal 3 is \(a_{3}\), where there are no available parking slots. Hence, the algorithm provides the next available area, \(a_{2}\) assigning \(d_{7}\) to \(s_{2}\). The same happens to \(d_{8}\), which is assigned to \(s_{3}\).  
Essentially, the proposed algorithms are able to associate parking slots to drivers as long as the number of available parking slots in the whole car park is enough to cover the number of drivers.