# Joint Content Recommendation and Delivery in Mobile Wireless Networks with Outage Management
## 4 Heuristic Algorithms for Joint Content Recommendation and Delivery
### Radio Resource Allocation
#### 4.1.1 Sum Rate Maximization  
A straight-forward heuristic is to maximize the sum data rate of multi-user OFDM systems. In this case, the problem becomes a classic multi-user OFDM system rate adaptive optimization problem. The optimization problem is formulated as:\[\begin{split}\text{maximize}&\sum_{u=1}^{U}\sum_{k=1}^{K}c_{uk} \rho_{uk}\\ \text{subject to}& B*\sum_{u=1}^{U}\sum_{k=1}^{K}\frac{f(c_{uk })}{\alpha_{uk}^{2}}*\rho_{uk}\leq P_{T}\\ &\sum_{u=1}^{U}\rho_{uk}\leq 1\end{split} \tag{20}\]  
where decision variables are bit allocation variables \(c_{uk}\) and channel allocation variables \(\rho_{uk}\). This problem is itself an NP-hard integer programming problem. To solve this problem effectively, an improved subcarrier and power adaptive allocation algorithm is proposed. The pseudo code of the algorithm is shown in Algorithm 1. The algorithm is a low complexity suboptimal algorithm, which includes two steps: subcarrier allocation and bit/power allocation. First, let us define a new variable:  
\[\Delta p_{uk}(c)=\frac{f(c+1)-f(c)}{\alpha_{uk}^{2}} \tag{21}\]  
which indicates the extra power required when one more bit is allocated to user \(u\) on subcarrier \(k\). This variable is used for our algorithm to allocate the channel and bits in a greedy fashion. To prevent the case where some users are not assigned with any bit, the algorithm initiates by allocating a carrier to each user. Once the bit allocation is completed, we can get the available transmission data rate of each user.  
```
0:\(U\), \(K\), \(P_{T}\), \(\alpha_{uk}^{2}\)
0:\(c_{u}\), \(P_{u}\)
1:(1) Initialization:  Let \(A=\{1,2,\ldots,K\}\) denote unassigned subcarrier sets; \(P_{u}=0\) is the power allocated to user \(u\); \(c_{uk}=0\) represents the number of bits allocated on the subcarrier \(k\) allocated to the user \(u\); \(c_{u}=0\) indicates the total number of bits allocated to the user \(u\); \(A_{u}=\varnothing\) denotes the set of subcarriers assigned to the user \(u\);
2:(2) Carrier allocation:
3:for\(u=1,2,\ldots,U\)do
4: find subcarrier \(k\) that minimizes \(\Delta p_{uk}(0)\), and assign the subcarrier to the user \(u\); meanwhile, \(A_{u}=A_{u}\cup\{k\}\), \(A=A-\{k\}\)
5:if\(A=\varnothing\)then break;
6:while\(A\
eq\varnothing\)do
7: find the subcarrier \(k\) with the smallest \(\Delta p_{uk}(0)\) in the set \(A\), and assign them to the corresponding user \(u\); meanwhile \(A_{u}=A_{u}\cup\{k\}\), \(A=A-\{k\}\)
8:(3) Bit and power allocation:
9:while\(\sum_{u=1}^{U}p_{u}\leq P_{T}\)do
10: Traverse the subcarriers corresponding to all the users; find the subcarrier \(k\) and the corresponding user \(u\) with the smallest \(\Delta p_{uk}(c_{uk})\), and allocate 1 bit of data to the subcarrier; meanwhile \(c_{uk}=c_{uk}+1\), \(P_{u}=P_{u}+\Delta p_{uk}(c)\), \(c_{u}=c_{u}+1\)
11:return\(c_{u}\), \(P_{u}\)
```  
**Algorithm 1** Sum rate maximization algorithm.  
We note that Algorithm 1 tends to allocate more bits and power to users with good channel conditions. Although this will maximize the sum capacity, it results in unfairness among users and does not necessarily give high total interest. For example, a user with poor channel condition may be allocated with a very low capacity and hence cannot support the transmission of large, but highly interested files. To overcome such a drawback and improve user fairness, the following algorithm is proposed as an alternative to Algorithm 1.