## 5 The Proposed GMDPSO for Our Protocol
### GMDPSO: Greedy Discrete PSO with Memory
The defined \(\odot\) operation actually is used to find which relay nodes are different between these two routing paths, and these differences will give a particle the fly direction. **Definition 4 (Velocity Operator).**\(\oplus\). _Velocity \(\oplus\) Velocity is also a velocity vector. Given two velocity vectors \(V_{1}=\{v_{1}^{1},\,v_{1}^{2},\,\ldots,\,v_{1}^{N^{\prime}}\}\) and \(V_{2}=\{v_{2}^{1},\,v_{2}^{2},\,\ldots,\,v_{2}^{N^{\prime}}\}\), then \(V_{3}=V_{1}\oplus V_{2}=\{v_{3}^{1},\,v_{3}^{2},\,\ldots,\,v_{3}^{N^{\prime}}\}\). \(v_{3}^{j}\) can be compute as follows:_

\[v_{3}^{k}=\left\{ \begin{array}{ll}1&condition\ 1:if\quad v_{1}^{k}+v_{2}^{k} \geqslant 1\\ 0&condition\ 2:otherwise\end{array} \right. \tag{31}\]

Suppose \(V_{1}=\textit{Pbest}_{i}\ominus X_{i}(t)\) and \(V_{2}=\textit{Gbest}\ominus X_{i}(t)\), then, _condition1_ means that once the _kth_ relay node in particle \(i\) (i.e., \(v_{1}^{k}=1\)) needs to be changed, which is decided by its own knowledge (i.e., \(v_{1}^{k}=1\)) or by swarm knowledge (i.e., \(v_{2}^{k}=1\)) or both of them (i.e., \(v_{1}^{k}=1\) & \(v_{2}^{k}=1\)), it must be changed finally. The definition of the operator \(\oplus\) is easy to understand and easy to perform. Moreover, it can ensure binary-coded consistency for velocity, which is easier for the position to work with. **Definition 5 (Coefficient \(\times\) Velocity). **_Coefficient \(\times\) Velocity is still velocity vector. Given the Coefficient \(\omega\) and the velocity vector \(V_{1}=v_{1}^{1},\,v_{1}^{2},\,\ldots,\,v_{1}^{N^{\prime}}\), then \(V_{2}=\omega\,\times\,V_{1}=\{v_{2}^{1},\,v_{2}^{2},\,\ldots,\,v_{2}^{N^{\prime }}\}\). Where \(v_{2}^{j}\) can be compute as follows:_

\[v_{3}^{j}=\left\{ \begin{array}{ll}1&condition\ 1:if\quad v_{1}^{j}=1\\ 1&condition\ 2:if\quad v_{1}^{j}=0\ \ \&\ \ \omega\geqslant 0.5\\ 0&condition\ 3:if\quad v_{1}^{j}=0\ \ \&\ \ \omega<0.5\end{array} \right. \tag{32}\]

_condition1 means that if a relay node needs to be changed, then change it without regard to the \(\omega\). Condition2 and condition3 are conditions for mutation operation of particle, which means that although a relay node does not need to be changed(i.e., \(v_{1}^{i}=0\)), it still maybe be changed in a mutation probability (i.e., 0.5). Mutation operation of particle can promote the diversity of particles and avoid falling into the local optimum._

**Definition 6 (Position Updating Operator) \(\otimes\). \(\otimes\) is very important component in our update rules, which is used by particle to update its position with its new velocity. Position \(\otimes\) Velocity generates a new position. A good design for operator \(\otimes\) should drive a particle to a better position. Given an old position \(X_{t}=\{x_{1}^{1},\,x_{2}^{2},\,\ldots,\,x_{2}^{N^{\prime}}\}\) and a new velocity \(V_{t+1}=\{v_{t+1}^{1},\,v_{t+1}^{2},\,\ldots,\,v_{t+1}^{N^{\prime}}\}\), then the new position \(X_{t+1}=X_{t}\otimes V_{t+1}=\{x_{t+1}^{1},\,x_{t+1}^{2},\,\ldots,\,v_{t+2}^{N^ {\prime}}\}\), the element \(x_{t+1}^{i}\) of \(X_{t+1}\) can be computed as follows:_

\[x_{t+1}^{i}=\left\{ \begin{array}{ll}bestRN_{i}\quad\text{if}\quad v_{t+1}^{i }=1\ \ \&\ x_{t}^{i}\in Path_{j}^{t+1}\\ x_{t}^{i}\quad\text{otherwise}\end{array} \right. \tag{33}\]

_where \(x_{t}^{i}\in Path_{j}^{t+1}\) means that the old node \(x_{t}^{j}\) is selected as a relay node in the \(Path_{j}^{t+1}\) in \(X_{t+1}\), in other words, if \(x_{t}^{i}\) is not a relay node, it need not to be changed. Notably, \(X_{i}\) means a routing path tree that contains \(N_{S}\) routing path branches, and \(Path_{j}\) is only one routing path branch of the routing path tree. Therefore, only these old nodes will be changed that satisfies the following conditions simultaneously: they are chosen as the relay nodes and their corresponding velocities are set to 1, i.e. \(v_{t+1}^{i}=1\ \ \&\ x_{t}^{i}\in Path_{j}^{i+1}\).