Under the background of the modern energy systems, the degree of interconnection and coupling between the power system and natural gas systems is gradually increasing. The economic dispatch model is becoming more and more complex. However, the economic dispatch of an integrated energy system is a high-dimensional, multi-period optimization problem, especially the multi-period joint optimization will greatly reduce the convergence speed of the model. Moreover, the electric power system and the natural gas system belong to two independent systems, which have a limited understanding of each other's information changes. In this paper, the cost of comprehensive operation is considered, and then the objective function is modeled. Based on the idea of k-means clustering, a granularity partition algorithm, which is based on the improved k-means clustering, is designed. To improve this algorithm, this paper adopts the shortest distance method to cluster the original data. Then, it adopts the rough clustering results to calculate the clustering center, and then applies the k-means clustering. From the source side heating coupling optimization and the load side load curve, the introduction of an air source heat pump at the source side and the consideration of waste heat recovery of electricity to the gas device can improve the flexibility of energy supply mode and optimize the heat supply coupling at the source site. Besides, it can equivalently decouple the problem of wind curtailment caused by the constraint of "determining power by heat" in co-generation, realize electric energy substitution and reduce the carbon emission of co-generation. Based on the principle of calorific value equivalence, the load side analyzes the energy conversion value of electric and thermal users, and forms a comprehensive demand response mechanism with energy substitution under the guidance of various energy price signals to assist wind power integration and consumption. Through the coordination and optimization of source and load, the phenomenon of wind power curtailment is significantly reduced while ensuring the economic operation of the system.