# [Project] Parameters for Load Balance in 5G Wireless Network
###### tags: `Project Report`
:::success
Goal:
紀錄演算法、AI/ML Model 輸入輸出參數
:::
:::warning
Reference:
[1] [Handover in 5g slice](https://ieeexplore.ieee.org/document/9618576)
[2] [VeraTM RIC Test - Scenario Generation Data list](https://hackmd.io/@87pBT_HNTnSO7vkP9K831Q/HJE0XI24q)
[3] [Load balancing in Network Slice 說明問題、假設](https://hackmd.io/47ZQxcnGTZyf45ukNlV_cQ)
[4] [Data Analysis - RIC Test Simulated Data](https://hackmd.io/ZGXpctgMTyexz-cOXr4ojg?view)
:::
[TOC]
## Load Balance Algorithm (TS xApp)
### Goal
**To maximize $p_k,_s$ for all $s$ with $x^n_k$ and $t^n$ maximized**
### Input
| Representation | Parameter | RIC Test Data List |
| -------- | -------- |----------------------------------|
| UEs | $k ∈ K = {1, 2, . . . , K}$ | UE, Name
| BSs | $n ∈ N = {1, 2, . . . , N}$ | Cell, Name
| Slices | $S = {{1, 2, . . . , S}}$ | UE, SliceId
| Coverage| $c^n_k$ = 1, if UE $k$ is in the coverage area of BS $n$ ; 0, otherwire| UE, Viavi.Geo.x, Viavi.Geo.y - Cell, Viavi.Geo.x, Viavi.Geo.y > Cell, Viavi.Radio.sectors
| The UE demanding to use slice | $d_k,_s$ = 1, if UE $k$ demands to use slice $s$ ; 0, otherwise| UE, Name && UE, SliceId
| Limited capacity of the slice on each BS $n$| $b^n_s$ | Cell, RRU.PrbAvailDl / $S$
| required data rate to use each slice | $r_s$ | UE, RRU.PrbUsedDl
| UE, Connectivity information of UE $k$| $x^n_k$ = 1, if UE $k$ gets service from BS $n$ ; 0, otherwise| UE, RF.servingId
| UE, Acceptance or rejection information of the request of UE $k$ to get service from slice $s$| $p_k,_s$ = 1, if UE $k$ is provided with slice $s$ ; 0, otherwise| Cell, RRU.PrbAvailDl / $S$ > 0
| Throughput in neighboring cells |$t^n$| Cell, DRB.UEThpDl
### Parameters
| Representation| Parameter |
| -------- | -------- |
| Load of slice $s$ in BS $n$ | $f_s,_n$ = $\Sigma$ $r_s$ * $p_k,_s$ for K, S |
| Utilization of each slice | $u_s,_n$ = $f_s,_n$ / $b^n_s$ for S, N|
### Output
| Parameter | Representation |
| -------- | -------- |
| Algorithm exec time | $t$ |
| Total num of $p_k,_s$ | $\Sigma$ $p_k,_s$ |
| Average utilization of BSs | $\Sigma$ $u_n$ / $N$ |
| Average utilization of Slices | $\Sigma$ $u_s,_n$ / ($S$*$N$) |
Average utilization of Slices ->
UE 1
: neighbor cell 1 , ( 27% + 30% + 50% ) * 1/3
: neighbor cell 2, 0% 10% 20%
: neighbor cell 3, 10% 5% 10%
: neighbor cell 4, 2% 3% 5%
: neighbor cell 5, 8% 7% 10%
( n1 + n2 + n3 + n4 + n5 ) * 1/5
UE 2
...
### ANALYTICAL MODEL
:::warning
Ref:
https://d-nb.info/1157074219/34
https://www.baeldung.com/java-knapsack
https://www.theoptimizationexpert.com/case-studies/knapsack/
:::
| Variable | Denoted As |
| :-------- | :-------- |
| User Equipments | $k ∈ K = {1, 2, . . . , K}$ |
| Base Stations | $n ∈ N = {1, 2, . . . , N}$ |
| Slices | $s ∈ S = {{1, 2, . . . , S}}$ |
| Required PRB to use slice $s$ | $r_k,_s$ = $\{x \mid x ∈ \mathbb{N}^+\}$ |
| Slice $s$ has a limited capacity on BS $n$ | $b^n_s$ = $\{x \mid x ∈ \mathbb{N}^+\}$ |
|Coverage area information of UE $k$ by BS $n$| $$c^n_k = \begin{cases}1, & \text{if UE $k$ is in the coverage area of a BS $n$} \\0, & \text{otherwise}\end{cases}$$ |
|Demand of UE $k$ to use slice $s$ | $$d_k,_s = \begin{cases}1, & \text{if UE $k$ demands to use slice $s$ $\hspace{3em}$} \\0, & \text{otherwise}\end{cases}$$ |
| Connectivity information of UE $k$ to BS $n$ | $$x^n_k = \begin{cases}1, & \text{if UE $k$ gets service from a BS $n$ $\hspace{3em}$} \\0, & \text{otherwise}\end{cases}$$
| Acceptance or rejection of the request of UE $k$ to get service from slice $s$| $$p_k,_s = \begin{cases}1, & \text{if UE $k$ is provided with a slice $s$ $\hspace{2.5em}$} \\0, & \text{otherwise}\end{cases}$$|
| Load of slice $s$ in BS $n$ | $f_s,_n$ = $\sum\limits_{k∈K} x^n_k r_k,_s p_k,_s ,\hspace{1em} \forall s ∈ S , \forall n ∈ N$ |
| Utilization of slice $s$ | $u_s,_n$ = $f_s,_n / b^n_s,$ $\hspace{1em}$ $\forall s ∈ S , \forall n ∈ N$ |
$\mathop{\max} \hspace{2.6em} \sum\limits_{s∈S} \sum\limits_{n∈N} \frac{u_s,_n}{|S||N|}$
$subject$ $to$ $\sum\limits_{n∈N} x^n_k \leq 1 , \hspace{1em} \forall k ∈ K,$
$\hspace{4.5em}$ $x^n_k \leq c^n_k , \hspace{1em} \forall k ∈ K , \forall n ∈ N,$
$\hspace{4.5em}$ $p_k,_s = d_k,_s , \hspace{1em} \forall k ∈ K , \forall s ∈ S,$
$\hspace{4.5em}$ $\sum\limits_{k∈K} x^n_k r_k,_s p_k,_s \leq b^n_s , \hspace{1em} \forall s ∈ S , \forall n ∈ N ,$
$\hspace{4.5em}$ $p_k,_s , d_k,_s ∈ \{0,1\} , \hspace{1em} \forall k ∈ K , \forall s ∈ S,$
$\hspace{4.5em}$ $x^n_k , c^n_k∈ \{0,1\} ,\hspace{1em} \forall k ∈ K , \forall n ∈ N.$
### SIMULATION
| Parameter | Value |
| -------- | -------- |
| $\|K\|$ | $20$ |
| $\|N\|$ | $34$ |
| $\|S\|$ | $3$ |
| $r_k,_s$ | $R_k,_s \sim \mathcal{U}(0,91)$ |
| $b^n_s$ | $B^n_s \sim \mathcal{U}(0,91)$ |
| $c^n_k$| Randomly Generated by RIC Test |
| $d_k,_s$ | Randomly Generated |
| $x^n_k$ | Randomly Generated by RIC Test |
## Throughput Prediction (QP xApp)
### Goal
預測UE鄰近基地台的Throughput ,為UE選擇最佳的基地台,提高UE上網速度
### [Input (Explained in here)](https://hackmd.io/ZGXpctgMTyexz-cOXr4ojg?view)
| Parameter| RIC Test Data List |
| -------- | -------- |
| pdcpBytesDl | Cell, QosFlow.PdcpPduVolumeDl |
| availPrbDl |Cell, RRU.PrbAvailDl |
### Output
| Parameter | RIC Test Data List |
| -------- | -------- |
| Throughput | Cell, DRB.UEThpDl |
## Algorithm Flow Chart

