## 3 Beamformer Design
### IRS Phase Adjustment
Defining  
\[\mathbf{B}(\gamma)\doteq\mathbf{1}_{K}-\sqrt{P}\min\Biggl{\{}1,\frac{N}{\| \mathbf{S}_{H}[\sqrt{\gamma}\mathbf{1}_{K}-\sqrt{P}\mathbf{g}]\|}\Biggr{\}} \mathbf{HS}_{H},\]  
the square of the LS estimation error is given as  
\[\varepsilon=\left\|\mathbf{B}(\gamma)[\sqrt{\gamma}\mathbf{1}_{K}-\sqrt{P} \mathbf{g}]\right\|^{2}.\]  
As in Section 3.1, the equalized signal level \(1+\gamma-\varepsilon=1+\gamma-\|\mathbf{B}(\gamma)[\sqrt{\gamma}\mathbf{1}_{K} -\sqrt{P}\mathbf{g}]\|^{2}\) is an increasing function of \(\gamma\) until the point \(\|\mathbf{S}_{H}[\sqrt{\gamma}\mathbf{1}_{K}-\sqrt{P}\mathbf{g}]\|=N\) is reached. Again, the overall shape of \(1+\gamma-\|\mathbf{B}(\gamma)[\sqrt{\gamma}\mathbf{1}_{K}-\sqrt{P}\mathbf{g}]\| ^{2}\) over \(\gamma\) is assured to be concave and the maximum of the equalized signal level can be obtained at \(\gamma^{*}\) by conducting the GSS over \(\gamma\) within the feasible range of \(0\leq\gamma\leq\hat{\gamma}=\lambda_{max}^{2}(\mathbf{H})P\). Finally, we take only the phases the elements of found \(\mathbf{GE}\), while discarding the magnitude components of the vector as \(\phi_{i}=e^{i\angle\phi_{i}}\), \(i=1,\ldots,N\). Again, the overall optimization is a concave one of \(\gamma\) as summarized in Algorithm 2, where the IRS phase shift vector \(\mathbf{GE}\) is found as a by-product after discarding the magnitude values and leaving only the phase values. ```
1. Find \(\mathbf{S}_{H}\). 2. Calculate \(\mathbf{B}(\gamma)\) and conduct the GSS over \(\gamma\) to locate \(\gamma^{*}\) where \(1+\gamma-\varepsilon\) peaks. 3. Calculate \(\mathbf{G}\) with the found \(\gamma^{*}\). 4. Calculate \(\phi_{i}=e^{j\angle\phi_{i}},\ i=1,\ldots,N\). ```  
**Algorithm 2** AP pre-coder optimization algorithm  
Second, we provide a user grouping approach, with the optimal phase alignment of [16] applied to each group. The minimum operator in (7) not only prevents any user from controlling the IRS exclusively, but also forces the user channels to be handled on an equal basis. Therefore, one reasonable approach in this case is a round-robin method, where each user is allowed to take up the IRS in turn to pick up a few IRS antenna elements with the strongest gain paths among the previously unselected antenna elements, and to adjust the phases of the selected paths as in [16]. This process is repeated until the all IRS antenna elements are selected, that is, each element falls in a territory among \(K\) user channel territories. In this way, all \(K\) user channels have equal opportunity to share the IRS and to apply the algorithm of [16] with approximately \(N/K\) IRS antenna elements. At each round of IRS antenna selection, the number of selected elements is determined to minimize the disparity among the sums of user channel gains selected so far. After all the IRS antenna elements are determined to fall in selected territories, the sums of the aligned channel gains of user channels are approximately equal. The above \(\mathbf{\Phi}\) decision scheme is summarized in Algorithm 3. To save computation, we may apply the Algorithm 3 until some number of elements less than \(N\) are selected, and leave the remaining unselected ones with random phases, leveraging the fact that the added channel gain suma from these elements are averaged out by the randomness. The method introduced in [19] first uses a simple mathematical model to define the numbers of elements in the groups and allocates the reflecting elements in a block-wise manner according to the defined number of elements. On the other hand, Algorithm 3 allocates reflecting elements one-by-one into groups in a round-robin fashion while it checks out the channel gains accreted so far to keep the final channel gains as uniform as possible. Therefore, it is expected that Algorithm 3 is superior to the method in [19] in equalizing the channel gains. However, the comparison of these two methods in the problem setting of this work is beyond the main concerns of this paper, and thus is skipped.