Blockchain-Based Decentralized Power Dispatching Model for Power Grids Integrated with Renewable Energy and Flexible Load

: To cope with the energy crisis and environmental pollution, the future development of the power system has to change towards a clean, low-carbon, ﬂexible, and diversiﬁed direction. This paper proposes a decentralized power dispatching model based on blockchain technology to address the problems of uncertainty, privacy, security, and reliability in power dispatching systems containing renewable energy and ﬂexible loads. Considering the uncertainty of wind, photovoltaic, and ﬂexible load integration into the power grid, the total generation costs of the system are established


Background
The digitalization and intelligence of electricity and energy services is the development direction of the power system, as well as an essential condition for realizing the upgrading of the energy structure and improving the competitiveness of enterprises [1]. With the rapid development of renewable energy technologies and demand-side management in the existing electricity market environment and usage scenarios, the power systems dispatching containing renewable energy and flexible loads have the demands of comprehensive business coverage, significant differences in customer demand, difficulty in controlling the operation system, and high social requirements for the trustworthiness of grid enterprises [2][3][4]. In response to these demands, there is an urgent need for a power system dispatching that meets the market operation rules and the requirements of trustworthy control to help the power grid distribute electricity better and more effectively [5]. As an emerging technology, blockchain can build a trusted topological network between power plants, electricity sellers, grids, and customers [6][7][8]. Therefore, combining blockchain with power dispatching to build a power dispatching system suitable for renewable energy and

Literature Review
With the rapid development of renewable energy technologies and demand-side management, the scale of renewable energy sources and flexible loads has gradually increased, putting forward new requirements for traditional power system dispatching [9]. At the same time, the demand for power trading and consumption by each electric power company is increasingly prominent. The selection of suitable power trading methods to meet the requirements of economic efficiency targets under current technical conditions has become a topic of discussion among scholars [10][11][12][13][14]. A novel approach to discovering an optimal multi-area dynamic economic dispatch solution integrated with wind power and pumped hydroelectric storage was proposed in [10]. An efficient optimization algorithm considering the merits of the whale optimization algorithm and wavelet mutation was also presented to handle the trade-off between generation cost and water consumption complications. The authors of [11] submitted a day-ahead optimal dispatch model for a power system with thermal power, hydropower, and flexible loads as dispatchable resources. According to the anti-peak regulation, the system dynamic power regulation margin model considering adjacent periods was established to address the uncertainty in the net load power fluctuation rate and sufficiently use the dispatchable resources to reduce wind curtailment. To minimize the impact of the randomness and volatility of renewable energy on the economic operation of AC/DC hybrid microgrids, a multitime-scale rolling optimization strategy was proposed for the grid-connected AC/DC hybrid microgrids [12]. It considers the source-load uncertainty declined with time scale reduction and the scheduling cooperation problem of different units on different time scales. The authors of [13] proposed a holistic framework of data-driven robust joint chanceconstrained economic dispatch optimization, seamlessly incorporating deep learning-based optimization to utilize renewable energy in power systems effectively. The authors of [14] characterized the stochastic emission-aware economic dispatch with a storage system using two frameworks, namely a chance-constrained framework and a robust optimization framework. The authors highlighted their differences and connections by studying the trade-offs between robustness and overall cost. The studies in the literature [10][11][12][13][14] belong to traditional centralized dispatching, which faces many challenges: the unified dispatch center needs to collect global data and process all decision variables in a short period, and the power dispatching system has high-communication pressure, high-security risks, and low-operational efficiency.
Each electric power company expects to retain the right of autonomous dispatching operation to protect its interests and data privacy. Blockchain technology combines the technical features of destructing, decentralization, and security, which fits the future development needs of power dispatching [15][16][17]. Therefore, based on blockchain technology, a decentralized power trading model with each electric power company's autonomous operation and collaborative management is one of the essential directions for power dispatching [18][19][20][21][22]. The authors of [15] developed a new decentralized peer-to-peer energy trading platform to address the abovementioned challenges. The platform consists of two essential layers: market and blockchain. The market layer featured a parallel and short-term pool-structured auction and was cleared using a novel decentralized ant colony optimization method. This market arrangement guarantees a near-optimally efficient market solution, preserves players' privacy, and allows inter-temporal market product trading. The authors of [16] addressed a sustainable microgrid design problem where blockchain technology was used for peer-to-peer energy trading in the microgrid. The adoption of blockchain technology in peer-to-peer energy trading ensures the security and sustainability of participants in the microgrid. It enables the participants to take control of the energy system without needing a central regulatory authority. A dispatching architecture for an integrated energy system was proposed, which includes an iteration Processes 2023, 11, 1673 3 of 21 chain, terminal value chain, data layer, network layer, contract layer, consensus layer, and application layer, using distributed dispatching method and distributed data storage, intelligent contract, consensus mechanism, multi-chain expansion, and encryption technology in blockchain [17]. An integrated blockchain-based energy management platform was proposed that optimizes energy flows in a microgrid while implementing a bilateral trading mechanism [18]. Physical constraints in the microgrid were respected by formulating an optimal power flow problem, which was combined with a bilateral trading mechanism in a single optimization problem. The alternating direction method of multipliers decomposed the problem to enable distributed optimization, and a smart contract was used as a virtual aggregator. By leveraging blockchain, the authors of [19] proposed secure data aggregation based on homomorphic encryption and the practical byzantine fault tolerance consensus. Meanwhile, proposed automatic power dispatching by utilizing the particle swarm optimization algorithm and smart contracts. The studies in the literature [15][16][17][18][19] have mainly focused on decentralized power trading. In contrast, studies on blockchain technology in power dispatch systems containing renewable energy and flexible loads are relatively scarce. Table 1 includes the main features of the literature on power dispatching with renewable energy and flexible loads. At present, there are the following shortcomings in the studies on power dispatching with renewable energy and flexible loads:

1.
For centralized power dispatching: the high cost of operation and maintenance of the dispatching center, and the stability is poor. There is a risk of unauthorized access and malicious tampering of critical data, directly threatening system security.

2.
For centralized power dispatching: the dispatching center has difficulty obtaining accurate, comprehensive, and real-time information, and the accuracy of forecasts is low, making it difficult to achieve the desired utilization of renewable energy and flexible loads.

3.
For decentralized power dispatching: the existing model usually lacks a supervisory system to verify the data's correctness and ensure safe and reliable system operation.

Literatures Dispatching Types Contributions Shortcomings
Ref. [10] Centralized power dispatching A bi-objective economic dispatch for a wind-thermal energy storage system The dispatch center has difficulty obtaining accurate information, making it difficult to achieve the desired utilization of renewable energy Ref. [11] Centralized power dispatching A day-ahead optimal dispatch model was formulated for a power system with thermal power, hydropower, and controllable load as dispatchable resources There is a risk of unauthorized access and malicious tampering of critical data, which directly threatens system security Ref. [12] Centralized power dispatching A multi-time-scale rolling optimization strategy was proposed for the grid-connected AC/DC hybrid microgrids High cost of operation and maintenance of the dispatching center, and the stability is poor Ref. [13] Centralized power dispatching A distributionally robust joint chance-constrained economic dispatch model was developed to hedge against distributional uncertainty present in multiple constraints Does not incorporate storage in the proposed optimization framework

Literatures Dispatching Types Contributions Shortcomings
Ref. [14] Centralized power dispatching Characterized the stochastic economic dispatch with a storage system utilizing two frameworks, namely a chance-constrained framework and a robust optimization framework Does not investigate the detailed regional price in a network comprising a distributed storage system under the implementation of the carbon tax scheme Ref. [15] Decentralized power dispatching Developed a new decentralized local energy trading platform, called DeTrade, with a practical and realistic integration of blockchain technology Does not consider the uncertainty related to the prosumer's commitment, as well as the intermittency of renewable energy Ref. [16] Decentralized power dispatching Developed a peer-to-peer energy trading market mechanism, where energy pricing is determined through a credit-based payment scheme by applying blockchain technology Does not incorporate demand-side management mechanisms into the peer-to-peer energy trading scheme Ref. [17] Decentralized power dispatching A dispatching architecture for an integrated energy system was proposed by using the distributed dispatching method There is no established reward and punishment mechanism to improve the integrity and practicality of the architecture Ref. [18] Decentralized power dispatching An integrated blockchain-based energy management platform was proposed that optimizes energy flows in a microgrid whilst implementing a bilateral trading mechanism Lacks a supervisory system to verify the correctness of the data and to ensure safe and reliable system operation Ref. [19] Decentralized power dispatching An automatic and distributed microgrid power dispatching solution based on the particle swarm optimization algorithm and Ethereum smart contracts were proposed Does not incorporate renewable energy and demand-side management mechanisms into the dispatching solution

This paper
Decentralized power dispatching Proposes a decentralized power dispatching model based on blockchain technology to address the problems of uncertainty, privacy, security, and reliability in power dispatching systems The calculation example in the paper was completed using a simulation program in a single-machine environment without achieving a real dispatching run To cope with the energy crisis and environmental pollution, the future development of the power system has to change towards a clean, low-carbon, flexible, and diversified direction. The power system of the future is bound to be an energy system that incorporates multiple forms of energy, including renewable energy and a combination of centralized and decentralized power dispatching. Considering the shortcomings in the studies on power dispatching with renewable energy and flexible loads, this paper proposes a decentralized power dispatching model based on blockchain technology by fusing decentralized power dispatching methods with blockchain technology to address the problems of uncertainty, privacy, security, and reliability in power dispatching systems containing renewable energy and flexible loads. Therefore, the main contributions of this work can be summarized as follows: 1.
This paper combines blockchain with power dispatching to build a power dispatching system suitable for renewable energy and flexible loads to be connected to the grid.

2.
Considering the uncertainty of wind, photovoltaic, and flexible load integration into the power grid, the total generation costs of the system are established, and the smart contracts of the decentralized power dispatching are proposed.

3.
The proof of work (PoW) consensus mechanism is improved. The hash operation that must be repeated in the PoW algorithm is replaced by an optimized computation process using a blockchain-based genetic algorithm (BD-GA). The proof of work-loadgenetic algorithm-based (PoW-GAD) consensus algorithm is proposed.
The remainder of this paper is organized as follows: Section 2 introduces the materials and methods. In Section 3, the results are discussed. Section 4 concludes this study. The energy supply entities manage and dispatch the system, which requires reducing information disclosed to the public during the operation to improve the system's privacy. While aiming for the maximum benefit of all entities, the authenticity of the data is ensured, and the fairness and justice of the system are maintained. The decentralized algorithm based on the Lagrange multiplier method can decompose the distributed energy dispatching problem into several sub-problems calculated by the energy-supplying entities. Each entity can maximize its interests by finding the optimal solution to the sub-problem. However, the decentralized algorithm alone cannot fully meet the above needs of the system. Blockchain technology has three distinctive features, which can be combined with the decentralized algorithm as the technical support for decentralized power dispatching [23][24][25].

1.
Decentralization: By allocating unit servers to the energy supply entities and accessing the blockchain system based on peer-to-peer transmission, the energy supply entities can perform decentralized computing and jointly participate in the operation and maintenance of the blockchain.

2.
Reliable operation: The blockchain's distributed bookkeeping enables each unit server to have a complete blockchain backup. When the information of a few servers is wrong, the correct information can be copied through the data backup of other servers. Based on the consensus mechanism, it can ensure that each entity agrees on the information on the chain. The reliability of data information during decentralized computing is guaranteed.

3.
Data security: Before the server of the energy supply entity is initially connected to the blockchain system, the corresponding private and public keys are generated in one direction through asymmetric encryption. The private key is used to sign the summary information, such as calculation results, digitally. The public key can verify the identity of the information sender and whether the information has been tampered with by others during the transmission process. Hash encryption, widely used in blockchains, is also a form of asymmetric encryption. After the summary information is converted into hash values, information changes will inevitably lead to changes in hash values, which can ensure that the summary information is not tampered with.
Hash values cannot reverse the information content, which ensures that the data is not leaked.

Decentralized Power Dispatching Architecture
Combining blockchain with power dispatching to build a power dispatching system suitable for renewable energy and flexible loads to be connected to the grid, the architecture of the decentralized power dispatching is shown in Figure 1. The data layer is the basis where data are stored through distributed bookkeeping. The primary data include the output data of each energy supply entity, the transfer variables of the distributed algorithm, the number of iterations, and the time. The network layer is based on peer-to-peer transmission for relevant data communication, where the entities have equal status in the communication process. Through peer-to-peer communication in the network layer, the consensus layer uses consensus algorithms to ensure that the entities agree on the consistency variables and operational results in the energy dispatching. Consensus mechanisms and consistency protocol consensus algorithms are used according to the characteristics of the leading and child chains, respectively. The contract layer uses smart contracts to transform system protocols and rules, such as the system's decentralized power dispatching operation model, into an automatically executed program, making the dispatching calculation process intelligent, procedural, and transparent. The application layer also encapsulates typical application scenarios and cases for the power dispatching system. The system can draw on the existing instances to intelligently regulate the results of the dispatching calculation. To quantitatively predict the ability of a regional power system to accept wind power at time t, this paper proposes the concept of wind power pre-penetration rate. Definition of wind power pre-penetration rate: refers to the ratio of the predicted output of wind power to the system load, i.e.,: The data layer is the basis where data are stored through distributed bookkeeping. The primary data include the output data of each energy supply entity, the transfer variables of the distributed algorithm, the number of iterations, and the time. The network layer is based on peer-to-peer transmission for relevant data communication, where the entities have equal status in the communication process. Through peer-to-peer communication in the network layer, the consensus layer uses consensus algorithms to ensure that the entities agree on the consistency variables and operational results in the energy dispatching. Consensus mechanisms and consistency protocol consensus algorithms are used according to the characteristics of the leading and child chains, respectively. The contract layer uses smart contracts to transform system protocols and rules, such as the system's decentralized power dispatching operation model, into an automatically executed program, making the dispatching calculation process intelligent, procedural, and transparent. The application layer also encapsulates typical application scenarios and cases for the power dispatching system. The system can draw on the existing instances to intelligently regulate the results of the dispatching calculation. Wind power uncertainty

Blockchain-Based Decentralized Power Dispatching Cost Models and Smart Contracts
To quantitatively predict the ability of a regional power system to accept wind power at time t, this paper proposes the concept of wind power pre-penetration rate. Definition of wind power pre-penetration rate: refers to the ratio of the predicted output of wind power to the system load, i.e.,: where P WF.jt is the predicted output of wind power j at time t. P D.t is the total system load at time t. N W is the number of wind power turbines, and j is the wind power turbine no. The wind power output prediction error is closely related to the wind power prepenetration rate and wind power output prediction accuracy. To more accurately grasp the impact of wind power prediction errors on the system, this paper takes the maximum of the following two calculation methods when calculating the wind farm output prediction error.
where A W.jt is the prediction accuracy of wind power output.

Photovoltaic uncertainty
Considering the random and uncertain nature of photovoltaic power output, it is impossible to analyze and evaluate every photovoltaic power output scenario. Clustering analysis is an effective tool to solve this problem. The core idea of the K-means clustering algorithm is that for n vectors x k (k = 1, 2, . . . , n), they are divided into m groups G i (i = 1, 2, . . . , m), and the cluster center of each group is found so that the value function of the distance indicator is minimized. When the Euclidean distance is chosen as the non-similarity metric between the vector x k in group G i and the corresponding clustering center c i , the value function can be defined as: To evaluate the difference before and after the improvement of the K-means clustering algorithm, the intra-cluster variance measure q and inter-cluster variance measure Q were introduced to analyze the clustering effect, which is mathematically described as: where x is the object in G i and c i and c j are the clustering centers of G i and G j , respectively.

Flexible load uncertainty
Load weights indicate how much each load type participates in the system's scheduling. Since the roles that each type of load engages in the system dispatch are different, the load can be classified into three types based on the degree of involvement of each load in the dispatch, as shown in Table 2. In power dispatching, the dispatching level of the load can be obtained in conjunction with the actual situation. The range of values of the dispatch level is taken as the initial weight interval of the load. The initial weight interval of class r load at time t is: Processes 2023, 11, 1673 8 of 21 Using fuzzy mathematical theory to fuzzify the above equation: where a, b are correction factors. Then, the weight interval of the load at time t is: The weight interval model for load participation in the dispatching is: Define the weight of load participation in dispatching at time t as: The cost model for the system call load at time t is: where k 1 (t), k 2 (t) are function coefficients. P D.rt is the r-class load at time t.

Wind power cost
The wind power cost model has two components: firstly, the cost of energy storage, and secondly, the cost of flexible loads. (12) where k E (t) is the energy storage cost factor. C E (t) is the energy storage cost. ζ t is the weight factor.

2.
Photovoltaic cost By introducing the abandonment penalty cost and the loss of load penalty cost, the abandonment penalty cost and the loss of load penalty cost of photovoltaic plant z at time t are expressed as: where C PV is the penalty cost per unit of photovoltaic abandonment. E PV,zt,s is the amount of electricity abandoned. C LOSS is the penalty cost per unit of lost load. E LOSS,zt,s is the amount of electricity lost.
Processes 2023, 11, 1673 9 of 21 For the system operating cost caused by the photovoltaic connected to the system, the fluctuation compensation cost is introduced to measure it. The fluctuation compensation cost of photovoltaic plant z at time t is: where K H is the fluctuation compensation cost factor. P DEH is the upper limit of photovoltaic output fluctuation. P S,zt is the photovoltaic output during the sampling period, and P B,zt is the energy storage output during the sampling period. P S-B,zt,s is the photovoltaic output fluctuation after energy storage compensation during the sampling period. P J,zt,s is the fluctuation compensation power during the sampling period. The photovoltaic cost model consists of the three components mentioned above: 3.

Thermal power cost
The thermal power cost model is given in the following equation: where a i is the linearized cost function coefficient. P G.it is the active output of thermal power unit i at time t.
In summary, the total generation costs of the system over the dispatching period are as follows:

Objective function
Considering the wind power cost, the photovoltaic cost, and the thermal power cost, the objective function is as follows:

Constraints
Power balance constraint: Thermal power unit output power constraint: where P min Gi , P max Gi are the upper and lower limit constraints of the thermal power unit i, respectively.
Thermal power unit climbing constraint: where D Ri , U Ri are the decrease rate and increase rate of active output of thermal power unit i during time t, respectively. β i is the predetermined confidence level. Energy storage system constraints: In a blockchain system, multiple nodes must reach a consensus on the same operation and instruction to operate correctly. However, the nodes contain faulty and malicious nodes, and such nodes work with the inability to send data or send out harmful data, which eventually leads to the failure of the consensus process and hinders the system's operation. Thus, some consensus algorithm is needed to constrain this process and ensure the consistency and security of the system.
The most widely used consensus algorithm in current blockchain systems is the proof of work (PoW) consensus algorithm [26][27][28]. In a blockchain system using PoW, the process of generating and verifying a new block is as follows: 1.
When a node generates a new block, it first needs to pack and hash the newly developed interaction information in the system to generate a fresh Merkel root, which is encapsulated to form a new block header.

2.
The block header is then subjected to multiple SHA256 operations, and if the result is less than the target value, it is certified complete and broadcast to the whole network. If the result is greater than or equal to the target value, the random number in the block header is changed, the operation is performed again, and so on, until the requirement is met.

3.
When a node is the first to broadcast to the whole network to announce its completion, the entire network nodes verify the result. The block is valid if the number of nodes acknowledging the block as good exceeds 50%. Suppose it wants to modify or reject a generated block's information during this process. In that case, the malicious node must have far more arithmetic power than any other node to ensure it is always the first to complete the calculation. It must also control at least 50% of the nodes in the network to ensure that the block is validated and becomes a valid block. The security of the PoW algorithm is: where h ca is the maximum number of malicious nodes supported in the system and n is the total number of nodes. It can be seen that although the PoW algorithm has a high fault tolerance rate, it requires a large number of hashing operations when generating new blocks, consuming a large number of arithmetic resources in the system, and the computational results generated during this operation are not helpful in practice. At the same time, the nodes of the power dispatching system suitable for renewable energy and flexible loads to be connected to the grid are limited by their power consumption and size, and their arithmetic power is unlikely to be too high [29]. Thus, it takes a lot of time to complete and validate a calculation, which makes it difficult to cope with sudden fluctuations in the output of renewable energy sources and the speed required for ad hoc dispatching tasks on the grid. Therefore, the PoW algorithm cannot be applied to this paper's power dispatching model and needs to be improved to increase its applicability and computational speed.
In this paper, the PoW consensus mechanism is improved. The hash operation that must be repeated in the PoW algorithm is replaced by an optimized computation process using a blockchain-based genetic algorithm (BD-GA) [30]. The proof of work-load-genetic algorithm-based (PoW-GAD) consensus algorithm is proposed. The specific function of the algorithm is as follows:

1.
When a node needs to generate a new block, the same as the PoW algorithm, the received broadcast message is first packaged to create the Merkel root.

2.
The time-consuming SHA256 operation is first eliminated in the verification session. When each node needs to verify whether a block is a valid block, if the block is the result of an optimization calculation, each node is made to separately verify the calculation result contained in the league (the calculation result is brought into the GA algorithm and recalculated to determine whether the result meets the system constraints and boundary conditions and whether the operating cost is optimal). Suppose the block is purely data content such as instructions, operations, or information (e.g., information on generation, load forecast declarations, etc.). In that case, the GA algorithm calculation result defaults to 1 to indicate that the block is pure data and proceeds directly to the next step.

3.
For a block containing the result of an optimization calculation, if more than 50% of the nodes verify that the result is valid, the block is validated by the consensus algorithm and is an exemplary block.

4.
A vote is taken for blocks containing pure data content to determine whether the block is valid. The consensus algorithm validates the block if more than 50% of the nodes vote to approve the data.
Due to the inheritance of the 50% node identity feature of the PoW algorithm, the PoW-GAD algorithm security is similar to that of PoW, i.e.,: where f PoW-GAD is the number of malicious nodes the PoW-GAD blockchain system can accommodate. This paper integrates the blockchain node cost model and smart contract algorithm. The given blockchain calculation flow is shown in Figure 2.
The calculation process of blockchain nodes can obtain the power output value of blockchain nodes through the blockchain node cost model and smart contract-solving algorithm, which drives the decision-making behavior of each power supply to operate in the direction that is beneficial to the grid operation. The block body mainly contains the dispatch results of the current period and the power output plan for the next period.

Case Setting
The smart contract model in the paper is solved by invoking CPLEX on MATLAB simulation software to verify the feasibility of the proposed optimal dispatching strategy and to simulate and compare the operational security and efficiency of the blockchain system. The simulation case includes eight conventional thermal power plants, wind farms, and photovoltaic plants. The dispatching period is 96 time periods, and the data information of the traditional thermal power units is shown in Table 3.    The wind power output, photovoltaic output, and system load data are shown in Figure 3. Other data are as follows: the forecast accuracy of wind power is 0.9, C PV is 7000 RMB/MW, C LOSS is 7000 RMB/MW, and the ratio of the fixed load is 40%. The percentage of flexible load A is 30%, the percentage of flexible load B is 30%, and the a and b are 0.5 and 1, respectively. The flexible load participates in dispatching for the dispatching times 25-96, and the parameters of the flexible load are shown in Table 4. The energy storage cost price is 500 RMB/MW; the energy storage parameters are shown in Table 5.
The wind power output, photovoltaic output, and system load data are shown in Figure 3. Other data are as follows: the forecast accuracy of wind power is 0.9, CPV is 7000 RMB/MW, CLOSS is 7000 RMB/MW, and the ratio of the fixed load is 40%. The percentage of flexible load A is 30%, the percentage of flexible load B is 30%, and the a and b are 0.5 and 1, respectively. The flexible load participates in dispatching for the dispatching times 25-96, and the parameters of the flexible load are shown in Table 4. The energy storage cost price is 500 RMB/MW; the energy storage parameters are shown in Table 5.  The model in Section 2.2 is discussed by simulating models 1-3. The model in this paper is model 3, model 1 is the traditional single thermal power dispatching model, and model 2 is the dispatch model from Ref. [31]. Table 1 shows the essential characteristics of the three models.

Results and Discussion
Results are obtained by running simulations on the three models in Table 6. The security and efficiency of the consensus algorithm are discussed. The dispatch models' economics and reserve requirements are discussed and analyzed.  The model in Section 2.2 is discussed by simulating models 1-3. The model in this paper is model 3, model 1 is the traditional single thermal power dispatching model, and model 2 is the dispatch model from Ref. [31]. Table 1 shows the essential characteristics of the three models.

Results and Discussion
Results are obtained by running simulations on the three models in Table 6. The security and efficiency of the consensus algorithm are discussed. The dispatch models' economics and reserve requirements are discussed and analyzed.

Discussion of the Consensus Algorithm
In this paper, the proof of work (PoW) consensus mechanism is improved. The hash operation that must be repeated in the PoW algorithm is replaced by an optimized computation process using a blockchain-based genetic algorithm (BD-GA). The proof of work-load-genetic algorithm based (PoW-GAD) consensus algorithm is proposed. The security and efficiency of the consensus algorithm proposed in this paper are discussed through the results of simulation operations.

Security Verification of the Consensus Algorithm
The probability of the system being successfully attacked after using the PoW-GAD consensus algorithm can be shown in Figure 4. As the user's devices are generally connected to the Internet through the router, the corresponding devices can be controlled through the router after the attack. The power entity with the PoW-GAD consensus algorithm is compared with the probability data of the router being attacked. In contrast, the computer or server in the control center performs the calculation and control independently. Therefore, the comparison is made with the probability of a single computer or server being attacked. The two possibilities above do not have accurate data and can only be based on the fact that the router is poorly protected and vulnerable to attack. A higher value of 0.8 and a lower value of 0.1 can be used for comparison because the server is better protected and less vulnerable. It is sufficient to show the trend in the probability of the two figures with the number of nodes.

Models
Dispatching Types Dispatching Methods Characteristics

Discussion of the Consensus Algorithm
In this paper, the proof of work (PoW) consensus mechanism is improved. The hash operation that must be repeated in the PoW algorithm is replaced by an optimized computation process using a blockchain-based genetic algorithm (BD-GA). The proof of workload-genetic algorithm based (PoW-GAD) consensus algorithm is proposed. The security and efficiency of the consensus algorithm proposed in this paper are discussed through the results of simulation operations.

Security Verification of the Consensus Algorithm
The probability of the system being successfully attacked after using the PoW-GAD consensus algorithm can be shown in Figure 4. As the user's devices are generally connected to the Internet through the router, the corresponding devices can be controlled through the router after the attack. The power entity with the PoW-GAD consensus algorithm is compared with the probability data of the router being attacked. In contrast, the computer or server in the control center performs the calculation and control independently. Therefore, the comparison is made with the probability of a single computer or server being attacked. The two possibilities above do not have accurate data and can only be based on the fact that the router is poorly protected and vulnerable to attack. A higher value of 0.8 and a lower value of 0.1 can be used for comparison because the server is better protected and less vulnerable. It is sufficient to show the trend in the probability of the two figures with the number of nodes.  As shown in Figure 4, the probability of a successful attack on a power entity using the PoW-GAD consensus algorithm decreases exponentially as the number of nodes in the system increases. The probability of being successfully attacked at a node count of 30 is approximately 5%, which is essentially an impossible event regarding probability statistics. If the number of nodes increases, the probability approaches infinitely close to zero. This is because the PoW-GAD consensus algorithm has the property that 50% of the nodes agree before a block can be generated, and the more nodes there are, the more nodes need to be controlled for an attack, and the more difficult the attack will be. In contrast, the traditional power entity is computed and controlled through only one computer or server in the control center, and system security is independent of the number of nodes. Thus, once that server has been breached, the entire system is also controlled. In summary, the improved PoW-GAD algorithm, while inheriting the security features of the PoW algorithm, adapts to the blockchain-based decentralized power dispatching structure, improves system security, and lays the foundation for blockchain-based decentralized power dispatching operation.

Efficiency Verification of the Consensus Algorithm
The efficiency of the improved consensus algorithm is discussed through two metrics: block throughput and block consensus time. Block throughput refers to the number of blocks generated per second, and block consensus time refers to the time required to complete consensus. Figure 5 shows the block production of the two consensus algorithms, PoW and PoW-GAD, in the same environment. It can be seen that the block throughput of the improved consensus algorithm PoW-GAD is higher than PoW because the hashing operations that need to be repeated in the PoW algorithm are replaced with an optimized computation process based on the genetic algorithm in the improved algorithm, thus facilitating the block generation speed.
tistics. If the number of nodes increases, the probability approaches infinitely close to zero. This is because the PoW-GAD consensus algorithm has the property that 50% of the nodes agree before a block can be generated, and the more nodes there are, the more nodes need to be controlled for an attack, and the more difficult the attack will be. In contrast, the traditional power entity is computed and controlled through only one computer or server in the control center, and system security is independent of the number of nodes. Thus, once that server has been breached, the entire system is also controlled. In summary, the improved PoW-GAD algorithm, while inheriting the security features of the PoW algorithm, adapts to the blockchain-based decentralized power dispatching structure, improves system security, and lays the foundation for blockchain-based decentralized power dispatching operation.

Efficiency Verification of the Consensus Algorithm
The efficiency of the improved consensus algorithm is discussed through two metrics: block throughput and block consensus time. Block throughput refers to the number of blocks generated per second, and block consensus time refers to the time required to complete consensus. Figure 5 shows the block production of the two consensus algorithms, PoW and PoW-GAD, in the same environment. It can be seen that the block throughput of the improved consensus algorithm PoW-GAD is higher than PoW because the hashing operations that need to be repeated in the PoW algorithm are replaced with an optimized computation process based on the genetic algorithm in the improved algorithm, thus facilitating the block generation speed. As shown in Figure 6, the block consensus times of PoW and PoW-GAD consensus algorithms are compared under the same environment. In the same running time, the block consensus time under the PoW consensus algorithm is 6200-6800 ms, while the con- As shown in Figure 6, the block consensus times of PoW and PoW-GAD consensus algorithms are compared under the same environment. In the same running time, the block consensus time under the PoW consensus algorithm is 6200-6800 ms, while the consensus time under the PoW-GAD consensus algorithm is only about 4000 ms, which reduces the time required for consensus. The above results demonstrate that the PoW-GAD consensus algorithm proposed in this paper is more efficient.

Analysis of System Operating Costs
A comparative analysis is carried out with the wind and photovoltaic grid-connected traditional optimized dispatching model to analyze the model's validity in this paper. Figure 7 shows the results of the thermal power unit output. From Figure 7, it can be seen that the proposed power dispatching strategy has certain peak-shaving and valley-filling operations compared with Model 1 and Model 2. The system costs in Table 7 are obtained through relevant calculations. The data in the table are in RMB. O z is the cost of thermal power generation, O w is the cost of wind power, and O w.e is the cost of energy storage caused by wind power. O w.d is the cost of flexible load, O s is the cost of photovoltaic, and O s.c is the cost of photovoltaic abandonment penalty. O s.f is the cost of load loss penalty, and O s.e is the cost of energy storage caused by photovoltaic. χ w is the rate of wind abandonment, and χ s is the rate of photovoltaic abandonment. The dispatching model in this paper uses flexible loads to regulate the scenery uncertainty and uses the method proposed to classify the flexible loads. From the calculation results, it can be seen that the dispatching method in this paper has the effect of reducing the system cost and, at the same time, increasing the usage rate of the wind and photovoltaic. The division of the flexible load can make the flexible load more relevant in dealing with the uncertainty of wind power and photovoltaic. In addition, this paper considers the regulation role of energy storage so that the flexible load and storage can make deep regulation of the grid integration with wind and photovoltaic.

Analysis of System Operating Costs
A comparative analysis is carried out with the wind and photovoltaic grid-connected traditional optimized dispatching model to analyze the model's validity in this paper. Figure 7 shows the results of the thermal power unit output. From Figure 7, it can be seen that the proposed power dispatching strategy has certain peak-shaving and valley-filling operations compared with Model 1 and Model 2. The system costs in Table 7 are obtained through relevant calculations. The data in the table are in RMB. Oz is the cost of thermal power generation, Ow is the cost of wind power, and Ow.e is the cost of energy storage caused by wind power. Ow.d is the cost of flexible load, Os is the cost of photovoltaic, and Os.c is the cost of photovoltaic abandonment penalty. Os.f is the cost of load loss penalty, and Os.e is the cost of energy storage caused by photovoltaic. χw is the rate of wind abandonment, and χs is the rate of photovoltaic abandonment. The dispatching model in this paper uses flexible loads to regulate the scenery uncertainty and uses the method proposed to classify the flexible loads. From the calculation results, it can be seen that the dispatching method in this paper has the effect of reducing the system cost and, at the same time, increasing the usage rate of the wind and photovoltaic. The division of the flexible load can make the flexible load more relevant in dealing with the uncertainty of wind power and photovoltaic. In addition, this paper considers the regulation role of energy storage so that the flexible load and storage can make deep regulation of the grid integration with wind and photovoltaic.    For the reserve requirements of wind and photovoltaic grid integration, conventional thermal power units are currently generally used as a reserve. The model in this paper uses energy storage and flexible loads for regulation. The reserve requirements for the conventional model and the model in this paper were calculated, and the data in the Table 8 are in MW. DR is the reserve requirement, DR s is the flexible load reserve, DR g is the conventional thermal reserve, and DR e is the energy storage reserve.  Figure 8 shows the reserve demand and regulation analysis when a conventional thermal unit is used as a reserve. Figure 9 shows the reserve demand and regulation analysis when the method in Ref. [31] is used as a reserve. Figure 10 shows the analysis of the reserve demand and regulation of the system after adopting the method in this paper.  The analysis of the calculation results for the reserve demand and regulation situation shows that the conventional model generally uses traditional thermal units to act as reserves. The reserve demand of the case is not fully satisfied. The regulation is less than half of the reserve demand at certain times, such as 0-22 and 75-96. Low restriction of the reserve demand at this point will result in wind and light abandonment. The reserve demand for Ref. [31] and the method proposed in this paper comes from flexible loads and energy storage. By optimizing the use of energy storage and flexible load, the required reserve of the case can be satisfied. The two can function well as they complement each other at certain times. However, Ref. [31] only considers the regulation of wind power output and does not include photovoltaics in the dispatch model, which lacks specific adaptation scenarios. In this paper, the reserve demand caused by wind power and photovoltaics can be satisfied by using energy storage and flexible loads. At the same time, using the method of this paper for the division of flexible loads so that flexible loads play a specific complementary role can better play the regulation function of flexible loads.

Analysis of Optimization Algorithms
To verify the good performance of the optimization algorithm in this article, the schemes were set using light ray optimization algorithm (LRO) and whale optimization algorithm (WOA), and the differences in computational accuracy and speed between the three algorithms were compared and analyzed. The three algorithms are solved 10 times each, and the average value is shown in Table 9.  Table 9 shows that the optimization algorithm in this article has significant advantages in computational speed and accuracy compared to the other two algorithms. Due to the use of distributed computing in this article, the number of iterations and calculation time is significantly reduced. Although the optimal values of WOA and LRO algorithms have fewer iterations, their optimal values are far inferior to the algorithms in this paper, and the reason for this is that they fall into the local optimum too early. The iteration results of the three algorithms are compared in Figure 11. The WOA and LRO algorithms have a faster iteration speed in the early stage. Among them, the LRO algorithm, which was always in the leading position before 80 iterations, basically stopped updating the optimal value afterward. This also indicates that these two algorithms have poor global search ability and are prone to falling into local optima. Especially the LRO algorithm, although it has a faster calculation speed, has the greatest possibility of falling into local optima. Although the algorithm in this article had a slower iteration speed in the early stage, it still maintained strong optimization ability by comparing a large number of different calculation results generated by many nodes in the middle and later stages, ultimately surpassing the other two algorithms.

Conclusions
The paper proposes a decentralized power dispatching model based on blockchain technology by fusing decentralized power dispatching methods with blockchain technology to address the problems of uncertainty, privacy, security, and reliability in power dispatching systems containing renewable energy and flexible loads. The conclusions are as follows: 1. Considering the uncertainty of wind, photovoltaic, and flexible load integration into the power grid, the total generation costs of the system are established, and the smart contracts of the decentralized power dispatching are proposed. The power dispatching model in this paper has certain peak-shaving and valley-filling operations. Moreover, the power dispatching method reduces the system cost and increases the usage rate of wind and photovoltaic. The division of the flexible load can make the flexible load more relevant in dealing with the uncertainty of wind power and photovoltaic. 2. The proof of work (PoW) consensus mechanism is improved. The hash operation that must be repeated in the PoW algorithm is replaced by an optimized computation process using a blockchain-based genetic algorithm (BD-GA). The proof of work- Figure 11. Comparison of the iterative results of the three algorithms.

Conclusions
The paper proposes a decentralized power dispatching model based on blockchain technology by fusing decentralized power dispatching methods with blockchain technology to address the problems of uncertainty, privacy, security, and reliability in power dispatching systems containing renewable energy and flexible loads. The conclusions are as follows: 1.
Considering the uncertainty of wind, photovoltaic, and flexible load integration into the power grid, the total generation costs of the system are established, and the smart contracts of the decentralized power dispatching are proposed. The power dispatching model in this paper has certain peak-shaving and valley-filling operations. Moreover, the power dispatching method reduces the system cost and increases the usage rate of wind and photovoltaic. The division of the flexible load can make the flexible load more relevant in dealing with the uncertainty of wind power and photovoltaic.

2.
The proof of work (PoW) consensus mechanism is improved. The hash operation that must be repeated in the PoW algorithm is replaced by an optimized computation process using a blockchain-based genetic algorithm (BD-GA). The proof of work-loadgenetic algorithm-based (PoW-GAD) consensus algorithm is proposed. The improved PoW-GAD algorithm, while inheriting the security features of the PoW algorithm, adapts to the blockchain-based decentralized power dispatching structure, improves system security, and lays the foundation for blockchain-based decentralized power dispatching operation.

3.
Blockchain technology is applicable in power dispatch with renewable energy and flexible loads. The proposed model can operate effectively without disclosing device parameters to the public, with higher throughput and shorter consensus time.
In response to various service needs, the decentralized power dispatching model based on blockchain technology requires attention in the following areas:

1.
The calculation example in the paper was completed using a simulation program in a single-machine environment without achieving a real dispatching run. The next step will be establishing a real blockchain platform through Ethereum and conducting more in-depth experimental verification.

2.
For the power dispatching model, it is possible to consider adding a capital trading chain and establishing a reward and punishment mechanism to improve the integrity and practicality of the model. Data Availability Statement: Data sharing is not applicable. If there is a need for code, readers can contact the author, who may provide it after evaluation.

Conflicts of Interest:
The authors declare no conflict of interest.