## 3 Minimal Zone Searching (MZS), a New Positional Algorithm  
The goal of the proposed algorithm is to find the smallest possible zone where the visitor is likely to be at a certain point in time. As we saw in the previous section, we are working with data coming from sensors based on a time window of 5 s.  
Most approaches in indoor positioning systems, such that trilateration or triangulation only takes three to four sensors who recorded the maximum value of RSSI. With this approach we are taking into account all sensors in the room. The algorithm considers the set S of sensors as input, each sensor \(s\in S\) is given by its coordinates (\(x_{s}\), \(y_{s}\)) and its RSSI value \(L_{s}\), and computes a minimal zone as the representation of possible positions of the individual. The algorithm iterates until a the optimal zone is reached. At each iteration \(i\), a new zone \(zone_{i}\) is computed from the centroid of the zone issued from the previous iteration and the RSSI values of each sensor s. The treatment is initialized with the first zone \(zone_{0}\) defined as the convex hull of sensors within the room (Equation (1)):  
Figure 4: Recalibration of computed point based on room limit. The MZS algorithm (Algorithm 1) starts by computing the convex hull of sensors within the room, as explained in Equation (1), \(zone_{0}\) represents the initialization step. \[zone_{0}=Hull(x_{s},y_{s}:sensors) \tag{1}\]  
The zone is then refined as the convex hull of a set of distance points, each distance points \(\Gamma_{s}\) is computed from a sensor s and the value of \(L_{s}\) according to the centroid c of the previous convex hull: (Equations (2) and (3)). \[\Gamma_{s}= \begin{bmatrix}x_{c}\\ y_{c}\end{bmatrix} +L_{s} \begin{bmatrix}cos(\alpha_{s})\\ sin(\alpha_{s})\end{bmatrix}  \tag{2}\]  
where we consider a set of sensors noted b described by their coordinate \(b:(x_{s},y_{s})\), and \(L_{s}\) is a distance in meter computed based on the RSSI value returned by a sensor \(s\) at a time \(t\). The centroid \(C_{0}(x_{c},y_{c})\), \(\alpha_{s}\) the angle in radiant between the centroid \(C\) and sensor \(s\). The next execution (n=1), consider the convex hull of all \(\Gamma_{s}\) point and the new centroid \(C_{1}\). The iteration of the zone calculation is based on the following equation:  
\[zone_{i}=Hull(\{DistancePoints(L_{s},C_{zone_{i-1}}):sensor\ s\}) \tag{3}\]  
where \(C_{zone_{i-1}}\) is the centroid of the \(zone_{i-1}\) and DistancePoints() is a direct reference to Equation (2). ```
Input: A set of sensors S, each sensor \(s\in S\) is given with its position (\(x_{s}\),\(y_{s}\)) and the distance \(L_{s}\), A distance threshold D, A max nb of iteration M Output: A minimal zone init \(Hull\leftarrow\{\}\); \(Hull\leftarrow\) compute_hull(S); // At this point, the variable \"Hull\" corresponds to \(zone_{0}\) centroid \(\leftarrow\) new_centroid ; nb_iter \(\leftarrow\) 0; repeat \(\texttt{nb\_iter}++\); \(\texttt{centroid}\leftarrow\) new_centroid ; \(\texttt{li\_DP}\leftarrow\) []; forall s in Sdo \(\Gamma_{s}=DistancePoints(L_{s},centroid)\) ; \(\texttt{li\_DP}.push(\Gamma_{s})\); \(\texttt{Zone}\leftarrow\) compute_hull(li_DP) ; \(\texttt{new\_centroid}\leftarrow\) get_centroid(Zone); until\(computeDistance(centroid,new\_centroid)>D\) nb_iter \(<M\); returnZone
```  
**Algorithm 1**Minimal Zone Searching. The algorithm will stop when the size and position of \(zone_{i-1}\) and \(zone_{i}\) are comparable and where only minor changes occur, or if we reach the maximum number of executions, i.e., when we obtain a small distance between two consecutive centroids. The threshold value used in this paper is 0.1 m. Using the dataset from our experimentation, we observed that the algorithm needs on average 6 iterations and 0.2 s of computation time to find a \"stable\" zone, which is suitable for a real time execution.