**3. Objective Function Formulation**

This paper considers the overall system operation cost as the objective for the microgrid optimization. It mainly considers the operation and maintenance costs of wind turbines, photovoltaics, diesel generators and energy storage systems, the depreciation costs and energy loss costs of battery energy storage systems, and the emission costs brought about by the operation of diesel generators.

### *3.1. Cost Analysis of Distributed Power*

Because wind and solar are clean energy, regardless of the cost of power generation, so wind turbines and photovoltaic power generation systems mainly consider equipment maintenance costs [26]. Diesel generator operation needs to consider its power generation costs and operation and maintenance costs. Wind turbine and photovoltaic equipment maintenance costs are as follow [26],

$$\begin{array}{c} \mathsf{C}\_{\text{out}-pv} = \mathsf{c}\_{m-pv} \cdot P\_{pv,t} \\ \mathsf{C}\_{\text{out}-uv} = \mathsf{c}\_{m-ut} \cdot P\_{ut,t} \\ \mathsf{C}\_{\text{dc}} = \left( a \cdot P\_{\text{dc},t}^2 + b \cdot P\_{\text{dc},t} + c \right) + \mathsf{c}\_{\text{out}-dv} \cdot P\_{\text{dc},t} \end{array} \tag{9}$$

where *cm*−*pv*, *cm*−*wt* and *com*−*de* represent the unit power maintenance costs of photovoltaic power generation units, wind turbines and diesel generators, respectively, *com*−*de*, *Pwt,t* and *Pde,t* represent photovoltaic power generation units, the rated power output of the generator and the diesel generator at time *t*, *a*, *b*, and *c* respectively represent the power generation fitting coefficients of the diesel generators.

### *3.2. Analysis of Operating Cost of Energy Storage System*

The operation and maintenance costs of the energy storage system can be divided into fixed parts and variable parts. The former is related to the rated capacity of the energy storage system, and the latter is related to the cumulative power generation of the energy storage system, which can be calculated as follows [26,27],

$$C\_{\rm om-ess} = c\_{\rm m-ess} \cdot R\_{r-\rm ess} + c\_{\rm mc-res} \cdot E\_a \tag{10}$$

where *cm*−*ess*·*Rr*−*ess* represents a fixed part of the operation and maintenance cost of the energy storage system, *cm*−*ess* and *Rr*−*ess* represent the unit operation and maintenance cost and rated capacity of the ess, *cme*−*ess*·*Ea* represents the variable operation and maintenance of the energy storage system cost [27]. In addition to the operation and maintenance costs of the ess, the depreciation cost *Cb*−*ess* of the ess and the power loss *Clo-ess* are also considered.
