# Flexibility Based Day-Ahead Generation-Reserve Bilevel Decision Model
## 2 Day-Ahead Unit Commitment Model Considering Flexibility Constraint  
Given that operating reserve and conventional unit output state are closely related, it is essential for a day-ahead unit commitment model to provide necessary boundary conditions if the system flexibility is to be rational measured to assess the reserve capacity required. In the upper level, the day-ahead unit commitment model schedules the conventional unit start-up and output plan of 96 time periods based on the short-term forecast of wind power and load. Meanwhile, the constraints of the UC model also include the flexibility-based reserve obtained by the lower level. The specific model is as follows:  
where \(\Delta T\) is the length of time interval, \(\Delta T_{\text{R}}\) is the spinning reserve response time, \(R_{i,t}^{\text{U}}\) and \(R_{i,t}^{\text{D}}\) refer to the up and down reserve of unit \(i\) at time \(t\), \(r_{i}^{u}\) and \(r_{i}^{\text{d}}\) refer to the up and down ramping rate of unit \(i\).  
Minimum up and down time  
\[t_{i,\text{on}}^{\text{min}}\geq T_{i,\text{on}}^{\text{min}} \tag{10}\]  
\[t_{i\text{off}}^{\text{min}}\geq T_{i\text{off}}^{\text{min}} \tag{11}\]  
where \(t_{i,\text{on}}^{\text{min}}\) and \(T_{i\text{off}}^{\text{min}}\) refer to the minimum up and down duration of unit \(i\), \(T_{i,\text{on}}^{\text{min}}\) and \(T_{i,\text{off}}^{\text{min}}\) are the allowable minimum up and down time of unit \(i\).  
The UC model must keep enough flexibility resources to maintain the safe and reliable operation of the power system. Loss of flexibility probability (LOFP) is a flexibility index [17]. The UC model needs to keep the LOFP lower than the requirement set by operator to ensure the flexibility of system. Since the calculation of the LOFP is complicated, it is difficult to consider the LOFP in the optimization process. The quantitative relationship between the LOFP and reserve capacity is established by the reserve decision model in the lower level. In this way, the flexibility constraint is converted into the reserve constraint. In other words, in order to ensure that the flexibility of system meets the given requirement, the total up and down reserve capacity \(R_{t}^{\text{U}}\) and \(R_{t}^{\text{D}}\) provided by conventional unit must meet the reserve requirements calculated by the reserve decision model in the lower level.  
\[\left(R_{t}^{\text{U}},R_{t}^{\text{D}}\right)=f_{\text{R}}(\alpha,\ t) \tag{12}\]  
\[\sum_{i\in\Gamma}R_{i,t}^{\text{U}}=R_{t}^{\text{U}} \tag{13}\]  
\[\sum_{i\in\Gamma}R_{i,t}^{\text{D}}=R_{t}^{\text{D}} \tag{14}\]  
\[R_{i,t}^{\text{U}}\leq u_{i,t}\left(P_{i,\text{max}}^{\text{G}}-P_{i,t}^{\text {G}}\right) \tag{15}\]  
\[R_{i,t}^{\text{D}}\leq u_{i,t}\left(P_{i,t}^{\text{G}}-P_{i,\text{min}}^{\text {G}}\right) \tag{16}\]  
where \(f_{\text{R}}(\alpha,t)\) is the function of reserve established by the reserve decision model in the lower level at time \(t\), and it will be detailed in Section 3, \(\alpha\) refers to the given tolerance of the LOFP. The initial values of \(R_{t}^{\text{U}}\) and \(R_{t}^{\text{D}}\) are set as a certain proportion of the total load.  
The solution of the UC model in the upper level, including the start-up plan and output scheme of conventional unit, provides boundary conditions for the reserve decision model in the lower level.