Secure Energy Efficient Wireless Transmission: A Finite v/s Infinite-Horizon RL Solution Shalini Tripathi 1 , Ankur Bansal 2 , Holger Claussen 3 , Lester Ho 4 , and Chinmoy Kundu 5 Abstract In this paper, a joint optimal allocation of transmit power at the source and jamming power at the destination is proposed to maximize the average secrecy energy efficiency (SEE) of a wireless network within a finite time duration. The destination transmits the jamming signal to improve secrecy by utilizing full-duplex capability. The source and destination both have energy harvesting (EH) capability with limited battery capacity. Due to the Markov nature of the system, the problem is formulated as a finite-horizon reinforcement learning (RL) problem. We propose the finite-horizon joint power allocation (FHJPA) algorithm for the finite-horizon RL problem and compare it with a low-complexity greedy algorithm (GA). An infinite-horizon joint power allocation (IHJPA) algorithm is also proposed for the corresponding infinite-horizon problem. A comparative analysis of these algorithms is carried out in terms of SEE, expected total transmitted secure bits, and computational complexity. The results show that the FHJPA algorithm outperforms the GA and IHJPA algorithms due to its appropriate modelling in finite horizon transmission. When the source node battery has sufficient energy, the GA can yield performance close to the FHJPA algorithm despite its low-complexity. When the transmission time horizon increases, the accuracy of the infinite-horizon model improves, resulting in a reduced performance gap between FHJPA and IHJPA algorithms. The computational time comparison shows that the FHJPA algorithm takes 16.6 16.6 percent less time than the IHJPA algorithm. { 1 shalini.tripathi, 2 ankur.bansal}@iitjammu.ac.in, { 3 holger.claussen, 4 lester.ho, 5 chinmoy.kundu}@tyndall.ie † † aftertitle: I Introduction Wireless communication networks that use energy harvesting (EH) technologies have received a lot of attention because of their ability to extend their operating lifetime. Wireless networks with EH devices can be beneficial in various real-time applications, such as environmental monitoring, advanced healthcare delivery, industrial process control, vehicle tracking, smart homes, border surveillance, etc. [ 1 ] . To extend the lifetime of the EH Wireless networks, the network transmission power strategy should be optimized to adapt to the random EH process, channel variations in time, and the available battery energy. To optimize the cumulative performance of a network where optimization cannot be considered independently for each time slot (TS) due to the causality constraints on different parameters, sequential decision-making problems are formulated. The decisions are made using only past and current knowledge of the underlying stochastic processes without the knowledge of future information. These online optimization (stochastic) problems require full statistical knowledge along with the causal information on the realizations of the underlying stochastic processes [ 2 ] . Solutions to these problems can be obtained optimally through the use of the reinforcement learning (RL) technique, which uses the Markov Decision Process (MDP) framework. Based on the time horizon during which power allocation strategies are optimized for a network, the RL problems fall into two categories: finite-horizon and infinite-horizon [ 3 , 2 , 4 , 5 , 6 , 7 , 8 , 9 ] . In finite-horizon problems, the policies execute actions at a predetermined number of finite decision epochs. For example, the transmit power of a network is optimized for a finite number of TSs [ 3 , 2 , 4 , 5 ] . Finite-horizon modelling is most appropriate for problems where the problem setting is inherently non-stationary and varies over different time stages [ 10 ] . In contrast, infinite-horizon problems never terminate and provide stationary policies for the steady state. Infinite-horizon modelling is implemented in practice when the number of decision epochs is infinite or initially unknown [ 11 ] . Infinite-horizon modelling is used for power allocation in wireless networks, assuming the network’s lifetime is infinite or stochastic, in [ 6 , 7 , 8 , 9 ] . Recently, there has been an increasing focus on improving the security of the EH wireless system due to the open nature of the wireless medium [ 12 , 13 , 9 ] . The wireless systems must not only be secure, it should also be energy efficient (EE) to prolong the lifetime of wireless networks [ 14 ] . An Unmanned aerial vehicle (UAV)-reconfigurable intelligent surface (RIS)-assisted maritime communication system under jamming attacks is considered in [ 15 ] . A deep RL (DRL)-based approach is proposed to jointly optimize the transmission power of a base station, the placement of the UAV-RIS, and the RIS’s reflecting beamforming by maximizing the system EE. In [ 12 ] , RIS-assisted mmWave UAV communication system is considered in the presence of eavesdroppers. The worst-case secrecy energy efficiency (SEE) of the system is maximized by jointly optimizing the flight trajectory using active and passive beamforming based on RIS. In [ 13 ] , a multi-RIS-aided simultaneous wireless information and power transfer (SWIPT) wireless network is considered. The SEE of the system is maximized by jointly optimizing the beamforming of an access point, the RIS phase shifts, and the RIS ON/OFF control. While all the aforementioned works [ 14 , 15 , 12 , 13 ] address EE using RL approaches, [ 14 , 15 ] do not consider SEE. Though [ 12 , 13 ] consider SEE, [ 12 ] does not incorporate EH capabilities and [ 13 ] assumes EH only at the destination node. There is a practical need for EH at both the source and the destination nodes to enhance the network’s lifetime. Recently in [ 9 ] , joint optimization of transmit and jamming power is carried out using RL assuming a full-duplex destination node with EH capability at both the source and destination nodes, however, its objective is to maximize long-term expected total transmitted secure bits over the lifetime of the network rather than SEE. To the best of our knowledge, no existing work in the literature simultaneously incorporates EH at both the source and destination nodes while also maximizing SEE using RL approaches. Motivated by the above discussion, this paper presents a novel joint power allocation strategy, optimizing both the transmit power at the source and the jamming power at the destination by leveraging the destination’s full-duplex capability to maximize SEE. While prior studies adopt either finite [ 3 , 2 , 4 , 5 ] or infinite-horizon [ 6 , 7 , 8 , 9 ] RL models, our work is the first to investigate and compare both in maximizing SEE in joint transmit and destination jamming power allocation problems, providing valuable insights into how optimal policies evolve with respect to varying time horizons in the considered system. Our contributions can be summarized below. • We study the optimal joint power allocation for source and destination to maximize average SEE over fixed TSs where the full-duplex destination uses jamming for secrecy. Both source and destination have EH capabilities. The problem is formulated as a finite-horizon MDP and a solution is provided using RL approaches. • We propose a finite-horizon joint power allocation (FHJPA) algorithm for the finite-horizon formulation and compare its performance with that of the infinite-horizon joint power allocation (IHJPA) algorithm proposed for the infinite-horizon formulation. A comparative analysis of these approaches is carried out in terms of SEE, expected total transmitted secure bits, and computation complexity by including a greedy algorithm (GA) as a baseline. Notation: \mathbb{P[\cdot]} denotes the probability of an event, \mathbb{E}\left[\cdot\right] denotes the expectation operator. \max\{\cdot\} and \min\{\cdot\} denote the maximum and minimum of its arguments, respectively. \mathcal{O}(\cdot) shows the worst case complexity of an algorithm. II System Model We consider a wireless communication system comprising a source node ( S ), a destination node ( D ), and a passive eavesdropper ( E ), as shown in Fig. 1 . S and D are equipped with EH devices powered by rechargeable batteries with limited energy storage, while E relies on a traditional power source. The communication occurs in discrete TSs, indexed by k\in\mathcal{K}=\{0,1,\ldots,K-1\} , where K is the total number of available TSs known a priory and each TS has a fixed duration of T_{s} seconds [ 3 , 8 , 7 , 5 ] . Node S is assumed to have an uninterrupted data supply for transmission in all TSs. At the same time, D operates in full-duplex mode. This allows D to receive signals from S while simultaneously transmitting jamming signals to degrade the received signals at node E . The jamming process creates self-interference at D . We assume that a self-interference cancellation (SIC) mechanism exists at D , which reduces most of this self-interference, though some residual self-interference persists. The effectiveness of SIC is characterized by a parameter 0\leq\alpha\leq 1 , where \alpha=1 represents no SIC and \alpha=0 corresponds to perfect SIC [ 16 ] . Additionally, a central processing unit (CPU) is assumed to be present in the network, equipped with knowledge of global channel state information (CSI) and battery status, which it utilizes for making power allocation decisions. Fig. 1 : A wireless system with an EH source, an EH full-duplex destination, and a passive eavesdropper. II-A EH Model Harvested energy at S and D in the k th TS is denoted as H_{\textrm{S}}^{(k)}\in\mathcal{H}_{\textrm{S}} and H_{\textrm{D}}^{(k)}\in\mathcal{H}_{\textrm{D}} , respectively. Here, \mathcal{H}_{\textrm{S}}=\{0,E_{\textrm{S}}\} and \mathcal{H}_{\textrm{D}}=\{0,E_{\textrm{D}}\} represent the sets of feasible harvested energy levels. The EH process at both nodes is modelled as independent and non identically distributed Bernoulli processes with probabilities p and q , respectively. We also assume that the EH process is independent of data transmission. Consequently, in each TS k\in\mathcal{K} , the probabilities of S and D harvesting E_{\textrm{S}} and E_{\textrm{D}} units of energy are given by \mathbb{P}[H_{\textrm{S}}^{(k)}=E_{\textrm{S}}]=p and \mathbb{P}[H_{\textrm{D}}^{(k)}=E_{\textrm{D}}]=q , respectively, while no energy is harvested with probability \mathbb{P}[H_{\textrm{S}}^{(k)}=0]=1-p and \mathbb{P}[H_{\textrm{D}}^{(k)}=0]=1-q , respectively. S and D are equipped with finite-capacity batteries, with respective capacities B_{\textrm{S}}^{\max} and B_{\textrm{D}}^{\max} energy units. The battery energy levels at S and D in the k th TS are denoted by B_{\textrm{S}}^{(k)}\in\mathcal{B}_{\textrm{S}} and B_{\textrm{D}}^{(k)}\in\mathcal{B}_{\textrm{D}} , respectively, where \mathcal{B}_{\textrm{S}}=\{0,1,\ldots,B_{\textrm{S}}^{\max}\} and \mathcal{B}_{\textrm{D}}=\{0,1,\ldots,B_{\textrm{D}}^{\max}\} define the sets of possible discrete battery states. The energy used for data transmission and jamming in any TS is constrained by the available battery energy in the respective nodes in that TS. Additionally, the harvested energy cannot be stored beyond the battery’s maximum capacity. The harvested energy H_{\textrm{S}}^{(k)} in the k th TS together with the transmitted energy at the k th TS are utilized to update the battery state for the (k+1) th TS. Consequently, the battery states in the (k+1) th TS are updated as follows \displaystyle B_{\textrm{S}}^{(k+1)}\hskip-2.84544pt \displaystyle=\hskip-2.84544pt\left\{\hskip-5.69046pt\begin{array}[]{lcl}\min\{B_{\textrm{S}}^{(k)}-P_{\textrm{S}}^{(k)}T_{s}+E_{\textrm{S}},B_{\textrm{S}}^{\textrm{max}}\}\,\,\mbox{for}\,\,H_{\textrm{S}}^{(k)}\hskip-2.84544pt=\hskip-2.84544ptE_{\textrm{S}}\\ B_{\textrm{S}}^{(k)}-P_{\textrm{S}}^{(k)}T_{s}\hskip 82.51282pt\mbox{for}\,\,H_{\textrm{S}}^{(k)}=0\end{array}\right. \displaystyle B_{\textrm{D}}^{(k+1)}\hskip-2.84544pt \displaystyle=\hskip-2.84544pt\left\{\hskip-5.69046pt\begin{array}[]{lcl}\min\{B_{\textrm{D}}^{(k)}-P_{\textrm{D}}^{(k)}T_{s}+E_{\textrm{D}},B_{\textrm{D}}^{\textrm{max}}\}\,\,\mbox{for}\,\,H_{\textrm{D}}^{(k)}\hskip-2.84544pt=\hskip-2.84544ptE_{\textrm{D}}\\ B_{\textrm{D}}^{(k)}-P_{\textrm{D}}^{(k)}T_{s}\hskip 82.51282pt\mbox{for}\,\,H_{\textrm{D}}^{(k)}=0\end{array}\right. where P_{\textrm{S}}^{(k)}\in\mathcal{P} and P_{\textrm{D}}^{(k)}\in\mathcal{P} represent the power levels used by S and D , respectively, for transmission and jamming in the k th TS. The set of M possible transmit power levels is given by \mathcal{P}=\{P_{1},P_{2},\ldots,P_{M}\} , ensuring that power constraints P_{\textrm{S}}^{(k)}T_{s}\leq B_{\textrm{S}}^{(k)} and P_{\textrm{D}}^{(k)}T_{s}\leq B_{\textrm{D}}^{(k)} hold. The EH and data transmission operate with distinct sets of hardware, allowing these two critical processes to function independently and concurrently. The EH in the k th TS will be available for use in the (k+1) th TS onward. II-B Channel and Signal Transmission Model The channel power gain for a given link XY during the k th TS is represented as G_{\textrm{XY}}^{(k)} , where \textrm{XY}\in\{\textrm{SD, SE, DD, DE}\} corresponds to the links between nodes \textrm{X}\in\{\textrm{S, D}\} and \textrm{Y}\in\{\textrm{D, E}\} . The self-interference link at D is denoted by DD . The values of G_{\textrm{XY}}^{(k)} are quantized into L discrete levels such that G_{\textrm{XY}}^{(k)}\in\mathcal{G} , where \mathcal{G}=\{G_{1},G_{2},\ldots,G_{L}\} . Within a given TS, the channel power gain remains constant but transitions to a new value in the next TS according to the predefined set \mathcal{G} . This transition is assumed to follow a first-order Markov process [ 7 ] , which models the uncertainty of wireless communication channels. The received signals at D and E during the k th TS can be expressed as \displaystyle y_{\textrm{D}}^{(k)} \displaystyle=\sqrt{G_{\textrm{SD}}^{(k)}P_{\textrm{S}}^{(k)}}x_{\textrm{S}}^{(k)}+\sqrt{\alpha G_{\textrm{DD}}^{(k)}P_{\textrm{D}}^{(k)}}w_{\textrm{D}}^{(k)}+z_{\textrm{D}}^{(k)}, (5) \displaystyle y_{\textrm{E}}^{(k)} \displaystyle=\sqrt{G_{\textrm{SE}}^{(k)}P_{\textrm{S}}^{(k)}}x_{\textrm{S}}^{(k)}+\sqrt{G_{\textrm{DE}}^{(k)}P_{\textrm{D}}^{(k)}}w_{\textrm{D}}^{(k)}+z_{\textrm{E}}^{(k)}, (6) where x_{\textrm{S}}^{(k)} and w_{\textrm{D}}^{(k)} denote the unit energy information and jamming signals transmitted by S and D , respectively. The term \alpha accounts for self-interference attenuation, and z_{\textrm{D}}^{(k)} , z_{\textrm{E}}^{(k)} are additive white Gaussian noise (AWGN) components at D and E respectively, with mean zero and power spectral density N_{0} W/Hz. The corresponding signal-to-interference-plus-noise ratios (SINRs) at D and E in the k th TS are given by \displaystyle\gamma_{\textrm{D}}^{(k)}=\frac{G_{\textrm{SD}}^{(k)}P_{\textrm{S}}^{(k)}}{\alpha P_{\textrm{D}}^{(k)}G_{\textrm{DD}}^{(k)}+WN_{0}},~~~\gamma_{\textrm{E}}^{(k)}=\frac{G_{\textrm{SE}}^{(k)}P_{\textrm{S}}^{(k)}}{P_{\textrm{D}}^{(k)}G_{\textrm{DE}}^{(k)}+WN_{0}}, (7) respectively, where W is the bandwidth of the channel. II-C Performance Metric We define SEE as the performance metric for which we first define the achievable secrecy rate. The achievable secrecy rate of the network, measured in bits per second (bps), during the k th TS is determined by the difference in achievable rates between the destination and the eavesdropper. It is expressed as \displaystyle C_{\textrm{S}}^{(k)}=\max\{C_{\textrm{D}}^{(k)}-C_{\textrm{E}}^{(k)},0\}\hskip 9.24994pt\text{bps}, (8) where C_{\textrm{D}}^{(k)}=W\log_{2}{(1+\gamma_{\textrm{D}}^{(k)})} and C_{\textrm{E}}^{(k)}=W\log_{2}{(1+\gamma_{\textrm{E}}^{(k)})} denote the achievable rates for the destination and eavesdropping channels during the k th TS, respectively. The function \max\{\cdot\} in ( 8 ) ensures that the secrecy rate remains non-negative. The average SEE is defined as the average number of secure bits transmitted per energy unit over K TSs and is expressed as [ 14 ] \displaystyle\eta_{E}=\mathbb{E}\left[\frac{1}{K}\sum_{k=0}^{K-1}\frac{C_{\textrm{S}}^{(k)}T_{s}}{(P_{\textrm{S}}^{(k)}+P_{\textrm{D}}^{(k)})T_{s}}\right], (9) where \mathbb{E}[\cdot] represents the expectation over all stochastic variables, including G_{\textrm{XY}}^{(k)} for all \textrm{XY}\in\{\textrm{SD, SE, DD, DE}\} , as well as H_{\textrm{S}}^{(k)} and H_{\textrm{D}}^{(k)} . III Problem Formulation The objective of the problem formulation is to maximize the average SEE over K TSs in ( 9 ), where K is known a priory , by optimally allocating P_{\textrm{S}}^{(k)} and P_{\textrm{D}}^{(k)} in each TS. Accordingly, we formulate the problem of finding the joint power allocation for transmitting and jamming power as \displaystyle\text{P1}:\underset{\{P^{(k)}_{\textrm{S}},P^{(k)}_{\textrm{D}}\}_{k=0}^{K}}{\text{maximize}} \displaystyle\eta_{E} (10a) \displaystyle\text{s.t.}\,(\ref{battery_Bs}),(\ref{battery_Bd}) (10b) \displaystyle 0\leq P_{\textrm{S}}^{(k)}\leq{B_{\textrm{S}}^{(k)}}/{T_{s}} (10c) \displaystyle 0\leq P_{\textrm{D}}^{(k)}\leq{B_{\textrm{D}}^{(k)}}/{T_{s}}. (10d) The constraint associated with updating the battery states at S and D in each TS, considering the transmit power and harvested energy, is expressed in ( 10b ). The transmit and jamming power constraints are respectively expressed in ( 10c ) and ( 10d ). As our system follows the Markov property, the formulated problem in ( 10 ) is an online sequential decision-making problem with finite action and state spaces with a bounded and consistent immediate reward function. Therefore, we use the RL framework, which is essentially an MDP, to obtain the optimal policy in each decision epoch to maximize the average reward over finite K number of TSs [ 17 ] . We require an MDP model for the RL-based solution which has a tuple consisting of states, actions, rewards, and transition probabilities. Assume that the state in k th TS is defined as s^{(k)}=(G_{\textrm{SD}}^{(k)},G_{\textrm{SE}}^{(k)},G_{\textrm{DD}}^{(k)},G_{\textrm{DE}}^{(k)},\allowbreak B_{\textrm{S}}^{(k)},B_{\textrm{D}}^{(k)}) . The state space is given by \mathcal{S}=\mathcal{G}_{\textrm{SD}}\times\mathcal{G}_{\textrm{SE}}\times\mathcal{G}_{\textrm{DD}}\times\mathcal{G}_{\textrm{DE}}\times\mathcal{B}_{\textrm{S}}\times\mathcal{B}_{\textrm{D}} with finite number of discrete possible states N_{S} (the cardinality of \mathcal{S} ). An action a^{(k)} is taken in the k\in\{1,2,\ldots,K\} th TS to optimize the problem P1, i.e., a pair of transmit powers \{P_{\textrm{S}}^{(k)},P_{\textrm{D}}^{(k)}\} is decided in each TS from the feasible action set U(s^{(k)}) such that a^{(k)}\in U(s^{(k)}) where \displaystyle U(s^{(k)})=\bigg\{P_{\textrm{S}}^{(k)},P_{\textrm{D}}^{(k)}\mid 0\leq P_{\textrm{S}}^{(k)}\leq\frac{B_{\textrm{S}}^{(k)}}{T_{s}},0\leq P_{\textrm{D}}^{(k)}\leq\frac{B_{\textrm{D}}^{(k)}}{T_{s}}\bigg\}. (11) The action a^{(k)} belongs to the set \mathcal{A}=\{\delta_{1},\ldots,\delta_{N_{A}}\} of all possible actions where an action \delta_{i} for any i\in\{1,\ldots,N_{A}\} is the pair of transmit power levels \{P_{m}\in\mathcal{P},P_{n}\in\mathcal{P}\} for any m,n\in\{1,\ldots,M\} , and N_{A}=M^{2} is the total number of possible actions. State transition probability of transitioning to the state s^{(k+1)} in the (k+1) th TS from the state s^{(k)} by taking an action a^{(k)} in the k th TS is expressed as \displaystyle\mathbb{P}[s^{(k+1)}\mid s^{(k)},a^{(k)}]=\mathbb{P}[G_{\textrm{SD}}^{(k+1)}\mid G_{\textrm{SD}}^{(k)}]\times\mathbb{P}[G_{\textrm{SE}}^{(k+1)}\mid G_{\textrm{SE}}^{(k)}] \displaystyle~~~~\times\mathbb{P}[G_{\textrm{DD}}^{(k+1)}\mid G_{\textrm{DD}}^{(k)}]\times\mathbb{P}[G_{\textrm{DE}}^{(k+1)}\mid G_{\textrm{DE}}^{(k)}] \displaystyle~~~~\times\mathbb{P}[B_{\textrm{S}}^{(k+1)}\mid B_{\textrm{S}}^{(k)},H_{\textrm{S}}^{(k)},P_{\textrm{S}}^{(k)}]\times\mathbb{P}[H_{\textrm{S}}^{(k)}] \displaystyle~~~~\times\mathbb{P}[B_{\textrm{D}}^{(k+1)}\mid B_{\textrm{D}}^{(k)},H_{\textrm{D}}^{(k)},P_{\textrm{D}}^{(k)}]\times\mathbb{P}[H_{\textrm{D}}^{(k)}], (12) where \mathbb{P}[B_{\textrm{S}}^{(k+1)}\mid B_{\textrm{S}}^{(k)},H_{\textrm{S}}^{(k)},P_{\textrm{S}}^{(k)}] and \mathbb{P}[B_{\textrm{D}}^{(k+1)}\mid B_{\textrm{D}}^{(k)},H_{\textrm{D}}^{(k)},P_{\textrm{D}}^{(k)}] are equal to 1 if ( II-A ) and ( II-A ) are satisfied, zero otherwise. We also have \mathbb{P}[H_{\textrm{S}}^{(k)}]=p when H_{\textrm{S}}^{(k)}=E_{S} , \mathbb{P}[H_{\textrm{S}}^{(k)}]=1-p when H_{\textrm{S}}^{(k)}=0 , \mathbb{P}[H_{\textrm{D}}^{(k)}]=q when H_{\textrm{D}}^{(k)}=E_{D} , and \mathbb{P}[H_{\textrm{D}}^{(k)}]=1-q when H_{\textrm{D}}^{(k)}=0 . If \mathbb{P}[B_{\textrm{S}}^{(k+1)}\mid B_{\textrm{S}}^{(k)},H_{\textrm{S}}^{(k)},P_{\textrm{S}}^{(k)}] and \mathbb{P}[B_{\textrm{D}}^{(k+1)}\mid B_{\textrm{D}}^{(k)},H_{\textrm{D}}^{(k)},P_{\textrm{D}}^{(k)}] are equal to zero, then ( 12 ) also becomes zero indicating the impossibility of a transition from state s^{(k)} to state s^{(k+1)} while taking action a^{(k)} . An action a^{(k)} also results in an immediate reward R^{(k)}(s^{(k)},a^{(k)}) . In the context of our problem, the immediate reward function in the k th TS from ( 8 ) is \displaystyle R^{(k)}(s^{(k)},a^{(k)})=\frac{C_{\textrm{S}}^{(k)}T_{s}}{(P_{\textrm{S}}^{(k)}+P_{\textrm{D}}^{(k)})T_{s}}=\frac{C_{\textrm{S}}^{(k)}}{P_{\textrm{S}}^{(k)}+P_{\textrm{D}}^{(k)}} (13) and the average reward is expressed in ( 9 ). IV Proposed Solutions In this section, we provide an optimal and a low-complexity sub-optimal solution for the proposed problem in ( 10 ). The optimal solution to the problem is provided with the help of the backward induction (BI) algorithm [ 17 ] , denoted as the finite-horizon joint power allocation (FHJPA) algorithm in this paper. The sub-optimal solution is a greedy one, as explained later in this section. These finite-horizon solutions are compared with an infinite-horizon solution, denoted as the infinite-horizon joint power allocation (IHJPA) algorithm. All the solution methodologies are described in detail in the following subsections. IV-A Finite-Horizon Joint Power Allocation (FHJPA) The FHJPA algorithm is described in Algorithm 1 . For its execution, the algorithm requires the value function for each state-action pair (s^{(k)},a^{(k)}) for the k th TS for any s^{(k)}\in\mathcal{S} and a^{(k)}\in\mathcal{A} . The value function is the sum of the immediate reward and the expected future reward when the action a^{(k)} is taken in the state s^{(k)} and is mathematically defined by Bellman’s equation in ( 16 ) [ 17 ] . The FHJPA algorithm essentially utilises the well-known BI algorithm, which starts iterating from the last TS, as shown in line 1, and moves sequentially toward the first TS. In the k th iteration, the algorithm finds the maximum value function V(s^{(k)}) for each s^{(k)}\in\mathcal{S} as in ( 16 ) and its corresponding optimal policy d^{*}(s^{(k)}) , i.e. a pair of optimal transmit powers, as in ( 17 ) [ 17 ] . The maximum value function in ( 14 ) is simply the maximum immediate reward as no future reward is possible for the last TS. The optimal policy d^{*}(s^{(k)}) corresponding to each s^{(k)}\in\mathcal{S} is stored in a look-up table. In the Transmission Phase , as described in Algorithm 2 , the power allocation for each TS is implemented by directly retrieving the actions corresponding to the state in that TS from the look-up table. Algorithm 1 Algorithm 1: FHJPA Input: Set of states, actions, state transition probabilities, and rewards. Output: Optimal policy d^{*}(s) . 1: Set k=K and compute V(s^{(k)}) and d^{*}(s^{(k)}) , for all s^{(k)}\in\mathcal{S} by \displaystyle V(s^{(k)})=\max_{a^{(k)}\in U(s^{(k)})}R(s^{(k)},a^{(k)}), (14) \displaystyle d^{*}(s^{(k)})=\arg\max_{a^{(k)}\in U(s^{(k)})}R(s^{(k)},a^{(k)}). (15) 2: Set k=k-1 and compute V(s^{(k)}) and d^{*}(s^{(k)}) , for all s^{(k)}\in\mathcal{S} by \displaystyle V(s^{(k)}) \displaystyle=\max_{a^{(k)}\in U(s^{(k)})}\Big[R(s^{(k)},a^{(k)})+\sum_{s^{\prime}\in\mathcal{S}}\mathbb{P}(s^{\prime}|s^{(k)},a^{(k)})\,V(s^{\prime})\Big], (16) \displaystyle d^{*}(s^{(k)}) \displaystyle=\mathop{\mathrm{argmax}}\limits_{a^{(k)}\in U(s^{(k)})}\Big[R(s^{(k)},a^{(k)})+\sum_{s^{\prime}\in\mathcal{S}}\mathbb{P}(s^{\prime}|s^{(k)},a^{(k)})\,V(s^{\prime})\Big]. (17) 3: If k=1 , stop. Otherwise, return to step 4. Algorithm 2 Algorithm 2: Transmission Phase Input : Optimal policy d^{*}(s) . Output : Average SEE over K TSs. 1: Set \eta_{E}=0 2: Set k=0 3: while k\leq K-1 do 4: Track channel states G_{\textrm{SD}}^{(k)},G_{\textrm{SE}}^{(k)},G_{\textrm{DD}}^{(k)} and G_{\textrm{DE}}^{(k)} 5: Track available battery B_{\textrm{S}}^{(k)} and B_{\textrm{D}}^{(k)} 6: Set s^{(k)}=(G_{\textrm{SD}}^{(k)},G_{\textrm{SE}}^{(k)},G_{\textrm{DD}}^{(k)},G_{\textrm{DE}}^{(k)},B_{\textrm{S}}^{(k)},B_{\textrm{D}}^{(k)}) 7: Obtain a^{(k)}=(P_{\textrm{S}}^{(k)},P_{\textrm{D}}^{(k)}) from look-up table for state s^{(k)} 8: Consume P_{\textrm{S}}^{(k)} and P_{\textrm{D}}^{(k)} for transmission and jamming respectively. 9: Calculate the average SEE as in ( 13 ) for state s^{(k)} . 10: Update battery B_{\textrm{S}}^{(k)} and B_{\textrm{D}}^{(k)} using ( II-A ) and ( II-A ) respectively 11: \eta_{E}=\eta_{E}+\frac{C_{\textrm{S}}^{(k)}}{P_{\textrm{S}}^{(k)}+P_{\textrm{D}}^{(k)}} 12: Set k=k+1 13: end while 14: \eta_{E}=\frac{\eta_{E}}{K} IV-B Greedy Algorithm (GA) In each TS, the GA chooses the action that maximizes the immediate reward. Thus, the power is allocated as \displaystyle a^{(k)}=\mathop{\mathrm{argmax}}\limits_{a^{(k)}\in U(s^{(k)})}R^{(k)}(s^{(k)},a^{(k)}). (18) IV-C Infinite-Horizon Joint Power Allocation (IHJPA) The IHJPA algorithm, which is essentially an infinite-horizon RL algorithm, can be implemented to maximize the average SEE in ( 10 ) when K is a random variable, not known a priory . In an infinite-horizon problem, K depends on the discount factor \Gamma which is the probability that the network remains operational in a TS [ 17 , 9 ] . The well-known policy iteration (PI) algorithm can be utilized to develop the IHJPA algorithm. The PI algorithm implements Bellman’s equation of optimality [ 17 , pp. 174] . We have implemented Algorithm 1: Planning Phase of [ 9 ] for the IHJPA algorithm. The IHJPA algorithm provides the optimal policy in a look-up table. Then the Transmission Phase needs to be implemented for the power allocations in each TS. V Results and Discussions In this section, we compare the performance of FHJPA, GA, and IHJPA algorithms in terms of the average SEE and expected total transmitted secure bits. The expected total transmitted secure bits for K TSs is defined as \mu=\mathbb{E}\left[\sum_{k=0}^{K-1}C_{\textrm{S}}^{(k)}T_{s}\right]\text{bits} , where the expectation is taken over all the stochastic variables, including the expectation over the random variable K in the case of the IHJPA algorithm. For a fair comparison between FHJPA and IHJPA algorithms, the mean value of the total number of available TSs in IHJPA algorithm is assumed to be the same as the total number of TSs available in FHJPA algorithm. In this case K=1/(1-\Gamma) , where 1/(1-\Gamma) is the mean of the total number of available TSs in the IHJPA algorithm. Unless otherwise specified, the system parameters considered for the simulation are W=2 MHz, N_{0}=10^{-20.4} W/Hz, \alpha=10^{-5} , T_{S}=5 ms, E_{\textrm{S}}=2 and E_{\textrm{D}}=2 energy units, where one energy unit corresponds to 2.5 \mu J, the probabilities of harvesting E_{S}=2 and E_{D}=2 energy units are p=0.5 and q=0.5 , respectively, B_{\textrm{S}}^{\textrm{max}} = B_{\textrm{S}}^{\textrm{max}} = 5 energy units, \mathcal{P}=\{0,0.5,1,2\} mW, the channel states are assumed to be \{G_{1},G_{2}\}=\{1.655\times 10^{-13},3.311\times 10^{-13}\} where the channel state transition probabilities are \mathbb{P}(G_{\textrm{1}}\mid G_{\textrm{1}})=\mathbb{P}(G_{\textrm{2}}\mid G_{\textrm{2}})=0.9 , and \mathbb{P}(G_{\textrm{2}}\mid G_{\textrm{1}})=\mathbb{P}(G_{\textrm{1}}\mid G_{\textrm{2}})=0.1 . The initial state s^{(0)} is defined as (G_{2},G_{2},G_{2},G_{2},B_{\textrm{S}}^{\textrm{max}},B_{\textrm{D}}^{\textrm{max}}) . The parameter values are considered from [ 7 ] . (a) (b) Fig. 2 : Average SEE and expected total transmitted secure bits versus E_{\textrm{S}} for K=10 and K=20 . In Figs. 2a and 2b , we compare the average SEE and expected total transmitted secure bits versus E_{S} for different values of K , respectively. It is observed in Fig. 2a that the FHJPA algorithm significantly outperforms the GA and IHJPA algorithms. As K is a known fixed value, the finite-horizon MDP modelling for the proposed problem is accurate and hence, the FHJPA algorithm outperforms the IHJPA algorithm. Unlike the FHJPA algorithm, the GA only maximizes the immediate reward without considering the future reward, hence, the GA performs worse than the FHJPA algorithm. However, as E_{S} increases, the performance of the GA gradually tends toward the performance of the FHJPA algorithm. Furthermore, the GA outperforms the IHJPA algorithm beyond a certain E_{S} . The poor performance of the IHJPA algorithm is due to the MDP modelling of the problem through infinite-horizon RL when K is low. We also find that the average SEE saturates as E_{S} increases. The higher value of E_{S} results in more available energy at S , which tends to fill the battery to its maximum value and results in performance saturation. The figure also depicts that as the total number of TSs increases from K=10 to K=20 , the average SEE increases for all algorithms. When we compare the expected total transmitted secure bits in Fig. 2b , we find that the FHJPA algorithm is the worst and the GA outperforms both FHJPA and IHJPA algorithms after a certain E_{S} . As the aim of the optimization is to maximize the average SEE, the FHJPA algorithm reduces the transmit power which results in this observation. On the other hand, as E_{S} becomes higher, the GA can afford to allocate more power in each TS which leads to better expected total transmitted secure bits, however, this also lowers the average SEE of the GA as observed in Fig. 2a . Figs. 2a and 2b also indicate that optimization of the average SEE may not lead to better total transmitted secure bits. Hence, the system optimization should consider a tradeoff between the average SEE and total transmitted secure bits. Fig. 3 : Average SEE versus E_{\textrm{D}} for K=10 and K=20 . In Fig. 3 , we replicate the performances of Fig. 2a by varying E_{D} . The observations regarding the relative performance of algorithms and the performance concerning K are similar to those in Fig. 2a . Further, it is noticed that the increase in E_{D} has a negligible impact on the average SEE performance of all the algorithms. The expected total transmitted secure bits performance by varying E_{D} is similar to that in Fig. 2b , hence, not shown to avoid unnecessary repetition. (a) When q=0.5 . (b) When p=0.5 . Fig. 4 : Average SEE versus EH probability p and q where K=20 . In Fig. 4a and Fig. 4b , we compare the average SEE of the algorithms versus p and q , respectively. In Fig. 4a , the average SEE gradually improves and saturates as p increases. A higher p leads to increased energy availability at S , which tends to fill the battery to its maximum capacity. The greater amount of available energy in the battery tends to saturate the average SEE. Interestingly, as in Fig. 2a , the GA performance gradually reaches the performance of the FHJPA algorithm here as well. Thus, it can be concluded that when the battery at S has sufficient energy due to the increased amount of harvested energy or the probability of harvesting, the performance of the GA and FHJPA algorithms becomes similar. This implies that the maximization of the immediate reward in each TS becomes nearly optimal in the finite horizon when there is enough energy in the battery of S . We also find that as K increases from 20 to 100 , the performance gap between FHJPA and IHJPA algorithms decreases. As K increases, the accuracy of infinite-horizon modelling improves, hence, the performance gap decreases. In Fig. 4b , the increase in q has a negligible effect on the average SEE performance of FHJPA and IHJPA algorithms. However, the performance of the GA degrades with increasing q . From Figs. 2 , 3 , and 4 it can be inferred that increasing the harvested energy and probability of harvesting at both S and D positively impact both the average SEE and expected total transmitted secure bits for all the algorithms (except for the GA in Fig. 4b only). the increase in these parameters at S has a greater impact on improving the system performance as compared to the increase in these parameters at D. Algorithms Planning phase Transmission phase FHJPA \mathcal{O}((K-1){N_{S}}^{2}N_{A}) \mathcal{O}(K) GA - \mathcal{O}(KN_{A}) IHJPA \mathcal{O}\big({N_{A}^{N_{S}}}/{N_{S}}\big) \mathcal{O}(K) TABLE I: Complexities of different algorithms. The computational complexities of the algorithms are compared in Table I for both the planning and transmission phases. The complexities of the FHJPA, GA, and IHJPA algorithms can be obtained following [ 14 ] and [ 9 ] , respectively. The GA does not involve a planning phase as it directly allocates power in the transmission phase without requiring a look-up table. VI Conclusion This work investigates a joint allocation of transmit power at the source and jamming power at the destination to maximize the average secrecy energy efficiency of a system equipped with energy harvesting devices with limited battery capacities over a finite time slot. We propose a finite-horizon algorithm (FHJPA) and compare it with a low-complexity greedy algorithm (GA). Additionally, we propose an infinite-horizon algorithm (IHJPA) to compare it with the finite-horizon algorithm. We observe that the FHJPA algorithm outperforms other algorithms due to the accuracy of modelling the problem using finite-horizon MDP. As the time horizon increases, the accuracy of the infinite-horizon modelling improves and the performance gap between FHJPA and IHJPA algorithms reduces. We also find that greedily optimizing the immediate reward in each time slot, a low-complexity technique, may be nearly optimal when sufficient energy is available in the source’s battery. The computational complexities of all algorithms are also analyzed. The FHJPA algorithm is found to take 16.6 percent less computational time compared to the IHJPA algorithm. We finally conclude that system optimization should strike a balance between maximizing average secrecy energy efficiency and increasing the total number of securely transmitted bits rather than optimizing a single performance metric.