{'fraction_non_alphanumeric': 0.039113615740961845, 'fraction_numerical': 0.012727446391900281, 'mean_word_length': 4.39469277341234, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 5, '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}}
Robust Beamforming Design for IRS-Aided URLLC in D2D Networks

Intelligent reflecting surface (IRS) and device-to-device (D2D) communication are two promising technologies for improving transmission reliability between transceivers in communication systems. In this paper, we consider the design of reliable communication between the access point (AP) and actuators for a downlink multiuser multiple-input single-output (MISO) system in the industrial IoT (IIoT) scenario. We propose a two-stage protocol combining IRS with D2D communication so that all actuators can successfully receive the message from AP within a given delay. The superiority of the protocol is that the communication reliability between AP and actuators is doubly augmented by the IRS-aided first-stage transmission and the second-stage D2D transmission. A joint optimization problem of active and passive beamforming is formulated, which aims to maximize the number of actuators with successful decoding. We study the joint beamforming problem for cases where the channel state information (CSI) is perfect and imperfect. For each case, we develop efficient algorithms that include convergence and complexity analysis. Simulation results demonstrate the necessity and role of IRS with a well-optimized reflection matrix, and the D2D network in promoting reliable communication. Moreover, the proposed protocol can enable reliable communication even in the presence of stringent latency requirements and CSI estimation errors.

system and jointly optimized the user grouping and the blocklength allocation at the base station (BS), as well as the reflective beamforming at the IRS for latency minimization.
Device-to-device (D2D) communication is another potential technology to achieve URLLC. In most mission-critical applications, devices (e.g. sensors, machines, actuators, robots) are in close proximity to each other. Thus, the channel between the devices is much more reliable than that between the access point (AP) and the device, thereby rendering the D2D network promising to reduce resource consumption, lower communication latency, and improve reliability [12,13]. Recently, there are studies on the design of D2D-based URLLC systems. A probability-based D2D activation and power allocation scheme was proposed in [14] to deal with the extremely high qualityof-service (QoS) requirements in URLLC for real-time wireless control systems, where each sensor autonomously decides whether to participate in the control process without interactive communications. The authors in [15] developed a D2D-based two-phase transmission protocol for URLLC, where each group's messages are combined and the BS multicasts them to the leaders in groups in the first phase, while leaders help to relay messages to other users in their groups in the second phase. In [16], authors investigated the contentionbased radio resource management for URLLC-oriented D2D communications.
Some research works further combined the technologies of IRS and D2D communication and studied the IRS-assisted D2D network design. For instance, the authors in [17] considered deploying IRS in the integrated data and energy network coexisting with D2D communication to maximize the minimum throughput of the information-demanded users. In [18], a resource allocation design for the IRS-aided joint processing coordinated multipoint (JP-CoMP) system with underlaying D2D network was investigated. The authors in [19] studied an IRS-aided D2D communication system over Rician fading channels with the consideration of practical hardware impairments at both the terminals and IRSs. However, the optimization of most of these works is based on Shannon capacity with assumptions of infinite blocklength and zero error probability. If we directly apply the results and conclusion of these works to URLLC-oriented applications, we may get the underestimated delay performance and overestimated reliability performance [20]. This necessitates the IRS-assisted D2D network design for URLLC under the finite blocklength (FBL) regime. Towards this end, one practical factor needed to be considered is the channel state information (CSI) estimation. On the one hand, IRS can only passively reflect signals and is not able to transmit or receive pilot symbols. On the other hand, the transmission time interval (TTI) of URLLC systems is very short, so that the time for channel training is highly restricted. Consequently, the perfect knowledge of CSI may not be available in practice. This entails a robust IRS-assisted D2D network design for URLLC under the imperfect CSI scenario.

B. Contributions
In this paper, we propose a two-stage protocol to enable reliable communication between the AP and actuators in the IIoT scenario assisted by IRS and D2D networks under the scenarios of perfect and imperfect CSI. This is achieved by jointly optimizing the active beamforming at the AP and the reflective beamforming at the IRS to maximize the number of actuators with successful decoding. The main contributions of this paper are summarized as follows.
• A communication protocol for dual augmented reliability by combining IRS and D2D networks in a specified latency requirement is proposed. The reliable communication design is investigated under the scenarios of perfect and imperfect CSI. In this way, URLLC in IIoT scenario can be enabled. • With perfect CSI, we propose two efficient algorithms with guaranteed convergence and polynomial time complexity. One is the AltMin algorithm, dealing with unitmodulus constraints by relaxation first and then projection into a feasible region. The other one is a penalty-based successive convex approximation (SCA) algorithm which decomposes the product of active and passive beamformers and avoids using the alternating optimization method.
For the imperfect CSI case, a semidefinite relaxation (SDR)-based block coordinate descent (BCD) algorithm is proposed for robust design. The proposed algorithms show better performance than other baseline schemes. • The advantages of IRS with well-optimized phase shifts and the D2D network to enhance reliable communication are verified by simulations compared to other baseline schemes. Due to the doubly improved reliability from the combined usage of IRS and D2D network, as well as the multiuser diversity, the proposed two-stage protocol can ensure reliable communication between AP and actuators even under stringent delay requirements and it is shown to be robust to the uncertainties of CSI. The rest of the paper is organized as follows. In Section II, we present the system model, the two-stage communication protocol, and the problem formulation. The reliable communication design under the perfect and imperfect CSI scenarios are given in Section III and Section IV, respectively. Simulation results are presented in Section V and Section VI concludes the paper.
Notations: I n refers to an n × n identity matrix. x i , X ij stand for the i-th element of a vector x and the (i, j)th element of a matrix X, respectively. diag(x) denotes a diagonal matrix whose diagonal elements are extracted from a vector x.

II. SYSTEM MODEL
We consider a downlink multiple-input single-output (MISO)-URLLC system between AP and K actuators in the IIoT scenario, where AP is equipped with N t antennas and all actuators indexed by k = {1, · · · , K} are equipped with a single antenna. As shown in Fig. 1, inspired by a D2D-based two-phase transmission protocol [15], we leverage an IRS with M reflecting elements and the D2D network to doubly enhance the transmission reliability. Thus, all actuators can successfully receive critical messages in the form of short packets from AP within a delay of τ seconds. The symbols used throughout the paper and their definitions are listed in Table I  The channels from the AP to the actuator k, from the AP to the IRS, and from the IRS to the actuator k are denoted by h d,k ∈ C Nt , H dr ∈ C M ×Nt , h r,k ∈ C M , respectively. We denote the channel from the actuator j to actuator k by g jk ∈ C. The coherence time and bandwidth of all channels are assumed to be the same for tractability, denoted as T seconds and B Hz, respectively. Given that the positions of all actuators are fixed and the target latency requirement τ is much smaller than the channel coherence time T , we adopt a quasi-static block-fading channel model, i.e., the channel gains remain constant within one coherence block and vary independently across blocks.
The transmission from AP to the actuators follows a twostage IRS-aided D2D communication protocol, as shown in Fig. 2. The description of each stage is given below.

A. IRS-aided first-stage transmission
In the first stage with a duration of τ 1 seconds, the transmitted signal at the AP is x (I) = ws, where w ∈ C Nt is the beamforming vector for broadcasting at the AP, and s denotes the combined symbol with unit power intended for all actuators. The received signal at the actuator k consists of a direct signal from AP and a reflected signal from IRS, which can be given by y where is the phase shift of the m-th reflecting element, and z Denote the cascaded AP-IRS-actuator channel and the vector containing diagonal elements of matrix Φ Φ Φ by G k = diag h H r,k H dr and v = [φ 1 , · · · , φ M ] H ∈ C M , respectively. The SNR of the k-th actuator in the first stage can be represented as Based on the normal approximation of the maximum achievable rate with finite blocklength codes [21], we characterize the maximum achievable rate of the actuator k over L 1 = τ 1 B channel uses in the first stage by where D is the number of data bits, V x e −t 2 /2 dt. Note that equation (2) characterizes the relationship between the achievable rate, transmission time (channel uses) and decoding error probability. From (2), the decoding error probability can be represented as (3) Note that f 1 γ If the SNR of actuator k can reach the threshold γ (I) th , we regard that the k-th actuator can successfully decode the message in the first stage, otherwise, the packet reception of actuator k ends with failure in the first stage. Thus, for any actuator k, we define an indicator a (4)

B. Second-stage D2D transmission
In the second stage with a duration of τ 2 = τ − τ 1 seconds, the actuators with successful decoding in the first stage relay messages over a D2D network to the rest of actuators. The transmit signal of the actuator j in the second stage is x where P is the common transmit power for all actuators. Here, we don't consider power control due to the following two factors: 1) the global CSI of the D2D network is not available at the AP; 2) the actuators that act as relays transmit the signal at the maximum power, which can improve the received SNR and is more aligned with the requirements of the URLLC scenario.
If actuator k cannot decode the message successfully in the first stage, it will receive relayed signals in the second stage from actuators with successful reception. Thus, the received signal of actuator k in the second stage can be expressed as y is the AWGN. At the end of this stage, the actuator k jointly decodes the signals received in two stages via maximum-ratio combining (MRC). The received SNR of actuator k in the second stage is given by Then, the maximum achievable rate of actuator k over L 2 = τ 2 B channel uses in the second stage can be characterized by where ε (II) k is the decoding error probability. From equation (6), ε (II) k can be expressed as

C. Problem Formulation
In this paper, we aim to develop a reliable communication design between an AP and multiple actuators within a given delay requirement. Based on the two-stage communication protocol, our goal is to maximize the number of actuators with successful decoding by jointly designing the active beamforming at the AP and the reflection matrix at the IRS, i.e., where constraints (9b) and (9c) denote the maximum transmit power constraint at AP and the unit-modulus constraint of each reflecting element.
We assume that at least one actuator can successfully decode the message in the first stage. Note that the higher the number of actuators that can successfully decode the signal in the first stage (i.e., the higher the number of actuators that act as relays to relay messages in the second stage), the higher the probability of successful reception that the remaining actuators have via D2D network in the second stage [15]. This is mainly due to the multiuser diversity and the strong D2D link between actuators in close proximity. Motivated by this, we transform problem P1 into an alternative form that aims to maximize the number of actuators with successful decoding in the first stage. As a result, fewer remaining actuators are required to reach the SNR threshold γ (II) th for reliable reception in the second stage. Therefore, problem P1 can be reformulated as We can obtain the active beamformer w at the AP, phase shifts v and indicator a In this section, to achieve a reliable communication design with perfect CSI, we propose two effective algorithms with guaranteed convergence, namely the AltMin algorithm and the penalty-based SCA algorithm.

A. Problem Transformation
In this case, the CSI of direct AP-actuator channels h d,k , ∀k and cascaded AP-IRS-actuator channels G k , ∀k are assumed to be perfectly known at the AP, which can be obtained by channel estimation methods in [23].
In problem P2, a (I) k given by equation (4) is a discrete function over beamformers w and v. This discrete nature complicates the solution and makes it difficult to apply the standard optimization techniques. In view of this, we introduce a set of auxiliary variables q = [q 1 , · · · , q k ] T 0 to characterize the SNR gap between the achievable SNR γ (I) k and the SNR threshold γ (I) th . In particular, q k = 0 means the SNR condition γ That is, the number of zero elements in vector q denotes the number of actuators with successful decoding. Therefore, maximizing K k=1 a (I) k (the number of actuators with successful decoding in the first stage) is equivalent to minimizing q 0 (the number of nonzero elements in vector q). In this way, we transform P2 into an equivalent but a more tractable and continuous form, which can be formulated as P3 : min (11f) where (11d), equivalent to (10b), guarantees that at least one actuator can successfully decode the message in the first stage.
The challenges in solving P3 mainly include the 0 -norm in the objective function and constraint (11d), the strictly nonconvex constraint (11b) due to the coupling of w and v in the form of a product, and the unit-modulus constraint (11f). To overcome these challenges, we propose two effective algorithms below.

B. Proposed AltMin Algorithm
In this algorithm, we apply an alternating optimization technique to solve this minimization problem. Hence, we call this algorithm AltMin. Specifically, we alternately optimize q, w with given v and q, v with given w. In the following, we elaborate the design of the AltMin algorithm. With Further, based on the first-order Taylor approximation, |b H k w| 2 is lower bounded by where w (i) is the solution obtained in the i-th iteration. In this way, (11b) can be approximated by a convex constraint, i.e., Next, we apply the reweighted 1 technique [24] to deal with the 0 -norm. The principle is to use the weighted 1 -norm to approximate the 0 -norm and then update the weights. To be more specific, q 0 can be approximated by where ω k , ∀k are positive weights. Here, weights are updated by ω k is the solution obtained in the i-th iteration and ν is a small number. Note that the weights can be interpreted as penalties, i.e., large weights encourage zero entry q k while small weights discourage nonzero q k .
Based on the above transformations, the optimization problem of q, w with given v can be given by (15e) It is a convex problem, which can be solved by existing convex program solvers like CVX [25].
With given w, constraint (11b) can be rewritten as where By applying the first-order Taylor approximation, where v (i) is the solution obtained in the i-th iteration. Thus, we can convert constraint (11b) into a convex one The same technique is applied to deal with q 0 . The remaining challenge is the nonconvex unit-modulus constraint (11f). To make it more tractable, we first relax it as Accordingly, we have the following convex optimization problem | v m | ≤ 1, ∀m.
(20e) Note that the solution obtained by solving AltMin−P4−2 may not satisfy the unit-modulus constraint. One way to construct feasible phase shifts is given by With given w and the obtained solution v * , the remaining q k can be obtained by the closed-form expression q k = γ The overall AltMin algorithm is summarized in Algorithm 1. This algorithm alternately optimizes two blocks defined by problems AltMin−P4−1 and AltMin−P4−2, respectively. The objective function denoted by , v (i+1) are the optimal solutions obtained for both blocks. The inequalities hold since γ (I) k can be maximized with optimal w (i+1) , v (i+1) , thereby reducing q k and lowering the objective function. Hence, the algorithm is guaranteed to converge to a stationary point of problem P3 in polynomial time [26]. Given v (t) , inner iteration index i = 0 5:  Update q (j+1) , v (j+1) by solving problem AltMin−P4−2 with given v (j) . 13: In each iteration, the complexity of solving problem [27], where K +N t is the number of optimization variables and 2K + 2 is the number of affine and convex constraints. Similarly, the complexity of solving problem AltMin−P4−2 is O((K + M ) 3 (2K +M +1)). Thus, the computational complexity order

C. Proposed Penalty-based SCA Algorithm
In this algorithm, we first handle the coupling problem. Let then we can equivalently rewrite constraint (11b) as where W = ww H , V = vv H . Note that W and V remain coupled in the form of a product in constraint (22). However, we can leverage the following equality to decompose the product, which is given by where A, B F = Tr(A H B) is the Frobenius inner product. Therefore, constraint (22) can be equivalently written as Note that the left-hand-side (LHS) term in constraint (24) is in the form of difference-of-convex function. We apply the first-order Taylor approximation to the convex function W + R k VR H k 2 F , thus the LHS term is lower bounded by (25) as shown at the top of the next page, where W (i) , V (i) are the solutions obtained in the i-th iteration. In this way, we can transform constraint (24) into a convex one For the q 0 , we use reweighted 1 -norm for approximation. Through above transformations, problem P3 can be reformulated as where constraint (27f) is introduced to guarantee the unitmodulus of each IRS element.
Our main focus now is to deal with the rank-one constraints in (27h). To this end, we apply the following lemma to represent them equivalently.

Lemma 1. For any
Proof. For any A ∈ H n , the inequality A * = i σ i ≥ A 2 = max i {σ i } holds, where σ i is the i-th singular value of matrix A. And the equality holds if and only if A is rankone. Thus, the implicit constraint of Hermitian matrix A, i.e., A * − A 2 ≥ 0 functions simultaneously with the constraint (28), which requires that A * − A 2 = 0, i.e., A is a rankone matrix.
According to Lemma 1, rank-one constraints of W, V can be equivalently reformulated as Then, we adopt the penalty-based method by moving constraint (29) into the objective function, thereby resulting in the following optimization problem where ρ > 0 is a penalty factor penalizing the violation of constraint (29). The following proposition demonstrates the equivalence of problems SCA−P4 and SCA−P5. By solving problem SCA−P5, we can recover w, v from rankone solutions W, V by eigenvalue decomposition. Proposition 1. Let W s , V s be the optimal solutions of problem SCA−P5 with penalty factor ρ s . For sufficiently small ρ s → 0, any limit points W, V of the sequence {W s , V s } are optimal solutions of problem SCA−P4.
Proof. Please refer to Appendix A.   Update q (i) = q, W (i) = W, V (i) = V.
Note that nuclear norm W * , V * and spectral norm W 2 , V 2 are convex functions [28]. Hence, the penalty terms are in a form of difference-of-convex function. To make it tractable, we exert the first-order Taylor series approximation on W 2 and V 2 , thereby approximating the penalty terms as equations (31) and (32), where λ λ λ max (W), λ λ λ max (V) denote the eigenvector corresponding to the largest eigenvalue of matrix W, V, respectively, and W (i) , V (i) are the solutions obtained in the i-th iteration.
Therefore, the optimization problem that needs to be solved in the i-th iteration can be expressed as s.t. (27b) − (27g), which can be efficiently solved by standard convex program solvers such as CVX [25].
According to the preceding analysis, we propose a penaltybased SCA algorithm to solve problem SCA−P6, which is summarized in Algorithm 2. By iteratively solving a sequence of problem SCA−P6 at feasible points, we can obtain a stationary-point solution of problem P3 after convergence [26].
IV. WORST-CASE ROBUST BEAMFORMING In this section, we proceed to investigate a robust design to achieve reliable communication in the worst-case. To resolve the robust beamforming problem, we propose a SDR-based BCD algorithm. Moreover, convergence and complexity analysis is given for the proposed algorithm.

A. Uncertainty Modeling
Although the CSI of the direct channel h d,k from the AP to the actuator k can be estimated by conventional methods, CSI acquisition of AP-IRS channel H dr and IRS-actuator channel h r,k is more challenging. The is because without the help of active RF chains, a passive IRS cannot transmit and receive signals for channel estimation. Instead of estimating these two individual channels H dr and h r,k , it is more preferable to attain the estimated CSI of the cascaded AP-IRS-actuator channel G k . In addition, the difficulty of channel estimation increases in URLLC systems since the time for pilot training is highly limited due to short TTI. Thus, it is more practical to consider the case with imperfect CSI of both direct APactuator channels and cascaded AP-IRS-actuator channels. This is different from most existing IRS-related works that only consider the uncertainty of cascaded AP-IRS-actuator channels [29,30].
Channel uncertainty modeling mainly falls into two categories: 1) stochastic CSI error, where the CSI error is assumed to follow the circularly symmetric complex Gaussian (CSCG) distribution; 2) bounded CSI error, where all CSI errors lie in a norm-bounded uncertainty region. From [31], we know that based on the worst-case bounding approach, we can convert the probabilistic constraint involving Gaussian CSI uncertainties into a deterministic norm-bounded form. Hence, in this paper, we adopt the norm-bounded CSI error model. Specifically, the CSI of the direct AP-actuator channel h d,k and the cascaded AP-IRS-actuator channel G k can be modeled as h d,k =ĥ d,k + ∆h d,k , whereĥ d,k , G k are the estimates of the direct AP-actuator channel and the cascaded AP-IRS-actuator channel, respectively. The corresponding estimation errors ∆h d,k , ∆G k , lying in continuous sets Ω h d,k , Ω G k are norm-bounded by δ h d,k , δ G k , respectively. Meanwhile, δ h d,k > 0, δ G k > 0 represent the level of channel uncertainty, which can be chosen smaller for more accurate quantization and channel estimation.

B. Proposed SDR-based BCD Algorithm
Under the case with imperfect CSI, R k = G H k h d,k , the effective channel from AP to actuators, contains the uncertainty of direct AP-actuator channels and cascaded AP-IRS-actuator channels, which can be expressed as The robust beamforming problem for imperfect CSI can be given by ICSI−P4 : (37h) Constraint (37b) has the following meaning. If the SNR of actuator k can reach the SNR threshold for all possible CSI errors, we consider that the k-th actuator can successfully decode the message in the first stage, i.e., q k = 0. Otherwise, the decoding of actuator k fails and q k is a positive number. Furthermore, it is challenging to deal with the infinite number of nonconvex SNR constraints in (37b) due to the continuity of the channel uncertainty set. The difficulties that remain to be solved are the q 0 and rank-one constraints.
First, we need to apply the S-procedure in Lemma 2 to convert the infinite number of SNR constraints in (37b) into a finite number of constraints. To this end, we recast (37b) as Further, denote r k = vec(R k ),r k = vec( R k ), ∆r k = vec(∆R k ) bounded by ∆r k 2 ≤ δ k . Thus, constraint (37b) can be transformed into the following more tractable form as Lemma 2. (S-procedure for the complex case [28]): Let F 1 , F 2 ∈ H n , s 1 , s 2 ∈ C n , z 1 , z 2 ∈ R. The following implication According to Lemma 2, the infinite number of constraints in (39) can be represented as the following K matrix inequalities The reweighted 1 method is applied to cope with q 0 . Note that the rank-one constraints in (37h) are nonconvex and difficult to solve. In view of this, we first drop the rank-one constraints to obtain a relaxed problem. Therefore, we have the following optimization problem It is essential to emphasize that W, V remain coupled in the form of the Kronecker product in the matrix inequality constraint (43b), which is different from the coupling problem of W, V in the real-valued inequality constraint (22) as mentioned in Section III-C. Therefore, we cannot leverage a similar technique for the product decomposition. In light of this, we use a BCD method to split problem ICSI−P5 into two subproblems, i.e., we alternately optimize q, W with given V and q, V with given W, which can be seen below. Both two subproblems are semidefinite program (SDP) that can be solved by the CVX tool [25]. The overall SDR-based BCD algorithm is summarized in Algorithm 3.

14:
until |A 16: are the optimal solutions obtained for subproblems ICSI−P6−1 and ICSI−P6−2, respectively. The inequalities hold as γ (I) k can be maximized with optimal W (i+1) , V (i+1) , thereby reducing q k and lowering the objective function. Therefore, the algorithm can be solved in polynomial time [26] with guaranteed convergence.
According to [27,Theorem 3.12], the complexity of an SDP problem with m SDP constraints, where each constraint involves an n × n PSD matrix, is given by O √ n log 1 mn 3 + m 2 n 2 + m 3 , where is the convergence tolerance. For SDP problems ICSI−P6−1 and ICSI−P6−2, we have m = K + 1, n = N t and m = K + 1, n = M + 1, respectively. Thus, the computational complexity of each iteration of the proposed BCD algorithm When the SDR-based BCD algorithm converges, the obtained solutions W, V are not always rank-one. To obtain feasible rank-one solutions, we perform the following Gaussian randomization procedure [30]. First, we decompose V ,1 , . . . , λ v,M +1 ) are unitary matrices containing eigenvectors and a diagonal matrix with eigenvalues on its diagonal, respectively. Then, we generate a vector satisfying v = U v Σ Σ Σ 1 2 v e v , where e v ∼ CN (0, I M +1 ). Further, we normalize each element of v and obtain v * as the optimal phase shift. Next, we decompose W as W = U H w Σ Σ Σ w U w and obtain a sub-optimal solution as w = U H w Σ Σ Σ 1 2 w e w , where e w ∼ CN (0, I Nt ). For randomly generated vectors e w , the best w * is selected if it satisfies the transmit power constraint (43b) and the SNR constraint (37e) while minimizing the Iteration index objective function.

V. SIMULATION RESULTS
In this section, we provide simulation results to evaluate the performance of the proposed two-stage IRS-aided D2D communication protocol in terms of reliable communication capability between AP and actuators under the perfect and imperfect CSI scenarios.

A. Simulation Setup
The AP and IRS are located at (0,0,15) meter (m) and (50,50,15) m, respectively, and all actuators are randomly and uniformly distributed on a circle centered at (50,50,0) m with a radius of 20 m. The path loss is modeled as PL = C 0 d −α [32], where C 0 , set as -30 dB, is the path loss at the reference distance 1 m, d is the link distance, and α is the path loss exponent. The small-scale fading of AP-IRS and IRS-actuator channels are assumed to be Ricean fading. The direct link between AP and actuators and the D2D link are modeled as Rayleigh fading. Assume the system operates in a mini-slot fashion, i.e., τ 1 = τ 2 . The carrier frequency is set as 2.4 GHz. Considering the imperfect CSI effects, an uncertainty ratio, denoted by κ, is defined as κ = δ k R k F , where κ ∈ [0, 1] [33]. Unless otherwise specified, other parameters are listed in Table II.
To evaluate the proposed protocol in terms of reliability, we define a performance metric called Probability of Reliable Communication (PRC) as the ratio of the number of experiments where all actuators can successfully decode the message over total experiments. For comparison, we consider the following schemes: 1) Upper bound: we relax the rankone constraints, i.e., rank(W) = 1, rank(V) = 1 and then solve problem P3 until convergence, which serves as a performance upper bound; 2) Proposed AltMin algorithm: the approach is proposed in Section III-B for the perfect CSI scenario; 3) Proposed penalty-based SCA algorithm: the method is proposed in Section III-C for the perfect CSI case; 4) Baseline 1: IRS is deployed for packet transmission, but we adopt random phase shifts; 5) Baseline 2: IRS is not introduced into the system; 6) Proposed SDR-based BCD algorithm: the approach is proposed in Section IV for the imperfect CSI scenario; 7) Penalty-based BCD algorithm: the penalty-based method is used to handle the rank-one constraints for the imperfect CSI case.

B. Convergence of the Proposed Algorithms
We plot the convergence performance of the proposed Alt-Min algorithm and the proposed penalty-based SCA algorithm for K = 20, N t = 4, M = 20, D = 500 bits, τ = 0.5 ms. As it can be seen from Fig. 3, both algorithms converge monotonically, and the proposed penalty-based SCA algorithm requires significantly more iterations to converge than the proposed AltMin algorithm. In particular, the proposed AltMin algorithm converges after about 5 iterations on average, while the penalty-based SCA algorithm needs another 30 iterations on average to converge. This is because the number of optimization variables and constraints in the penalty-based SCA algorithm is much higher than those in the AltMin algorithm, which was discussed in more detail in Section III-B and Section III-C. Fig. 4 shows the PRC performance versus the packet size D for different schemes when K = 20, N t = 2, M = 10, τ = 1 ms. It can be seen that the proposed AltMin algorithm and the penalty-based SCA algorithm can achieve reliable communication within 700 data bits. Moreover, AP and actuators in both proposed algorithms can also communicate reliably at 800 bits with 99% probability. Particularly, the PRC performance of the two proposed algorithms is close to the upper bound scheme, which demonstrates the effectiveness of the proposed algorithms. In contrast, with the random-phase IRS, reliable communication between AP and actuators can be achieved within 500 bits in the baseline 1 scheme. The PRC performance degrades significantly compared to the proposed algorithms with optimal reflective beamforming. This shows the importance of optimizing the reflection matrix, which can greatly improve the quality of the received signal by intelligent reflection. In the baseline 2 scheme, without the support of IRS, the actuators can only communicate reliably within 300 bits, which has worse PRC performance. This is because the received SNR in the first stage is significantly reduced without the help of IRS. As a result, the number of actuators with  successful decoding in the first stage decreases significantly, i.e., the number of actuators to relay messages in the second stage decreases. Consequently, the number of actuators that can successfully decode the message in the second stage also decreases. From the comparison of the proposed algorithms with baseline 1 and 2, we know that the integration of IRS with optimized phase shifts into the system play an important role in improving reliability, which confirms the necessity of the IRS in the two-stage protocol.

D. Necessity of IRS
To clarify the necessity of IRS in a two-stage communication protocol, we investigate the effect of distance variation between the AP and actuators on the PRC performance by comparing the proposed algorithms and the No-IRS scheme for K = 10, N t = 2, D = 900 bits, τ = 1 ms. We set the location of actuators mentioned above as reference points, i.e., all actuators are randomly and uniformly distributed on a circle centered at (50,50,0) m with a radius of 20 m. Then in order to represent the distance variation between the AP and actuators, we increase the horizontal and vertical coordinates of the actuators at the same time. From Fig. 5, we can observe that when the distance between the AP and actuators is large, the actuators cannot communicate reliably with the AP under the No-IRS scheme. This is because of the poor channel quality of the direct link between the AP and the actuators. After the deployment of IRS into the communication protocol, by increasing the number of IRS reflecting elements, actuators can successfully receive the messages sent by the AP even when they are far from each other.

E. Impact of Second-stage D2D Transmission
We now examine the role of the second-stage D2D transmission. For this purpose, we plot the average number of actuators with successful decoding in each stage and the total number in two stages under the proposed AltMin algorithm and the baseline 2 scheme for different packet size D. From  Fig. 6, it can be seen that the average number of actuators with successful decoding in the first stage decreases as the packet size D increases. Accordingly, the remaining actuators with decoding failures must rely on the second-stage D2D transmission to achieve reliable communication. In particular, the D2D network begins to function at D > 200 bits in the proposed AltMin algorithm and at D > 100 bits in the baseline 2 (i.e., No-IRS). Moreover, when the size of the data packets is larger, the second-stage D2D transmission plays a greater role. In addition, we find that when the data packet becomes larger (taking 800 bits as an example), about 30% of the actuators in the proposed algorithm rely on the D2D network to achieve reliable communication, while in the baseline 1 scheme, the number of users who need to rely on D2D network to realize reliable communication is up to about 70%. This shows that the IRS-assisted first-stage transmission can effectively reduce the communication load of the second-stage D2D network.

F. Impact of Delay
In Fig. 7, we study the effects of delay on the PRC performance for different schemes when K = 20, N t = 4, M = 20, D = 500 bits. It can be observed that the baseline 1 and 2 schemes are sensitive to delay and their PRC performance is poor, especially for strict latency requirements. The proposed algorithms, on the other hand, can ensure reliable communication even for small delay (e.g. τ = 0.5 ms). This is due to the doubly improved reliability of the proposed two-stage protocol through the combined use of IRS and the D2D network. Thus, the proposed two-stage IRS-aided D2D communication protocol is crucial and better copes with URLLC-oriented applications.  not actively send and receive signals, it also requires a power supply to maintain the operation of each reflecting element and the intelligent controller. So in this case, 20 reflecting elements are sufficient for all actuators to successfully decode the 900bit packet within 1 ms, which can provide some insight into the practical application. Furthermore, compared to baseline 1, the proposed algorithms have a large performance gap, which becomes smaller as the number of reflecting elements increases. This is because more reflecting elements can provide higher spatial degree of freedom (DoF), significantly improving the received signal. In particular, the PRC performance for K = 20 is better than that for K = 10, which benefits from the multiuser diversity and the second-stage D2D transmission between actuators with proximity to each other. At the same time, it is worth noting that the message that AP sends in the first stage and the successful-decoding actuators relay in the second stage is the same combined message, so there is no interference between the actuators. More specifically, the number of actuators that can successfully decode the signal in  the first stage is higher for K = 20 than for K = 10, i.e., the number of actuators that act as relays to relay messages in the second stage becomes larger, increasing the probability of successful reception of the remaining actuators.

G. Impact of Number of Reflecting Elements
H. Impact of Number of Antennas Fig. 9 shows the effects of the number of antennas N t on the PRC performance for different K and schemes when M = 10, D = 900 bits, τ = 1 ms. As it can be seen from Fig. 9, the probability of reliable communication between AP and actuators improves as the number of antennas increases since more antennas provide a higher diversity gain. The PRC performance of the proposed AltMin algorithm is slightly better than that of the penalty-based SCA algorithm, and the performance gap between the proposed algorithms and the upper bound narrows as N t increases. The reason why the PRC performance for K = 20 is better than that for K = 10 was discussed in Section V-G. In addition, when we compare the proposed algorithms with baseline 1, we also find that as the number of antennas increases, the received signal of the direct link becomes stronger and the influence of the reflection matrix optimization becomes weaker. That is, reliable communication via the random phase IRS can be guaranteed if the number of antennas is sufficiently large, but it is achieved at the expense of the high cost of maintaining the antenna arrays. This demonstrates the necessity of using IRS with well-optimized phase shifts.

I. Impact of CSI Uncertainty
In Fig. 10, we investigate the impact of CSI uncertainty on the PRC performance for different schemes when K = 10, N t = 4, M = 10, D = 400 bits, τ = 1 ms. It can be seen that the PRC performance deteriorates when the accuracy of the CSI estimate decreases. This is because the difficulty of performing accurate active beamforming at AP and reflective beamforming at IRS increases with the poorer quality of the CSI estimate, resulting in poorer PRC performance. The proposed SDR-based BCD algorithm outperforms the penaltybased BCD algorithm and baseline 1 (i.e., IRS with random phase shifts) over the entire range of the considered CSI uncertainty ratio, which shows that the proposed algorithm can fully and efficiently exploit the spatial DoF to improve the reliability even when the CSI uncertainty exists.The proposed algorithm can guarantee reliable communication with a probability of 98%, even in the presence of large CSI estimation errors. This confirms the robustness of the proposed algorithm to CSI uncertainty.

VI. CONCLUSION
In this work, we exploited the potential of IRS and D2D communication to enable URLLC between an AP and multiple actuators in the IIoT scenario. We proposed a two-stage protocol where MRC is adopted for joint decoding the superimposed signal (direct signal from AP and reflected signal from IRS) in the first stage and the signal from D2D links in the second stage. The optimization problem was formulated to maximize the number of actuators with successful reception by jointly optimizing the active beamforming at AP and the phase shifts at IRS. We studied the joint beamforming problem under the scenarios of perfect and imperfect CSI of both direct AP-actuator channels and cascaded AP-IRSactuator channels, where efficient algorithms with complexity and convergence analysis were proposed for each case. Simulation results confirmed the role and importance of IRS and D2D communication in enhancing reliability compared to other baseline schemes. Thanks to the doubly enhanced reliability via IRS and D2D network, the proposed twostage protocol can achieve reliable communication even under stringent latency requirements and even in the presence of CSI uncertainties.

APPENDIX A PROOF OF PROPOSITION 1
For problem SCA−P4, we denote the objective function by f (W, V) and let W , V be its optimal solutions. Hence, we have f (W , V ) ≤ f (W, V). Denote the objective function of problem SCA−P5 by g(W, V; ρ) and its optimal solutions by W s , V s for penalty factor ρ s . Thus, we have g (W s , V s ; ρ s ) ≤ g (W , V ; ρ s ), i.e., where (a) holds as W , V are the optimal solutions of problem SCA−P4, which satisfy the rank-one constraints, i.e., W * − W 2 = 0, V * − V 2 . From (46), we have Denote W, V by limit points of sequence {W s , V s } and there is an infinite subsequence S such that lim s∈S W s = W, lim s∈S V s = V. By taking the limit as s → ∞ for s ∈ S on both sides of (47), we can obtain that lim where (b) holds owing to the continuity of the function X * − X 2 . Combing (48) with W * − W 2 ≥ 0, V * − V 2 ≥ 0, we have W * − W 2 = 0, V * − V 2 = 0, so W, V are feasible for problem SCA−P4. Moreover, by taking the limit as s → ∞ for s ∈ S in (46), we have where (c) holds as the penalty factor ρ s and W s * − W s 2 , V s * − V s 2 are nonnegative. Note that W, V are feasible for problem SCA−P4 and its objective function f (W, V) is no larger than f (W , V ) obtained from optimal solutions W , V of problem SCA−P4. Thus, W, V are also optimal to problem SCA−P4. This completes the proof.