## 3 Optimization of Day-Ahead Operation
### Problem Formulation  
The focus of this work is on developing a methodology for load peak-shaving to be applied to the management of autonomous HES. In this regard, EMS monitors the state variables of all the elements connected to the point of common coupling (Figure 1). Then, using this information and the day-ahead forecasts of wind power and load demand, determines how power sources should be dispatched to minimize the operating costs of the system for the corresponding day. Note that the influence of forecasting error on system operation has not been considered in this work. In a general sense, BESS operation can be defined by means of three different states: charging, discharging, and disconnection. These states can be represented by using integers: charging can be represented as \(+1\), discharging can be represented as \(-1\), whereas \(0\) represents the battery disconnection. The goal of the management strategy proposed in this paper consists of finding out the appropriate pattern (charging, discharging, and disconnection) of usage of BESS during the day in order to reduce NL-peak. This is carried out by means of a heuristic optimization algorithm in which each individual or agent is represented as shown in Figure 2. If NL is negative, it means that BESS should be charged in order to store the energy surplus during periods of high wind speed. On the contrary, when NL is positive, it is not evident whether BESS should be discharged or disconnected from HES. Thus, a set of \(I\) individuals, who take into account different operational conditions (discharging and disconnection) during different hours, is considered. The structure of a single individual (\(i=1,\ldots,I\)) at a determined iteration (\(k\)) of the heuristic optimization algorithm can be described according to (28):  
\[\overrightarrow{\hat{g}}_{(i,k)}=\left[ \begin{array}{ccccc}g_{(i,1,k)}&\cdots& g_{(i,L,k)}&\cdots&g_{(i,T,k)}\end{array} \right]\forall\;i=1,\ldots,I; \tag{28}\]  
where each element \(g_{(i,t,k)}\) is an integer between \(-1\) and \(+1\), depending on the time (\(t\)) and NL value (\(P_{N(t)}\)). Similarly, the population or group of agents of the optimization algorithm for iteration \(k\) can be expressed as a matrix according to (29):  
\[G_{(k)}=\left[ \begin{array}{c}\overrightarrow{\hat{g}}_{(1,k)}\\ \vdots\\ \overrightarrow{\hat{g}}_{(ik)}\\ \vdots\\ \overrightarrow{\hat{g}}_{(Lk)}\end{array} \right]. \tag{29}\]  
Considering a determined individual \(i\), the value of its objective function (\(O_{(ik)}\)) during a determined iteration (\(k\)), which has to be minimized, is calculated according to (30):  
\[O_{(ik)}=\sum_{t=1}^{T}P_{N(t)}P_{C(i,t,k)}\;\forall\;i=1,\ldots,I;k=1,\ldots, K; \tag{30}\]  
where the pattern \(P_{C(i,t,k)}\) corresponds to that obtained from the application of the model previously described in Section 2 (Equation (20)), considering the influence of power converter (\(P_{C(i,t,k)}=P_{C(t)}\)). In other words, \(P_{C(i,t,k)}\) is calculated according to (20), the indexes \(i\) and \(k\) have been introduced to represent the fact that it is calculated for a specific individual (\(i\)) during a determined iteration (\(k\)). The magnitude presented in (30) does not have any physical meaning. Indeed, this has been taken from previous experience of BESS operating in RTP programs [39], where sold and purchased power all over the day is considered as the optimization variable. Following this analogy, \(P_{C(i,t,k)}\) can be considered as the transaction power of BESS (sold and purchased power), whereas \(P_{N(t)}\) could be considered as linearly related to the fuel-consumption curve of the diesel generator. In other words, in the analogy with selling and purchasing prices under RTP, the variable \(P_{N(t)}\) could be considered as a linear function of fuel-consumption costs.