## 2 Supervisory and Control System Based on Real-Time Power Management
### Energy Cost Optimization
#### 2.3.6 Objective Function
\begin{array}{l}\text{min}\ C_{total}=C_{G}+C_{S}+C_{PVS}+C_{EV\_penalty}\\ \text{with respect to }:\\ \left\{\begin{array}{l}p_{PV}(t_{i})+p_{S\_D}(t_{i})+p_{G\_S}(t_{i})=p_{S\_C }(t_{i})+p_{G\_I}(t_{i})+p_{IIREV\text{s}}(t_{i})\\ p_{S}(t_{i})=p_{S\_C}(t_{i})-p_{S\_D}(t_{i})\\ p_{G}(t_{i})=p_{G\_I}(t_{i})-p_{G\_S}(t_{i})\\ p_{PV}(t_{i})=p_{PV\_MPT}(t_{i})-p_{PV\_S}(t_{i})\\ p_{IIREV\text{s}}(t_{i})=p_{IIREV\text{s}}\,\text{D}(t_{i})-p_{IIREV\text{s}} \,s(t_{i})\\ \text{if }p_{PV\_MPPT}(t_{i})\geq p_{IIREV\text{s}}\,\text{D}(t_{i})\text{ then }\left\{\begin{array}{l}p_{IIREV\text{s}}\,S(t_{i})=0\\ p_{G}(t_{i})\geq 0\\ p_{S}(t_{i})\geq 0\\ \end{array}\right.\end{array}\right.\\ \text{if }p_{PV\_MPPT}(t_{i})\leq p_{IIREV\text{s}}\,\text{D}(t_{i})\text{ then }\left\{\begin{array}{l}p_{PV\_S}(t_{i})=0\\ p_{G}(t_{i})\leq 0\\ p_{S}(t_{i})\leq 0\\ \end{array}\right.\\ \text{SOC}_{S\_min}\leq soc_{S}(t_{i})\leq SOC_{S\_max}\\ soc_{S}(t_{i})=SOC_{S_{0}}+\frac{1}{3600\times E_{Bal}}\int\limits_{t_{0}}^{t} p_{S}(t_{i})\Delta t\\ p_{PV}(t_{i})\geq 0\\ p_{IIREV\text{s}}(t_{i})\geq 0\\ 0\leq p_{IIREV\text{s}}\,\text{s}(t_{i})\leq p_{IIREV\text{s}}\,\text{D}(t_{i}) \\ 0\leq p_{PV\_S}(t_{i})\leq p_{PV\_MPPT}(t_{i})\\ -P_{G\_S\_max}\leq p_{G}(t_{i})\leq P_{G\_I\_max}\\ -P_{S\_max}\leq p_{S}(t_{i})\leq P_{S\_max}\\ p_{PV\_S}(t_{i})=0\,\text{ii}\,SOC_{S}(t_{i})\leq SOC_{S\_max}\\ if\,\,M_{\text{p}}=1\,\text{then }0\leq p_{EV\text{s}}(t_{i})\leq P_{PV\_fast\_max}\, \forall t_{i}\in[t_{arr_{s}}t_{dep_{p}}]\\ if\,\,M_{\text{p}}=2\,\text{then }0\leq p_{EV\text{s}}(t_{i})\leq P_{PV\_ after_max}\,\forall t_{i}\in[t_{arr_{s}}t_{dep_{p}}]\\ if\,\,M_{\text{p}}=3\,\text{then }0\leq p_{EV\text{s}}(t_{i})\leq P_{PV\_slow\_max}\, \forall t_{i}\in[t_{arr_{s}}t_{dep_{p}}]\\ p_{EV\text{s}}(t_{i})=0\,\forall t_{i}\
ot\in[t_{arr_{s}}t_{dep_{p}}]\\ p_{IIREV\text{s}}\,\text{D}(t_{i})=\frac{N_{\text{p}}}{v}\,\,p_{EV\text{s}}(t _{i})\,\forall t_{i}\in[t_{arr_{s}},t_{dep_{p}}]\\ SOC_{EV\_min}\leq soc_{EV\text{s}}(t_{i})\leq SOC_{EV\_max}\,\forall t_{i} \in[t_{arr_{s}},t_{dep_{p}}]\\ soc_{EV\text{s}}(t_{i})=0\,\forall t_{i}\
ot\in[t_{arr_{s}},t_{dep_{p}}]\\ soc_{EV\text{s}}(t_{i})=SOC_{EV\_arr_{s}}(t_{i})\,\forall t_{i}=t_{arr_{s}} \\ SOC_{EV\text{s}}(t_{i})\geq SOC_{EV\_arm_{s}}(t_{i})\,\forall t_{i}\in[t_{arr_{s}} t_{dep_{p}}]\\ SOC_{EV\text{s}}(t_{i})\leq SOC_{EV\_des_{v}}\,\forall t_{i}=t_{dep_{p}}\\ soc_{EV\text{s}}(t_{i+1})=SOC_{EV\_arr_{s}}(t_{i})+\frac{p_{EV\text{s}}(t_{i} )\cdot\Delta t}{E}\,\,\forall t_{i}\in[t_{arr_{s}},t_{dep_{p}}]\\ SOC_{EV\text{s}}.\text{dep}_{G\_I\_max}(t_{i})=soc_{EV\text{s}}(t_{i})\, \forall t_{i}=t_{dep_{p}}\\ \text{t}_{ch_{0}}=t_{dep_{p}}-t_{arr_{p}}\\ \frac{(SOC_{EV\_dep}-SOC_{EV\_err_{s}}(t_{i})\cdot)E}{p_{EV\text{s}}(t_{i}) \cdot E}\leq t_{ch_{v}}\,\forall t_{i}\in[t_{arr_{v}},t_{dep_{v}}]\\ t_{i}=\{t_{0},t_{0}+\Delta t,t_{0}+2\Delta t,\ldots,t_{F}\}\\ v=\{1,2,\ldots,N_{\text{p}}\}\end{array}  \tag{39}\]  
The decision variables in this optimization problem are \(p_{EV\text{s}}\), \(p_{IIREV\text{s}}\,\text{s}\), \(p_{G}\), \(p_{PV\text{s}}\), \(p_{S}\), \(soc_{S}\), and \(soc_{EV\text{s}}\), in which they are continuous variables.