{'fraction_non_alphanumeric': 0.04667710260424079, 'fraction_numerical': 0.014543902091931123, 'mean_word_length': 4.117390037867755, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Joint Location and Communication Study for Intelligent Reflecting Surface Aided Wireless Communication System

Intelligent reflecting surface (IRS) is a novel burgeoning concept, which possesses advantages in enhancing wireless communication and user localization, while maintaining low hardware cost and energy consumption. Herein, we establish an IRS-aided mmWave-MIMO based joint localization and communication system (IMM-JLCS), and probe into its performance evaluation and optimization design. Specifically, first, we provide the signal, channel and estimation error models, and contrive the working process of the IMM-JLCS in detail. Then, by configuring appropriate IRS phase shifts, we derive the closed-form expressions of the Cramer-Rao Lower Bound (CRLB) of the position/orientation estimation errors and the effective achievable data rate (EADR), with respect to the time allocation ratio of the beam alignment and localization stage (BALS). Subsequently, we investigate the trade-off between the two performance metrics, for which we propose a joint optimization algorithm. Finally, we carry out simulations and comparisons to view the trade-off and validate the effectiveness of the proposed algorithm, in the presence of distinct levels of estimation uncertainty and user mobility. Our results demonstrate that the proposed algorithm can find the joint optimal solution for the position/orientation estimation accuracy and EADR, with its optimization performance being robust to slight localization or channel estimation errors and user mobility.


I. INTRODUCTION
The fifth-generation (5G) mobile communication network has been standardized and commercially deployed in part since the first quarter of 2020, while the researches on the sixth-generation (6G) mobile communication have already begun to advance [1]- [3]. With an enormous amount of worldwide mobile communication devices to be served, various key enabling technologies, including the millimeter-wave (mmWave), massive multiple-input-multiple-output (MIMO) and ultra-dense network (UDN), have been developed to fulfil the requirements of Gbps level of achievable data rate, high spectral efficiency, mass connectivity, ultra-reliability and low latency [3]. While these technologies possess prominent advantages in improving the wireless communication performance, they are still facing several challenging and inevitable issues. First, the mmWave is susceptible to blockage and suffers from serious free-space propagation loss in the atmosphere due to its high frequency [4]. Second, the massive MIMO and UDN consist of large-scale antenna arrays and serried base stations (BSs), resulting in high hardware cost and energy consumption [5], [6]. In view of these problems, the future 6G will focus more on the exploration of novel communication paradigms on the foundation of the current 5G.
between the positioning accuracy and EADR, with distinct system settings, the two performance metrics may not simultaneously reach their own maximums, but instead, can possibly achieve their joint optimal point. Therefore, a joint optimization algorithm is required for guiding the optimal system setup. Third, the IRS phase shifts need to be adjusted to cater for the localization and communication requirements, but the phase shift adjustment depends on the MU's position information in turn. Thus, a specific framework of the system's working process should be designed to facilitate the IRS configuration in the real-world application scenarios.
To the best of our knowledge, we have not found the related works carried out by considering the above three aspects. Consequently, in this article, we first establish an IRS-aided mmWave-MIMO based joint localization and communication system (IMM-JLCS) and design a framework of its working process, and then probe into the trade-off and joint optimization on the positioning accuracy and EADR, with our contributions summarized as follows.
• We construct a 3D IMM-JLCS in the presence of an obstacle which blocks the LoS link.
In this IMM-JLCS, first, we divide a communication period with a fixed duration into three stages, i.e. beam alignment and localization stage (BALS), effective data transmission stage (EDTS) and joint optimization stage (JOS), for position/orientation estimation, effective data transmission, and joint optimization on the localization and communication performances, respectively. Then, we design a complete framework of the working process for the considered system within each communication period. • We calculate the CRLBs of the position/orientation estimation errors and the EADR of the effective data transmission to evaluate the potential localization and communication performances, and derive their approximate closed-form expressions with respect to the time allocation ratio of the BALS by configuring appropriate IRS phase shifts. • Under different time allocation ratio, we investigate the trade-off between the positioning accuracy and EADR. Based on the insight provided by the trade-off, we formulate a joint optimization problem to optimize the time allocation ratio, in order to find a joint optimal solution of the CRLB and EADR. By solving this problem with the Lagrangian multipliers and the Karush-Kuhn-Tucker (KKT) conditions, we finally propose a joint optimization algorithm for the two performance metrics. • In order to view the trade-off and validate the effectiveness and robustness of the proposed algorithm, we carry out simulations in the presence of distinct levels of 1) user mobility and 2) channel and position/orientation estimation errors. Moreover, we numerically compare the designed IRS phase shifts with random IRS phase shifts in terms of the potential localization and communication performances, for the purpose of evaluating the performance improvement brought by the IRS phase shift configuration in our work.
The remainder of this article is organized as follows. In Section II, we present the system model and the working process of the IMM-JLCS. In Section III, we calculate the position/rotation error bounds and the EADR, and derive their approximate closed-form expressions in relation to the time allocation ratio. In Section IV, we discuss the trade-off between the two performance metrics, and propose the joint optimization algorithm. In Section V, we carry out simulations to view the numerical results and make performance comparisons. In Section VI, we draw the overall conclusions.
Notations: Boldfaces and italics stand for the vectors or matrices and the constants or variables, respectively. X T , X * , X H and X −1 represent the transpose, conjugate, conjugate-transpose and inverse of X.
[X] (a,b) represents the (a, b)-th element in X. tr(X) denotes the trace of X. diag(x 1 , x 2 , ..., x n ) stands for a diagonal matrix with its diagonal elements of (x 1 , x 2 , ..., x n ).
. and . 2 symbolize the 1 -norm and 2 -norm. ⊗ and symbolize the Kronecker product and Hadamard product. Re{x} and Im{x} are the real part and imaginary part of x. x denotes the estimate of x. E a [X] denotes the expectation of X on a if X is a random matrix in relation to a. a X represents the gradient of X with respect to a, while ∂x ∂a represents the partial derivative of x with respect to a. (a, b) ∼ U {(x, y) : x 2 + y 2 ≤ r 2 } represents that the point (a, b) is uniformly distributed in the circular region with center of (0, 0) and radius of r.

II. SYSTEM MODEL AND WORKING PROCESS DESIGN
We consider an IMM-JLCS in the 3D scenario, as illustrated in Figure 1. A BS with uniform linear array (ULA) consisting of N t B antennas, localizes and communicates with a MU with ULA consisting of N r M antennas. The LoS path is assumed to be obstructed by an obstacle, e.g. the edifice or infrastructure. Due to the mmWave's susceptibility to blockage, the LoS link is assumed unavailable in such situations, so that a uniform square planar IRS containing N = L×L passive reflecting elements, with L being the number of rows or columns of the IRS, is employed to establish a strong VLoS reflection path to assist the localization and wireless data transmission. The adjacent element spacing of the antennas on the BS/MU or the reflecting units on the IRS is d = λ/2, where λ denotes the signal wavelength. To facilitate the analysis, an auxiliary 3D Cartesian coordinate system is established to indicate the positions of the IRS, the BS and the MU. The IRS and the antenna array on the BS are placed parallel to y − o − z plane and x-axis, respectively, with their centers located at v = (v x , v y , β IRS ) T ∈ R 3 and q = (q x , q y , β BS ) T ∈ R 3 , where β IRS and β BS symbolize the heights of the IRS and BS relative to the MU on the ground. The MU moves and rotates by angle α ∈ [0, 2π) in the x − o − y plane, with the center of its antenna array located at p = (p x , p y , 0) T ∈ R 3 . Here, v and q are known and invariant after the deployments of the IRS and BS, while p and α are unknown and need to be estimated.
This system is designed to achieve the goals of: 1) localizing the MU and determining its orientation from the received signals; 2) transmitting effective data from the BS to the MU; and 3) jointly optimizing the position/orientation estimation accuracy and the EADR. The three tasks are completed independently in a communication period with the fixed duration of T c . Specifically, as shown in Figure 2, which indicates the timeline of the tasks, one communication period is divided into three stages: the BALS with the duration of T b , the EDTS with the duration of T d , and the JOS with the duration of T o . In the BALS, the BS sequentially emits several pilot signals to the MU for beam alignment and position/orientation estimation. Afterwards, in the EDTS, the BS communicates with the MU by transmitting the information-carrying signal. Finally, in the JOS, the system performs joint optimization on both the localization and communication performances. When the system is running, T c and T o are fixed, while T b and T d are alterable but satisfy Tc , while that for T d is 1 − To Tc − . Moreover, the BS can partially activate N B ≤ N t B adjacent antennas for signal emission and deactivate the other N t B − N B antennas, while the MU activates totally N M = N r M antennas for signal reception. The position of the MU is assumed to be approximately invariant within one communication period, but change between distinct communication periods. The MU's position in the (l −1)-th communication period, denoted by (p x , p y )| (l−1) , is uniformly distributed within a circular area with the radius of Υ (x,y) and center point of the MU's position in the l-th communication period, denoted by (p x , p y )| l , i.e. (p x , p y )| (l−1) = (p x , p y )| l + (δ px , δ py ), with (δ px , δ py ) given by where different Υ (x,y) can embody different levels of user mobility.
Based on the aforementioned geometry and functionality of this system, we will subsequently illustrate the signal, channel and estimation error models, and elaborate the system's working process in detail.

A. Transmitted Signal Model
We first describe the transmitted signal models in the BALS and EDTS. In the BALS, let the pilot signal be denoted by a continuous time-domain waveform x 0 (t), with the bandwidth of B and duration of T s . For simple analysis, we assume that x 0 (t) has the unit power and flat spectrum, which causes its power spectrum, denoted by |X 0 (ω)| 2 , to be a constant of |X 0 (ω)| 2 = Ts [42]. When transmitting each pilot signal, the BS selects a column of codewords as the unitnorm transmit beamforming vector w B , which satisfies w B = 1, from a predetermined DFT codebook C BS ∈ C N B ×N B . Specifically, the m B -th column of C BS is expressed as where m B = 1, 2, ..., N B . Thus, the transmitted pilot signal is expressed as where √ P T X stands for the average transmitting power. In the EDTS, let the signal carrying the effective information be denoted by x 1 (t) with the bandwidth of B and the duration of T d . Hence, the transmitted information-carrying signal is expressed as where w B represents the optimal transmit beamformer, which, together with the optimal receive combining vector w M at the MU (detailed in Section II-C), contributes to maximizing the received signal-to-noise ratio (SNR) among all the beamformers searched from C BS .

B. Wireless Channel Model
We next illustrate the wireless channel model. As shown in Figure 1, the VLoS channel is composed of two tandem parts, denoted by H BI from the BS to the IRS, and H IM from the IRS to the MU, which are modelled as where ϕ a IRS,1 , ϕ e IRS,1 and ϕ T X,1 are the azimuth AOA, elevation AOA at the IRS and the AOD at the BS for the BS-IRS link, while ϕ a IRS,2 , ϕ e IRS,2 and ϕ RX,1 are the azimuth AOD, elevation AOD at the IRS and the AOA at the MU for the IRS-MU link. These parameters are related to the positions and rotation angle of the MU according to The array response vectors in H BI and H IM are given by a T X (ϕ T X,1 ) = 1, e j 2πd λ sinϕ T X,1 , ..., e j 2πd a RX (ϕ RX,1 ) = 1, e j 2πd λ sinϕ RX,1 , ..., e j 2πd a IRS (ϕ a IRS,1 , ϕ e IRS,1 ) = 1, e j 2πd As the IRS is able to induce adjustable phase shifts on the impinging signal wave from the BS through H BI , and reflect it to the MU through H IM , the entire channel is expressed as where h 1 = h 1 √ ρ 1 , with h 1 symbolizing the complex channel gain, and ρ 1 embodying the path loss of the BS-IRS-MU link. Specifically, ρ 1 satisfies 1 [38], where ζ denotes the power attenuation coefficient; d 1,1 = v − q 2 and d 1,2 = p − v 2 are the distances between the BS and IRS, and between the IRS and MU, respectively. Θ = δ × diag(e jθ 1 , e jθ 2 , ..., e jθ N ) ∈ C N ×N is the diagonal phase shifting matrix of the IRS, in which δ ∈ (0, 1] represents the reflection coefficient, and θ i , for i = 1, 2, ..., N , represents the i-th IRS phase shift. In the considered system, Θ can be configured differently in the BALS and EDTS. Specifically, in the BALS, Θ can be adjusted into Θ = Θ 1 , which is the optimal configuration for the localization performance. In the EDTS, Θ can be adjusted into Θ = Θ 2 , which is the optimal configuration for the data transmission performance. Detailed information about the configurations of Θ 1 and Θ 2 will be given in Section III.

C. Received Signal Model
We then elaborate the received signal models in the BALS and EDTS. In the BALS, when the MU receipts one pilot signal, it selects a column of codewords as the receive combining vector where m M = 1, 2, ..., N M . Hence, the received pilot signal is expressed as where symbolizes the time delay of the VLoS path; c ≈ 2.99792458 × 10 8 m/s is the speed of light. n(t) stands for the additive white Gaussian noise (AWGN) at the MU, with mean of 0, variance of σ 2 w and power spectral density of N 0 = σ 2 w B . In the EDTS, the received information-carrying signal is expressed as where w M is the optimal receive combining vector, which, together with the optimal transmit beamformer w B at the BS, contributes to maximizing the received SNR among all the receive combining vectors searched from C M U .

D. Working Process
We subsequently expound the working process of this system. Here, we consider the l-th communication period as an example, and present the flowchart of the working process in Figure  3. From Figure 3, we describe the procedure as five steps: • Step 1: When the l-th communication period begins, the IRS controller determines a Θ 1 based on the estimated azimuth AOD ( ϕ a IRS,2 ) and elevation AOD ( ϕ e IRS,2 ) at the IRS from the (l − 1)-th communication period, and adjusts the IRS phase shifting matrix into Θ 1 .
• Step 2: The BS and MU simultaneously search w B and w M from C BS and C M U column-bycolumn, i.e. exhaustive search, in the BALS. When searching each beam pair of (w B , w M ), the BS transmits a pilot signal x 0 (t) to the MU for beam alignment and position/orientation estimation. When this procedure ends, the BS totally sends M = N B × N M pilot signals, after which it outputs the estimated parameters including h 1 , p, α, as well as ϕ a IRS,2 and ϕ e IRS,2 which are mapped from p and α according to (9) and (11), and then calculates the CRLB of the position/orientation estimation error based on (43) in Section IV-B. The ϕ a

IRS,2
and ϕ e IRS,2 are stored for determining Θ 1 in the next communication period, and are adopted by the IRS controller to determine Θ 2 for the subsequent effective data transmission in this communication period. The h 1 is substituted into (44) in Section IV-B for calculating the EADR of this communication period. The CRLB and EADR are stored as objectives to be optimized, and will be input to the joint optimization module in Step 4.
• Step 3: When the BALS terminates, the BS and MU decide a beam pair of ( w M , w B ), which is selected corresponding to the maximum received SNR from all beam pairs searched during the BALS. Then, the IRS phase shifting matrix is adjusted into Θ 2 in the EDTS, and the BS sends x 1 (t) to the MU for effective data transmission.
• Step 4: When the EDTS terminates, the signal transmission and reception are suspended, and the joint optimization module is actuated. The CRLB and EADR, obtained in Step 2, are input to the joint optimization module, which aims at finding a that makes the CRLB and EADR jointly optimal. After the optimization process, the output of is used to design and update T b and T d , which guides the BS to determine the number of the activated antennas or the codebook size, for the next communication period.
• Step 5: The working process turns to the beginning of the (l + 1)-th communication period, and repeats Step 1 to Step 4.
It is noted that the Θ 1 in the l-th communication period is determined by ϕ a IRS,2 and ϕ e IRS,2 , which are estimated in the (l − 1)-th communication period. This may result in a hysteretic update of Θ 1 in the presence of user mobility, which will be discussed in the simulations.
In addition, as the positioning and channel estimation algorithms in the mmWave communication scenarios have been investigated in the related works [30], [32], [34], [40], here we assume that h 1 , p and α can be acquired by some existing estimation techniques based on, e.g. maximum-likelihood, compressed sensing, et al. which are out of the scope of this paper. Instead, we model the estimation errors below, which exist in most estimation methods.
E. Estimation Error Model 1) Localization Error: By referring to [41], the estimated position p and rotation angle α are, respectively, expressed as where p and α are the actual position and rotation angle of the MU; ∆p represents the position estimation error, which is uniformly distributed within a circular region with the radius of (x,y) and center point of (0, 0); ∆α represents the rotation estimation error, which is uniformly 2) Channel Estimation Error: According to [47], the estimated complex channel coefficient h 1 is expressed as where h 1 is the actual complex channel coefficient; ∆ h 1 denotes the channel estimation error, which follows a zero-mean complex Gaussian distribution with the variance of σ 2 h . Based on the signal and estimation error models, in the next section, we will first obtain the position error bound (PEB), rotation error bound (REB) and EADR, and then derive their closed-form expressions with respect to the time allocation ratio .

III. SYSTEM PERFORMANCE METRICS
For evaluating the performances of the position/orientation estimation and effective data transmission, this section first introduces PEB/REB and EADR as performance metrics, and then derives their closed-form expressions in relation to by configuring appropriate IRS phase shifting matrices in the BALS and EDTS.
A. PEB and REB

1) Mathematical Description:
The PEB and REB can be derived from the Fisher information matrix (FIM). Preceding the derivations of the FIM, we should first define a variable vector containing the unknown channel parameters to be estimated. As described in Section II, because the positions of the BS and IRS are known, ϕ T X,1 , ϕ a IRS,1 and ϕ e IRS,1 can be geometrically determined by q and v. As a result, the unknown parameters are those related to p, which are involved in where h R,1 = Re{ h 1 } and h I,1 = Im{ h 1 } are the real part and imaginary part of h 1 .
The FIM of η with respect to w B , w M and Θ 1 can be derived from [30]: where f (y 0 |η) is the likelihood function of y 0 (t) conditioned on η, given by where is the deterministic noiseless signal part in y 0 (t).
In order to avoid affecting the coherence of reading, we provide the derivations and exact expressions of the elements in J η (w B , Θ 1 , w M ) in Appendix A.
Afterwards, we calculate the FIM for p x , p y and α. Let T ∈ R 3×6 denote a Jacobian matrix composed of the partial derivatives of the channel parameters in η on p x , p y and α. The elements in T are derived in Appendix B.
Finally, let g be defined by g = (p x , p y , α) T . Thus, the FIM for g, defined by J g (w B , Θ 1 , w M ), is expressed as (30) is computed for a single beam pair of (w B , w M ). As there are M = N B × N M beam pairs searched during the beam alignment procedure and the FIM is calculated for all the beam pairs, we will totally obtain M different J g (w B , Θ 1 , w M ) in the BALS. Owing to the additive property of the FIM, we obtain the entire FIM according to From (31), we obtain the actual PEB in meters and REB in radians for the MU by calculating where Eq. (32) and Eq. (33) indicate that the PEB and REB are proportional to the trace of the inverse matrix of J , so that the more beams are searched during the beam alignment, the more J g (w B , Θ 1 , w M ) and the lower PEB or REB are obtained, which improves the potential location/orientation estimation performance.

2) Phase Shift Design:
Based on (32) and (33), the optimal configuration of Θ 1 in the l-th communication period should make the FIM achieve its maximum. Referring to Observation 2 and Eq. (12) in [36], we similarly retrospect γ IRS in Appendix A, on which the position/rotation estimation performance primarily depends if w B and w M are given. Because γ IRS can be further expressed as where θ 1 is a column vector which satisfies Θ 1 = diag θ 1 . According to (34), we have |γ IRS | ≤ N , and |γ IRS | reaches its maximum when θ 1 = a IRS (ϕ a IRS,2 , ϕ e IRS,2 ) a * IRS (ϕ a IRS,1 , ϕ e IRS,1 ).
Because the IRS phase shifts are adjusted based on the estimated parameters, the optimal Θ 1 is designed as where ϕ a IRS,2 (l − 1) and ϕ e IRS,2 (l − 1), according to Figure 3, represent the estimated ϕ a IRS,2 and ϕ e IRS,2 in the (l − 1)-th communication period.

3) Approximate Closed-form Expression:
From Appendix A, the elements in J η (w B , Θ 1 , w M ) are related to γ T X,1 , γ RX,1 ,γ IRS , γ RX,1 , γ IRS,a and γ IRS,e , if P T X , T s , N 0 , B and h 1 are fixed. Among these parameters, only γ T X,1 , γ RX,1 and γ RX,1 are associated with w B and w M , which vary in the beam alignment procedure. Note that in (31), J can be equivalently written as another form: To derive the closed-form expression, we should calculate A, which is equivalent to calculating (87).
After a few manipulations, we obtain the expressions of the elements in A, denoted by A i,j for i = 1, 2..., 6 and j = 1, 2, ..., 6, in Appendix C, and show that A is independent of or does not change with . As a result, we have P EB( ) = tr J −1 1:2,1:2 which are inversely proportional to √ .

1) Mathematical Description:
According to (20) and the time allocation pattern in Figure 2, the EADR is expressed as 2) Phase Shift Design: The optimal configuration of Θ 2 in the l-th communication period should make the EADR achieve its maximum. According to (39), we have For simple analysis, we assume that the antenna arrays have high angular resolution when N B and N M is large, so that w M and w B approximately satisfy w M ≈ 1 √ N M a RX (ϕ RX,1 ) and IRS,2 , ϕ e IRS,2 ) a * IRS (ϕ a IRS,1 , ϕ e IRS,1 ) , Because the IRS phase shifts are adjusted based on the estimated parameters, the optimal Θ 2 is designed as where ϕ a IRS,2 (l) and ϕ e IRS,2 (l), according to Figure 3, stand for the estimated ϕ a IRS,2 and ϕ e IRS,2 in the l-th communication period.

3) Approximate Closed-form Expression:
Here, if the estimation errors are assumed to be slight, i.e.
x ≈ x for variable x, by substituting (41) into (39), we obtain which is an approximate function of when the other parameters are given.

IV. TRADE-OFF AND JOINT OPTIMIZATION
This section discusses the trade-off between PEB/REB and EADR, and proposes an algorithm to find the joint optimal solution for the potential localization and data-transmission performances by optimizing the time allocation ratio .

A. Trade-off between PEB/REB and EADR
From (37), (38) and (42), it is indicated that as grows, the PEB and REB continuously decreases, resulting in an improvement of the potential localization performance, while the EADR varies in a non-monotonic way. The occurrence of this phenomenon can further be explicated by retrospecting the system working process in Section II. As shown in Figure 2 and 3 in Section II, when T b is extended, more beams are searched and more pilot signals are transmitted during the BALS, leading to a higher positioning accuracy. Meanwhile, with more beams searched, the codebook size at the BS is expanded and more antennas are concomitantly activated, leading to a higher received SNR. However, as T c and T o are fixed, prolonging the BALS shortens the EDTS and reduces 1 − To Tc − , which, according to (42), influences the EADR dominantly. Therefore, there exists a trade-off between PEB/REB and EADR. In view of this trade-off, we will jointly optimize the two performance metrics in the remainder of this section.

B. Joint Optimization
Before the joint optimization problem is formulated, an objective function as a weighted sum of (PEB + REB) and EADR with respect to is first constructed. Since the system can only acquire the estimates of the position/orientation and channel parameters related to the MU, based on (37), (38) and (42), we define with X and Y given by where T, A and h 1 are the estimates of T, A and h 1 . Specifically, T and A are obtained by replacing p, α, h 1 and the corresponding ϕ RX,1 , ϕ a IRS,2 , ϕ e IRS,2 in T and A with p, α, h 1 and the corresponding ϕ RX,1 , ϕ a IRS,2 , ϕ e IRS,2 . Then, the joint optimization problem is formulated as where ξ represents a predetermined weight parameter. Subsequently, in order to solve (P 1), we construct a Lagrangian function by introducing a multiplier λ 1 : According to the KKT conditions, the optimal should satisfy: From (49a) to (49d), it is noted that: 1) if λ 1 = 0, we need to solve and obtain = 1 . If 1 satisfies 0 < 1 ≤ 1 − To Tc , it is a solution which meets the KKT conditions. 2) If λ 1 = 0, we need to solve and obtain = 2 = 1 − To Tc and λ 1 = 1 is also a solution that meets the KKT conditions. Finally, if 1 and 2 both satisfy the KKT conditions, the optimal , denoted by , is obtained by = arg min Based on the above analysis, we design the Algorithm 1 to minimize the objective function in (P1) and find the optimal solution of . Forasmuch as the performance of Algorithm 1 is closely related to the estimation uncertainty, the influences of the estimation errors on the optimization performance will be discussed in the following Section V.

V. NUMERICAL RESULTS
This section presents the simulation results of the performance metrics as well as their tradeoff, and investigates the joint optimization performance of the proposed algorithm, in the presence of different levels of user mobility and estimation uncertainty.

Algorithm 1: Joint Optimization Algorithm for Solving (P1)
Input: The estimated parameters including h 1 , p, α, the corresponding AOAs and AODs; Compute X and Y, initialize ξ; Obtain = 1 by solving (50); Obtain the optimal by calculating = arg min Obtain the optimal from = 1 ; else if λ 1 ≥ 0 then Obtain the optimal from = 2 = 1 − To Tc ; else Empty solution for optimal ; Output: as the optimal time allocation ratio;

A. System Parameters
Before the simulations, we set the system parameters in Table I by referring to [32], [42]. According to the parameters, we further obtain the signal wavelength λ = c/f c ≈ 5 mm, the antenna spacing d = λ/2 = 2.5 mm, and the distances between BS and MU (d 0 = 60 m), BS and IRS (d 1,1 = 30 m) and IRS and MU (d 1,2 ≈ 53.85 m).

B. Performance Metrics and Trade-off
First, we numerically investigate the trade-off between PEB/REB and EADR, and discuss the impact of the user mobility and localization error on the performances. Figure 4 displays the log 10 (P EB) and log 10 (REB) as functions of the normalized time allocation ratio Tc Tc−T 0 × , in the presence of different levels of (a) localization error, and (b) user mobility. Both Figure 4 (a) and Figure 4 (b) indicate that: 1) as or N grows, log 10 (P EB) and log 10 (REB) decrease, leading to a better potential position/orientation estimation performance.
2) The localization error with (x,y) ≤ 7 m and α ≤ π 6 rad, and user mobility with Υ (x,y) ≤ 7 m, slightly impact (increase) log 10 (P EB) and log 10 (REB) because they influence the IRS phase shift design for Θ 1 . 3) Under the assumption of perfect estimation, i.e. no estimation error, the approximate closed-form expressions in (37) and (38) coincide with the original (32) and (33), testifying the correctness of the derivations in Appendix C. Figure 5 depicts the EADRs as functions of Tc Tc−T 0 × , in the presence of different levels of localization error. It is demonstrated that: 1) as N grows, the EADR increases, while as   Υ (x,y) and N . The curves with legend "Approximate Closed-form" represent the results of (37) and (38), while the marks with legend "Original" represent the results of (32) and (33). The discrete marks represent the results averaged on 50 Monte Carlo trials. grows, the EADR first ascends to a maximum and then descends to zero. 2) The localization error with (x,y) ≤ 7 m and α ≤ π 6 rad degrade the EADR, as they influence the IRS phase shift design for Θ 2 . 3) Under the assumption of perfect estimation, the original (39) is lower  than the approximate closed-form expression in (42) at several points. This is because the beam pair of ( w M , w B ) is obtained from the codebooks, which may not precisely equal to Figure 6 plots the EADRs as functions of log 10 (P EB) and log 10 (REB), in the presence of different levels of (a) localization error, and (b) user mobility. It is illustrated that when the PEB/REB achieves the minimum, the EADR decreases to zero; when the EADR reaches its maximum, the PEB/REB does not achieve its own optimal state. Therefore, a trade-off exists between the PEB/REB and EADR, which share a joint optimal point represented by the peak of each curve.

C. Comparisons with Random Phase Shifts
The random IRS phase shifts can embody the reflection characteristic of scatterers without phase adjustment, which universally exist in the mmWave communication environment [32]. For evaluating the performance improvement brought by the IRS phase shift design, we compare Θ 1 and Θ 2 with random IRS phase shifts in terms of the PEB/REB and EADR performances.
The comparisons are shown in Figure 7, where the random IRS phase shifts are uniformly distributed within [−π, π]. It is indicated that the PEB/REB with Θ 1 and EADR with Θ 2 are, respectively, lower and higher than those with random IRS phase shifts. This implies that an appropriate IRS phase shift configuration can improve the localization and data transmission performances to a large extent.

D. Joint Optimization
Then, we investigate the joint optimization performance of our proposed algorithm in Section IV. Figure 8 depicts the optimal time allocation ratio ( ) by varying √ N in Figure 8 (a) and N t B or N r M in Figure 8 (b), in the presence of different levels of estimation errors and user mobility. Figure 8 (a) indicates that as √ N grows, decreases, demonstrating that more time should be allocated for the EDTS. Figure 8 (b) indicates that as N t B or N r M grows, first increases rapidly and then decreases slowly, hinting that when the BS and MU are equipped with less than 8 antennas, adding more antennas will significantly alter by allocating more time for the BALS. Both Figure 8  , while the estimation errors of the position/orientation and channel coefficient reduce to some extent. Figure 9 depicts the joint optimal EADRs and log 10 (P EB + REB), which are obtained by substituting into (37), (38) and (42) after running Algorithm 1. It is shown that under the assumption of perfect estimation and Υ (x,y) = 0 m, the joint optimal EADRs and log 10 (P EB +REB) are on the peaks of the blue curves, which stand for the EADRs as functions of log 10 (P EB + REB). This validates the effectiveness of our proposed algorithm. Moreover, the joint optimal EADRs and log 10 (P EB + REB) with Υ (x,y) = 7 m or with (x,y) = 7 m, α = π 6 and σ 2 h = σ 2 w , are close to those with Υ (x,y) = 0 m and perfect estimation, demonstrating that our proposed algorithm is insensitive to slight estimation errors and user mobility.

VI. CONCLUSION
In this article, by adopting the IRS to assist the mmWave-MIMO based wireless communication and localization in the 3D scenario, we first built an IMM-JLCS and designed its working process, then derived the approximate closed-form expressions of its PEB/REB and EADR with respect to the time allocation ratio of the BALS, subsequently investigated the tradeoff between the two performance metrics, and finally proposed a joint optimization algorithm based on the Lagrangian multiplier and KKT conditions, to find the joint optimal PEB/REB and EADR, as well as the corresponding optimal time allocation ratio. The simulation results validated the effectiveness of the proposed algorithm, and its robustness to slight localization or channel estimation errors and user mobility. Consequently, the system and algorithm presented In Appendix A, we provide the derivations and expressions of J η i ,η j in the FIM for channel parameters. It is remarkable that according to (29), we should first calculate the partial derivative of u 0 (t) on each parameter in η, and obtain where γ T X,1 = a H T X (ϕ T X,1 )w B with the i-th element in c RX,1 ∈ C N M and the [p + (q − 1)L]-th elements in c a IRS,2 ∈ C N and c e IRS,2 ∈ C N given by where p = 1, 2, ..., L and q = 1, 2, ..., L.
Due to the integral form in (29), we should then calculate Ts dt. Thanks to the Parseval's theorem, we have As a result, the 6 diagonal elements and the 15 upper triangular elements among 6 × 6 = 36 entries in J η (w B , Θ 1 , w M ) are derived as J τ1,ϕ RX,1 = J τ1,ϕ a IRS,2 = J τ1,ϕ e IRS,2 = J τ1, h R,1 = J τ1, h I,1 = 0 (77) Finally, due to the symmetry of the FIM (J η i ,η j = J η j ,η i ), each lower triangular element equals to its corresponding upper triangular element.