## 7 SMEP Algorithms
### AuxDataQueue Compression Algorithm
```
Parameters 01 \(m\): the number of zones such that \(\textit{DataQueue}\{0..2^{m}\}\) Global Variables 01 \(\textit{AuxDataQueue}\{0..2^{Zone}\{m-1\}+1\}\): an auxiliary data queue for compressing a sensor sequence in the last zone 02 \(\textit{AP}\): a variable for the absolution position of the latest ground sensor data  Local Variables 01 \(c\): the number of compressions for a sensor data sequence in \(\textit{Zones}\{m-1\}\) 02 \(\textit{AuxDQinx}\): an index for AuxDataQueue 03 \(\textit{ZoneBpSeq}\): a temporal bit string variable for I-bit sequence  Procedure 01 Set \(c\)=\(\textit{Zones}\{m-1\}\) 02 Initialize \(\textit{ZoneBpSeq}\)0 = \(eb\) (an empty bit string) 04 Allocate memory \(\textit{AuxDataQueue}\{0..2^{c+1}\}\) 05 Initialize \(\textit{AuxDQinx}=1\) 06 while(\(\textit{AuxDQinx}\leq 2^{c+1}\)) do 07 Set \(\textit{AP}\)=\(\textit{AP}\)+1 08 Read a ground sensor data \(S_{0,Ap}\) from a sensor 09 Insert \(S_{0,Ap}\) into \(\textit{AuxDataQueue}\{\textit{AuxDQinx}\}\) 10 if (\(receive(\textit{CRmessage})=\) true) 11 then return '_FinishMode_' 12 else Set \(\textit{AuxDQinx}\)=\(\textit{AuxDQinx}\)+1 13 Continue 14 endif 15 endwhile 16 Set [Value, j, \(\textit{ZoneBpSeq}\)0] = \(\textit{AuxDataQueue}\textit{Compression}\{\textit{AuxDataQueue}\), m\} 17 Select \(S_{cp}\) from the \(2^{m-1}-1\) positioned interval of \(\textit{DataQueue}\) by the _selection by minimum error_ rule by using \(\textit{ZoneCompHistory}\{m-2,c+1\}\) as a base sensor data and its absolute position and by using [Value,j] as the value and absolute position of the sensor data selected in the next interval in the c+1 th compression,  this is, Set \(p= \begin{array}{c}\textit{arg min}\\ \textit{i}\in[2^{m-1,2^{m}}]\end{array} (E_{i})\) 18 Set \(\textit{DataQueue}\{2^{m}-1\}=S_{cp}\) 19 Set \(\textit{ZoneBpSeq}\)0 = \(\textit{I-bit position}\{\textit{DataQueue}\{2^{m}-1\}\}\) 0 \(\textit{ZoneBpSeq}\)0 by using \(\textit{ZoneBpSeq}\{m-1\}\) 20 Set \(\textit{DataQuet}\{2^{m}\}\) = Value 21 Set \(\textit{ZoneBpSeq}\{m-1\}\) = \(\textit{ZoneBpSeq}\)0 22 Set \(\textit{ZoneCmpHistory}\{m-1,c+1\}\) = \(\textit{[Value,j]}\) 23 return '_Contine_' Endprocedure
```
**Algorithm 2**_LastZoneCompression(DataQueue, m)_

The _LastZoneCompression_ procedure allocates the _AuxDataQueue_ array space in order to make the last zone be taken to the one more compression (procedure line 4). Hence, the size of _AuxDataQueue_ array space must be \(2^{Zones}\{m-1\}+1\). Next, this procedure begins to read ground sensor data and insertsthem into _AuxDataQueue_ (from procedure line 6 to line 15). Whenever the procedure reads a ground sensor data, it checks if the communication failure has been recovered using _Receive(CRmessage)_ function (procedure line 10). If the check is true, the procedure returns to the calling procedure, the SMEP main procedure, and informs the recovery from the communication failure to that procedure by returning _'FinishMode'_ (procedure line 11). After filling up _AuxDataQueue_ the procedure calls the _AuxDataQueueCompression_ procedure to compress a ground sensor data in _AuxDataQueue_ (procedure line 16). The _AuxDataQueueCompression_ procedure returns a finally selected sensor data value, its absolute position, and its zone bit sequence (procedure line 16). The procedure uses the returned value and absolute position to select one between two last sensor data by the _selection by minimum error_ rule (procedure line 17). The finally selected sensor data and the returned value are inserted into _DataQueue[2m \(-\) 2]_ and _DataQueue[2m \(-\) 1]_, respectively, as the results of the last zone compression (procedure line 18 and line 20). The I-bit position of the finally selected sensor data and the returned bit sequence are used for a last zone bit sequence (procedure line 19 and line 21).