*2.3. Diesel Generator Model*

The diesel generator is in charge of satisfying the load that cannot be provided by the wind generator, the battery bank, or both. In addition, this task has to be done considering the technical constraints of the diesel unit. If only the effect of wind generator needs to be considered, NL is calculated according to (21):

$$P\_{\mathcal{N}(t)} = P\_{L(t)} - P\_{\mathcal{W}(t)} \; \forall \; t = 1, \ldots, T; \tag{21}$$

On the other hand, if the joint effect of the wind generator and BESS needs to be considered, NL can be defined using (22):

$$P\_{N(t)} = P\_{L(t)} - P\_{W(t)} + P\_{B(t)} \; \forall \; t = 1, \ldots, T. \tag{22}$$

As aforementioned, the diesel generator has to supply NL as defined in (21) or (22), fulfilling the constraint (23):

$$P\_D^{\min} \le P\_{D(t)} \le P\_D^{\max} \; \forall \; t = 1, \dots, T. \tag{23}$$

To determine the power dispatch of the diesel unit, the parameter *PaD*is defined according to (24):

$$P\_D^t = \max\left(0, P\_{N(t)}\right) \forall \, t = 1, \ldots, T. \tag{24}$$

*Appl. Sci.* **2019**, *9*, 5221

Then, depending on the value of *PaD*, diesel generation (*PD*(*t*)), power surplus (*PEXC*(*t*)), and power not supplied (*PENS*(*t*)) are determined by following (25–27), respectively,

$$P\_{D(t)} = \begin{cases} P\_D^{\min}; P\_D^a > 0, \ P\_D^a \le P\_D^{\min} \\ P\_D^a; P\_D^a > P\_D^{\min}, P\_D^a \le P\_D^{\max} \\ P\_D^{\max}; P\_D^a > P\_D^{\max} \end{cases} \quad \forall \ t = 1, \ldots, T; \tag{25}$$

$$P\_{EXC(t)} = \begin{cases} P\_D^{min} - P\_D^{\text{tr}} \; P\_D^{\text{tr}} > 0 \; \mathcal{P}\_D^{\text{tr}} \le P\_D^{min} \\\ 0 \; \; P\_D^{\text{tr}} > P\_D^{min} \; \mathcal{P}\_D^{\text{tr}} \le P\_D^{max} \\\ \mathcal{O} \; \; P\_D^{\text{tr}} > P\_D^{max} \end{cases} \quad \forall \; t = 1, \ldots, T; \tag{26}$$

$$P\_{\rm ENS(t)} = \begin{cases} \begin{array}{c} 0; \, P\_D^{\rm at} > 0, \, P\_D^{\rm at} \le P\_D^{\rm min} \\ 0; \, P\_D^{\rm at} > P\_D^{\rm min}, \, P\_D^{\rm at} \le P\_D^{\rm max} \\ P\_D^{\rm at} - P\_D^{\rm max}; \, P\_D^{\rm at} > P\_D^{\rm max} \end{array} \, \forall \, t = 1, \ldots, T. \end{cases} \tag{27}$$

Once the mathematical model of HES has been defined, the optimization technique proposed in this paper will be clearly explained in the next section.
