## 3 User Clustering and Power Allocation Co-Design
### Lagrangian Multiplier Based Dynamic Programming Model for Power Allocation
Considering the particular \(j\)-th cluster with \(n^{j}\) users, let \(H_{i}^{j}\) represents the normalized channel gain between the BS and the \(i\)-th users in this cluster, where \(i=1,2,\cdots,n^{j}\) and  
\[H_{1}^{j}\geq H_{2}^{j}\geq\cdots\geq H_{n^{j}}^{j}. \tag{14}\]  
The maximum transmission power of the \(j\)-th cluster is represented as \(P_{max}^{j}\), and the power allocated to each user in this cluster is denoted as  
\[P^{j}=\Bigl{\{}P_{1}^{j},P_{2}^{j},\ldots,P_{n^{j}}^{j}\Bigr{\}}. \tag{15}\]  
Denote the minimum data transmission rate required by the QoS of the \(i\)-th user in the \(j\)-th cluster as \(R_{i}^{j}\), then the throughput maximization problem of the particular cluster can be formulated as  
\[\max_{p^{j}}\sum_{i=1}^{n^{j}}\omega_{j}b\log_{2}\Biggl{(}1+\frac{H_{i}^{j}P_ {i}^{j}}{\omega_{j}+\sum_{k=1}^{i-1}H_{i}^{j}P_{k}^{j}}\Biggr{)} \tag{16}\]  
under the following constraints:  
* maximum transmission power constraint of the cluster \[\sum_{i=1}^{n^{j}}P_{i}^{j}\leq P_{\max}^{j},\] (17)
* necessary power constraint for efficient SIC of each user \[ \begin{split}& H_{i-1}^{j}P_{i}^{j}-\sum_{k=1}^{i-1}H_{i-1}^{j}P_ {k}^{j}\geq P_{T},\\ &\forall i\in\Bigl{\{}2,3,\ldots,n^{j}\Bigr{\}},\end{split} \] (18)* minimum data transmission rate requirement of each user \[ \begin{split}&\omega_{j}b\log_{2}\left(1+\frac{H_{i}^{j}p_{i}^{j}}{ \omega_{j}+\sum_{k=i+1}^{n}H_{i}^{j}p_{k}^{j}}\right)\geq R_{i}^{j},\\ &\forall i\in\Big{\{}1,2,\ldots,n^{j}\Big{\}}.\end{split} \] (19)  
```
0:\(f(j,p)\), \(\xi\)
0: Power allocation result \(\{\bar{P}_{1},\bar{P}_{2},\ldots,\bar{P}_{c}\}\), maximum energy efficiency \(E_{max}\) with energy consumption \(P_{sum}\)
1:for\(i=0\) to \(\left\lfloor\frac{P_{B}}{\xi}\right\rfloor\)do
2:\(T(0,i\xi)\gets 0\)
3:endfor
4:for\(j=1\) to \(c\)do
5:for\(i=0\) to \(\left\lfloor\frac{P_{B}}{\xi}\right\rfloor\)do
6:\(p\gets i\xi\)
7:\(T(j,p)\gets 0\)
8:for\(k=0\) to \(\left\lfloor\frac{\min\left(p,\omega_{j};p_{B}\right)}{\xi}\right\rfloor\)do
9:if\(T(j-1,p-k\xi)+\bar{f}(j,k\xi)>T(j,p)\)then
10:\(T(j,p)\gets T(j-1,p-k\xi)+f(j,k\xi)\)
11:\(A(j,p)\gets k\xi\)
12:endif
13:endfor
14:endfor
15:endfor
16:\(E_{max}\gets 0\)
17:\(P_{sum}\gets 0\)
18:for\(i=0\) to \(\left\lfloor\frac{P_{B}}{\xi}\right\rfloor\)do
19:\(p\gets i\xi\)
20:if\(\frac{T(c,p)}{p}>E_{max}\)then
21:\(E_{\max}\leftarrow\frac{T(j,p)}{p}\)
22:\(P_{sum}\gets p\)
23:endif
24:endfor
25:\(p\gets P_{sum}\)
26:for\(j=c\) down to \(1\)do
27:\(\bar{P}_{j}\gets A(j,p)\)
28:\(p\gets p-\bar{P}_{j}\)
29:endfor
```  
**Algorithm 1** Inter-cluster dynamic programming algorithm
This optimization problem can be solved by the Lagrangian multiplier method [54,55]. Concretely, by applying the Lagrangian multiplier method, the optimal problem can be expressed as  
\[ \begin{split} L\Big{(}P^{j},\lambda,\mu,v\Big{)}=&\sum \limits_{i=1}^{n^{j}}\omega_{j}b\log_{2}\Bigg{(}1+\frac{H_{i}^{j}P_{i}^{j}}{ \omega_{j}+\sum\limits_{k=i+1}^{n^{j}}H_{i}^{j}P_{k}^{j}}\Bigg{)}+\lambda \Bigg{(}\sum\limits_{i=1}^{n^{j}}P_{i}-P_{\max}^{j}\Bigg{)}+\\ &\sum\limits_{i=1}^{n^{j}}\mu_{i}\Bigg{(}H_{i}^{j}P_{i}^{j}-\left( \omega_{j}+\sum\limits_{k=1}^{i-1}H_{i}^{j}P_{k}^{j}\right)\Bigg{(}2^{\frac{n ^{j}_{i}}{n^{j}}}-1\Bigg{)}\Bigg{)}+\sum\limits_{i=2}^{n^{j}}v_{i}\Bigg{(}H_{i -1}^{j}P_{i}^{j}-\sum\limits_{k=1}^{i-1}H_{i-1}^{j}P_{k}^{j}-P_{T}\Bigg{)}\\ &\text{where }\lambda,\,\mu=\big{\{}\mu_{1},\mu_{2},\ldots,\mu_{n^{j}} \big{\}}\text{ and }v=\big{\{}v_{1},v_{2},\ldots,v_{n^{j}}\big{\}}\text{ are the Lagrangian multipliers.}\\ \end{split}