# Optimal Control of a Virtual Power Plant by Maximizing Conditional Value-at-Risk
## 2 Problem Formulation
### Objective Function and Constraints  
The VPP needs to plot its daily dispatch in the electricity market, and the proposed model combines the expected profit and risk. The objective of Equation (14) is to maximize the VPP's profit, where risk income is also included. Risk income equals the summation of the average income of the VPP under various scenarios, and the CVAR considers not only risk but also economic income. Total income and total cost of the VPP are formulated in Equations (15) and (16), respectively.  
\[\textit{Profit}^{DA}=\textit{Max}\left[\frac{1}{m}\sum_{n=1}^{m}\left(R(n)-C(n )\right)+\mu^{DA}(\xi-\frac{1}{m(1-\beta)}\sum_{n=1}^{m}Z_{n}\times R_{\text{ exp}})\right] \tag{14}\]  
\[R(n)=\sum_{t=1}^{t}\lambda_{\textit{VPP}}^{t}\times\text{P}_{\textit{load}}^{t} +\sum_{t=k}^{t}\left(\lambda_{\textit{VPP}}^{t}(P_{\textit{load}}^{t}-P_{ \textit{cur}}^{t})+\lambda_{\textit{DR}}^{t}P_{\textit{DR}}^{t}\right)+\sum_{t =l+1}^{24}\lambda_{\textit{VPP}}^{t}P_{\textit{load}}^{t} \tag{15}\]  
\[C(n)=\sum_{t=1}^{k-1}\left(\lambda_{\textit{top}}^{t}P_{\textit{ load}}^{t}\pm\lambda_{\textit{top}}^{t}P_{\textit{load}}^{t}+\lambda_{\textit{top}}^{t}P_{ \textit{cur}}^{t}+\lambda_{\textit{top},\textit{cur}}^{t}+\lambda_{\textit{top },\textit{cur}}^{t}P_{\textit{soc}}^{t})+\sum_{t=1}^{k}\left(\lambda_{\textit{top }}^{t}P_{\textit{cur}}^{t}+\lambda_{\textit{top}}^{t}P_{\textit{soc}}^{t}+ \lambda_{\textit{top}}^{t}P_{\textit{soc}}^{t}+\lambda_{\textit{top}}^{t}P_{ \textit{soc}}^{t}+\lambda_{\textit{top}}^{t}P_{\textit{soc}}^{t}+\lambda_{ \textit{top}}^{t}P_{\textit{soc}}^{t}+\lambda_{\textit{top}}^{t}P_{\textit{soc }}^{t}+\lambda_{\textit{top}}^{t}P_{\textit{soc}}^{t}+\lambda_{\textit{top}}^{t}P _{\textit{soc}}^{t}+\lambda_{\textit{top}}^{t}P_{\textit{soc}}^{t}+\lambda_{ \textit{top}}^{t}P_{\textit{soc}}^{t}}\right)\] \[+\sum_{t=1}^{k}\left(\lambda_{\textit{top}}^{t}P_{\textit{soc}}^{t} \pm\lambda_{\textit{top}}^{t}P_{\textit{soc}}^{t}+\lambda_{\textit{top}, \textit{cur}}^{t}P_{\textit{soc}}^{t}+\lambda_{\textit{top},\textit{cur}}^ {t}P_{\textit{soc}}^{t}\right) \tag{16}\]  
The daily dispatch in the objective function is divided in three intervals. DR interval is performed from h _k-th_ to h _l-th_. During the NO_DR interval, the profit of the VPP only comes from selling the electricity to the aggregated load, while the costs of the VPP will include the cost of buying electricity from ISO, WTs, PVs, and the operating cost of the battery. The profit of the DR interval includes the profit of selling electricity after load curtailment (\(\lambda_{\textit{VPP}}^{t}(P_{\textit{load}}^{t}-P_{\textit{cur}}^{t})\)) and the provision of ISO to restate any money (\(\lambda_{\textit{DR}}^{t}P_{\textit{DR}}^{t}\)) to DR. Similarly, the VPP must provide the rebate money to the aggregated load in the DR interval (\(\lambda_{\textit{top}}^{t}C_{\textit{cur}}^{t}\)).  
The following constraints are also defined with:  
1. VPP energy balance constraint \[P_{\textit{load}}^{t}=P_{\textit{iso}}^{t}+P_{\textit{ess}}^{t}+P_{\textit{ cur}}^{t}+P_{\textit{w}\_{\textit{test}}}^{t}+P_{\textit{s}\_{\textit{test}}}^{t}\] (17) 2. demand response \[P_{\textit{cur}}^{t}=P_{\textit{load}}^{t}\times\left(1-e^{-\theta^{t}( \lambda_{\textit{in}}^{t}-\lambda_{\textit{top}}^{t})}\right)\] (18) 3. rebate constraints \[\lambda_{\textit{VPP}}^{t}\leq\lambda_{\textit{inc}}^{t}\leq\lambda_{\textit {DR}}^{t}\] (19) 4. the expected return on investment \[\zeta-\left(R(n)-C(n)\right)\leq Z_{n}\times R_{\text{exp}}\] (20) 5. the rate of expected return on investment \[Z_{n}=\frac{R(n)-C(n)}{C(n)}\geq 0\] (21) 6. the capacity of battery \[0\leq\left(P_{\textit{es}}^{initial}+\sum_{t=1}^{H}P_{\textit{es}}^{t}\right) \leq P_{\textit{es},\textit{max}}\] (22)