# Online Distributed User Association for Heterogeneous Radio Access Network
## 4 Algorithm Description  
In the following, we consider a static environment and implement a centralized solution, and later compare with our proposed schemes to show the novelty. Figure 2 shows a static environment, where the UEs have no mobility and the channel condition remains constant. The centralized entity requires some primitives before making any decisions. Below are the numbers of functions with their meanings, which are essential to running the centralized solution.  
1. \(Neighborod(BS_{j})\) = Set of BSs neighbors to BS \(j.\)\(1\leq j\leq\textbf{B}\)
2. \(Can\_Access(i)\) = Number of BS(s) that can be accessed by the \(i\)th UE. \(1\leq i\leq\textbf{U}\)  
The UE obtains the \(Can\_Access(i)\) value by performing an initial BS search. The BSs whose SINR is greater than a threshold, \(\tau\), are considered. UEs are responsible for sending the \(Can\_Access()\) value to their respective BSs, and the BSs, in turn send these parameters to the centralized entity. Algorithm 1 is then executed at the centralized entity, where it searches for the BS having optimum \(\lambda_{j,k}\) value at each loop. By optimum \(\lambda_{j,k}\), we mean the minimum for \(\lambda_{j,k}^{load1}\) and maximum for \(\lambda_{j,k}^{load2}\). Upon finding the BS, the centralized entity searches for neighboring BSs which are having optimum \(\lambda_{j,k}\) values. Then, a UE selection strategy is applied to select a particular UE. UE whose \(Can\_Access()\) value is 2 is given higher priority over the UE whose \(Can\_Access()\) value is 3 and so on, because Algorithm 1 gives priority to UEs which have a lesser number of BSs in its range. As we consider two load values,  
Figure 2: User equipments (UEs) placed in a homogeneous environment. Some UEs can access two or more macro base stations (BSs).  
\(\lambda_{j,k}^{load1}\) and \(\lambda_{j,k}^{load2}\), a proper decision must be taken for the BS selection at steps 2 and 4 of the algorithm. For \(\lambda_{j,k}^{load1}\), \(min\) is considered at step 2 and \(max\) is considered at step 4, while for \(\lambda_{j,k}^{load2}\) the opposite decisions are taken. This is because of the nature associated with \(\lambda_{j,k}^{load1}\) and \(\lambda_{j,k}^{load2}\), where higher value of the former gives a higher load, while the opposite holds true for the latter.  
```
1: Assign UEs to the BSs which have \(Can\_Access()=\)1;
2: Find the BS with a \(opt\)\((\lambda_{j,k})\) value, \(L=opt\)\(\{\lambda_{j,k}\}\), \(\forall j\in\mathrm{B},\forall k\in\mathrm{K}\)
3:\(L_{nh}=neighbourhood\)\((L)\)
4: Find a BS which has a \(opt\)\(\lambda_{j,k}\) value and is a neighbor to BS \(L\), \(S=opt\)\(\{\lambda_{j,k}|j,k\in L_{nh}\}\),\(\forall j\in\mathrm{B},\forall k\in\mathrm{K}\)
5:if\(L\cap S=\phi\)then
6:\(L_{nh}=L_{nh}-\{S\}\)
7:if\(L_{nh}=\phi\)then
8: Do not consider this base station in future processing
9: Go to Row 2
10:endif
11: Go to Row 4
12:else
13:\(A=L_{nh}\cap S,c=2\)
14: Select an UE \(i\) whose \(Can\_Access(i)=c,i\in A\)
15:if\(Can\_Access(i)=\phi\)then
16:\(c=c+1\)
17: Go to Row 14
18:endif
19: Assign the Selected UE to BS \(L_{nh}\)
20:endif
21: Update the \(\lambda_{j,k}\), \(\forall j\in\mathrm{B},\forall k\in\mathrm{K}\)
22: Goto Row 2
```  
**Algorithm 1** Centralized solution  
The above-mentioned scheme works well in a static, idealistic environment where there is no mobility and the channel quality remains intact. A slight change in the \(Can\_Access()\) value triggers the centralized entity to re-run the algorithm from scratch, which is not suitable for a dynamic case. Hence, we develop distributed methods to handle the dynamic nature of the environment. Two schemes are developed for UEs with mobility using a distributed scheme: (a) the probability-based and (b) the \(d\)-choices-based selection, which try to balance the load over the whole network.