## 5 Use Case: IWSN Resilience Using Maintenance 5.0
### Applying Novel Maintenance 5.0 to Previos Study
#### 5.2.3 Field Level (Physical Assets)  
At the _physical asset_ level, energy consumption was analyzed and used for constant jamming mitigation through asset configuration changes. Once the jammer is detected, it is up to the mitigation algorithm to recover the appropriate level of PDR, RSSI, and Energy of the network in the shortest possible time. In this case calculations are made only for Energy. The IWSN _resilience_ has been approached in two ways:  
1. Cooperative and collaborative schemes. According to a previous study [107], resilience can be achieved by using a collaborative scheme between network nodes when a jamming attack of any kind appears. Greater availability is obtained in an IWSN when greater quantity of the available routes is found, reducing transmission latency, and reducing energy consumption. In this resilience approach, the method proposed in Section 4.3.1 and Figure 19 will be used, since it deals with signals with real-time data. Resilience is the area between the Energy (J) with No_Jamming and the Energy (J) with constant jamming in the three stages of the \(\text{P}_{\text{L}}(\text{t})\): (1) symptoms, (2) detection and (3) mitigation, presented in Equation (1) and Figure 11. From the data obtained in a previous experiment (see Table 9), the energy metric in a normal cooperative scheme operation had a value of 0.09 J, and when there was a jamming attack, the value goes up to 0.37 Joules. In this example, time \(t_{0}=0.6\) s, \(t_{1}=1.6\) s, \(t_{2}=2\) s, and \(t_{3}=3\) s, were randomly taken. Calculations of the parameters \(A\), \(B\), \(\omega\) and \(\alpha\) have been carried out using trapezoidal integration with sampling every 0.1 s; the following values were obtained: \(B=\frac{0.37-0.09}{2}=0.14\); \(A=0.09+0.14=0.23\); \(\omega=\frac{\pi}{16-6}=0.31416\); \(\varphi=16\frac{\pi}{16-6}=5.0265\). With those values, performance functions can be calculated. The raised cosine for the symptoms interval: \(P_{ Symptoms}(t)=0.23+0.14\cos(\left(\frac{\pi}{10}\right)t-\left(\frac{16\pi}{10 }\right))\); the maximum value for the detection interval: \(P_{Detection}(t)=0.23+0.14=0.37\), and the raised cosine for mitigation:  
Figure 18: Node-red: Communication to Telegram Bot and Historic data through MQTT protocol. Figure 21, Worker 5.0 gives advice to the agent [124], so the agent considers the human experiences to decide the action to be accomplished in the environment. The human engineer gives advice and changes the rewards given by some fixed reward function to influence an agent's learning [119]. The feedback can be evaluative, corrective, or just guidance. Equation (7) shows the Q-learning algorithm, where an episode (or trial) describes a sequence from the initial state to the terminal state, and a specifies de learning rate [118]. \[Q(s_{t},a_{t})\gets Q(s_{t},a_{t})+\alpha\bigg{[}r_{t+1}+\underset{a}{ \max}Q(s_{t+1},a)+Q(s_{t},a_{t})\bigg{]} \tag{7}\]  
In this work, a brief simulation of the Q-learning algorithm has been carried out using a Python language program with which it has been evaluated which would be the optimal routing to send the data packets to the WSN coordinator, avoiding the areas of the network affected by a constant jammer. Worker 5.0 gives advice like corrective feedback, guidance and instructions [124]. In this simulation, the \(\alpha\) and \(\gamma\) parameters from Equation (7) are instructions given by the human worker. In addition, Worker 5.0 gives corrective feedback by informing Agent L about the optimal action. Figure 22 shows the network generated by the python code [138], which simulates the distribution of Figure 15.  
On one hand, a gamma discount factor (\(\gamma=0.2\)) has been chosen since, due to the environment of uncertainty that exists in the network, it is desired to hold on to current or tangible rewards, which resembles a collaborative network scheme [107]. On the other hand, despite the fact that an IWSN traditionally presents a deterministic scenario, due to  
Figure 21: Worker 5.0—IWSN interaction in Reinforcement Learning.