## 3 Proposed Resilient Demand Forecasting Systems
* If SIDS detects any malicious node correctly, set \(\widehat{\mathbf{fitness}}\left(\overrightarrow{\mathbf{pos_{q}(t,I)}}\right)\) to zero and change the state(s) of the detected malicious node(s) from malicious to normal in \(\left(\overrightarrow{\mathbf{ST_{q}(t,I)}}\right)\). Else if \(\widehat{\mathbf{D_{q}(t+k)}}\)\(\widehat{\mathbf{D_{g}(t+k)}}\) when the objective is shifting the demand upward or \(\widehat{\mathbf{D_{q}(t+k)}}\)\(\widehat{\mathbf{D_{g}(t+k)}}\) when the objective is shifting the demand downward, set \(\widehat{\mathbf{fitness}}\left(\overrightarrow{\mathbf{pos_{q}(t,I)}}\right)\) to zero. Else estimate the fitness using the following formula: \[\widehat{\mathbf{fitness}}\left(\overrightarrow{\mathbf{pos_{q}(t,I)}}\right)=\mathbf{100 }\times\mathbf{\tan}^{-1}\left(\left|\widehat{\frac{\widehat{\mathbf{D_{g}(t)}}- \widehat{\mathbf{D_{q}(t)}}}{\widehat{\mathbf{D_{g}(t)}}}}\right|\right)\] (3)  
_Step 3._ Find the personal best position of each particle at the current \(I\)th iteration from the positions it has visited before and set the personal best position \(\left(\overrightarrow{\mathbf{pos_{q}}}\right)\) of the \(q\)th particle to it. If it is the first iteration, set the \(\overrightarrow{\mathbf{pos_{q}}}\) to its current position. We denote the fitness of \(\overrightarrow{\mathbf{best_{q}}}\) by \(\left(\widehat{\mathbf{fitness}}\left(\overrightarrow{\mathbf{pos_{q}(t,I)}} \right)\right)\). Find the global best position of all particles \(\left(\overrightarrow{\mathbf{best}}\right)\) from the positions they have visited before. We denote the fitness of \(\overrightarrow{\mathbf{gbest}}\) by \(\left(\widehat{\mathbf{fitness}}\left(\overrightarrow{\mathbf{gbest}}\right)\right)\). _Step 4._ Update the velocity of each malicious DPV in \(q\)th particle using the following equation:  
Figure 3.0  
where \(\mathbf{rand(1,1)}\) is a random number between (0,1). \(\mathbf{C_{1}}\) and \(\mathbf{C_{2}}\) are learning factors. We set the learning factor to 2 (\(\mathbf{C_{1}=C_{2}=2}\)). _Step 5._ Update each particle's position using the following equation:  
Figure 3.1Repeat steps 2-5 until the stopping criterion is satisfied. _Step 6. \(\overrightarrow{gbest}\)_ contains the optimal measurements for the malicious sensors. \(\left[\overrightarrow{gbest},\overrightarrow{ST}\right]\) is an optimal attack signature, wherein \(\overrightarrow{ST}\) is a vector containing the state of each DPV in \(\overrightarrow{gbest}\). EHS generates attack signatures through repeated games and keeps updating the attack signature database by adding new signatures. _SIDS_: The flowchart for SIDS is provided in Figure 3.2 The task of SIDS is to classify DPVs into one of the two groups: malicious (1) and normal (0). It uses an ensemble of GRNNs to perform the classification task. Each member GRNN is trained to classify one DPV as either normal or malicious. Target outputs vary between member GRNNs. During training, each GRNN's target outputs are the states (malicious state or normal state) of the corresponding DPV at a given time step. However, the input vectors of all member GRNNs are the same. During training, the raw input is \(\overrightarrow{gbest}\). During testing, the raw input is the vector of measurements transmitted by the DPVs. SIDS sends the raw input to TMS. TMS updates \(TS\) and \(SE\) accordingly. SIDS estimates the time series of the skewness coefficients of residuals at each time step by moving a sliding window over the residual series in \(SE\). This yields the matrix \(SK\) containing the skewness series of each DPV. The input vector contains 100 consecutive most recent lagged variables from \(TS\) and \(SK\). Figure 3.3 Flowchart for SIDS. It is worth noting that when malicious DPVs are detected, they get converted to normal DPVs at the very time step, so that from the next time on, they provide the actual measurements. However, there are no ways to recover the actual measurements of the recovered DPVs at time step \(t\) when they are first detected as having compromised.