## 4 Optimization Problem Formulation
### Objective Function  
The main optimization object is to improve the economics of the system allocation and decrease the cost of the microgrid operator. The multi-microgrid system discussed in the proposed model, which consists of several microgrids, is assumed to be owned by one single operator. Therefore, minimizing  
Figure 3: Mechanism of the cooperative optimization.  
the total operation cost of the whole system is regarded as the objective function. The total cost can be described by Equations (4)-(7).  
\[C_{MMS}=C_{RMG}+C_{OBMG} \tag{4}\]  
\[C_{RMG}=\sum_{r=1}^{N_{RMG}}C_{r}^{RMG} \tag{5}\]  
\[C_{OBMG}=\sum_{o=1}^{N_{OBMG}}C_{o}^{OBMG} \tag{6}\]  
\[N_{MG}=N_{RMG}+N_{OBMG} \tag{7}\]  
where \(C_{M\text{MS}}\) is total cost of the whole multi-microgrid system, \(C_{RMG}\) and \(C_{OBMG}\) are the total costs of RMGs and OBMGs, and \(C_{r}^{RMG}\) and \(C_{o}^{OBMG}\) are the costs of the \(r\)th RMG and the \(o\)th OBMG. \(N_{MG}\) is the number of all microgrids in the system. \(N_{RMG}\) and \(N_{OBMG}\) are numbers of RMGs and OBMGs.  
The cost of each microgrid includes the costs of wind generation, solar generation, EVs and the cost of exchanging power with the main grid. It is calculated by Equation (8).  
\[C_{i}^{\text{MG}}=C_{i}^{PV}+C_{i}^{WT}+C_{i}^{EV}+C_{i}^{G} \tag{8}\]  
where \(C_{i}^{PV}\), \(C_{i}^{WT}\), \(C_{i}^{EV}\) and \(C_{i}^{EV}\) are costs of PV generation, wind power, EV operation, and energy exchanging with the main grid. Costs of PV generation and wind power are formulated by capital costs and costs of maintenance--they are constant values. Therefore, the costs of PV and wind generation can be calculated as Equation (9).  
\[\left\{\begin{array}{l}C_{i}^{PV}=C_{PV}\cdot N_{i}^{PV}\\ C_{i}^{WT}=C_{WT}\cdot N_{i}^{WT}\end{array}\right. \tag{9}\]  
where \(C_{PV}\) and \(C_{WT}\) are costs of single PV module and wind turbine, and \(N_{i}^{PV}\) and \(N_{i}^{WT}\) are numbers of PV modules and wind turbines in the \(i\)th microgrid.  
Since the battery will depreciate with the increasing of charging/discharging cycles, extra charging and discharging caused by V2G services can significantly raise the cost of EV owners. In order to compensate for the EV owners, the extra cost caused by V2G should be considered. Considering depreciation expense, the cost the EVs can be calculated by Equation (10).  
\[C_{i}^{EV}=N_{i}^{EV}\cdot C_{EVBCDI}+\sum_{t=1}^{T}\sum_{j=1}^{N_{i}^{EV}}P_ {i,j}^{EV}(t)\cdot p^{EV}(t)+\sum_{j=1}^{N_{i}^{EV}}C_{depi,j}^{EV} \tag{10}\]  
where \(N_{i}^{EV}\) is the number of EVs in the \(i\)th microgrid, \(T\) is the optimization period, \(C_{EVBCDI}\) is the cost of EVBCDI, \(P_{t}^{EV}\) is the price of EV charging and discharging, and \(C_{dep}^{EV}\) is the depreciation cost which is related to the charging/discharging cycles and is calculated according to [21].  
Most of the energy in the main grid is generated from thermal plants, which produce large amount of pollutant as CO\({}_{2}\) and SO\({}_{2}\). In order to produce as little pollution as possible and to increase the utilization rate of RESs, energy exchanging with the main grid should be restricted. Therefore, in this paper, an environmental penalty is introduced. The costs of exchanging energy with the main grid can be calculated by Equation (11).  
\[C_{i}^{G}=\sum_{t=1}^{T}p^{G}(t)\cdot P_{i}^{G}(t)+\sum_{t=1}^{T}C_{i}^{Open} (t) \tag{11}\]where \(p^{G}(t)\) is the prices of trading energy with the main grid, \(P_{i}^{G}(t)\) is the exchanging power of the \(i\)th microgrid with the main grid in the \(t\)th hour, and \(C_{i}^{Open}(t)\) is the environmental penalty of the \(t\)th hour.  
\[C_{i}^{Open}(t)=[\max(0,P_{i}^{G}(t))]\cdot k_{env} \tag{12}\]  
where \(k_{env}\) is the pollution factor, and it is determined by the types and proportion of pollutants [22].