# Fingerprint Based Codebook for RIS Passive Beamforming Training
## 4 Proposed Fingerprint-Based PBF Scheme  
This section presents the proposed PBF scheme using the FP-based CB. Similar to other CB-based solutions, this scheme is performed in three main stages: first, designing the CB; here we design our codebook based on fingerprint points. Then, the system performs a searching stage through a specific group of selected RPs, i.e., configuring RIS elements only using these RPs. After that, the scheme selects the best codeword for the RIS to obtain the desired performance using the rote learning method due to its simplicity.  
To design the fingerprint-based codebook, \(\mathbf{W}\), the interested area is divided into \(P\) points, as shown in Figure 3. The number of points denotes the total number of the designed CB codewords. The space between the points is determined according to the acceptable CB size and complexity. Here, we assume a 3 m horizontal and vertical space, \(d_{s}\), between each point, so the number of points is 200 when considering a network coverage area of \(30\times 60\) m\({}^{2}\). Then, in an offline phase, the beamforming vector corresponding to each point, i.e., the reflection pattern, is determined once using channel estimation and the PBF optimization scheme that was proposed in [18] or any other preferable CE-based scheme. After that, the system stores the x-y coordinates of the \(P\) points with their current optimal RPs that are selected for these points in the FP codebook, \(\mathbf{W}\), as presented in Table 1. These RPs are the optimal ones only in certain channel conditions, i.e., when the  
Figure 2: Example of (**a**) random CB and (**b**) SDM-CB generation in CB-PBF schemes.  
system determines them, and for sure, with channel changes, they will not remain optimal. However, they can present possible optimal or sub-optimal RPs in future online stages. Moreover, they are more descriptive than randomly generated RPs.  
In the online phase, when a new RX requests to connect to the TX, the system estimates the RX position, \((x^{\prime},y^{\prime},z^{\prime})\). Then, using Table 1, the Euclidean distance, \(d_{p}\), between the estimated RX location and each \(p\)th FP point is calculated as:  
\[d_{P}=\sqrt{\left(x^{\prime}-x_{p}\right)^{2}+\left(y^{\prime}-y_{p}\right)^{2 }+\left(z^{\prime}-z_{p}\right)^{2}} \tag{2}\]  
Here, we assume \(z^{\prime}\) and \(z_{p}\) are constant at the RX plane, i.e., \(z^{\prime}=z_{p}=1\) m. By sorting the distances, the nearest \(C\) points can be determined. Then, the corresponding C RPs to these points are chosen as the candidate codewords for the searching stage. Because the estimated location comes with an error due to several reasons [16], we consider using these \(C\) candidate RPs instead of using the nearest RP, thus obtaining better performance, as will be discussed in the results section, where this \(C\) parameter is affected by the localization accuracy. After defining the \(C\) candidate RPs, the system examines these RPs, and the RX sends uplink feedback corresponding to each RP. Therefore, the learning stage selects the RP that can maximize the searching OF, where we assume maximizing the RX received power, \(y_{r}\), as OF. Algorithm 1 summarizes this scheme. Using our proposed scheme for the PBF process, the system overhead will be \(\mathcal{O}(C)\), while the computational complexity will be reduced to \(O(\text{CM})\).  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multicolumn{1}{c}{**Point ID**} & **1** & **2** & **3** &. &. & \(P\)\(-\)**1** & \(P\) \\ \hline
**x coordinate**, \(x_{p}\) & 1.5 & 1.5 & 1.5 &. &. & 28.5 & 28.5 \\ \hline
**y coordinate**, \(y_{p}\) & 1.5 & 4.5 & 7.5 &. &. & 55.5 & 58.5 \\ \hline
**PBF vector** & \(\mathbf{\theta_{1}}\) & \(\mathbf{\theta_{2}}\) & \(\mathbf{\theta_{3}}\) & & & \(\mathbf{\theta_{P-1}}\) & \(\mathbf{\theta_{P}}\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: FP codebook.  
Figure 3: The area of interest and fingerprint point distribution.