# Modified Echo State Network Enabled Dynamic Duty Cycle for Optimal Opportunistic Routing in EH-WSNs
## 3 Proposed Modified Echo State Network (MESN) Model  
In EH-WSNs, nodes can consistently harvest energy from the surroundings. However, the energy acquisition in EH-WSNs is usually deficient, time varied and unstable. The dynamic and heterogeneous duty cycle (DC) of nodes can be used to improve energy acquisition and hence, would keep the nodes operational for a longer time. It is noticeable that the traditional opportunistic packet-forwarding schemes in EH-WSNs do not consider the concept of dynamic DC while building, the relay set and selecting the forwarding paths. Thus, the performance is lower than expected by using conventional OPEH in EH-WSNs when dynamic DC is not used. [PERSON] et al. (2020) have improved dynamic and heterogeneous DC methods but used the traditional ESN model utilizing random weight selection for neurons in the reservoir layer which may produce an unstable output. Therefore, in this article, MESN is utilized for the same purpose and the method is described next. The proposed modification in ESN enhances the efficiency of predicting the expected energy acquisition precisely for enabling better duty cycle calculation. In traditional ESN, every cycle of the training phase consists of refreshing the weights of the neurons; until the error amongst output and input is within tolerance. The weights generated during the training phase will be used to test on the newer data. However, the weight selection procedure is time-consuming. This article overcomes this limitation by using WOA with ESN for optimally selecting the weights in the reservoir layer of ESN, named as MESN. MESN is an enhancement over the ESN. ESN is a neural network algorithm that has high correctness in guessing time-series data, regardless of whether the data fluctuate rapidly. Hence, ESN can be utilized to assess the time-sensitive fluctuating energy acquisition estimations of the next slot. ESN provides more accuracy in predicting expected energy acquisition compare to pure mathematical model-based algorithms, especially for a rapidly changing environment. ESN comprises three layers, namely the input layer, dynamic layer and the output layer, respectively. Also, ESN has the training and analyzing phases similar to the machine learning algorithm. During training, the weights of the neurons are refreshed in every cycle until the training error between output and input is within acceptable limits. However, the training of traditional ESN is time-consuming. We have proposed modified ESN for acquiring the optimal set of weights to be applied in the interconnection links of ESN for improving the trained prediction model. In modified ESN, the WOA is applied to choose the interconnection weights optimally. Figure 1 shows the proposed MESN and depicts the various layers. Here, the input data is the expected active transmission cost (EATC) [20] of the active relay set, and the corresponding target is the expected energy acquisition value of the next time slot. Likewise, the training data is generated and trained with MESN. Here, input(\(t\)) represents input data, _internal_(\(t\)) represents neurons and _output_(\(t\)) represents output data. _Winput_ represents the weight matrix for input, _Winternal_ represents the weight matrix for neurons, and _Woutput_ represents the weight matrix for output. During training, the training error is reduced depicted by Equation (1) below:  
\[W_{output}=arg\ min\frac{1}{q}\sum_{i=1}^{q}\bigl{(}F_{output}\bigl{(}W_{ output}internal(t)\bigr{)}-output(t)\bigr{)}^{2} \tag{1}\]Until the training error is reduced, the weights of the neurons are modified to generate the prediction model. Equation (2) represents the weights update mechanism for the neurons in the dynamic layer:  
\[\textit{internal}(t)=F\big{(}W_{\textit{input}}\textit{input}(t)+W_{\textit{ internal}}\textit{internal}(t-1)\big{)} \tag{2}\]  
where \(F()\) represents the activation function of the dynamic layer.