## 2 An Optimization Model for Wind Farms with an ESS
### Variability Criteria for Wind Power Generation  
The variability is defined as the power deviation at the PCC in a 5-min time step. The grid code model for the variability is described as follows:  
\[-\sigma^{\text{var}}\times Cap^{Wind}\leq P_{t}^{Wind}-P_{t-1}^{PCC}-P_{t}^{ch}+ P_{t}^{dch}-P_{t}^{Excess}+P_{t}^{Short}\leq\sigma^{\text{var}}\times Cap^{Wind}\ t=2,3,\cdots,t^{max}, \tag{12}\]  
where \(\sigma^{\text{var}}\) is the wind farm capacity ratio of the variation criteria, and \(P_{t}^{Excess}\) and \(P_{t}^{Short}\) are the surplus variables for the upward and downward power, respectively, that exceed the variation criteria. The power at the PCC at time step \(t\) is defined by its representation in Equation (12) since the amount of ESS charging-discharging at time step \(t\) can change the power deviation of the adjacent time step. The surplus variables should have a non-zero value only if the power deviation at the two adjacent time steps exceeds the variability criteria in the opposite sides of the equation. Additional constraints for these surplus variables are required since Equation (12) is insufficient to determine the surplus. These constraints are described as follows:  
\[P_{t}^{Excess}=\delta_{t}^{Excess}\Big{(}P_{t}^{wind}-P_{t-1}^{PCC}-P_{t}^{ch}- \sigma^{\text{var}}\times Cap^{Wind}\Big{)}t=2,3,\cdots,t^{max}\text{ and} \tag{13}\]  
\[P_{t}^{Short}=\delta_{t}^{Short}\Big{(}P_{t}^{wind}-P_{t-1}^{PCC}+P_{t}^{dch}+ \sigma^{\text{var}}\times Cap^{Wind}\Big{)}t=2,3,\cdots,t^{max}, \tag{14}\]  
where \(\delta_{t}^{Excess}\) and \(\delta_{t}^{Short}\) are binary variables representing the state of exceeding the upper and lower variation criteria, respectively, in time-step \(t\). These variables are below 1 at a single time step, as follows:  
\[\delta_{t}^{Excess}+\delta_{t}^{Short}\leq 1\ t=2,3,\cdots,t^{max}. \tag{15}\]  
The surplus variables in Equations (13) and (14) mitigate the deviation between the wind farm generation at time step \(t\) and the power at the PCC at time-step \(t-1\), along with the charging/discharging power at time-step \(t\). In short, the surplus variables are assumed to be control variables to mitigate the variability in wind power generation.  
The process of determining the value of the surplus variables is described in Figure 2, where the power deviation and the upper and lower criteria are observed.  
Figure 2: Determination of the surplus variable for power exceeding the upper and lower variation criteria.  
The surplus variables can be determined by the upper and lower criteria. If the power deviation (the solid line) is within the criteria (the dotted line), these variables must be zero since the deviation does not exceed the criteria. In this case, the variables in Equations (13) and (14) are zero since both variables in Equation (15) are zero. However, if the deviation is outside of the criteria, the surplus variables should be the amount of power exceeding the criteria. In this case, the excess power is equal to variables \(P_{t}^{Excess}\) or \(P_{t}^{Short}\) in Equation (13) or (14), since the binary variable, \(\delta_{t}^{Excess}\) or \(\delta_{t}^{Short}\), is 1.  
In this optimization problem, Equations (13) and (14) reflect the above process and are depicted as nonlinear constraints. Therefore, MILP constraint linearization is required, as described in Appendix A.