# Energy Trading Strategy for Heat and Electricity-Coupled Microgrid Based on Cooperative Game
## 6 Distribution Solution
### Algorithm Implementation
\right.\\ \end{array}\]
```

**Algorithm 1**Executed by MGO

```
1:Initialized: \(\left\{u_{Mi}^{h},\beta_{Mi^{\prime}}^{h},\chi_{Mi^{\prime}}^{h},t_{Mi}^{h} \right\}^{[k+1]}\) = 0, \(t\) = 0.00001
2:repeat
3: (1) updated \(\left\{p_{Mi^{\prime}}^{h},el_{Mi^{\prime}}^{h},\lambda_{Mi^{\prime}}^{h},t_{Mi }^{h}\right\}^{[k+1]}\) from MGO in receive buffer
4: (2) solve local optimal problem in (33) \[\left\{p_{Mi^{\prime}}^{h},el_{Mi^{\prime}}^{h},\lambda_{Mi^{\prime}}^{h},t_{ Mi}^{h}\right\}^{[k+1]}=\text{argmin}L_{i}^{h}\]
5: (3) update dual variables send \(\alpha_{Mi}^{h}[t+1]=\alpha_{Mi}^{h}[i+\rho_{1}(p_{Mi}^{h}[i+1]-p_{Mi}^{h}[i +1])\) \(\beta_{Mi}^{h}[i+1]=\beta_{Mi}^{h}[i+\rho_{2}(e_{Mi}^{h}[i+1]-e_{Mi}^{h}[i+1 ])\) \(\gamma_{i}^{h}[t+1]=\beta_{Mi}^{h}[i+\rho_{3}(\lambda_{Mi}^{h}[i+1]-\lambda_{Mi} ^{h}[i+1])\) \(\zeta_{Mi}^{h}[t+1]=\zeta_{Mi}^{h}[i+\rho_{4}(t_{Mi}^{h}[i+1]-\lambda_{Mi}^ {h}[i+1])\)
6: (4) send \(\left\{p_{Mi^{\prime}}^{h},el_{Mi^{\prime}}^{h},\lambda_{Mi^{\prime}}^{h},t_{ Mi}^{h}\right\}^{[k+1]}\) to MGO
7: (5) update interaction index \(t=t+1\)
8:until the convergence condition in (35) are satisfied
9:end
```

**Algorithm 2**Executed by User

## 7 Case Study

To verify the effectiveness of the proposed [PERSON] bargaining cooperative strategy, this paper uses the Yalmip tool with CPLEX to model and solve all the optimal problems under the MATLAB2016a compiler environment. The operation computer configuration is a 2.5 GHz Intel Core-i5 processor with16 GB of RAM and a 64-bit Windows 10 system. ### Basic Data

In the paper, an MG comprised of three DRAs, a CHP system, and a PV generation system is selected as the study case. The data of heat load, electricity load, electricity prices, and photovoltaic are the measurement data of three commercial buildings provided by Hefei Thermal Power Group and Anhui Electric Power Co., Ltd. The time scale of data is hourly. The daily electricity demands of users and PV energy are shown in Figure 2, and the daily heat demands are shown in Figure 3. The adjustable proportion range of heat and electric load is set to 20%, respectively. Time-of-use (TOU) prices data for power grids are shown in Table 1. The price range of thermal energy is 0.15 RMB/kWh to 0.5 RMB/kWh, of which 0.15 RMB/kWh is the original thermal energy price. The price of natural gas is 2.33 RMB/m\({}^{3}\), and the comfort coefficient of users 1, 2, and 3 are 0.04, 0.045, 0.05, respectively. The parameter \(k_{i}^{h}\) is given according to the original load demand, as



Figure 5 shows the heat trading prices of users. As depicted in Figure 5, the heat prices are all higher than the original (minimize) selling prices and lower than the maximum selling prices. Therefore, users will cut off parts of cuttable thermal demand to reduce unnecessary expenditure. ### Energy Consumption of Users

Users' energy consumption strategies based on hybrid DR are shown in Figure 6a-c, respectively. To simplify the description, the energy consumption of user 1 in Figure 6a is taken as an example. Compared with the original electricity demand, the optimized demand decreases in time slots 9-12 and 18-21, mainly because the trading price in these two periods is close to the peak price. In 24 and 1-5 and 13-17 periods, the load demand increases because the trading prices in time slots 24 and 1-5 are close to valley prices, and the trading prices in time slots 13-17 are lower than the grid price. On the other hand, compared with the original thermal demand, the optimized heat demands are lower, indicating that the user can reduce the heat load demand according to the thermal price. Furthermore, as the thermal price in the 10-12 period is lower than that in other periods, users' enthusiasm to participate in thermal DR is reduced, and thermal demand in these periods is lower. Figure 4: Electricity trading prices after bargaining. Figure 5: Heat trading prices after bargaining. ### Energy Supply Strategy of MGO

Figure 7 shows the energy supply strategy of the CHP system in both original and optimized situations.