# A Comparative Analysis of Wi-Fi Offloading and Cooperation in Small-Cell Network
## 4 Comparison between Cooperation and Wi-Fi Offloading in Small-Cell Network
### Switching between SCRE and SORE
```
1:Input:\(hij,R_{j}^{th},P_{i}^{max},RB_{total},L_{i},N,\alpha,\beta\)
2:Output:\(R_{j}\)
3:\(x_{ij}^{k}=1\) without repetition of \(k^{\prime}s\quad\forall j\)
4:\(p_{i,j}^{k}=(P_{i}^{max}-\Delta_{i})/N_{i}\quad\forall i\in I\)
5:Calculate \(R_{j}\;\forall j\)
6:\(R_{j}^{th}\) [or \(N\)] \(R_{j}^{th}>\alpha\) [or \(N<\beta\) (SCRE case) ]
7:while\(RB_{i}<RB_{total}\)do
8:for all users to \(R_{j}\;<\;R_{j}^{th}\;OR\;RB_{i}<RB_{total}\)then
9: For All BSs Check if\(i^{\prime\prime}==BS\)
10: where \(i^{\prime\prime}\subseteq F_{j}\leftarrow\underset{i\in I^{\prime}}{\operatorname{ argmax}}\{h_{i,j}\}\)
11:if\(RB_{i^{\prime}}\;\leq\;RB_{total}\)then
12:\(x_{i^{\prime},j}^{k}=1\), increment values of \(M_{j}\), \(N_{i^{\prime}}\), \(RB_{i^{\prime}}\)
13:elseif\(\Delta h\{i^{\prime},i^{\prime\prime}\}<v_{th}\)and\(RB_{i}^{\prime\prime}<RB_{total}\)then
14:\(x_{i^{\prime\prime},j}^{k}=1\), increment values of \(M_{j}\), \(N_{i^{\prime\prime}}\), \(RB_{i^{\prime\prime}}\)
15:elseif Available power of \(i^{\prime}>0\)then
16:\(p_{i^{\prime},j}^{k}=\Delta_{i}/2\)
17:endif
18: Update powers allocation
19: Calculate \(R_{j}\)
20:else
21: For All BSs and RBs Check its associations
22:while\(R_{j}>R_{j}^{th}\)do
23:\(\Delta_{i}=\Delta_{i}+\operatorname{extra}\) power allocated to user \(j\)
24:endif
25:endif
26:endfor
27:endwhile
28:\(R_{j}^{th}<=\alpha\) [or \(N>=\beta\) (SORE case) ]
29:while\(L_{i}<L_{total}\)do
30:for all UEs do
31:if\(R_{j}\;<\;R_{j}^{th}\;OR\;RB_{i}<RB_{total}\)then
32: For All BSs Check if\(i==BS\)
33:if\(RB_{i}<RB_{total}\)then
34:\(y_{i,j}^{k}=1\), increment values of \(M_{j}\), \(N_{i^{\prime}}\), \(RB_{i}\)
35:elseif\(d_{i^{\prime},j}<d_{w}^{th}\)AND\(L_{i^{\prime}}>0\)then
36:\(z_{i^{\prime},j}=1\)
37: Provide rate according to its data rate demand
38:else
39:if\(\Delta_{i}>0\)then
40:\(p_{i,j}^{k}=\Delta_{i}/2\)
41:endif
42: Update powers allocation
43: Calculate \(R_{j}^{o}\)
44:endif
45:endfor
46:endwhile
47:Overall Rate is \(R=\sum_{j}R_{j}\)
```  
**Algorithm 3** Switching between Cooperation and Offloading (SCO)We consider two network parameters before switching, i.e., user data rate requirement and user density. The data rate threshold and user density is used to perform switching to enhance the data rate in the small-cell network. After executing SCRE and SORE algorithms, the data rate threshold \(\alpha\) and user density \(\beta\) are computed, which are then used by SCO algorithm to switch to either SCRE or SORE (\(\alpha\) and \(\beta\) are called switching parameters). Depending upon the switching parameters, when SCO algorithm switches to SCRE, it executes the main while loop for SCRE (from line 7 to 28). Similarly, when SCO switches to SORE, it executes the main while loop for SORE (from line 8 to 26). After the switching operation, we obtain the achievable data rate \(R_{j}\) for each user \(j\). Lastly, the achievable data rate of the network is calculated. The SCO algorithm is applied to all the UEs in SC network. The order of complexity of SCO is \(O(5(M\times N)+2(M\times N\times K)(1+4M_{j}+K(3(M\times N)+8))\).