## 4 Optimal Energy Management Based on the Minimization of the Conditional VaR  
In this paper a microgrid in grid-connected operating mode is considered, including a renewable energy source, i.e., PV, an energy storage device, i.e., a battery, and a power demand as depicted in Figure 1. The output power supplied by the PV systems is given by Equation (6), as follows [52]  
\[P_{PV}=P_{STG}\times\frac{G_{ING}}{G_{STG}}(1+k(T_{C}-T_{r})) \tag{6}\]  
where, the output power of the module at irradiance \(G_{ING}\) is represented by \(P_{PV}\), \(P_{STG}\) represents the maximum power of the module at standard test conditions (STC), the incident irradiance is given by \(G_{ING}\), \(P_{STG}\) stands for the irradiance at STC \(1000\times\frac{w}{m^{2}}\), the temperature coefficient of power is given by \(k\), and \(T_{r}\) and \(T_{C}\) represent the reference temperature and the cell, respectively. The considered rolling horizon time could be transformed to be discrete into \(N\) intervals of a duration of \(\Delta t\) while the demand of the power is supplied by any of the following, the ESS, the PV, or by the grid at every time step. According to Figure 1, for \(t=1\), \(2\),..., \(\mathrm{T_{N}}\), eight decision variables are available and are shown in the following expression. \[P_{t}=(P_{t}^{GD},P_{t}^{GS},P_{t}^{PVD},P_{t}^{PVS},P_{t}^{PVG},P_{t}^{SG},P_ {t}^{SD},s_{t}) \tag{7}\]  
where, \(P_{t}^{ij}\) specifies the quantity of power moved commencing in unit \(i\) and ending in unit \(j\) in the given the time step \(t\). In the equation, the superscripts \(D\), \(G\), _PV_, and \(S\) each represent the demand, grid, PV, and ESS, respectively. In this case \(s_{t}\) is the quantity of the ESS at the \(t\)th time step. Figure 1: Proposed system overview of a microgrid. Assuming that \(s_{t}\) is given, \(s_{t+1}\) is then equal to  
\[S_{t+1}=s_{t}+\frac{\eta^{C}(P_{t}^{GS}+P_{t}^{PVS})-(P_{t}^{SD}+P_{t}^{SG})}{S_{ Battery}} \tag{8}\]  
where, \(S_{Battery}\) is the maximum capacity of the battery and \(\eta^{C}\) is the charging efficiency. Regarding the mentioned assumption, the cost, which is imposed to the microgrid system owner while exchanging power with the grid in each time step, is represented by the following expression (9). \[\text{Cost}_{t}(P_{t},C_{t})=(P_{t}^{GD}C_{t}^{GD}+P_{t}^{GS}C_{t}^{GS})-(\eta ^{D}P_{t}^{SG}C_{t}^{SG}+P_{t}^{PVG}C_{t}^{PVG}) \tag{9}\]  
where, \(C_{t}^{GD}\), \(C_{t}^{GS}\), \(C_{t}^{SG}\) and \(C_{t}^{PVG}\) are the electricity prices and \(\eta^{D}\) is the discharging efficiency. In order to keep the model simple, equal values are given for the prices i.e., \(C_{t}^{GD}=C_{t}^{GS}=C_{t}^{SG}=C_{t}^{PVG}=C_{t}\) which is acceptable in the majority of the electricity markets. Thus, Equation (10) expresses the cost function as follows. \[\text{Cost}_{t}(P_{t},C_{t})=[(P_{t}^{GD}+P_{t}^{GS})-(\eta^{D}P_{t}^{SG}+P_{t} ^{PVG})].C_{t} \tag{10}\]  
As a consequence, the cost incurred by the owner of the system is identical to the profit achieved from the power supplied to the load demand by the ESS and the renewable energy resource and subtracting the cost of the grid supplied power. Thus, at every time step for an optimum operation a straightforward policy would be the minimization of the cost at \(t\)th stage through the resolution of the subsequent linear optimization equation:  
\[\text{Min}\;\text{Cost}_{t}(P_{t},C_{t}) \tag{11}\]  
In this paper such a strategy will be further labeled as the simple policy. Even though the aforementioned policy is quite direct, it does not take into account the effect of choices on the ESS level future condition. So it cannot be a practical stimulating model. The risk neutral policy is another option to the abovementioned strategy since it takes into account the global cost over the predicting time horizon.