# Social Milieu Oriented Routing: A New Dimension to Enhance Network Security in WSNs
## 3 Algorithm Description
### Proposed QA_OSTP  
In this part, we describe the components of our algorithm and the related key scheme design in detail.  
As mentioned in Section 3.3, before the execution of QA_OSTP, all the values of trust between participants and recommendations of intermediate participants in wireless sensor networks should be obtained through mining techniques. The whole network structure is constructed from the recommendations from the intermediate participants. Then, this two-tier relationship information, together with the intermediate participants and these two QoT constraints, is treated as the input of the QA_OSTP algorithm, based on which the trustor node will be able to perform the algorithm. The output of QA_OSTP will be the _ground state_ with the lowest energy in the related TISG model, which corresponds to the optimal social trust path between the trustor node and the target trustee node. The optimal social trust path should satisfy these two QoT-attribute constraints and yield the best utility with the criteria defined by the trustor node.  
Notations that are used in QA_OSTP are shown in Table 2. Pseudo-code of QA_OSTP is given in Algorithm 1. The first outermost loop is controlled by \(T\). Here, we choose a linear annealing schedule consisting of the initial temperature \(T_{0}\) and \(Max_{\mathrm{steps}}\). Each Monte Carlo step for QA_OSTP consists of a loop starting from the second outermost loop where \(M\) is a tunable multiplier; \(M\times\ N\) moves are conducted at each step after which the control parameter is decreased. QA_OSTP keeps making the next Monte Carlo step each time until the termination condition is satisfied. The replicas are always connected to each other in numerical order in the same way throughout the search for spin products. The random disturbing means only changing the order in which replicas are selected for search. We find this is an efficient scheme, which can promote diversity in the population of configurations.  
\begin{table}
\begin{tabular}{c c} \hline \(G\) & Social graph of WSNs with two QoT parameters \\ \(S_{\mathrm{s}}\) & Trustor node \\ \(D_{\mathrm{s}}\) & Target trustee node \\ \(\mathcal{F}_{p}\) & Utility of a social trust path configuration \\ \(P\) & The number of replicas \\ \(T\) & Temperature parameter \\ \(T_{0}\) & Optimal initial temperature \\ \(\Gamma\) & Transverse field \\ \(\Gamma_{0}\) & An initial value of the transverse field \\ \(M\) & Fixed number of nearest neighbors of participant \\ \(\rho\) & Sequence number of a certain replica \\ \(N\) & Number of nodes in WSNs \\ \(\varphi\) & The series number of replica \\ \(\tau_{\mathrm{total}}\) & Total CPMC time \\ \(Max_{\mathrm{steps}}\) & Maximum number of CPIMC steps \\ \(N_{i}\) & Number of iterations \\ \(\omega_{\rho}\) & A social trust path configuration \\ \(\omega\) & A series of \(\omega_{\rho}\), also known as \(\{\omega_{p}\}\) \\ \(\omega_{\rho}^{\prime}\) & Neighbor of configuration \(\omega_{\rho}\) \\ \(V_{p}^{T}\) & Trust constraint of social trust path \\ \(V_{p}^{T}\) & Recommendation degree constraint of social trust path \\ \hline \end{tabular}
\end{table}
Table 2: Notations used in QA_OSTP.