## 3 Objectives
The ESS not only should strive to keep the CP between in the region but it also should counter react  
Figure 12: Typical daily electricity consumption profile of a domicile. any steep variation of the current inside the range. Peak shaving is more effective when targeting the uppermost area as energy prices spikes during high demand, whereas valley filling should consider the lowermost area when energy price is the lowest. Evidently, this plays a role in improving system stability by increasing the gap between the maximum power demand and the maximum capacity of the utility gird. The CP of multi energy source MG (Figure 14) varies dependently on the availability of renewables, from previous discussions, prior knowledge of the average consumption value is a critical information on which the algorithm bases its decisions. Forecasting the consumption profile is a necessary procedure for decision synthesis, a multi variable utility function can be devised to that end taking into consideration the time of day, the day of week, reoccurring events, temperature, weather and many other variables [34]. Through accumulation of historical data and employment of advance machine learning it is possible to predict these parameters required for the optimization algorithm. Integrating renewables into the MG must take into consideration the dynamics of said sources. On the one side, introducing an energy source would most definitely reduce the electrical billing and improve overall reliability, however, abrupt untimely fluctuations in energy flow could elevate the stress on the utility power plants [35]. Figure 14: Simulated case of energy contribution in a multi-source microgrid. Figure 13: Modes of energy management. The optimized controller is in fact a rule-based trading model that automates the functionality of the EESS, storing (buying) energy when it's cheapest then discharging later (selling) when it's most expensive. The performance of this model is evaluated every 24 h with indices that refers to the overall cost and the flatness of the consumption profile. \[\left\{ \begin{array}{l}\mathrm{C}_{\mathrm{ost}}=\beta_{\mathrm{price}}\mathrm{ f}_{\mathrm{I}=0\mathrm{h}}^{\mathrm{I}=24\mathrm{h}}\mathrm{I}_{\mathrm{grid}} \mathrm{e}^{(\mathrm{r}\cdot\beta_{\mathrm{flat}})}\mathrm{d}t\\ \mathrm{r}=\left(\frac{\mathrm{I}_{\mathrm{grid}}}{\mathrm{I}_{\mathrm{max}}} \right)^{\beta_{\mathrm{stability}}}-1\\ \mathrm{J}_{\mathrm{flat}}=\frac{\mathrm{T}\cdot\beta_{\mathrm{price}}\mathrm{ f}_{\mathrm{grid}}\mathrm{e}^{(\mathrm{r}\cdot\beta_{\mathrm{flat}})}}{\mathrm{C}_{ \mathrm{ost}}}\end{array} \right. \tag{57}\]  
The economical cost is locally determined without the need for global communications as described in Equation (56), it is set such that it would increase exponentially as it approaches maximum energy production capacity. \(\mathrm{I}_{\mathrm{max}}\) denotes the maximum capacity of the bus and \(\beta_{\mathrm{stability}}\) the weight given for the penalty of approaching the maximum capacity, \(\beta_{\mathrm{flat}}\) scales the exponential curves to highlight the contrast between low consumption and high consumption, whereas \(\beta_{\mathrm{price}}\) is a linear coefficient that can either be set to a static value or be communicated with the provider. These coefficients shape the objective function towards the user preferences. The exponential penalizing of the grid's current doesn't just encompass the economical objective but it also extends to the green objective, less use of the utility gird means less GHG emissions. The variable \"r\" is the normalized index of stable operation, in Equation (7), when the surface was selected, it was assumed that the source is able to provide an infinite supply of energy, however, in reality the system is bounded by a power rating. For positive values of \"r\" the system stability is compromised.