## 3 Optimization Formulation
### Constraints
#### 3.2.2 The Second-Stage Constraints  
In this section, the operating parameters of each component in the CVPP, as well as the CVPP's ability in the BE market, considering uncertainties in RES and demand, are described in the second-stage constraints as follows:  
1. Active power balance constraint in the DA market: Equation (21) shows that at any time \(t\), the CVPP's net production/consumption should equal the selling/buying power in the DA contract. Equation (22) shows that customers can be supplied by RES, ESS, or from the market. \[P^{t}_{sell,DA}-P^{t}_{buy,DA}=P^{t,s}_{RES}+\left(P^{t,s}_{ESS,disch}-P^{t,s}_{ ESS,ch}\right)-P^{t,s}_{D\_forecast}\] (21) \[P^{t,s}_{D\_forecast}=P^{t,s}_{grid-load,DA}+P^{t,s}_{RES-load}+P^{t,s}_{ESS- load}\] (22)
2. RES operation: At time \(t\), the RES' actual power output corresponding to scenario \(s\) of uncertain parameters is \(P^{t,s}_{RES}\). Equation (23) shows that the upward reserve supply capacity of RES is limited by the difference between the predicted available power output \(P^{t,s}_{RES\_forecast}\) and the actual power output \(P^{t,s}_{RES}\). Similarly, Equation (24) shows that RES' limitation of downward reserve capacity is the difference between the actual power output \(P^{t,s}_{RES}\) and the minimum power threshold \(P_{RESmin}\). Equation (25) shows that RES provides a part of CVPP's contract in the DA market while meeting customers' electricity consumption in CVPP. Additionally, the excess energy from the RES can be accumulated in the ESS to utilize the RES' available power output. \[u^{t,s}_{RES}P_{RESmin}\leq P^{t,s}_{RES}+P^{t,s}_{RES,RU}\leq u^{t,s}_{RES}P^{ t,s}_{RES\_forecast}\] (23) \[u^{t,s}_{RES}P_{RESmin}\leq P^{t,s}_{RES}-P^{t,s}_{RES,RD}\leq u^{t,s}_{RES}P^{ t,s}_{RES\_forecast}\] (24) \[P^{t,s}_{RES}=P^{t,s}_{RES-grid,DA}+P^{t,s}_{RES-load}+P^{t,s}_{RES-ESS}\] (25)
3. ESS operation: The operating model of ESS in the energy and reserve markets is described by two sets of constraints as follows: * The ESS operating parameters in the DA market are described in Equations (26)-(29). Equations (26) and (27) limit the ESS charging/discharging power, while Equation (28) describes the change in the ESS energy level after each time block \(\Delta t\). Equation (29) shows that the ESS energy level should be set to an initial level at the end of each day to ensure its operation the next day. This paper assumes that the initial energy level is 50% of the ESS rating capacity. \[0\leq P^{t,s}_{ESS,disch}=P^{t,s}_{ESS-grid,DA}+P^{t,s}_{ESS-load}\leq u^{t,s} _{ESS}P_{ESSmax}\] (26) \[0\leq P^{t,s}_{ESS,ch}=P^{t,s}_{grid-ESS,DA}+P^{t,s}_{RES-ESS}\leq\left(1-u^{ t,s}_{ESS}\right)P_{ESSmax}\] (27) \[E_{ESSmin}\leq E^{t,s}_{ESS,DA}=E^{t-1,s}_{ESS,DA}+\Delta t\times\eta\times P^{ t,s}_{ESS,ch}-\Delta t\times P^{t,s}_{ESS,disch}/\eta\leq E_{ESSmax}\] (28) \[E^{t=0,s}_{ESS,DA}=E^{t=96,s}_{ESS,DA}=0.5E_{ESSmax}\] (29) * The association between the ESS's upward/downward reserve provision ability in the BE market and its scheduling in the DA market, as well as its status switching, is described by Equations (2)-(15). * Besides, this study only focuses on the CVPP's operating schedule within one day, so the degradation and self-discharging levels of ESS are considered negligible and can be ignored. 4. The CVPP's reserve energy provision in the BE market: The following equations describe the CVPP's ability in the BE market. Equations (30) and (31) show that reserve energy can be provided by RES, ESS, and customers. The binary parameter \(u_{BC}^{t,s}\) in (30) represents whether CVPP has a BC contract to provide upward reserve capacity at time \(t\). During the periods with an upward reserve capacity contract, \(u_{BC}^{t,s}\) equals 1, and the CVPP needs to provide reserve energy at least equal to the signed reserve capacity \(SR^{t}\). By contrast, during the rest of the day, CVPP can take full advantage of its capabilities in providing both upward and downward reserve energy (32).