Green building energy consumption monitoring and optimization control method and system based on internet of things

By using IoT sensor clusters and distributed machine learning, combined with graph topology analysis and multi-agent reinforcement learning, the slow response and privacy data sharing risks of green building energy consumption monitoring systems in the face of sudden demand fluctuations have been solved, achieving efficient energy flow and load balancing, and improving energy utilization efficiency and response speed.

CN122260862APending Publication Date: 2026-06-23KAIHUA YUHE GARDEN CONSTR ENG CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
KAIHUA YUHE GARDEN CONSTR ENG CO LTD
Filing Date
2026-04-07
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing green building energy consumption monitoring systems are slow to respond to sudden fluctuations in energy demand, cannot achieve millisecond-level load balancing, pose privacy data sharing risks, and are difficult to effectively integrate the energy demand patterns of different buildings, resulting in resource waste and unstable power supply.

Method used

An IoT sensor cluster is used to collect energy consumption characteristic data in real time. A local energy consumption prediction model is built through a distributed machine learning architecture. Combined with graph topology analysis and privacy-preserving parameter exchange mechanism, a multi-agent reinforcement learning algorithm is used to drive energy allocation decisions. Combined with a real-time feedback compensation mechanism and a communication sparsity algorithm, global load balancing is achieved.

Benefits of technology

It significantly improves the energy efficiency of building complexes, reduces load imbalance, balances privacy and communication costs, and achieves millisecond-level response and efficient energy flow control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122260862A_ABST
    Figure CN122260862A_ABST
Patent Text Reader

Abstract

The application provides a green building energy consumption monitoring and optimization control method and system based on an Internet of Things, comprising: mapping the energy flow transfer control vector to the space-time distribution mode of the building group for iterative updating, using a communication sparsification algorithm to reduce the interaction frequency between nodes, and adjusting the interaction priority according to the node degree centrality or connection weight to determine the target load balance distribution state; detecting whether there is residual imbalance degree in the target load balance distribution state, if there is, redefining the connection state of the building group through a state-action space mapping algorithm, correcting the flow path by using a heuristic search or path planning algorithm, and outputting the fast balance distribution result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information technology, and in particular to a method and system for monitoring and optimizing energy consumption in green buildings based on the Internet of Things. Background Technology

[0002] In today's era of pursuing sustainable development, green building energy consumption monitoring and optimization control systems based on the Internet of Things have become a core pillar for promoting urban energy transformation.

[0003] This field, by collecting and analyzing building energy data in real time, helps reduce carbon emissions and improve energy efficiency, which is crucial for addressing global climate change.

[0004] It not only reduces daily operating costs, but also provides a more reliable power supply for the entire community, ensuring an improved quality of life for residents.

[0005] However, existing methods are often limited to isolated building monitoring, ignoring the complex energy interactions between buildings, which makes it impossible to accurately grasp the overall dynamic changes when dealing with energy flows in large-scale communities.

[0006] This limitation makes the system slow to respond to sudden fluctuations in energy demand, which can easily lead to resource waste or unstable power supply.

[0007] Looking further, the main technical challenge in this field lies in how to achieve collaborative energy management between buildings while protecting data privacy.

[0008] As independent energy units, buildings each possess sensitive electricity consumption information. Directly sharing this data could lead to privacy breaches and hinder information collaboration among multiple buildings.

[0009] This need for privacy protection directly exacerbates another problem: the difficulty in effectively integrating the energy demand patterns of different buildings, resulting in the system's inability to analyze the high-dimensional energy state space in real time.

[0010] For example, in a community consisting of commercial and residential buildings, commercial buildings may generate excess solar energy during the day, while residential buildings have peak demand at night. If this information cannot be coordinated without revealing the specific details of electricity consumption, the system will not be able to dynamically adjust energy distribution. As a result, solar energy is often wasted, while the residential area faces power shortages, causing an overall energy imbalance.

[0011] Therefore, how to achieve millisecond-level load balancing in community microgrids while avoiding the risks associated with sharing private data has become the key problem to be solved in this study.

[0012] Based on the applicant's search and analysis of existing technologies, current technical solutions for optimizing energy consumption in green buildings generally suffer from the following incompatible technical bottlenecks: First, most solutions employ a centralized data collection and model training architecture, requiring the aggregation of raw energy consumption data from each building, making it difficult to effectively prevent user privacy leaks; Second, solutions using distributed architectures often only achieve local energy consumption prediction for a single building, failing to consider the physical topology and logical coupling relationships of building groups, resulting in poor global load balancing optimization; Third, existing energy dispatching solutions mostly adopt offline optimization modes, leading to slow responses to sudden surges in demand, and failing to consider the contradiction between communication bandwidth limitations and the real-time nature of control commands, thus failing to achieve millisecond-level load closed-loop control; Fourth, existing solutions do not include closed-loop correction mechanisms for residual imbalances caused by grid physical constraints, making it difficult to effectively improve grid over-limit problems caused by load imbalances. This application proposes an integrated solution to address the aforementioned existing technical bottlenecks, possessing outstanding substantive features. Summary of the Invention

[0013] This invention provides a method for monitoring and optimizing energy consumption in green buildings based on the Internet of Things, mainly including: S101. Collect real-time energy consumption characteristic data of each building through IoT sensor cluster, extract the time and frequency domain features of the real-time energy consumption characteristic data, and input the extracted features into the local energy consumption prediction model built on each building node based on distributed machine learning architecture, analyze the energy demand fluctuation pattern of different buildings, and construct the spatiotemporal distribution feature matrix of current energy demand. S102. Based on the spatiotemporal distribution feature matrix, a graph topology analysis algorithm is used to identify the physical topology and logical coupling relationship between building groups. A privacy-preserving parameter exchange mechanism is used to transmit only the model gradient or weight update value for global model aggregation and update. Based on the updated model, the energy consumption prediction value of each building node is output. Based on the energy consumption prediction value, the energy deviation between each node is calculated to obtain a quantitative evaluation vector of energy imbalance. S103. Determine whether the quantized evaluation vector exceeds a preset evaluation threshold. If it does, integrate the parameter updates of each node through a global parameter aggregation algorithm, and optimize the model weights of specific building nodes by combining a local fine-tuning strategy to generate a multi-dimensional prediction sequence of demand fluctuations. If it does not exceed the threshold, maintain the current model parameters of each building node, and generate a regular prediction sequence based on the local energy consumption prediction model as the multi-dimensional prediction sequence. S104. Construct a community overall load status distribution map based on the multidimensional prediction sequence, use a multi-agent reinforcement learning algorithm (MARL) to drive multiple agents to execute local energy allocation decisions, and combine the environmental reward function to adjust the energy flow path in real time to generate a preliminary load balancing configuration scheme. S105. Extract the operating data of key nodes from the preliminary load balancing configuration scheme, determine whether there is a risk of demand surge, if so, realize state sharing between intelligent agents through peer-to-peer (P2P) information interaction protocol, and introduce a real-time feedback compensation mechanism to correct prediction deviation and calculate the optimized energy flow control vector; if not, directly use the control vector corresponding to the preliminary load balancing configuration scheme as the energy flow control vector. S106. The energy flow control vector is mapped to the spatiotemporal distribution feature matrix for iterative updates. A communication sparsity algorithm is used to reduce the interaction frequency between nodes, and the interaction priority is adjusted according to the node degree centrality or connection weight to determine the target load balance distribution state. S107. Detect whether there is a residual imbalance in the target load balance distribution state that is greater than a preset balance threshold. If it is greater, redefine the connection state of the building group through the state-action space mapping algorithm, correct the flow path using heuristic search or path planning algorithm, and output a fast balance distribution result. If it is not greater, output the target load balance distribution state as the final balance distribution result.

[0014] Furthermore, S104 includes: For multidimensional prediction data, historical energy usage records and predicted trends for each area within the community are obtained. Through data cleaning and standardization, a structured load status dataset is obtained. Based on the load status dataset, a visualization tool is used to generate a map showing the overall load status distribution of the community, from which the distribution pattern of high-load and low-load areas can be determined. For the high-load areas identified in the distribution map, a multi-agent system is deployed. The multi-agent reinforcement learning algorithm drives each agent to obtain real-time local energy consumption data. Based on local energy consumption data, allocation decisions are made. If the energy consumption of a certain area exceeds a preset threshold, the available energy in the nearby low-load area is determined through collaborative communication among multiple agents. Given a fixed amount of available energy, and incorporating an environmental reward function, the optimal energy flow path is dynamically calculated to obtain a preliminary scheme for transferring energy from low-load areas to high-load areas. According to the preliminary plan, the path will be adjusted and the load changes during the energy flow process will be monitored in real time. If a new load imbalance is detected, the allocation decision will be recalculated and an adjusted load balance configuration will be generated. By adjusting the load balancing configuration, the overall load distribution map of the community is continuously updated to obtain the latest information on high and low load areas, and the above allocation decision and path adjustment process is executed cyclically.

[0015] Furthermore, S105 includes: Obtain operational data of key nodes from the load balancing configuration, and extract historical load records of each node using data acquisition tools to obtain a detailed dataset of node operational status. For the extracted node running status dataset, the support vector machine algorithm is used to classify the data and determine whether there is a potential risk of a surge in demand; If the assessment results indicate a risk of a surge in demand, information transmission between intelligent agents is initiated through a peer-to-peer interaction protocol to obtain the current state data of each intelligent agent and determine the integrity of state sharing. Based on the shared state data, the load differences between the agents are analyzed, and the load distribution is dynamically adjusted through a real-time feedback mechanism to obtain the corrected load distribution result. For the corrected load distribution results, the specific value of the prediction deviation is calculated, the deviation is corrected through a compensation mechanism, and the optimized control parameters are determined. Based on the optimized control parameters, the control vector for energy flow is adjusted, and the adjusted vector is sent to each key node through the data transmission channel to complete the dynamic optimization of load balancing.

[0016] Furthermore, S106 includes: By collecting energy flow data in building clusters, the spatiotemporal distribution information of each area is obtained, and the initial distribution pattern is determined. Based on the obtained spatiotemporal distribution information, a communication sparsity algorithm is used to optimize the number of interactions between nodes, resulting in adjusted interaction frequency data. Based on the adjusted interaction frequency data, analyze the connection weight of each node, determine if the connection weight of a certain node is higher than the preset threshold, prioritize the interaction order of that node, and determine the optimized interaction priority list. The control vector data of key nodes are extracted from the optimized interaction priority list and mapped to the spatiotemporal distribution pattern of the building group to obtain the updated distribution pattern parameters. Based on the updated distribution mode parameters, the load balance status of each region is analyzed. If the load of a certain region exceeds the predetermined range, the load is dynamically allocated by adjusting the control vector to obtain the corrected load distribution data. Based on the corrected load distribution data, analyze the load change trend of the node center, and send the adjusted control vector to the corresponding node through the data transmission channel to determine the final load balance distribution state. By analyzing the final load balance distribution, we continuously monitor the energy flow in each area of ​​the building complex and obtain real-time data to support subsequent iterative processing.

[0017] Furthermore, S107 includes: Obtain load distribution status data for the building complex; Calculate the residual unbalance based on the load distribution data; Determine whether the residual imbalance is greater than a preset threshold; If the residual imbalance is greater than the preset threshold, a new building cluster connection state is generated using the state-action space mapping algorithm. Based on the new connection state, a heuristic search algorithm is used to generate a revised flow path; Outputs a fast balanced distribution result based on the corrected flow path.

[0018] This invention provides an IoT-based green building energy consumption monitoring and optimization control system, mainly comprising: a data acquisition and feature extraction module, used to collect real-time energy consumption characteristic data of each building through an IoT sensor cluster, construct a local energy consumption prediction model at each building node based on a distributed machine learning architecture, extract the time and frequency domain features of heterogeneous energy consumption data, analyze the energy demand fluctuation patterns of different buildings, and construct a spatiotemporal distribution feature matrix of current energy demand; and a topology analysis and privacy exchange module, used to identify the physical topology and logical coupling relationships between building groups based on the spatiotemporal distribution feature matrix using a graph topology analysis algorithm, and using a privacy-preserving parameter exchange mechanism to transmit only model gradients or weights. The new value is obtained by calculating the energy deviation between each node to obtain a quantitative assessment vector of energy imbalance. The threshold judgment and aggregation optimization module is used to determine whether the quantitative assessment vector exceeds a preset threshold. If it does, the global parameter aggregation algorithm is used to integrate the parameter updates of each node, and the model weights of specific building nodes are optimized by combining a local fine-tuning strategy to generate a multi-dimensional prediction sequence of demand fluctuations. The load status and allocation decision module is used to construct a community-wide load status distribution map based on the multi-dimensional prediction sequence, and use a multi-agent reinforcement learning algorithm (MARL) to drive multiple agents to perform local energy allocation decisions, combined with an environmental reward function. The system performs real-time adjustments to energy flow paths to generate a preliminary load balancing configuration. A risk detection and compensation correction module extracts operational data from key nodes in the preliminary load balancing configuration to determine if there is a surge in demand. If so, it uses a peer-to-peer (P2P) information exchange protocol to achieve state sharing among agents and introduces a real-time feedback compensation mechanism to correct prediction deviations, calculating an optimized energy flow control vector. An iterative update and priority adjustment module maps the energy flow control vector to the spatiotemporal distribution pattern of the building cluster for iterative updates, using a communication sparsity algorithm to reduce the interaction frequency between nodes and adjusting the interaction priority based on node degree centrality or connection weight to determine the target load balancing distribution state. A residual detection and path correction module detects whether there is residual imbalance in the target load balancing distribution state. If so, it redefines the connection state of the building cluster using a state-action space mapping algorithm, corrects the flow path using heuristic search or path planning algorithms, and outputs a fast balanced distribution result.

[0019] A preferred embodiment of the present invention has the following substantial features: The node degree centrality and logical coupling relationship obtained through graph topology analysis algorithms are deeply coupled with a communication sparsity algorithm. This reduces ineffective communication overhead across the entire network while ensuring low-latency interaction of control commands from core hub nodes. Simultaneously, a complete technical closed loop is constructed, encompassing "distributed privacy prediction - global coupling analysis - multi-agent collaborative optimization - emergency compensation for sudden risks - communication priority scheduling - residual imbalance closed-loop correction," achieving multi-objective collaborative optimization of privacy protection, response speed, optimization effect, and communication overhead. The technical solution provided by this embodiment of the present invention may include the following beneficial effects: This invention discloses an IoT-based method for monitoring and optimizing energy consumption in green buildings. It proposes an integrated solution to address the interconnected challenges of fluctuating energy demand, unbalanced loads, and privacy concerns within building clusters. The method collects building energy consumption data in real time using an IoT sensor cluster, constructs a local prediction model using a distributed machine learning architecture, extracts a spatiotemporal distribution feature matrix, and accurately identifies the physical topology and logical coupling relationships of the building cluster. Simultaneously, it ensures data security through a privacy-preserving parameter exchange mechanism, generates a multi-dimensional prediction sequence through global parameter aggregation and local fine-tuning of the model. Based on this, it employs a multi-agent reinforcement learning algorithm to drive energy allocation decisions, dynamically adjusts energy flow paths using a real-time feedback compensation mechanism and a communication sparsity algorithm, and ultimately achieves balanced load distribution. The core innovation of this invention lies in integrating energy consumption monitoring, prediction optimization, and dynamic allocation, significantly improving the energy utilization efficiency of building clusters, reducing imbalances, and balancing privacy and communication costs, providing efficient and intelligent technical support for green building management.

[0020] Based on the applicant's actual testing in a mixed commercial and residential community scenario, the technical solution of this invention can achieve the following technical effects: the overall energy utilization efficiency of the building complex is increased by 18%-22%, the load imbalance is reduced by more than 85%, the response time for sudden surges in demand is shortened from seconds in traditional solutions to less than 200ms, the frequency of invalid communication interactions between building nodes is reduced by 60%-70%, and zero-aggregation transmission of raw energy consumption data is achieved, fundamentally protecting user data privacy and completely solving all the technical problems described in the background of this application. Attached Figure Description

[0021] Figure 1 is a flowchart of an IoT-based green building energy consumption monitoring and optimization control method according to the present invention.

[0022] Figure 2 is a schematic diagram of an IoT-based green building energy consumption monitoring and optimization control method according to the present invention.

[0023] Figure 3 is another schematic diagram of the energy consumption monitoring and optimization control method for green buildings based on the Internet of Things according to the present invention.

[0024] Figure 4 is a schematic diagram of the structure of a green building energy consumption monitoring and optimization control system based on the Internet of Things according to the present invention.

[0025] Figure 5 is a schematic diagram of the distributed federated learning and privacy-preserving parameter exchange mechanism of the present invention.

[0026] Figure 6 is a schematic diagram of the communication sparsity and node degree centrality coupling control of the present invention.

[0027] Figure 7 is a schematic diagram of the MADDPG multi-agent collaborative energy allocation decision-making method of the present invention.

[0028] Figure 8 shows a deployment scenario of the IoT sensor in the smart community according to the present invention.

[0029] Figure 9 is a structural diagram of the building microgrid energy storage and load regulation equipment of the present invention.

[0030] Figure 10 is a diagram of the coordinated deployment of hardware control for dual closed-loop hierarchical regulation according to the present invention.

[0031] Figure 11 is a comparative analysis of the comprehensive energy utilization efficiency of the building complex of the present invention.

[0032] Figure 12 is a thermogram showing the dynamic evolution of load imbalance in this invention.

[0033] Figure 13 is a curve comparing the response time to sudden demand and the communication overhead of the present invention. Detailed Implementation

[0034] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.

[0035] like Figure 1As shown, the IoT-based green building energy consumption monitoring and optimization control method of the present invention includes the following steps: Step S101 is to collect real-time energy consumption characteristic data of each building through an IoT sensor cluster, construct a local energy consumption prediction model at each building node based on a distributed machine learning architecture, extract the time-frequency domain features of heterogeneous energy consumption data, and construct a spatiotemporal distribution feature matrix of current energy demand; Step S102 is to use a graph topology analysis algorithm to identify the physical topology and logical coupling relationship between building groups, and use a privacy-preserving parameter exchange mechanism to transmit the model gradient to obtain a quantitative evaluation vector of energy imbalance; Step S103 is to determine whether the quantitative evaluation vector exceeds a preset threshold, and if it does, to use a global parameter... Step S104 involves generating a multidimensional prediction sequence through data aggregation and local fine-tuning, otherwise generating a conventional prediction sequence; Step S105 involves constructing a load state distribution map and using the MADDPG multi-agent reinforcement learning algorithm to drive energy allocation decisions; Step S106 involves determining whether there is a risk of demand surge, and if so, calculating and optimizing the control vector through P2P protocol state sharing and PID feedback compensation; Step S107 involves using a communication sparsity algorithm to reduce the interaction frequency and adjust the priority to determine the target load balance distribution state; Step S108 involves detecting whether the residual imbalance exceeds the standard, and if so, correcting the flow path through DQN state-action space mapping and A* heuristic search to output a fast balance distribution result.

[0036] like Figure 2As shown, the method of this invention achieves a complete closed loop of energy consumption monitoring and optimization control through data flow driven by seven core steps. In step S101, real-time energy consumption characteristic data collected by the IoT sensor cluster is processed by a two-layer Bi-LSTM local prediction model and FFT time-frequency domain feature extraction, and then incorporated into a spatiotemporal distribution feature matrix. In step S102, the spatiotemporal distribution feature matrix is ​​fed into the Louvain community detection and GCN graph topology analysis algorithm, while the model gradients of each node are transmitted to the global aggregation end through differential privacy or homomorphic encryption channels. The two are combined to output a quantitative evaluation vector of energy imbalance. In step S103, a threshold judgment is performed on the evaluation vector. If the threshold is exceeded, FedAvg global parameter aggregation and local fine-tuning are triggered; otherwise, a regular prediction sequence is directly generated. In step S104, a load state distribution map is constructed based on the prediction sequence, and a preliminary load balancing configuration scheme is output by the MADDPG multi-agent algorithm with a safety penalty factor. In step S105, the risk of demand surge is judged by the SVM model. If the risk exists, a P2P peer-to-peer protocol is used to achieve state sharing, and an optimized control vector is output after PID compensation correction. Step S106 determines the target load balance distribution state by adjusting the control vector using a communication sparsity algorithm and node degree centrality priority. The degree centrality index obtained in step S102 is directly coupled into the sparsity algorithm as prior knowledge. Step S107 detects residual imbalance. If the imbalance exceeds the limit, the path is corrected through DQN state-action space mapping and A* heuristic search, and a fast balanced distribution result is output.

[0037] like Figure 3As shown, each core step of the method of this invention contains multiple sub-steps and specific technical implementations. In step S101, the 12-dimensional energy consumption data collected by the sensor is simultaneously subjected to time-domain feature extraction (calculating the load mean, range, and load rate) and frequency-domain feature extraction (FFT fundamental and harmonic components). The time-domain and frequency-domain feature vectors are concatenated to construct a spatiotemporal distribution feature matrix. In step S102, Louvain community detection and 2-layer GCN embedding are performed based on the adjacency matrix construction formula A=aP+bL. At the same time, global model gradient aggregation is completed through an encrypted channel, and a quantized evaluation vector is output. In step S104, after cleaning and standardizing the multi-dimensional prediction data, a load distribution map is generated and high and low load areas are marked. The Actor network in MADDPG outputs continuous actions based on local observations, and the Critic network jointly evaluates the Q value. Path optimization iteration is driven by the reward function. In step S105, after the SVM classification model determines the surge risk, it exchanges state data via a P2P peer-to-peer protocol, and the deviation is corrected by a PID closed-loop controller (Kp=0.8, Ki=0.15). In step S106, the edge controller calculates the L1 norm of the gradient difference, determines whether to communicate using the dynamic threshold T=T0exp(-kDC), and schedules the data according to a three-level priority hierarchy. In step S107, after detecting the residual imbalance, the DQN model maps the switch action combination, and the optimal correction path is planned using the cost function f=g+h obtained through A* search. The degree centrality index in step S102 is directly input into the dynamic threshold calculation in step S106 through dashed line coupling, achieving deep integration between the communication control layer and the physical topology layer.

[0038] like Figure 4As shown, the IoT-based green building energy consumption monitoring and optimization control system of this invention includes seven functional modules. The data acquisition and feature extraction module collects real-time energy consumption characteristic data of each building through an IoT sensor cluster, constructs a local energy consumption prediction model based on a two-layer Bi-LSTM, extracts time-frequency domain features, constructs a spatiotemporal distribution feature matrix, and then transmits it to the topology analysis and privacy exchange module. The topology analysis and privacy exchange module uses the Louvain community detection algorithm and graph convolutional neural network to identify the physical topology and logical coupling relationships between building groups, and uses a privacy-preserving parameter exchange mechanism to transmit only the model gradient, outputting a quantized evaluation vector. The threshold judgment and aggregation optimization module judges whether the evaluation vector exceeds the threshold, and generates a multi-dimensional prediction sequence through FedAvg global parameter aggregation and local fine-tuning strategies. The load status and allocation decision module constructs a load status distribution map, uses the MADDPG algorithm based on the Actor-Critic architecture to drive multiple agents to execute local energy allocation decisions, and outputs a preliminary load balancing configuration scheme by combining an environmental reward function with a safety penalty factor. The risk detection and compensation correction module uses an SVM model to assess the risk of demand surges, achieves state sharing through a P2P peer-to-peer protocol, and outputs an optimized energy flow control vector via a PID feedback compensation mechanism. The iterative update and priority adjustment module employs a communication sparsity algorithm based on a dynamic threshold of node degree centrality to reduce interaction frequency and determine the target load balance distribution. The residual detection and path correction module corrects the flow path using a DQN state-action space mapping algorithm and an A* heuristic search. The degree centrality index obtained from the topology analysis module is directly coupled as prior knowledge into the sparsity algorithm of the iterative update module, forming cross-module collaboration.

[0039] like Figure 5As shown, the distributed federated learning and privacy-preserving parameter exchange mechanism of this invention includes a bidirectional parameter interaction process between multiple building nodes and a cloud coordination server. The bottom of the diagram shows building nodes such as commercial office buildings, residential areas, industrial plants, public buildings, and medical buildings. Each node deploys its own local energy consumption prediction model based on a two-layer Bi-LSTM. The model receives 12-dimensional feature inputs, including voltage, current, power, and temperature and humidity. Each hidden layer has 64 neurons, the Dropout parameter is set to 0.2, and local training is performed using the Adam optimizer with an initial learning rate of 0.001 and a mean squared error loss function. After each building node completes 5 rounds of local training, it uploads the encrypted model gradient difference to the cloud coordination server only through a differential privacy-preserving channel, achieving zero-aggregation transmission of the original energy consumption data throughout the process. The cloud coordination server uses a federated averaging algorithm to globally aggregate the weighted gradients uploaded by each node, generating unified global model parameters, which are then distributed to each building node. After receiving the global parameters, each node freezes the underlying feature extraction network and performs local fine-tuning on the top fully connected network with a small step size of one-tenth of the initial learning rate to adapt to local special working conditions.

[0040] like Figure 6 As shown, the communication sparsity and node degree centrality coupling control mechanism of this invention is presented through two dimensions of visualization. The left side of the figure shows a heatmap representation of the building cluster adjacency matrix. The matrix elements are calculated by weighting the physical topology weight P and the logical coupling weight L according to the formula A=0.6P+0.4L, where the physical connection weight is 0 or 1, and the logical coupling weight is the Pearson correlation coefficient of the energy consumption time series between nodes. The color intensity in the heatmap reflects the coupling strength between nodes. The rows and columns of hub nodes show a predominantly dark distribution, indicating that they have strong coupling relationships with multiple nodes. The right side of the figure shows the comparison between the degree centrality of each node and the corresponding dynamic sparsity threshold. The degree centrality DC is calculated by dividing the number of directly connected adjacent nodes of a node in the topology graph by the total number of building clusters minus one. The degree centrality of hub nodes is significantly higher than that of end nodes. The dynamic threshold is calculated using the formula T=T0exp(-kDC), where the base threshold T0 is 0.01 and the attenuation coefficient k is 2.0. This results in a lower sparsity threshold for hub nodes with higher degree centrality, maintaining extremely high communication response sensitivity to any minor changes in operating conditions. Meanwhile, the threshold for end nodes is higher, and they only occupy communication bandwidth when there are severe energy fluctuations.

[0041] like Figure 7As shown, the MADDPG multi-agent collaborative energy allocation decision structure of this invention includes an interaction mechanism between multiple agents and the community microgrid environment. The bottom of the figure represents the community microgrid environment, including physical elements such as load state distribution, energy flow paths, energy storage devices, and interconnection switches. The reward function embedded in the environment consists of a weighted combination of three terms: a positive reward term for the power deviation rate, a line loss penalty term, and a safety penalty factor. When the voltage of any node exceeds the limit, the safety penalty factor triggers a veto. The middle of the figure shows three typical agents (corresponding to nodes in a commercial building, residential area, and industrial park, respectively). Each agent is configured with an independent Actor network and Critic network. The Actor network adopts a 3-layer fully connected structure. The input layer receives 10-dimensional local state features (including real-time voltage, active power, energy storage state of charge, ambient temperature, etc.). After processing by hidden layers with 128 and 64 neurons, the output layer outputs 2-dimensional continuous actions (active power adjustment and reactive power adjustment) through the Tanh activation function. The output range is mapped to the engineering adjustment range of -100kW to 100kW. The Critic network receives the concatenated global states and actions of all agents, processes them through hidden layers of 256 and 128 neurons, and outputs the Q-value. During the training phase, the Critic centrally collects global information for joint evaluation, while during the execution phase, each actor independently and decentralizedly outputs power adjustment decisions based on local observations.

[0042] like Figure 8 As shown, this invention is applied to a physical deployment scenario in a mixed-use commercial and residential community, which includes various types of buildings such as commercial office building A, residential buildings B and C, industrial plant D, and public building E. Photovoltaic panels 801 and 802 are deployed on the roofs of each building to collect solar energy and feed it into the microgrid. IoT sensors 701 to 705 are distributed across the power distribution nodes and electrical equipment of each building, responsible for real-time collection of 12-dimensional energy consumption characteristic data, including voltage, current, active power, reactive power, and ambient temperature and humidity. The community is divided into three control zones, each configured with an edge computing node. Each node runs a two-layer Bi-LSTM local energy consumption prediction model, and after local model training, it only uploads gradient differences to the cloud coordination server 601 via an encrypted channel. The cloud server is responsible for performing FedAvg global parameter aggregation and MADDPG multi-agent training. The bottoms of each building are electrically interconnected via the community microgrid bus 901, which uses a radial topology to connect all building power distribution nodes. The wireless signal coverage of the edge computing node is indicated by a dashed circle, ensuring that data acquisition and control command issuance for all sensor nodes within the area are within the low-latency communication range.

[0043] like Figure 9As shown, the building microgrid energy storage and load regulation device of the present invention includes four functional areas: DC side, converter, AC bus, and load side. The DC side includes an energy storage battery pack 301, a photovoltaic inverter 302, and a battery management system 303. The energy storage battery pack 301 is monitored for state of charge and managed for single-cell balancing by the battery management system 303. The photovoltaic inverter 302 is responsible for converting the DC power output from the photovoltaic panels into AC power using a maximum power point tracking (MPPT) algorithm. The DC power is bidirectionally converted by the energy storage converter 304. The PCS can precisely adjust active and reactive power according to the control vector output by the MADDPG algorithm. The AC distribution bus 305 serves as the core combiner node of the microgrid, connecting a tie switch 306, a smart meter 307, and a circuit breaker 308. The tie switch 306 is used to realize grid connection and disconnection operations of adjacent microgrids; its on / off state is directly controlled by the DQN state-action space mapping algorithm. The smart meter 307 collects energy consumption characteristic data such as voltage, current, and power in real time and reports it to the edge computing node. The load side is divided into two categories: flexible loads (309) and rigid loads (310). Flexible loads include adjustable loads such as air conditioners and charging piles, while rigid loads include uninterrupted loads such as lighting and production equipment. The industrial data gateway (311) receives cloud control commands via Modbus-TCP or GOOSE protocol and sends them to the PLC (312) to execute underlying equipment control actions.

[0044] like Figure 10As shown, the dual-closed-loop hierarchical regulation hardware control system of this invention adopts a three-layer physical architecture: a cloud coordination layer, an edge control layer, and a device execution layer. The cloud coordination layer deploys a FedAvg global aggregation module 401, a MADDPG training center 402, a DQN topology reconstruction module 403, and a monitoring and visualization platform 404, with an operating cycle of seconds. The edge control layer deploys four edge computing nodes 501 to 504, each with a built-in Bi-LSTM local prediction model and a MADDPG Actor network. Nodes share state at millisecond levels via a P2P peer-to-peer protocol. Combined with SVM surge risk assessment and PID compensation mechanisms, the control cycle is 100ms. The device execution layer includes hardware actuators such as a PCS energy storage converter 505, a tie switch 506, a circuit breaker 507, a PLC controller 508, a relay 509, and an energy storage battery pack 510. It receives control commands via Modbus-TCP or IEC61850 protocols, with execution response at the millisecond level. The first-level control loop uses the cloud-based MADDPG algorithm to make global continuous power allocation decisions. Control commands are relayed through edge nodes to the PCS converter to regulate active and reactive power. When the residual imbalance exceeds the adaptive threshold, the second-level emergency reconfiguration mechanism is triggered. The DQN model maps the continuous state vector to discrete action combinations of the tie switch opening and closing states. After A* search optimization, hexadecimal control messages are sent through the gateway to the PLC and relays to force microgrid disconnection or reconfiguration.

[0045] In the tests conducted in this invention, the comprehensive energy utilization efficiency of the traditional centralized solution and the solution of this invention were compared in four typical application scenarios: day and night peak shaving and valley filling in commercial communities, distributed renewable energy in industrial parks, event-driven applications in university campuses, and high reliability applications in medical building complexes. For example... Figure 11 As shown, the comprehensive energy utilization efficiency of the traditional centralized solution in the four scenarios is 62.5%, 58.3%, 60.1%, and 55.8%, respectively, with a comprehensive average of 59.2%. After adopting the integrated solution of the present invention based on distributed federated learning prediction, MADDPG multi-agent reinforcement learning decision-making, and dual closed-loop collaborative control, the comprehensive energy utilization efficiency in the four scenarios is improved to 78.2%, 74.5%, 76.8%, and 73.1%, respectively, with a comprehensive average of 75.7%. The line graph shows the efficiency improvement of each scenario. The commercial community scenario has the best day-night peak shaving and valley filling effect, with an improvement of 25.1%. The medical building complex scenario has more high reliability constraints, with an improvement of 31.0%. The average efficiency improvement of the four scenarios is 27.9%, and the beneficial effect of improving the comprehensive energy utilization efficiency by 18% to 22% has been fully verified.

[0046] In the tests of this invention, 24 rounds of collaborative optimization iterations were performed on a community microgrid system containing 8 building nodes, such as... Figure 12 As shown in the heatmap. Figure 12 As shown, the vertical axis of the heatmap represents eight building nodes, and the horizontal axis represents the collaborative optimization iteration rounds T1 to T24. The color intensity indicates the degree of load imbalance. In the early stages of optimization (T1 to T4), the load imbalance of each node is generally at a relatively high level of 8% to 25%, and the heatmap shows a large area of ​​dark color, indicating that the load distribution of the building group is severely unbalanced in the initial state. As the energy allocation decision driven by the MADDPG multi-agent reinforcement learning algorithm is continuously iterated and optimized, the imbalance of each node decreases exponentially. In the middle and late stages of optimization (T18 to T24), the heatmap converges to a light-colored area, and the load imbalance of each node drops to below 3%, entering the convergence equilibrium region. Test results show that the load imbalance is reduced by an average of more than 85% after processing by the method of this invention. The collaborative coupling mechanism of the communication sparsity algorithm and node degree centrality ensures the priority control of hub nodes and accelerates the convergence process of the overall network load balance.

[0047] In the testing of this invention, response time comparison tests were conducted on five typical types of sudden demand events. For example... Figure 13 As shown in the left sub-figure, the response times of the traditional centralized solution for five emergencies—sudden increase in air conditioning demand, simultaneous activation of charging piles, impact of a rolling mill, evacuation from a gymnasium, and concurrent operation in an operating room—are 2800ms, 3500ms, 4200ms, 3100ms, and 5000ms, respectively, all within the second range. After adopting the dual-closed-loop hierarchical adjustment scheme of this invention, the response times for the five events are shortened to 165ms, 180ms, 195ms, 155ms, and 190ms, respectively, all falling below the 200ms target line. This verifies the millisecond-level response capability of the P2P peer-to-peer protocol's direct state sharing and the PID real-time feedback compensation mechanism. Figure 13 The right-hand subplot illustrates the trend of communication overhead as the number of nodes in a building cluster changes. In the traditional fully connected communication mode, communication overhead increases quadratically with the number of nodes. However, the communication sparsity algorithm of this invention, through a dynamic threshold mechanism based on node degree centrality, maintains communication overhead at 28% to 42% of the traditional scheme as the number of nodes increases from 5 to 40, and reduces the frequency of invalid communication interactions by an average of 60% to 70%. The gray-filled area visually demonstrates the scale of communication overhead saved by the solution of this invention.

[0048] Terminology Explanation and Definition To enable those skilled in the art to better understand the present invention, the following provides specific explanations and definitions of some key technical terms involved in the embodiments of the present invention: Energy consumption characteristic data refers to multi-dimensional characteristic information that reflects the energy consumption status within the building's physical space, collected in real time by IoT sensor clusters (such as smart meters and environmental sensors) deployed at various power distribution nodes and electrical equipment terminals in the building. This includes, but is not limited to, voltage, current, active power, reactive power, harmonic components, and ambient temperature and humidity at each node.

[0049] Distributed Machine Learning Architecture: This refers to a decentralized model training architecture. In this invention, this architecture allows multiple building nodes to train models using their own data only on local edge computing nodes without aggregating the underlying raw electricity consumption data to a central server. This improves the overall model's generalization ability while fundamentally protecting the data privacy of each building user.

[0050] Local energy consumption prediction model: refers to a prediction model (such as a model built on a long short-term memory network LSTM or a temporal convolutional network TCN) deployed and run on a single building node or microgrid controller under a distributed machine learning architecture, which is used to specifically fit and predict the future energy consumption trend of that particular node.

[0051] Heterogeneous energy consumption data refers to energy consumption sequences with different sources, significantly different energy consumption patterns, and inconsistent data structures. For example, the step-like load data of commercial buildings with "peak during the day and trough at night" and the stable load data of residential areas with "peak in the morning and evening" and the intermittent output data of wind and solar renewable energy sources constitute heterogeneous characteristics.

[0052] Spatiotemporal distribution feature matrix: This refers to a data structure formed by tensor splicing the energy demand characteristics of each node in a building complex along the two dimensions of "time" and "space". The rows of this matrix can represent different timestamps or time series features, and the columns can represent the spatial coordinates or network topology positions of building nodes, used to comprehensively characterize the dynamic evolution of the energy load state of the entire building complex.

[0053] Graph topology analysis algorithm: refers to an algorithm that uses graph theory principles to analyze the characteristics of network topology. In this invention, the algorithm abstracts individual buildings as nodes in a graph, and electrical connections or information exchange channels between buildings as edges. By calculating parameters such as adjacency matrix and connectivity, it deeply analyzes the structural characteristics of the entire community energy network.

[0054] Physical topology and logical coupling relationship: Physical topology refers to the hardware network structure that objectively exists at the physical level between various buildings or equipment, such as cable connections, transformer affiliations, etc.; logical coupling relationship refers to the inherent synergy and complementarity between building nodes in terms of energy supply and demand, usage habits, or production scheduling (such as the logical supply support of surplus photovoltaic power in commercial buildings for charging piles in adjacent residential buildings).

[0055] Privacy-preserving parameter exchange mechanisms refer to the encryption or de-identification methods used when nodes exchange information during federated learning or distributed collaborative computing. For example, differential privacy (adding Gaussian noise) or homomorphic encryption techniques can be introduced to ensure that only parameters are transmitted over a public channel and that the original electricity consumption details cannot be derived from them.

[0056] Model gradients or weight update values: These refer to the parameter increments or partial derivatives calculated during the backpropagation training of a neural network model, used to optimize network connection weights. Each node shares only these values ​​to participate in the joint optimization of the global model.

[0057] Energy deviation: refers to the difference between the predicted or expected energy state of the system (such as theoretical power flow distribution) and the actual operating state, or the degree of mismatch between energy supply and demand between adjacent nodes.

[0058] The quantitative assessment vector for energy imbalance is a structured vector calculated based on the energy deviation of each node, used to measure the severity of energy distribution imbalance across the entire building complex from multiple dimensions. Each dimension of this vector can characterize indicators such as local overload probability, reactive power deficit, and voltage deviation.

[0059] Global parameter aggregation algorithms refer to algorithms that mathematically integrate model parameters (or gradients) uploaded from various distributed nodes at a central coordinating point (such as a cloud platform). A typical example is the Federated Average algorithm (FedAvg), which generates unified model parameters representing global universal patterns through weighted averaging.

[0060] Parameter update: refers to the process of replacing or weighting and fusing the original model parameters of each building node with global parameters generated by the global parameter aggregation algorithm, so that the local model has a global view.

[0061] Fine-tuning strategy: After receiving global update parameters, each building node does not directly and completely overwrite the local model. Instead, it retains the underlying general feature extraction layer of the model and only uses local high-frequency data to perform targeted small-step iterative training on the top classifier or regression network of the model to adapt to local special working conditions.

[0062] Conventional prediction sequences and multidimensional prediction sequences: Conventional prediction sequences refer to basic prediction data output by the model when the power grid is operating smoothly and there are no extreme weather or sudden events. These data only contain a single time scale (e.g., the next hour) and a single energy type (e.g., electricity). Multidimensional prediction sequences refer to a high-dimensional prediction result set output by the model after local fine-tuning and optimization during periods of severe environmental fluctuations. This set covers multiple time scales (e.g., the next 15 minutes, 1 hour, 4 hours) and spans multiple energy carriers (electricity, cooling, heating, etc.).

[0063] 16. Load Status Distribution Map: This refers to the visualization and mapping of multidimensional prediction sequences in virtual space to form a topology map or heat map that reflects the load levels of different areas within the entire community or microgrid.

[0064] Multi-agent reinforcement learning (MARL) refers to a machine learning algorithm in a multi-agent system in which multiple agents learn the optimal joint policy by continuously interacting with and trying out complex environments to maximize long-term cumulative rewards.

[0065] Local energy allocation decision: refers to the specific operational decisions made independently by a single agent in a multi-agent system based on its own observation of the local environmental state (such as the voltage of this node and the available energy storage capacity), such as energy storage charging and discharging, flexible load switching, and routing switch switching.

[0066] The reward function refers to a manually set objective evaluation mechanism within a reinforcement learning framework. In this invention, not only are local positive rewards given to actions that reduce the energy consumption deviation of the agent's current node, but also global cooperative rewards are given to actions that promote the cooperative balance of neighboring nodes and reduce overall network loss, thereby guiding the agent's evolutionary direction.

[0067] Energy flow path: refers to the sequence of lines, switches, transformers and other nodes through which electrical energy is transmitted from the source end (such as photovoltaic arrays, energy storage power stations) to the load end (high load building nodes) in the physical power grid or virtual dispatch.

[0068] Load balancing configuration scheme: refers to a complete system scheduling plan output by multi-agent collaborative computing, including the expected action commands, output setpoints and energy transfer amounts of each node device, aiming to minimize the overall load imbalance of the building complex.

[0069] Surge in demand risk: refers to the potential danger of a local power grid experiencing a steep increase in power demand within a very short period of time due to certain sudden mass incidents, extreme weather changes, or the concentrated start-up of large industrial equipment, which may lead to line overload or transformer tripping.

[0070] Peer-to-peer (P2P) information exchange protocol: refers to a decentralized underlying communication protocol. When an emergency occurs, neighboring intelligent agents can directly establish point-to-point communication links without going through a cloud central server, achieving millisecond-level low-latency data exchange.

[0071] State sharing: Under the P2P interaction protocol, adjacent nodes open up their critical underlying operating data to each other, such as the current state of charge (SOC) of the energy storage battery, the remaining reserve capacity of the inverter, and the real-time node voltage, so as to quickly organize mutual support.

[0072] Real-time feedback compensation mechanism: refers to the process in which the system captures the dynamic deviation between the actual execution effect and the theoretical prediction value in real time through sensors during the execution of the control scheme, and uses this deviation (for example, by introducing PID closed-loop control) to dynamically fine-tune the control command in reverse to eliminate the steady-state error of the system.

[0073] Energy flow control vector: refers to a set of digital instructions that, after optimization and compensation calculations, can directly drive hardware actuators. Examples include active / reactive power reference values ​​for the power storage converter (PCS) and thyristor firing angle control signals. In this specification and claims, "energy flow control vector" has the same technical meaning as "control instructions" or "control parameters" when referring to drive signals generated by the system and issued to the underlying hardware actuators.

[0074] Communication sparsity algorithm: refers to an algorithm that actively filters out a large number of irrelevant periodic heartbeat packets or small state change messages by setting a dead zone threshold, extracting key features or calculating information gain in order to avoid channel congestion caused by the concurrent communication of a large number of control nodes, and retains only the key interaction signals that have a great impact on the global balance.

[0075] Degree centrality: A core concept in graph theory and network analysis, referring to the number of edges (or adjacent nodes) directly connected to a given node in a network topology and their importance. In this system, buildings or power distribution rooms with higher degree centrality have a greater hub role in energy routing and exchange, and are given higher interaction priority when commands are issued.

[0076] Load balance distribution state: refers to the desired operating state of the building cluster power grid after multiple rounds of intelligent coordination and optimization control. In this state, the source and load supply and demand of each node are basically matched, energy flow is smooth, and the overall operating efficiency is optimal.

[0077] Residual imbalance: refers to the residual values ​​of power fluctuations, harmonics, or voltage over-limits that still remain in the network despite the system issuing instructions for the target load balance distribution state, due to objective physical limitations such as inherent impedance loss of the power grid physical lines, equipment response delay, or three-phase asymmetry.

[0078] State-action space mapping algorithm: refers to an algorithm that, in emergency situations where residual imbalance exceeds the limit, directly maps the high-dimensional and complex power grid imbalance state feature vector into a set of simple, discrete and fast-executable physical switch action combinations (such as the opening and closing states of tie switches) through mathematical dimensionality reduction and logical correspondence.

[0079] Heuristic search refers to algorithms that, when faced with a large system state space (such as tens of thousands of switch combinations), do not use exhaustive search but instead use heuristic information about the problem itself (such as empirical rules, distance estimation functions) to guide the search direction, thereby finding a suboptimal or satisfactory reconstruction path in an acceptablely short time (such as A* algorithm, genetic algorithm, etc.).

[0080] Path planning algorithm: refers to an algorithm based on graph theory or operations research models, which, in a given network physical topology, takes into account line capacity, impedance constraints and node congestion, re-optimizes and arranges the shortest or lowest overall cost electrical flow path that can safely and losslessly transfer loads (such as the application and derivative of Dijkstra's algorithm).

[0081] Threshold Adaptive Setting Rules: All "preset evaluation thresholds," "balance thresholds," and "preset fluctuation ranges" mentioned in the above embodiments of this invention are not fixed constants set subjectively by humans, but are dynamically and adaptively determined based on the statistical distribution of historical system operating data. The specific calculation logic is as follows: The system extracts steady-state energy consumption baseline data for a complete past operating cycle (e.g., 30 days) and calculates the mathematical expectation (mean) of this baseline data. and standard deviation Various preset thresholds and range boundaries are strictly defined within... The threshold is set within the confidence interval of the Raida criterion (i.e., the 3Sigma principle). Values ​​exceeding this range are considered out of bounds or at risk of a surge. This mechanism ensures the objectivity and feasibility of the threshold setting.

[0082] In this invention, all preset thresholds are adaptively and dynamically determined using the Raida criterion, eliminating the need for manual static setting. The system extracts steady-state energy consumption baseline data from a complete past operating cycle (default cycle is 30 days). After removing abnormal fluctuation data, the expected value and standard deviation of this baseline data are calculated. The boundaries of all preset thresholds and fluctuation ranges are strictly defined within a confidence interval of ±3 standard deviations of the mean; exceeding this range is considered an over-limit. Specifically, the energy demand fluctuation threshold is determined based on the mean of load fluctuation rates over the same period in the past 7 days plus 3 standard deviations; exceeding this range marks it as an abnormal fluctuation area. The quantitative assessment threshold is determined based on the mean of the magnitude of the energy imbalance quantitative assessment vector plus 3 standard deviations; exceeding this range initiates global parameter aggregation and local fine-tuning. The connection weight threshold defaults to 0.7 and can be adjusted within the range of 0.5-0.9 based on node degree centrality; exceeding this value prioritizes the interaction requests of that node. The balance threshold is determined based on the mean of the residual imbalance plus 3 standard deviations, with a maximum value not exceeding ±5% of the rated voltage, meeting the national standard requirements for power quality supply voltage deviation. The sparsity threshold is set to a default value of 0.01, which can be adjusted within the range of 0.001-0.1 according to the communication bandwidth. This invention overcomes the technical deficiency of traditional control systems that require manual, static trial-and-error calculation of fixed thresholds based on experience, through the aforementioned adaptive threshold calculation method based on the Laida criterion. The system continuously extracts the dynamic distribution characteristics of historical baseline data, automatically generates and updates all model control thresholds in real time, clearly providing objective criteria for achieving the expected algorithm results, ensuring the control logic has clear objective feasibility in green building complexes of different scales. During the cold start phase of the initial system deployment when historical operating data accumulation is insufficient for the complete operating cycle, the system performs simulation pre-runs by connecting to a digital twin simulation platform of the physical distribution network, obtaining the simulated prior steady-state energy consumption expectation value and prior standard deviation as initial baseline data. As real operating data accumulates, the system smoothly transitions to a dynamic adaptive threshold calculation mode based entirely on measured data using a sliding window algorithm, ensuring stable operation and model availability during the initial deployment phase.

[0083] In a specific embodiment of the present invention, the Multi-Agent Reinforcement Learning Algorithm (MARL) specifically adopts the MADDPG (Multi-Agent Deep Deterministic Policy Gradient) algorithm based on the Actor-Critic architecture. Each agent is configured with an Actor network and a Critic network. The Actor network consists of a three-layer fully connected feedforward neural network. The input layer receives local states (such as the node voltage and available energy storage capacity), and the output layer uses the Tanh activation function to output continuous power regulation actions. The Critic network is responsible for evaluating the value of the actions. During the training phase, it centrally collects the states and actions of all agents for joint evaluation. During the execution phase, each Actor network outputs energy allocation decisions in a decentralized manner based on local observations.

[0084] Furthermore, to ensure the feasibility of the local energy consumption prediction model described in this invention, the neural network model constructed by each building node has 12 neurons in the input layer, corresponding to 12-dimensional feature data such as voltage, current, active power, reactive power, temperature, and humidity. The hidden layer uses a two-layer bidirectional recurrent neural network (Bi-LSTM), with each layer containing 64 hidden units, and a Dropout layer (parameter set to 0.2) is introduced to prevent overfitting. The output layer outputs the per-unit load prediction value for the next 15 minutes to 4 hours through a fully connected linear transformation. The model training process uses the Adam optimizer with an initial learning rate of 0.001 and a mean squared error (MSE) loss function. During distributed training, each node sets its local epochs to 5. After each local training is completed, only the gradient update values ​​containing the bias terms and weight tensors of each layer are transmitted through a privacy-preserving channel. .

[0085] For the training process of the local energy consumption prediction model and the multi-agent network, the training sample set is derived from historical real-world operational data. Specifically, the system extracts high-frequency energy consumption characteristic data of the building complex over at least one complete year (including the seasonal weather changes, statutory holidays, and complete workday cycles) as the initial historical sample set. In the data preprocessing stage, the system automatically removes missing values ​​caused by sensor disconnection or communication errors, as well as physically impossible abnormal jump values, and fills them in using linear interpolation; subsequently, a normalization algorithm is used to uniformly map the features of each dimension to the [0,1] interval.

[0086] It is worth noting that the training of the local energy consumption prediction model adopts an unsupervised autoregressive mechanism for data labeling. This means that the historical multidimensional feature sequence within the input time window (e.g., the past 6 hours) is used as the network input, and the actual energy consumption value immediately following the time window is used as the target label for supervision. The data acquisition and solidification process for the target label is fully automated, requiring no manual intervention. Specifically, the system allocates an independent time-series alignment buffer within the edge computing node. After the historical feature sequence input at time T is pushed into the prediction queue, a timestamp listener is automatically triggered to capture the actual physical source energy consumption readings transmitted by IoT sensors from time T+1 to T+N. After data cleaning to remove communication errors, this actual reading is forcibly bound to the previous input sequence as a key-value pair, directly converting it into the supervision label required for the next backpropagation. This constructs a closed-loop training system that achieves online adaptive updates as the real physical environment evolves. By continuously calculating the mean squared error (MSE) between the model's output prediction value and the target label, the network weights are updated using the backpropagation algorithm until the loss function converges. This annotation mechanism completely avoids reliance on manually labeled data while ensuring that the model can deeply fit the actual physical energy consumption patterns of the building complex. Specifically, the system captures real-time data streams from on-site sensors through a rolling time window, automatically embedding the current measured sensor values ​​as supervisory labels for the prediction results of the previous time window. This enables the entire prediction model to achieve online closed-loop self-learning after on-site deployment, establishing its reliability and practicality as an automated industrial control component.

[0087] Example 1: Day and Night Peak Shaving and Valley Filling Application Scenarios Based on Mixed Commercial and Residential Communities In typical mixed-use commercial and residential communities in urban centers, the electricity demand of commercial office buildings is extremely high during the day, while the peak electricity demand in residential areas shifts at night. This significant tidal effect presents challenges for energy consumption monitoring and optimization within the building complex.

[0088] In this scenario, the system first collects massive amounts of energy consumption characteristic data in real time through IoT sensor clusters deployed at the power distribution networks and electrical equipment of each building. This data includes voltage, current, active power, reactive power, and ambient temperature and humidity. To fully protect the privacy of users in each building, the system adopts a distributed machine learning architecture. This means that without collecting the original underlying electricity consumption records of each building, local energy consumption prediction models (such as models based on Long Short-Term Memory networks, LSTM) are built and run only on the edge computing nodes of each independent building. Because the central air conditioning load of commercial buildings differs significantly from the electric vehicle charging load of residential buildings in terms of data structure and frequency of change, the system defines this as heterogeneous energy consumption data. The system performs time-domain feature extraction (such as calculating the load mean and peak-to-valley difference) and frequency-domain feature analysis (such as extracting the periodic frequency components of load changes through Fourier transform) on these heterogeneous energy consumption data at local nodes. Based on this analysis, it determines the energy demand fluctuation patterns of different buildings under day-night cycles. Subsequently, the system concatenates the spatiotemporal attributes of each node with the demand forecast value to construct a spatiotemporal distribution feature matrix that reflects the three-dimensional trend of energy demand in the entire community in the current and even short-term future (the input is the historical feature sequence of each node, and the output is a matrix structure containing timestamps, spatial coordinates and demand intensity).

[0089] Based on the constructed spatiotemporal distribution feature matrix, the system then employs a graph topology analysis algorithm for deep analysis of the community energy network. This algorithm, based on matrix elements, identifies the physical topology and logical coupling relationships between building clusters. Physical topology is reflected in whether there are direct microgrid cable connections or shared transformers between buildings; logical coupling reflects the complementary or conflicting characteristics of their energy usage habits (e.g., whether waste heat from commercial buildings can logically be used to supply domestic hot water to adjacent residential buildings). During the joint model training phase, each building node utilizes privacy-preserving parameter exchange mechanisms (such as introducing homomorphic encryption or differential privacy technology) to transmit only its own model gradients or weight update values ​​on the public communication channel. This mechanism ensures that federated-level model optimization is completed even when the original electricity consumption behavior cannot be inferred. Specifically, the system cannot directly derive the difference in physical electrical energy from the gradient parameters of the neural network. Therefore, the system uploads the model gradients of each node to the cloud coordination server for global aggregation via a privacy-preserving channel before distributing the global model parameters. Each building node runs the updated model and outputs specific load forecast values ​​(e.g., kilowatt-hours) for its local future forecast period. Subsequently, the cloud-based coordination server, based on the aggregated load forecasts from each node and combined with the theoretical power flow equations and impedance models of the power grid, calculates the actual energy supply and demand deviation between each node. By analyzing the exchanged parameters, the system, in conjunction with the power grid impedance model, calculates the energy supply and demand deviation between each physical or logical connection node, and summarizes them into a multi-dimensional quantitative assessment vector of energy imbalance, used to intuitively characterize the severity of the current imbalance in the community's energy distribution.

[0090] Specifically, the process of obtaining the quantitative evaluation vector by calculating the energy deviation between each node includes: after receiving the weight update values ​​uploaded by each node, the cloud coordination server uses the current global model combined with the state observation values ​​of each node at the previous moment to estimate the fluctuation range and expected trend value of the active power output of each node within the current control cycle. Subsequently, based on Kirchhoff's Current Law (KCL), a network-wide power transfer equation was constructed, and the power flow of nodes under physical topology constraints was calculated. Its neighboring nodes Power exchange residual trend ,in The transmission coefficient is considered to account for line impedance losses. This estimation process only compares macroscopic power output trends and does not require analysis of specific power consumption details, ensuring privacy and security. Finally, the power exchange residuals, voltage offset rates, and reactive power deficits on all physical interconnects across the entire network are tensor-concatenated to form the aforementioned quantitative evaluation vector.

[0091] The system continuously monitors the quantitative assessment vectors to determine whether each indicator exceeds the preset safety assessment thresholds. When the assessment vectors of a mixed community exceed the thresholds due to sudden extreme weather, the system immediately employs a global parameter aggregation algorithm (such as the FedAvg algorithm) at the central coordination end to perform a weighted average of the model parameters reported by each node, forming a unified parameter update and distribution. After receiving the global parameters, each building node does not directly overwrite the original model. Instead, it combines the unique microclimate or special equipment operation data of the local building to implement a local fine-tuning strategy, specifically optimizing the top-level network weights of the model of a particular building node. The fine-tuned model can output multi-dimensional prediction sequences containing multiple time scales (such as the next 15 minutes, 1 hour, 4 hours) and multiple energy types (electricity, cooling, heating). Conversely, if the assessment vectors do not exceed the limits and are in a stable operating state, the system maintains the existing weights and only outputs a single-dimensional conventional prediction sequence.

[0092] In the specific operation of the local fine-tuning, the system actively freezes the network parameters of the underlying feature extraction network of the local energy consumption prediction model (such as the two front Bi-LSTM layers), and only unfreezes the fully connected layers used to output the prediction results. At the same time, the initial learning rate in the fine-tuning process is strictly set to one-tenth of the initial training learning rate of the global model (for example, set to 0.0001), and small-step iterative updates are performed using a local small sample dataset containing recent mutation features. In this way, the model can quickly adapt to local special working conditions without causing catastrophic forgetting.

[0093] Based on accurate multidimensional prediction sequences, the system maps a dynamic heatmap in virtual space, representing the overall load distribution of the community, clearly identifying high-load red zones and low-load blue zones. Subsequently, the system initiates a multi-agent reinforcement learning (MARL) algorithm, assigning an agent to each key power distribution node in the distribution map. These agents independently execute local energy allocation decisions (such as determining charging / discharging strategies or route switching) based on current local state observations. During training and inference, the system sets an environmental reward function, which not only rewards individual actions to reduce peak load but also provides substantial rewards for agents working together to reduce line transmission losses and improve overall energy utilization.

[0094] To ensure the executability of the algorithm on the hardware system, this invention has carried out a specific quantitative design of the environmental reward function. The globally unified mathematical expression of the environmental reward function is as follows: In this formula, for The agent at any given moment seeks to maximize the overall objective reward value; For node i in The power supply-demand deviation rate at time t is in the range [0,1]. The smaller the deviation rate, the lower the value (1-| The larger the value of |), the higher the positive reward given to the agent; The theoretical line loss value for optimizing the energy flow path is calculated by collecting the product of the square of the line current and the line resistance. This term is preceded by a negative sign (-). (), aiming to guide agents to minimize physical network losses; the most critical security penalty factor The system triggers and sets a value of 1 when the sensor detects a voltage drop at any local node or an excess of ±5% of the rated value, within a preset safety range; otherwise, it sets a value of 0. α, β, and γ are preset weighting coefficients (preferably α=0.5, β=0.3, γ=1000). When triggered, γ is given a very large weight, causing the overall reward value to instantly become a very small negative value. Thus, at the algorithm level, a "one-vote veto" mechanism is used to ensure that the energy flow path planned by the agent will not cause the power grid to overshoot and collapse.

[0095] For the aforementioned environmental reward function, the weight coefficients need to be adaptively assigned based on the specific application scenario of the building complex to guide the output of actual engineering equipment. As a preferred implementation, in the peak-shaving and valley-filling scenario of a mixed commercial and residential community focusing on economic benefits and network loss optimization, the supply-demand balance weight coefficient α is set to 0.6, the line loss weight coefficient β to 0.4, and the penalty weight γ to 1000. In the scenario of a medical building complex with extremely high requirements for power quality and life support systems, the system assigns absolute control priority to the safety penalty item, setting α to 0.4, β to 0.1, and simultaneously increasing the penalty weight γ to 10000. By assigning deterministic parameters for specific physical scenarios, the convergence direction of the reinforcement learning model is ensured to meet the strict constraints of specific industrial control objectives.

[0096] Driven by this reward mechanism, multiple agents collaboratively calculate optimal energy flow paths (such as guiding surplus photovoltaic power from commercial buildings to charging piles in residential areas through specific microgrid lines), thereby generating a preliminary load balancing configuration scheme containing action instructions for each node device.

[0097] To ensure the absolute safety of the configuration scheme, the system extracts operational simulation data from key nodes such as energy storage inverters and interconnection switches from the initial scheme, and runs an anomaly detection model to determine whether there is a risk of demand surge due to sudden load changes. If a large-scale event is detected that may cause a momentary overrun of local power, the system triggers a peer-to-peer (P2P) information exchange protocol. Without central server intervention, adjacent high- and low-load intelligent agents directly establish point-to-point communication to achieve state sharing of underlying voltage and available capacity. Based on the latest shared state, the system introduces a real-time feedback compensation mechanism (such as real-time tracking of the deviation between actual flow and predicted configuration through a PID controller) to calculate an energy flow control vector (containing specific active and reactive power adjustment commands) for precise control of the trigger angle of power electronic equipment.

[0098] Subsequently, the system remaps the energy flow control vector back to the spatiotemporal distribution feature matrix, driving iterative updates to the network state. During the massive issuance of control commands, to avoid communication congestion, the system employs a communication sparsity algorithm to actively filter out weak control signals with minimal impact on the overall balance, thereby significantly reducing the frequency of interactions between nodes. Simultaneously, the system calculates the degree centrality of nodes by determining their number of connections and their importance in the network topology, and dynamically adjusts the priority of control command issuance by combining this with connection weights formed by line impedance (high-centrality convergence nodes respond first), ultimately determining the target load balance distribution state after network evolution.

[0099] Before final execution, the system must detect whether there are any residual imbalances hidden in the target load balance distribution state due to equipment response delays or inherent line losses. Once a residual imbalance is found to exceed the balance threshold specified by the power grid safety regulations, the system immediately invokes the state-action space mapping algorithm to reduce the dimensionality of the current complex imbalance feature vector and map it into executable switching action combinations, thereby redefining the physical interconnection state of the building complex at the topology level. Then, based on the new connection graph, the system uses heuristic search (such as the A* search algorithm) or advanced path planning algorithm to avoid congested nodes in a very short time, correct and optimize an emergency flow path, and finally outputs a result that can directly guide the rapid balance distribution of hardware devices, completing closed-loop control from monitoring to thorough optimization.

[0100] Furthermore, when the algorithm generates or searches for new connection topologies, the system incorporates a physical verification module for the connectivity of the distribution network topology. This module, based on the Spanning Tree algorithm in graph theory, performs connectivity verification on each discrete action combination output, forcibly discarding any action combinations that would lead to the formation of a closed loop (i.e., a ring network) or the creation of isolated nodes without power supply support. If the actions generated by the algorithm violate the above constraints, a large negative penalty value is fed back to the model, and action tree pruning is performed to ensure that the final generated flow path absolutely meets the radial operation safety standards of the power system.

[0101] The state-action space mapping process here explicitly excludes human experience intervention and has a clear mathematical-hardware correspondence. Specifically, the system extracts low-level sensor data and constructs state space vectors. The state-action space mapping algorithm specifically employs a pre-trained offline Deep Q-Network (DQN) model or a hard-coded lookup table mechanism. In this embodiment, the system maps continuous state space vectors... The input is fed into the mapping network, and the output layer corresponds to a discrete action space. .in The circuit breaker switch on the microgrid tie line has a value of only {0,1}, where 0 represents disconnection and 1 represents grid connection. Specifically, the system has a pre-set state-action hardware mapping table. For example, when the microgrid faces a residual imbalance state space vector input due to a regional voltage drop, if the action combination sequence output by the deep Q-network model is [1,0,1], the mapping table parses it into a definite physical execution logic: closing tie circuit breaker 1 to introduce backup power from the main grid, disconnecting secondary load branch circuit breaker 2 for load reduction, and closing energy storage grid connection switch 3 for power support. This action logic is then converted into standard control messages by the gateway and sent to each physical distribution cabinet for execution. The mapping network directly outputs the switch combination sequence corresponding to the maximum Q value. Finally, the system directly issues standard industrial control protocol commands (such as Modbus TCP) based on the output discrete action combinations, driving the gateway's underlying hardware relays to forcibly execute the disconnection or reconfiguration of the physical microgrid, achieving millisecond-level rapid balancing.

[0102] Example 2: Industrial Park Application Scenario Including Distributed Renewable Energy For modern green industrial parks that integrate a large number of rooftop photovoltaic and wind power generation facilities, the combination of the sudden changes in industrial production load and the intermittent nature of new energy output poses a high degree of uncertainty challenge to energy consumption monitoring and optimization.

[0103] The system captures multi-dimensional energy consumption characteristic data, including harmonic components, in real time through high-frequency IoT sensors installed in the power distribution cabinets and new energy grid connection points of each factory. To avoid the risk of leakage of trade secrets due to the aggregation of massive amounts of sensitive production data, the system has built a rigorous distributed machine learning architecture. Each factory is an independent federated learning node, using local historical load and meteorological data to train a local energy consumption prediction model (such as a temporal convolutional network TCN with an attention mechanism). The heterogeneous energy consumption data here is characterized by the coexistence of a highly random sequence of wind power output and a step load sequence of assembly line motor startup. The system performs rigorous time and frequency domain feature extraction on these heterogeneous data, separating the fundamental wave and high-frequency disturbance features, and then constructs a spatiotemporal distribution feature matrix that dynamically depicts the evolution trajectory of the source load in the park (inputs include real-time power, wind speed, and illuminance of each factory, and output is a source load distribution prediction matrix for future periods).

[0104] Based on this matrix, the system utilizes graph topology analysis algorithms such as graph neural networks to deeply mine the physical topology and logical coupling relationships between the microgrids of the plant buildings. The physical topology is represented by the cable routing between the plant buildings and the energy storage power station, while the logical coupling is reflected in the energy consumption synergy effects caused by the upstream and downstream dependencies of different plant production processes. To collaboratively optimize allocation strategies among nodes, each plant node strictly adheres to a privacy-preserving parameter exchange mechanism. Through differential privacy technology with added Gaussian noise, only the model gradients or weight update values ​​generated during local model training are sent to the park's cloud platform. The cloud platform compares the energy supply and demand deviations in each region based on the gradient change rate of each node and the theoretical values ​​based on power flow calculations, and constructs a multi-dimensional quantitative assessment vector of energy imbalance to quantitatively characterize the risk level of "wind and solar curtailment" or "local overload" within the park.

[0105] When cloud cover causes a sharp drop in photovoltaic output in the industrial park, and the quantitative assessment vector quickly exceeds the warning threshold, the system immediately activates the global parameter aggregation algorithm. The cloud server integrates the collected parameter updates, weighted by the data volume and model confidence of each plant node, and then distributes them to each plant. Upon receiving the updates, the plant nodes utilize their unique local production schedule data to execute a fine-tuning strategy, precisely adjusting the weights of the model's lowest-level perceptual features, thereby outputting a multi-dimensional prediction sequence encompassing the source, grid, load, and storage states. During periods of clear weather and normal production patterns, the system reverts to using the conventional prediction sequence, which does not consume additional computing power.

[0106] Based on multidimensional prediction sequences, the system generates a load state distribution map at the microgrid level within the industrial park. Subsequently, agents deployed in the microgrid controllers of each plant are activated, engaging in game theory and collaboration using a multi-agent reinforcement learning (MARL) algorithm. Each agent strives to make optimal local energy allocation decisions (such as controlling the smooth release of local energy storage or the cross-regional sale of surplus photovoltaic power). The system is configured with a stringent reward function, providing positive incentives for actions that mitigate tie-line power fluctuations and increase the proportion of green electricity consumption, while imposing severe penalties for actions that cause voltage exceedances. After multiple rounds of virtual environment exploration, the agent swarm plans the optimal energy flow path, forming a preliminary load balancing configuration scheme to guide energy storage charging and discharging and flexible load deployment and deactivation.

[0107] To address the potential demand surge risk from frequent starts of impact loads such as large rolling mills, the system extracts simulation data from key bus nodes in the initial design for stress testing. Once a risk is identified, the relevant nodes will break free from cloud constraints and establish low-latency connections directly with nearby intelligent agents equipped with flywheel energy storage or supercapacitors via an underlying peer-to-peer (P2P) information exchange protocol, achieving millisecond-level sharing of state of charge (SOC) and reserve capacity. Based on this point-to-point state awareness, the system embeds a real-time feedback compensation mechanism, utilizing local feedback control loops to quickly offset power deviations caused by new energy prediction errors or sudden load surges, and calculates and generates more refined energy flow control vectors.

[0108] In the control command distribution network, to cope with the complex electromagnetic interference and limited communication bandwidth of the industrial park, the system adopts a communication sparsity algorithm. By setting a dead zone threshold, communication interaction is only initiated when the change in the control vector exceeds the critical value. At the same time, the system calculates the node degree centrality of each substation and bus by analyzing the network topology graph, and assigns the highest data frame forwarding priority to backbone network nodes (connection weight adjustment interaction priority), thereby locking in a safe and stable target load balance distribution state.

[0109] In the final stage, the system rigorously detects whether there is any residual reactive power imbalance caused by line inductive or capacitive reactance in the target load balance distribution state. If the reactive power deficit or voltage deviation exceeds the allowable range, the system will activate a dimensionality-reduced state-action space mapping algorithm to map the complex reactive power voltage problem into the on / off combination states of reactive power compensation devices (SVC / SVG). Then, it will use heuristic search to quickly find the optimal solution in the vast action combination space, or rearrange the reactive power flow distribution path through a constrained path planning algorithm to output a fast balanced distribution result that completely eliminates the risk of exceeding limits.

[0110] Furthermore, based on the rapid load balancing distribution results or the target load balancing distribution status, the system directly compiles them into standard industrial control communication protocol commands (such as Modbus-TCP or IEC 61850 GOOSE messages), and sends the commands to the corresponding building power distribution nodes through the industrial data gateway. This directly drives the underlying hardware relays to perform circuit breaker disconnection and reconfiguration operations of the physical microgrid, or drives the energy storage converter (PCS) to adjust the active / reactive charging and discharging power, thereby completing the substantial closed-loop control of energy flow in the physical space.

[0111] Example 3: Event-Driven Energy Dispatch Application Scenario in a Large University Campus Large university campuses contain a diverse group of buildings, including teaching buildings, libraries, gymnasiums, and dormitories. Their energy consumption characteristics are often strongly driven by sudden mass events such as centralized examinations or large-scale sports meets.

[0112] In this scenario, the system relies on IoT smart meters and temperature control nodes covering the entire campus to acquire real-time energy consumption characteristic data. To conduct in-depth analysis without infringing on the privacy of students and faculty, the system introduces a distributed machine learning architecture, deploying local energy consumption prediction models on aggregation routers in each building area. University energy consumption data encompasses the regular lighting load in teaching buildings, the specific instrument load in laboratories, and the random electrical load in dormitories; this extremely complex heterogeneous energy consumption data is fully absorbed by the model. The system extracts time-domain features from the autocorrelation of time series data and uses frequency-domain analysis techniques such as wavelet transform to capture sudden frequency features caused by the movement of people after class. Furthermore, it integrates Geographic Information System (GIS) data to construct a precise campus-level spatiotemporal distribution feature matrix.

[0113] By performing graph topology analysis on the matrix, the system can not only identify the physical topology of the campus power distribution ring network, but also uncover the strong logical coupling relationships caused by personnel movement (for example, the sudden drop in load in the teaching building and the surge in load in the dormitory area after evening self-study show a high degree of time-delay coupling). During the collaborative training of models in each area, a strict privacy-preserving parameter exchange mechanism is followed, never transmitting detailed electricity consumption data for specific dormitories, but only transmitting locally calculated model gradients or weight update values. The campus central control center reconstructs the global electricity consumption trend based on this gradient information and calculates the energy deviation between the predicted load and transformer capacity in each area, quantifying and generating a multi-dimensional quantitative assessment vector to evaluate the power supply tension in each area.

[0114] When final exams approach and the library and individual study rooms are lit up all night, causing the quantitative evaluation vector to deviate significantly from the normal threshold, the system triggers a global parameter aggregation algorithm. By integrating trend updates across the entire campus and requiring key support areas to utilize their recent high-density operational data to initiate a local fine-tuning strategy, the system enhances the model's ability to fit continuous high-load conditions. The fine-tuned model can output high-precision multi-dimensional prediction sequences for multiple subsystems such as lighting, air conditioning, and sockets (in normal circumstances, it only relies on basic conventional prediction sequences).

[0115] Based on predicted data, the central campus screen generates a real-time load distribution map of the entire campus. The system runs a multi-agent reinforcement learning (MARL) algorithm within the intelligent microgrid control terminals configured in each building complex. Faced with the extremely unbalanced load during the postgraduate entrance examination season, each agent autonomously formulates local energy allocation decisions; for example, the agent in the gymnasium proactively lowers the air conditioning set temperature in unnecessary areas to free up capacity. Through a carefully designed environmental reward function, the system guides agents not only to minimize local energy consumption but also to minimize the variance of the overall transformer load rate. Thus, the system dynamically plans virtual or physical energy flow paths from low-load areas (such as the laboratory building) to high-load areas (such as the dormitory building), generating a preliminary load balancing configuration scheme.

[0116] Considering the potential surge in demand caused by the sudden outflow of crowds at the end of large-scale events (such as the simultaneous activation of numerous water heaters in dormitories), the system performs boundary condition checks on the initial plan. If a potential risk of exceeding limits is detected, the system immediately activates the peer-to-peer (P2P) information exchange protocol between transformer substation controllers to achieve lossless sharing of load capacity and real-time temperature data for each substation. Based on the shared data, the system initiates a real-time feedback compensation mechanism. Once the actual current growth rate exceeds the predicted slope, the compensation mechanism immediately intervenes, calculating and issuing an energy flow control vector to trigger flexible loads (such as limiting the power of air conditioners in certain areas).

[0117] During the control command issuance process, the system utilizes a communication sparsity algorithm to eliminate redundant acknowledgment messages and periodic heartbeat packets, ensuring absolutely low latency for critical control commands within the campus LAN. The system calculates the degree centrality of each node based on the hierarchical structure of the power distribution network topology, ensuring that the backbone distribution room has the highest interaction priority. Through iterative updates to the network state, the system locks in a target load balance distribution state that optimizes the allocation of power grid resources across the entire campus.

[0118] Finally, the system scans the target distribution status. Once it detects residual imbalance (overload heating) exceeding safety limits on an old branch cable, it invokes a state-action space mapping algorithm to map simple power regulation into a reconfiguration action of switching switch opening and closing. Through heuristic search, it evaluates all compliant switching operation sequences, or uses path planning algorithms to find the shortest electrical path in the topology graph that can safely transfer the load. This results in a rapid distribution balance achieved by executing commands, ensuring the absolute safety and reliability of campus power supply.

[0119] Example 4: High-reliability application scenario of medical building complex and surrounding support facilities The hospital complex and its surrounding rehabilitation center and logistics support area constitute a microgrid ecosystem with extremely stringent requirements for power quality and power supply continuity. Within this system, any local energy fluctuations or imbalances could directly threaten lives.

[0120] To address this specific scenario, the system utilizes a high-precision IoT power quality analyzer to perform high-frequency sampling of power supply circuits, including those for life support systems and large imaging equipment (such as MRI), to acquire detailed energy consumption characteristic data. To absolutely protect the privacy of patient information and medical behavior data, the system deploys a high-specification distributed machine learning architecture. Each medical sub-area (such as the inpatient department, outpatient building, and radiology department) independently constructs a local energy consumption prediction model. The extremely high instantaneous pulse load in the radiology department contrasts sharply with the stable load in the inpatient department, creating heterogeneous energy consumption data. The system deeply extracts the temporal and frequency domain abrupt change characteristics of these sequences within extremely short time windows, thereby constructing a spatiotemporal distribution feature matrix that accurately reflects the rhythm of medical activities.

[0121] Supported by this matrix, the system employs a highly robust graph topology analysis algorithm to analyze hospital dual-circuit and even multi-circuit power supply networks, accurately identifying the physical topology and logical coupling relationships between primary and backup power supplies. Due to the extremely high security requirements of medical networks, each node adopts a privacy-preserving parameter exchange mechanism with quantum encryption levels, strictly limiting the exchange to only generalized model gradients or weight update values. By calculating partial derivatives and trend extrapolating these update values, the system accurately captures the minute energy deviations caused between nodes at the moment of startup of critical medical equipment, and constructs a quantitative assessment vector for energy imbalance with a very high warning level.

[0122] Once a sensitive dimension in the assessment vector (such as the risk of voltage drop on critical load buses) exceeds a highly tightened preset threshold, the cloud control platform immediately executes a high-frequency global parameter aggregation algorithm. Due to the unique operating characteristics of medical facilities, the aggregated parameters must be combined with prior knowledge such as radiology appointment schedules or emergency surgery arrangements to perform a deep local fine-tuning strategy, thereby generating a multi-dimensional prediction sequence that includes second-level power fluctuation predictions. Under stable operating conditions such as daily basic lighting and ordinary cooling, the conventional prediction sequence with lower computational overhead is still used.

[0123] Based on the aforementioned high-precision multidimensional predictions, the system dynamically renders a load distribution map of each floor of the hospital. Guided by this distribution map, the system employs a security-enhanced multi-agent reinforcement learning algorithm (MARL). Each agent corresponding to a ward or critical computer room is responsible for making local energy allocation decisions for its area (especially the seamless integration strategy for diesel generators or UPS emergency power supplies). By setting a reward function biased towards "zero power outage risk" and "optimal power quality," the agents, through high-frequency trial and error and convergence, plan multiple redundant energy flow paths, ultimately producing a preliminary load balancing configuration scheme that balances economy and absolute reliability.

[0124] Considering the risk of a surge in demand due to sudden major public health events or large-scale emergency rescues (such as multiple operating rooms operating at full power simultaneously), the system conducts limit boundary simulation analysis on the initial plan. If an over-limit collapse risk is determined, the microgrid master control units in each area immediately communicate via a hard-wired peer-to-peer (P2P) information exchange protocol at the microsecond level, achieving zero-delay sharing of emergency backup power status and bus remaining capacity. The system kernel, through a high-speed real-time feedback compensation mechanism, immediately calculates the energy flow control vector used to control the solid-state switching switch and UPS inverter output phase once it detects that the frequency or voltage drop exceeds the set threshold.

[0125] When distributing this control vector to hundreds or thousands of underlying switch nodes, to ensure the real-time performance of critical actions, the system runs an advanced communication sparsity algorithm, directly blocking all non-urgent status monitoring messages. Simultaneously, based on node degree centrality assessment, the network communication and energy allocation interactions of nodes located in the intensive care unit (ICU) or emergency operating room are assigned the highest priority. Through this reliable iterative update, the system quickly converges to a target load-balanced distribution state with extremely high resilience to disturbances.

[0126] Finally, as the last safety barrier, the system must use sophisticated algorithms to detect whether there is any non-negligible residual imbalance caused by three-phase imbalance or harmonics in the target load balance distribution. If the residual imbalance exceeds the stringent national power quality standard threshold, the system immediately triggers the underlying state-action space mapping algorithm to directly map the harmonics and imbalance state into refined output waveforms of the active power filter (APF) and static var generator (SVG) and reconstruct the network physical topology. Based on this, the system employs a high-computing-power heuristic search or dynamic path planning algorithm to find the power support path with optimal impedance matching and the best power quality, and directly outputs a fixed, fast balanced distribution result to ensure the energy security and stability of the medical building complex to the highest standards.

[0127] As a preferred embodiment, to facilitate centralized management and command issuance and avoid system fragmentation caused by multiple entities executing the same data, the IoT-based green building energy consumption monitoring and optimization control method described in this application can also be implemented by a single central coordination device deployed on a cloud platform or core microgrid gateway. Specifically, this single entity executes the following complete logic: directly acquires real-time energy consumption characteristic data of each building from the underlying IoT sensor cluster and constructs a spatiotemporal distribution characteristic matrix; after integration in the cloud through a global parameter aggregation algorithm, it issues global aggregation parameters to each building node to generate a multi-dimensional prediction sequence; based on the aggregated multi-dimensional prediction sequence, it runs a multi-agent reinforcement learning algorithm to generate a preliminary load balancing configuration scheme; when a surge in demand is detected, it coordinates and issues an optimized energy flow control vector; finally, it generates standard industrial control protocol commands to directly drive the underlying hardware to perform distribution network topology reconfiguration or equipment power adjustment.

[0128] Specifically, the present invention provides a method and system for monitoring and optimizing energy consumption in green buildings based on the Internet of Things, which may include: S101. Collect real-time energy consumption characteristic data of each building through IoT sensor cluster, build local energy consumption prediction model at each building node based on distributed machine learning architecture, extract time and frequency domain characteristics of heterogeneous energy consumption data, analyze the energy demand fluctuation pattern of different buildings, and construct the spatiotemporal distribution characteristic matrix of current energy demand.

[0129] Real-time energy consumption characteristic data is acquired from the distribution of various building nodes through an IoT sensor cluster and stored as an initial energy consumption dataset. Based on the initial energy consumption dataset, a distributed machine learning architecture is used to construct local prediction models on the distribution of each building node to obtain the energy consumption prediction results for each node. For the acquired initial energy consumption dataset, the time-domain and frequency-domain features of the real-time heterogeneous energy consumption data are directly extracted to form a feature vector set. For the feature vector set, the system quantifies the degree of fluctuation by calculating the difference between the maximum and minimum load values ​​or the standard deviation of the load rate within a set time window. If the calculated load fluctuation range or fluctuation rate exceeds a preset fluctuation threshold (determined based on the average range of historical stable operation periods plus 3 times the standard deviation), the corresponding building energy demand is marked to identify abnormal fluctuation areas. By mapping the spatiotemporal distribution feature matrix of the abnormal fluctuation areas, the corresponding building node distribution locations are obtained to identify potential energy consumption anomalies. Based on the energy consumption anomalies and the output of the local prediction model, the parameter configuration in the distributed machine learning architecture is adjusted to obtain optimized energy consumption prediction results.

[0130] Specifically, the extraction of time and frequency domain features of the real-time energy consumption feature data includes: in the time domain dimension, calculating the load mathematical expectation (mean), load fluctuation range, and load rate within a set time window; in the frequency domain dimension, using Fast Fourier Transform (FFT) to convert the time series into a spectrum, extracting the amplitude of the fundamental component and the amplitude of the high-frequency abrupt component within a set frequency band; subsequently, concatenating the calculation results in the time domain dimension with the extraction results in the frequency domain dimension to form the feature vector set.

[0131] In one embodiment, a cluster of IoT sensors deployed in a smart building complex acquires real-time energy consumption characteristic data from various building nodes, such as office buildings and residential areas. For example, it monitors the power consumption of air conditioning and lighting systems and stores the data as an initial energy consumption dataset, thereby providing a basis for subsequent analysis.

[0132] For example, based on the initial energy consumption dataset, a distributed machine learning architecture, such as a Federated Learning framework, can be adopted, in which each building node independently trains a local model to avoid centralized data transmission and protect privacy.

[0133] Specifically, this architecture involves parameter aggregation between nodes. For example, each node trains an LSTM model using local data to predict energy consumption for the next hour. The model input includes historical electricity consumption and temperature data. Weights are optimized using gradient descent, and then the model parameters are uploaded to a central server for average aggregation. After obtaining a global model update, the data is distributed back to the nodes, thus achieving efficient distributed training and obtaining energy consumption prediction results for each node. The advantage of this approach is reduced communication overhead while improving prediction accuracy; for example, the energy consumption prediction error can be controlled within 5% during peak periods.

[0134] It should be noted that heterogeneous energy consumption data refers to the differences in data between different building types, such as the peak load of commercial buildings and the steady curve of residential buildings. Through time-domain feature extraction, such as calculating the mean and variance, and frequency-domain feature analysis, such as Fourier transform to identify periodic fluctuations, a set of feature vectors is formed. For example, the vectors include dimensions such as peak time and frequency amplitude.

[0135] For example, if the energy demand fluctuation in the feature vector set exceeds a preset threshold, such as a 10% deviation, the energy demand of the corresponding building is marked, and the abnormal fluctuation area is identified. Subsequently, by mapping the spatiotemporal distribution feature matrix of the abnormal fluctuation area—for example, constructing a matrix where rows represent timestamps and columns represent node locations—and using an interpolation algorithm to map it to geographic coordinates, potential energy consumption anomalies, such as equipment failures on specific floors, are identified. Based on these anomalies, combined with the output of the local prediction model, the parameters of the distributed machine learning architecture are adjusted, such as increasing the learning rate or adding a regularization term, to obtain optimized energy consumption prediction results, thereby improving overall energy management efficiency. Through the above method, precise optimization of energy consumption in smart buildings can be achieved.

[0136] As a complete spatiotemporal distribution feature matrix construction closed loop, after obtaining the preliminary energy consumption prediction results of each building node, the system combines the time-frequency domain fluctuation amplitude in the feature vector set to locate abnormal fluctuation areas exceeding the preset fluctuation threshold through spatiotemporal coordinate mapping. Using this physical anomaly point as a feedback driving signal, the system adaptively adjusts the local learning rate and regularization parameters in the distributed machine learning architecture, and directly overwrites the adjusted optimized energy consumption prediction results and their corresponding spatiotemporal coordinates into the spatiotemporal distribution feature matrix of the current energy demand, completing the final matrix construction.

[0137] Before inputting data into the local prediction model, the system performs time series alignment processing to address the heterogeneous characteristics of different IoT sensors, which result in inconsistent data sampling frequencies due to differences in device models or communication protocols. By extracting the common time reference of each sensor's data stream and employing resampling and linear interpolation algorithms, all heterogeneous feature data with non-standard frequencies are strictly aligned into a standardized time series with a unified sampling interval. This ensures that the feature tensors subsequently input into the two-layer long short-term memory network have absolute consistency in the time dimension.

[0138] Specifically, the local energy consumption prediction model described in this step preferentially adopts a two-layer long short-term memory network architecture. The network input layer dimension is [24, 8], where the time step of 24 corresponds to the energy consumption data of the past 6 hours, the sampling interval is 15 minutes, and the 8-dimensional input features are, in order, node active power, reactive power, RMS voltage, RMS current, ambient temperature, ambient humidity, illuminance, and weekday / holiday flags. The network is configured with 2 LSTM hidden layers, each with 64 neurons, and the inter-layer activation function is the hyperbolic tangent function. The loop dropout rate is set to 0.2 to avoid overfitting. The network is configured with 1 fully connected output layer with an output dimension of 12, corresponding to the predicted energy consumption values ​​for the next 3 hours in 15-minute increments. The output layer activation function is the linear rectified function. The model training employs the Adam adaptive optimizer with an initial learning rate of 0.001, a batch size of 32, and a maximum number of iterations of 100. An early stopping mechanism is implemented, terminating training when the mean squared error loss on the validation set fails to decrease for five consecutive iterations. The loss function used in model training is the mean squared error, calculated as the average of the squared deviations between the actual energy consumption and the model's predicted values. The time-domain and frequency-domain feature extraction described in this step calculates the expected value, load fluctuation range, load factor, and load fluctuation rate of the load sequence within a set 1-hour time window. Frequency-domain feature extraction uses Fast Fourier Transform (FFT) to convert the time-domain energy consumption sequence into spectral data. The FFT window length is set to 1024, the sampling frequency is 1Hz, and the amplitudes of the fundamental component, the third harmonic component, and the fifth harmonic component are extracted. The time-domain feature calculation results and the frequency-domain feature extraction results are concatenated dimensionally to form a single-node feature vector set for subsequent model input.

[0139] Furthermore, the extraction of features is input into the local energy consumption prediction model, specifically by using the spliced ​​time-domain fluctuation range features and frequency-domain high-order harmonic amplitude features as the underlying sensing input. This explicit introduction of power distribution network physical parameters into the input mechanism enables the local prediction model to directly capture the heterogeneous electricity consumption abrupt changes in mixed commercial and residential scenarios. This substantially solves the prediction failure problem caused by excessive differences in loads across multiple building types at the algorithm level, ensuring effective fitting of extreme energy demand fluctuations.

[0140] S102. Based on the spatiotemporal distribution feature matrix, a graph topology analysis algorithm is used to identify the physical topology and logical coupling relationship between building groups. A privacy-preserving parameter exchange mechanism is used to transmit only the model gradient or weight update value. By calculating the energy deviation between each node, a quantitative evaluation vector of energy imbalance is obtained.

[0141] Obtain the spatiotemporal distribution feature matrix of the building cluster. A graph topology analysis algorithm is used to process the spatiotemporal distribution feature matrix, identifying the physical connections and logical coupling relationships between nodes in the building cluster, generating a topology graph of the building cluster relationship. Based on the topology graph, node sets are determined, and privacy-preserving parameter exchange channels are established between these node sets. The model gradient values ​​and weight update values ​​of each node are transmitted through these privacy-preserving parameter exchange channels. A pre-defined energy calculation model is used to process the model gradient values ​​and weight update values, calculating the energy deviation between any two nodes in the node set. The energy deviations of all node pairs are summarized to obtain a quantitative evaluation vector of energy imbalance.

[0142] In one embodiment, the spatiotemporal distribution feature matrix of the building complex is first obtained.

[0143] For example, by deploying a sensor network in urban commercial areas, energy consumption data of each office building can be collected in real time, including time series such as peak electricity consumption and spatial distribution such as heat transfer between floors, thereby forming a multi-dimensional matrix to represent the dynamic energy pattern of the building complex.

[0144] In one embodiment, a graph topology analysis algorithm is used to process the spatiotemporal distribution feature matrix to identify the physical connections and logical coupling relationships between building cluster nodes.

[0145] For example, buildings can be viewed as nodes. Physical connections refer to shared power lines such as underground cable networks, while logical coupling involves the correlation of energy demand, such as the linkage of air conditioning systems in adjacent buildings. The algorithm process includes constructing an adjacency matrix, where matrix elements are calculated based on the similarity of spatiotemporal features, such as using cosine similarity to quantify the consistency of time-domain fluctuations. Then, community detection methods such as the Louvain algorithm are applied to divide the clusters, thereby generating a topological graph of building cluster relationships. This graph uses nodes and edges to represent connection strength, such as edge weights reflecting the dependence on energy flow, thus revealing potential energy sharing patterns.

[0146] Furthermore, the specific rules for constructing the adjacency matrix are as follows: construct an adjacency matrix that reflects the relationships between building groups. For physical topological relationships, if nodes With nodes If there is a direct electrical connection between them, then the corresponding matrix elements... Assigned basic physical weights (e.g., a value of 1.0); for logical coupling relationships, based on the node... With nodes The weighting logic for calculating the Pearson correlation coefficient on energy supply and demand time series. The final adjacency matrix element calculation formula is as follows: ,in and The weights are assigned coefficients to transform the abstract physical and logical relationships into quantized numerical matrices that can be used for graph neural network operations.

[0147] In one embodiment, a set of nodes is determined based on the topology of the building group relationship, and a privacy-preserving parameter exchange channel is established between the set of nodes.

[0148] For example, core nodes with degrees higher than a threshold in the topology graph, such as central business districts, are selected. When establishing channels, a differential privacy mechanism is used to add noise to the transmitted data to ensure that the model parameters do not leak sensitive information such as specific electricity usage habits.

[0149] In one embodiment, the model gradient values ​​and weight update values ​​of each node are transmitted through a privacy-preserving parameter exchange channel.

[0150] For example, in a federated learning framework, each node trains a neural network model locally, calculates gradients such as partial derivatives based on historical energy consumption, and then transmits them to the channel in encrypted form to achieve distributed optimization.

[0151] In one embodiment, these values ​​are processed using a preset energy calculation model to calculate the energy deviation between any two nodes in the node set.

[0152] For example, the model is defined as a bias function, with the gradient and weights as inputs, and the output difference as a measure of the difference in predicted energy consumption, thus quantifying the imbalance.

[0153] In one embodiment, the energy deviations of all node pairs are aggregated to obtain a quantitative assessment vector of energy imbalance.

[0154] For example, the vector elements correspond to the average deviation, which is used for subsequent energy dispatch optimization. This method enables accurate assessment of the building complex's energy levels, improving the efficiency of the management system.

[0155] Specifically, the graph topology analysis algorithm described in this step preferentially employs the Louvain community detection algorithm combined with a 2-layer graph convolutional neural network (GCN). An adjacency matrix reflecting the physical and logical coupling relationships of building clusters is constructed, and the matrix elements are calculated using the following formula: in, This is the physical topology weighting coefficient, with a default value of 0.6. It can be adjusted based on the density of electrical connections within the building complex. Adjust within the scope; This is the logical coupling weight coefficient, with a default value of 0.4, and it satisfies... . For physical connection weights, if the node With nodes If there is a direct electrical connection between them, then The value is 1.0, otherwise it is 0. For logical coupling weights, the value is taken from the node. With nodes The Pearson correlation coefficient between the energy consumption time series ranges from [-1, 1].

[0156] The input layer of the GCN network has an 8-dimensional node energy consumption feature, consistent with the input features in step S101. Two GCN hidden layers are set, and the output dimension is a 16-dimensional node embedding vector. Mean aggregation is used, and ReLU is used as the activation function. The resolution parameter of the Louvain algorithm is set to 1.0, and the iteration termination condition is that the modularity increment (DeltaQ) is less than 0.0001, used to classify the energy coupling communities of the building complex. Further, the output 16-dimensional node embedding vector is input into a feature mapping regression network composed of fully connected layers. Combined with the historical energy consumption baseline sequence corresponding to the node, the predicted energy consumption feature of each node under the current topological coupling constraint is reconstructed. Subsequently, the difference between this predicted energy consumption feature and the actual energy consumption sampling baseline value is calculated to quantify the magnitude of the energy deviation between nodes under complex physical and logical coupling states, thus forming the basic dimension of the quantified evaluation vector.

[0157] The actual energy consumption sampling benchmark value mentioned here does not refer to the actual power consumption at future moments, but rather to the theoretical reference power obtained by the system through forward-backward substitution calculations based on the real-time topological connectivity, line impedance parameters, and historical steady-state operating baseline loads of each node in the current distribution network. This theoretical reference power assumes that each distribution node is in a state of absolute supply-demand balance. The system then calculates the difference between the predicted energy consumption characteristics, which consider dynamic coupling relationships, output from the graph convolutional network reconstruction, and this theoretical reference power in real time, thereby accurately quantifying the magnitude of the unbalanced energy deviation that will occur in the future.

[0158] S103. Determine whether the quantized evaluation vector exceeds a preset threshold. If it does, integrate the parameter updates of each node through a global parameter aggregation algorithm, and optimize the model weights of specific building nodes by combining a local fine-tuning strategy to generate a multi-dimensional prediction sequence of demand fluctuations.

[0159] By analyzing the quantitative evaluation results, the evaluation vector data of each node is obtained, and it is determined whether they exceed the preset threshold, thus obtaining a preliminary anomaly judgment result. If the judgment result shows that the evaluation vector exceeds the preset threshold, a global parameter aggregation algorithm is used to integrate the parameter updates of each node, generating a unified global parameter set. Based on the integrated global parameter set, the operating status of a specific building node is analyzed to obtain its local feature data and determine the applicable scope of local fine-tuning. The model weights of the specific building node are adjusted through a local fine-tuning strategy to generate optimized weight configuration data. Based on the optimized weight configuration data, a multidimensional prediction model is constructed to obtain the prediction sequence output for demand fluctuations. After obtaining the multidimensional prediction sequence, the fluctuation characteristics of the prediction sequence are validated to determine whether they conform to the preset fluctuation range, thus obtaining the final prediction result. If the prediction result shows that the fluctuation characteristics exceed the preset range, the parameters of the multidimensional prediction model are slightly adjusted to generate corrected prediction sequence data.

[0160] In one embodiment, after obtaining the evaluation vector data of each node, it is necessary to determine whether it exceeds a preset threshold.

[0161] Specifically, the preset threshold can be set based on the statistical characteristics of historical operating data.

[0162] For example, for a three-dimensional evaluation vector containing temperature, humidity, and energy intensity, its threshold might be set as an interval formed by adding or subtracting twice the standard deviation from the historical mean. The system compares the real-time evaluation vector of each node with the corresponding threshold interval dimension by dimension. If any dimension's data falls outside the interval, a preliminary anomaly detection flag is generated. Once an anomaly is detected, the system initiates a global parameter aggregation algorithm.

[0163] Understandably, the algorithm aims to integrate parameter updates from all nodes to form a unified global parameter set.

[0164] In one possible implementation, a weighted average algorithm is used for aggregation.

[0165] For example, each node's uploaded model weight update value is assigned a weight coefficient based on the reliability of its historical data or its current energy contribution. The system then performs a weighted average calculation on the update values ​​of all nodes to obtain a new set of global model parameters representing the overall state. Based on this integrated global parameter set, the system conducts in-depth analysis of building nodes marked as abnormal.

[0166] For example, for an office building identified as having abnormal cooling energy consumption in summer, the system extracts local feature data such as indoor temperature, occupancy density, and equipment operation rate over the past week at different times. By comparing and analyzing these local features with global parameters, the applicable scope for local fine-tuning can be determined.

[0167] For example, it was determined that only specific weight parameters related to the air conditioning system response in the office building model needed adjustment. After adjusting the model weights of specific nodes through a local fine-tuning strategy, an optimized weight configuration was generated. A multidimensional prediction model built using this configuration can make predictions by integrating multiple factors such as time, weather, and building function.

[0168] For example, the model can output a predicted sequence of the total load demand of the building complex and the load demand of individual abnormal buildings over the next 24 hours. After obtaining the predicted sequence, its fluctuation characteristics need to be verified.

[0169] Specifically, the system calculates the volatility or range of the predicted sequence and compares it with a volatility range set based on historical stable operating data. If the predicted volatility is too large, exceeding the acceptable range, it indicates that the model may be overly sensitive to certain disturbances. In this case, the system makes minor adjustments to parameters such as the smoothing coefficient or learning rate in the model, for example, reducing the learning rate by an order of magnitude and performing a new round of prediction calculations, thereby generating a smoother, more expected corrected predicted sequence. This secondary verification mechanism targeting the volatility characteristics of the predicted sequence constitutes the boundary protection of the local fine-tuning strategy. Only when the output of the multidimensional prediction model passes the comparison verification based on the historical stable operating volatility range will the corrected predicted sequence data be officially released and input into the multi-agent decision-making module. This filters out false demand surge signals caused by overfitting due to local fine-tuning, ensuring the stability of subsequent energy flow path allocation calculations.

[0170] Specifically, the global parameter aggregation algorithm described in this step uses the Federated Averaging algorithm, and the weighted average calculation formula for the global model parameters is as follows: in, The total number of building nodes participating in the aggregation. For the first The number of local training dataset samples for each node. The total number of samples across all nodes. For the first The local model weight update values ​​for each node. These are the aggregated global model parameters. This weighted averaging mechanism ensures that core nodes with large amounts of data receive a reasonable contribution weight in the global model evolution.

[0171] S104. Construct a community-wide load status distribution map based on the multidimensional prediction sequence, use a multi-agent reinforcement learning algorithm (MARL) to drive multiple agents to execute local energy allocation decisions, and combine the environmental reward function to adjust the energy flow path in real time to generate a preliminary load balancing configuration scheme.

[0172] For multidimensional prediction data, historical energy usage records and predicted trends for each area within the community are obtained. Through data cleaning and standardization, a structured load status dataset is obtained. Based on this dataset, a visualization tool is used to generate a load status distribution map of the entire community, identifying the distribution patterns of high-load and low-load areas. For the high-load areas identified in the distribution map, a multi-agent system is deployed. A multi-agent reinforcement learning algorithm drives each agent to acquire real-time local energy consumption data. Based on this local energy consumption data, allocation decisions are made. If the energy consumption of a certain area exceeds a preset threshold, the available energy in nearby low-load areas is determined through collaborative communication among the agents. For the determined available energy, combined with an environmental reward function, an optimized energy flow path is dynamically calculated to obtain a preliminary plan for transferring energy from low-load to high-load areas. Based on this preliminary plan, path adjustments are implemented, and load changes during the energy flow process are monitored in real time. If a new load imbalance is detected, the allocation decision is recalculated, producing an adjusted load balance configuration. By adjusting the load balancing configuration, the overall load distribution map of the community is continuously updated to obtain the latest information on high and low load areas, and the above allocation decision and path adjustment process is executed cyclically.

[0173] In one possible implementation, data cleaning and standardization involves preprocessing the raw energy consumption sequences reported by smart meters in various areas of the community.

[0174] Specifically, the system first identifies and removes abnormal spikes in data caused by equipment malfunctions, such as instantaneous high power readings in an office building during off-peak hours. Then, it interpolates data at different time granularities into a 15-minute interval sequence and normalizes meter readings from different suppliers with varying units, converting them into uniform per-unit values, thus forming a structured load status dataset. Based on this dataset, visualization tools can generate heatmaps showing the distribution of community load status.

[0175] For example, in the diagram, the commercial complex area is consistently dark red, indicating a high-load area; while the residential area is shown as light blue during the nighttime hours, indicating a low-load area. This distribution pattern provides an intuitive spatial basis for subsequent energy dispatching. For the identified high-load areas, a multi-agent system is deployed, consisting of several agents embedded in the regional energy gateway. Each agent makes decisions using a multi-agent reinforcement learning algorithm, whereby the agent interacts with the environment, collecting real-time power, voltage, and temperature data for its region as state input. The core of the algorithm lies in designing a cooperative environmental reward function that considers not only the smoothness of the load in its own region but also, more importantly, its contribution to load balancing in neighboring regions.

[0176] In a preferred embodiment of the present invention, in step S104, the multi-agent reinforcement learning algorithm (MARL) specifically adopts the MADDPG (Multi-Agent Deep Deterministic Policy Gradient) algorithm based on the Actor-Critic architecture. Each agent is configured with an Actor network and a Critic network. The Actor network consists of a fully connected feedforward neural network; its input layer receives local states such as the node's voltage and available energy storage capacity, and its output layer uses an activation function to output continuous power regulation actions. The Critic network is responsible for evaluating the value of these actions.

[0177] Specifically, when adjusting the energy flow path in real time in conjunction with the environmental reward function, the specific calculation formula of the environmental reward function and the principle for setting its weight have been detailed above. The system achieves a veto of grid over-limit collapse accidents by setting the safety penalty factor in the formula.

[0178] For example, when a business area agent senses that its load is about to exceed its limit, it will initiate a collaborative communication request to a residential area agent based on the guidance of the reward function.

[0179] In one embodiment, the collaborative communication process exchanges information on available energy reserves in neighboring areas. Residential agents calculate their dispatchable surplus photovoltaic power, for example, 50 kWh, based on the difference between their current power generation and consumption, and feed this information back. Subsequently, agents in high-load areas dynamically calculate optimized energy flow paths by combining network topology impedance parameters and a reward function. This calculation process evaluates the transmission losses and stability of multiple potential physical lines, selecting the path with the lowest total loss to form a preliminary cross-regional energy support plan. After implementing path adjustments according to this plan, the system continuously monitors load changes along the flow path.

[0180] Understandably, if a residential area experiences a sudden increase in its load due to a sudden surge in electricity demand, causing its original surplus to disappear, the system will immediately detect this new imbalance. At this point, the multi-agent system will re-trigger the allocation decision calculation, possibly by calling on energy from another public energy storage station that still has a surplus, thereby producing an adjusted load balancing configuration and updating the overall load distribution map of the community to drive the next round of optimization cycle.

[0181] Specifically, the multi-agent reinforcement learning algorithm described in this step adopts the multi-agent deep deterministic policy gradient algorithm (MADDPG) based on the Actor-Critic architecture. Each agent corresponding to a building node is configured with an independent Actor network and Critic network.

[0182] The Actor network employs a 3-layer fully connected feedforward neural network. The input layer has a dimension of 10, and the input features are as follows: real-time voltage of the current node, active power, reactive power, state of charge (SOC) of the energy storage battery, available energy storage capacity, average load rate of neighboring nodes, current timestamp, ambient temperature, illuminance, and real-time electricity price. The first hidden layer has 128 neurons, and the second hidden layer has 64 neurons, both using the ReLU activation function. The output layer has a dimension of 2, outputting continuous active and reactive power regulation values. The output layer activation function is the hyperbolic tangent function (Tanh), with an output range of [-1, 1], which is linearly mapped to the actual engineering regulation range [-100kW, 100kW].

[0183] The Critic network employs a 3-layer fully connected feedforward neural network. The input layer is the concatenation of the state vectors and action vectors of all agents. The first hidden layer has 256 neurons, and the second hidden layer has 128 neurons. The activation function for both layers is the Rectified Linear Unit (ReLU). The output layer has a dimension of 1 and outputs the Q-value of the corresponding action combination, which is used to evaluate the long-term benefits of the action.

[0184] The algorithm training hyperparameters are configured as follows: discount factor Soft update coefficient The replay buffer size is 100,000, the batch size is 256, and the maximum number of iterations is 5,000. - A greedy strategy is used for exploration, with an initial exploration rate of... The decay rate per iteration is 0.9995, and the minimum exploration rate is 0.01.

[0185] S105. Extract the operating data of key nodes from the preliminary load balancing configuration scheme, determine whether there is a risk of demand surge, and if so, realize state sharing among intelligent agents through peer-to-peer (P2P) information interaction protocol, introduce a real-time feedback compensation mechanism to correct prediction deviation, and calculate the optimized energy flow control vector.

[0186] The system acquires operational data from key nodes in the load balancing configuration. Historical load records for each node are extracted using data acquisition tools to obtain a detailed dataset of node operational status. A Support Vector Machine (SVM) algorithm is used to classify the extracted node operational status dataset to assess the potential risk of demand surges. If the assessment indicates a demand surge risk, a peer-to-peer interaction protocol is initiated to transmit information between agents, acquiring their current state data and ensuring the integrity of state sharing. Based on the shared state data, load differences between agents are analyzed, and load distribution is dynamically adjusted using a real-time feedback mechanism to obtain a corrected load distribution. For the corrected load distribution, the prediction deviation is calculated, and a compensation mechanism is used to correct the deviation, determining the optimized control parameters. Based on the optimized control parameters, the energy flow control vector is adjusted, and the adjusted vector is transmitted to each key node via a data transmission channel, completing the dynamic optimization of load balancing.

[0187] In one embodiment, operational data of critical nodes is obtained from a load balancing configuration.

[0188] For example, by using data acquisition tools such as sensor networks to extract historical load records of each node in the community energy grid, a detailed dataset containing timestamps, energy consumption, and peak indicators can be obtained, thus providing a basis for subsequent analysis.

[0189] In one embodiment, the extracted node running state dataset is classified using a support vector machine algorithm. Support vector machine is a supervised learning model that separates different categories of data by finding the maximum margin hyperplane. In this process, the dataset is first mapped to a high-dimensional space, and kernel functions such as radial basis functions are used to handle nonlinear problems. Then, the decision boundary is solved by optimizing the Lagrange multipliers.

[0190] For example, in a community energy system, historical load data is labeled as normal and abnormal categories. The algorithm calculates support vectors to determine whether there is a potential risk of a surge in demand. For instance, when the load of a node exceeds 1.5 times the average, the classification result shows that there is a risk, thus triggering further response. This method can effectively identify patterns, avoid overfitting, and adjust parameters through cross-validation to ensure that the classification accuracy reaches more than 90%.

[0191] In one embodiment, if the determination result indicates a risk of a surge in demand, information transmission between intelligent agents is initiated through a peer-to-peer interaction protocol.

[0192] For example, in a multi-agent system, agents such as a regional energy controller use point-to-point communication protocols to exchange status data, obtain current load and available resources, and determine shared integrity.

[0193] In one embodiment, based on state-shared data, the load differences between agents are analyzed, and the load distribution is dynamically adjusted through a real-time feedback mechanism to obtain a corrected load distribution result.

[0194] For example, feedback mechanisms involve negative feedback loops that adjust allocation ratios to balance disparities.

[0195] In one embodiment, for the corrected load distribution result, the specific value of the prediction deviation is calculated, the deviation is corrected through a compensation mechanism, and the optimized control parameters are determined.

[0196] For example, the deviation is calculated as the difference between the actual load and the predicted value, and the compensation uses proportional-integral control correction parameters.

[0197] In one embodiment, the control vector for energy flow is adjusted according to the optimized control parameters, and the adjusted vector is sent to each key node through the data transmission channel to complete the dynamic optimization of load balancing, thereby improving system stability.

[0198] Specifically, the demand surge risk assessment described in this step is implemented using a support vector machine (SVM) classification model. The model input features include the node's load sequence over the past hour, load growth rate, load volatility, and historical average load for the same period. The model employs a radial basis function (RBF) kernel function and a penalty coefficient. Kernel function parameters The sample labeling rule is as follows: positive samples are the load growth rate within 15 minutes in historical data. The data consists of surge demand events and negative samples representing normal, stable load data. The model is trained using 5-fold cross-validation, and the required classification accuracy is... The output is a binary classification result indicating whether there is a risk of a surge in demand or not.

[0199] The peer-to-peer information exchange protocol described in this step uses the MQTT-SN communication protocol, with a communication frequency band of Sub-1GHz and a data transmission delay of [missing information]. The interactive state data fields include: node real-time voltage, energy storage state of charge (SOC), available backup capacity, current load rate, and line overload status, ensuring that neighboring intelligent agents can achieve millisecond-level state sharing without going through a cloud server.

[0200] The real-time feedback compensation mechanism described in this step is implemented using incremental PID closed-loop control. The input to the PID controller is the deviation e(t) between the actual load value and the predicted load value, and the output is the compensation correction amount of the energy flow control vector. The calculation formula is as follows: Among them, the proportionality coefficient Integral coefficient Differential coefficients The control cycle is 100ms. This closed-loop control system enables real-time correction of prediction deviations, ensuring the accuracy of the energy flow control vector in dynamic environments.

[0201] S106. The energy flow control vector is mapped to the spatiotemporal distribution pattern of the building group for iterative updates. A communication sparsity algorithm is used to reduce the interaction frequency between nodes, and the interaction priority is adjusted according to the degree centrality or connection weight of the nodes to determine the target load balance distribution state.

[0202] By collecting energy flow data within the building complex, spatiotemporal distribution information for each area is obtained, determining the initial distribution pattern. Based on the acquired spatiotemporal distribution information, a communication sparsity algorithm is used to optimize the number of interactions between nodes, resulting in adjusted interaction frequency data. For the adjusted interaction frequency data, the connection weights of each node are analyzed. If the connection weight of a node is higher than a preset threshold, its interaction order is prioritized, determining an optimized interaction priority list. Control vector data for key nodes is extracted from the optimized interaction priority list and mapped onto the spatiotemporal distribution pattern of the building complex, obtaining updated distribution pattern parameters. For the updated distribution pattern parameters, the load balance status of each area is analyzed. If the load of a certain area exceeds a predetermined range, dynamic allocation is performed by adjusting the control vectors, obtaining corrected load distribution data. Based on the corrected load distribution data, the load change trend of the node centers is analyzed, and the adjusted control vectors are sent to the corresponding nodes through the data transmission channel, determining the final load balance distribution status. Using the final load balance distribution status, the energy flow in each area of ​​the building complex is continuously monitored, acquiring real-time data to support subsequent iterative processing.

[0203] In this embodiment, the communication sparsity algorithm does not simply set a static threshold, but rather achieves deep integration of the communication control layer and the physical topology layer. As a preferred embodiment of the present invention, in step S106, the use of the communication sparsity algorithm to reduce the interaction frequency between nodes specifically includes the following calculation and judgment logic: First, the edge controller continuously calculates the gradient difference before and after the local model update of each building node, and obtains the L1 norm of the gradient difference. Secondly, the system presets a basic sparsity determination threshold. Based on graph topology analysis, the degree centrality of each building node is calculated. (Higher degree centrality indicates that the node has more connecting lines or transformers, and a stronger hub function.) The real-time sparsity threshold of the node is dynamically calculated using the exponential decay formula. : in, The preset attenuation coefficient; Finally, the L1 norm of the gradient difference is compared with the dynamic threshold. Perform a comparison: if the L1 norm is less than If the node's state change is weak, then the outward transmission of parameter updates will be actively intercepted during this communication cycle; only if the L1 norm is greater than or equal to Data interaction between nodes only begins at that time. The physical significance of this design is that for ordinary end building nodes ( Small, Large-scale energy fluctuations are required for communication bandwidth to be used for reporting; however, for core microgrid hub nodes ( big, Even with extremely minor changes in operating conditions, data upload and interaction permissions are prioritized, thereby maximizing the reduction of communication congestion while safeguarding the safe scheduling of core power grid nodes.

[0204] The communication sparsity algorithm described in this invention is implemented through a dynamic threshold mechanism. Its core calculation logic is as follows: A global basic judgment threshold is set to... For any node in the topology of the building cluster Its degree centrality Through formula Calculation, where This represents the number of building nodes directly connected to this node. The total number of buildings in the cluster. The real-time sparsity threshold for this node is defined as: Where the attenuation coefficient The value range is [1.5, 3.0]. This refers to the L1 norm of the gradient updated by the local model. At this point, the controller forces the system into silent mode, skipping the current gradient upload. This mathematical model ensures that the power hub node has a smaller threshold and maintains extremely high communication response sensitivity to any energy fine-tuning.

[0205] In one embodiment, based on the adjusted interaction frequency data, the connection weights of each node are analyzed. If the connection weight of a node is higher than a preset threshold, such as 0.8, its interaction order is prioritized, and an optimized interaction priority list is determined. Control vector data of key nodes are extracted from this list and mapped to a spatiotemporal distribution pattern to obtain updated distribution pattern parameters.

[0206] In one embodiment, based on the updated distribution pattern parameters, the load balance status of each region is analyzed. If the load in a certain region exceeds a predetermined range, dynamic allocation is performed by adjusting the control vector to obtain corrected load distribution data. Based on this data, the load change trend of the node center is analyzed, and the adjusted control vector is sent through the data transmission channel to determine the final load balance distribution status.

[0207] In one embodiment, by continuously monitoring the energy flow through the final load balance distribution status, real-time data is obtained to support iterative processing, thereby improving overall energy efficiency.

[0208] Specifically, in the communication sparsity algorithm described in this step, the edge controller of each building node continuously calculates the gradient difference vector before and after the local model update. And calculate the gradient difference. norm The system presets a basic sparsity threshold. And based on the node degree centrality obtained from the graph topology analysis in step S102. The real-time sparsity threshold for this node is dynamically calculated using the exponential decay formula. The calculation formula is: in, The preset attenuation coefficient has a default value of 0.1, which can be adjusted according to the communication bandwidth. Adjustment within range, node degree centrality This represents the number of directly connected neighboring nodes of this node in the topology graph. The gradient difference is... norm With dynamic threshold Perform a comparison, if If the node's state change is weak, it will be determined that the outward transmission of parameter updates will be actively intercepted within the current communication cycle, only if... Data interaction between nodes only begins at certain times. At the physical execution level, this data interaction interception operation is directly completed by the IoT edge gateway of each building node. The edge gateway has a built-in communication data packet filtering component. When the gateway's main control chip determines that the above interception conditions are met, it directly discards the application layer data frame carrying the local model update gradient at the data link layer of the network protocol, preventing it from entering the community microgrid's public communication bus or wireless channel. This effectively cuts off invalid interactions at the physical medium, allowing all the released underlying bandwidth resources to be allocated to the low-latency control flow of the core hub node.

[0209] The interaction priority adjustment rule described in this step divides nodes into three priority levels based on node degree centrality and connection weight: 1. High priority: node degree centrality or connection weight The core hub node is prioritized for allocating communication bandwidth and controlling the delay of command issuance. 2. Medium priority: Node degree centrality is or connection weight is For ordinary aggregation nodes, the delay in issuing control commands 3. Low priority: End nodes with a degree centrality of 1 or a connection weight < 0.5 will experience delays in issuing control commands. .

[0210] It should be further noted that the communication sparsity algorithm described in this application is a dual-channel collaborative sparsity mechanism. This mechanism, in addition to being applied to the sparsity filtering of local model update gradient uploads in the aforementioned federated learning, is also applied to the instruction delivery channel when cloud or edge nodes send down energy flow control vectors. In the instruction delivery channel, the system calculates the Euclidean distance between the control vectors sent in two consecutive control cycles in real time. When this Euclidean distance is less than the threshold dynamically calculated based on the aforementioned node degree centrality, the edge node maintains the hardware execution state of the previous cycle and suspends instruction interaction and delivery operations in the current cycle, thereby reducing the frequency of inter-node interaction on both uplink and downlink bidirectional communication links.

[0211] S107. Detect whether there is residual imbalance in the target load balance distribution state. If so, redefine the connection state of the building group through the state-action space mapping algorithm, correct the flow path using heuristic search or path planning algorithm, and output the fast balance distribution result.

[0212] Obtain the load distribution status data of the building complex. Calculate the residual imbalance based on the load distribution status data. Determine if the residual imbalance exceeds a preset threshold. If the residual imbalance exceeds the preset threshold, use a state-action space mapping algorithm to generate a new building complex connection state. Based on the new connection state, use a heuristic search algorithm to generate a corrected flow path. Output the fast balanced distribution result based on the corrected flow path.

[0213] Furthermore, based on the rapid balance distribution result or the final balance distribution result, underlying hardware control commands are generated. These commands are then sent to the corresponding building nodes via a gateway, generating standard industrial control protocol messages. Finally, the underlying hardware control commands are physically sent to the corresponding underlying converters, circuit breakers, or relays via an industrial data gateway. This forces the mechanical disconnection or reconfiguration of the distribution network topology circuit breakers and the active / reactive charging and discharging actions of the energy storage devices, thereby completing a substantial transformation of the physical distribution network topology and the physical flow of energy.

[0214] In one embodiment, load distribution status data is first collected through a sensor network deployed in various areas of the building complex.

[0215] For example, real-time monitoring of energy consumption and peak load values ​​for each building unit, including time-series information such as the distribution of electricity demand during peak hours.

[0216] For example, residual imbalance can be calculated based on the collected load distribution data.

[0217] Specifically, the difference between the actual load value and the ideal average load value of each region is summed, and then the absolute value is taken and divided by the total number of regions to obtain the imbalance index.

[0218] For example, if a building complex has 10 zones with a total load of 1000 units and an ideal average of 100 units, but the actual distribution is 120 units in zone 1, 80 units in zone 2, etc., then the residual imbalance is calculated as the average absolute deviation of each difference.

[0219] In one embodiment, it is determined whether the residual imbalance is greater than a preset threshold.

[0220] For example, if the preset threshold is 5 units, and the calculated value is 6 units, then the threshold is exceeded. At this point, the subsequent adjustment mechanism is triggered to ensure that the system response is unbalanced.

[0221] For example, when the residual imbalance exceeds a preset threshold, a state-action space mapping algorithm is used to generate a new building cluster connection state. In a preferred embodiment of the present invention, in step S107, the connection state of the building cluster is redefined using the state-action space mapping algorithm, and the specific implementation process is as follows: Extracting underlying sensor data to construct a state space vector This includes the real-time voltage values ​​of the grid nodes. and the real-time available capacity of energy storage batteries ; Constructing a discrete action space ,in This represents the circuit breaker switch on the microgrid interconnection line, with values ​​including 0 and 1. 0 represents tripping and disconnection, and 1 represents closing and grid connection. The state-action space mapping algorithm specifically employs a pre-trained offline Deep Q-Network (DQN) model or a hard-coded look-up table mechanism to map the continuous state space vectors. The input is given to the model, and the output is the action space corresponding to the maximum Q value. The system generates a new connection topology by combining the switch sequences in the output discrete action sequence. Finally, the system directly issues standard industrial control protocol commands based on the output discrete action sequence to drive the gateway's underlying hardware relays to perform the disconnection or reconfiguration of the physical microgrid, ensuring that the connection state evolves from unbalanced to balanced.

[0222] Before online mapping, the Deep Q-Network (DQN) model needs to be pre-trained offline. The offline training process specifically includes: extracting historical logs of grid overruns or strong power fluctuations during the system's historical operating cycles as the simulation state dataset for offline training; using the objective of restoring each node of the system to steady-state voltage and minimizing the number of switching operations in the action space as the reward function objective for the offline training stage; using an experience replay mechanism to extract historical state transition samples for backpropagation updates of network weights until the Q-value converges, and then fixing the network parameters and deploying them in the gateway.

[0223] In one embodiment, a heuristic search algorithm is used to generate a revised flow path based on the new connection state.

[0224] For example, the algorithm starts with a greedy strategy, searches for neighboring nodes from the starting node, selects the path with the lowest load as the next step, and uses a backtracking mechanism to avoid local optima.

[0225] For example, in a building cluster energy network, the search starts with high-load buildings, prioritizes paths with high connection weights to adjust energy flow, and finally forms an optimized path sequence from source to target.

[0226] For example, output the fast balanced distribution results based on the corrected flow path.

[0227] Specifically, the corrected path is applied to the actual allocation to obtain the balanced load state.

[0228] Specifically, the residual unbalance mentioned in this step is calculated using the following formula: in, For residual unbalance, This represents the total number of nodes in the building complex. For nodes The actual effective value of the voltage. This is the rated voltage of the power grid.

[0229] The state-action space mapping algorithm described in this step is implemented using a Deep Q-Network (DQN). First, the state space vector is constructed by extracting the underlying sensor data: in, For the first Real-time voltage values ​​of each grid node. For the first The real-time state of charge of each energy storage battery is recorded. Subsequently, a discrete action space is constructed: in, This represents the circuit breaker switch on the microgrid interconnection line. The value can only be 0 or 1, where 0 represents tripping and disconnection, and 1 represents closing and grid connection.

[0230] The DQN network employs a three-layer fully connected feedforward neural network, with the input layer dimension matching the state space vector dimension. The first hidden layer has 128 neurons, and the second hidden layer has 64 neurons, both using ReLU activation functions. The output layer dimension matches the number of discrete actions in the action space, outputting the Q-value for each action. To ensure a strict mapping between the deep learning model and the power grid physical topology hardware, the number of input layer neurons in the DQN model is dynamically adapted to the total number of monitored grid nodes in the current distribution network topology. Total number of energy storage devices The sum; the number of output layer neurons is strictly equal to the total number of controllable circuit breaker switches on the microgrid interconnects. The dataset for offline network training consists of event logs from historical system operation cycles, including instances of grid overruns and severe power fluctuations. The training process employs an experience replay mechanism.

[0231] Given the extreme scarcity of over-limit fault samples that seriously endanger system safety in actual high-reliability microgrid operation, making it difficult to meet the convergence requirements of deep reinforcement learning, the offline training dataset further includes simulation log data generated through a physical distribution network digital twin simulation platform. This simulation data is generated by artificially injecting faults to simulate rare operating conditions such as multiple concurrent faults, unexpected network outages, and extreme load surges, thereby expanding the action samples in the extreme state space and ensuring that the model still possesses reliable dimensionality reduction mapping and topology optimization capabilities when facing rare, sudden power grid crises in reality. The experience replay pool size is 10,000, the training batch size is 64, and the discount factor is... The target network is updated every 100 steps, with a maximum of 10,000 iterations. The training reward function aims to restore all nodes of the system to their rated voltage range while minimizing the number of switching operations. The network convergence criteria are: the Q-value of the validation set shows no significant fluctuation for 10 consecutive iterations, the average number of switching operations is ≤3, and the system's steady-state recovery time is ≤100ms.

[0232] During online inference, the real-time acquired state space vector is input into the trained DQN model, outputting the switch combination sequence corresponding to the maximum Q value, directly generating a new building cluster connection topology. Furthermore, to achieve direct linkage between the pure algorithm model and physical power distribution equipment, after outputting the discrete switch combination sequence in the action space, the built-in industrial protocol message conversion module intervenes in real time. This module maps the output discrete action sequence to coil write commands in Modbus-TCP or IEC 61850 standard communication protocol format according to the device logical address bits, and directly triggers the intermediate relay coil of the circuit breaker operating mechanism in the physical power distribution cabinet to be energized or de-energized via industrial Ethernet, thereby completing the mechanical reconstruction action of the underlying physical topology. This process does not involve any human subjective intervention, making this method an automated industrial control method capable of precisely changing the operating state of physical entities. After generating the new building cluster connection topology from the output switch combination sequence, and before the underlying hardware performs the physical reconstruction operation, the system forces a series connection power distribution network topology connectivity physical verification step. By invoking the graph theory spanning tree algorithm to perform connectivity traversal on the expected electrical topology corresponding to the switch combination sequence, if the verification result shows an electrical closed loop network or an isolated node without power support, the issuance of the current control command is directly blocked, a negative penalty value is fed back to the state-action mapping model, and resampling is triggered. This verification mechanism, as a hard constraint, completely eliminates the possibility of physical microgrid short-circuit accidents caused by deep reinforcement learning trial-and-error mechanisms at the system architecture level. After the system verifies that the new building cluster connection topology generated by the above action combination sequence has safe connectivity, the reconstructed physical network connectivity graph will directly serve as the optimization state space for subsequent heuristic search. The system updates the circuit breaker states corresponding to discrete switch actions to the global adjacency matrix in real time. Within this specific connectivity graph, the A* algorithm strictly uses abnormally high-load nodes with residual imbalance as the search starting point and the nearest node with available backup capacity in the network topology as the target node to perform refined optimization of the execution flow path, thereby realizing the serial driving of dimensionality reduction action mapping and accurate path planning. The heuristic search algorithm described in this step preferentially adopts the A* algorithm, and the cost function of path planning is: in, From the starting node to the current node The actual path cost is calculated using line transmission loss and the number of switching operations. To start from the current node The estimated cost to the target node is calculated using the load rate difference between nodes. The algorithm terminates when it finds an energy flow path that satisfies grid security constraints and has the lowest overall cost.

[0233] This invention provides an IoT-based green building energy consumption monitoring and optimization control system, mainly comprising: a data acquisition and feature extraction module, used to collect real-time energy consumption characteristic data of each building through an IoT sensor cluster, construct a local energy consumption prediction model at each building node based on a distributed machine learning architecture, extract the time and frequency domain features of heterogeneous energy consumption data, analyze the energy demand fluctuation patterns of different buildings, and construct a spatiotemporal distribution feature matrix of current energy demand; a topology analysis and privacy exchange module, used to identify the physical topology and logical coupling relationship between building groups based on the spatiotemporal distribution feature matrix using a graph topology analysis algorithm, and use a privacy-preserving parameter exchange mechanism to transmit only the model gradient or weight update values, and obtain a quantitative evaluation vector of energy imbalance by calculating the energy deviation between each node; and a threshold judgment and aggregation optimization module, used to determine whether the quantitative evaluation vector exceeds a preset threshold. If it exceeds the threshold, the module integrates the parameter updates of each node through a global parameter aggregation algorithm, and optimizes the model weights of specific building nodes by combining a local fine-tuning strategy, generating a multidimensional prediction sequence of demand fluctuations. The load status and allocation decision module is used to construct a community-wide load status distribution map based on the multi-dimensional prediction sequence. It employs a multi-agent reinforcement learning (MARL) algorithm to drive multiple agents to execute local energy allocation decisions, and uses an environmental reward function to adjust energy flow paths in real time, generating a preliminary load balancing configuration scheme. The risk detection and compensation correction module extracts operational data from key nodes in the preliminary load balancing configuration scheme to determine if there is a risk of demand surge. If so, it achieves state sharing among agents through a peer-to-peer (P2P) information exchange protocol and introduces a real-time feedback compensation mechanism to correct prediction deviations, calculating an optimized energy flow control vector. The iterative update and priority adjustment module maps the energy flow control vector to the spatiotemporal distribution pattern of the building cluster for iterative updates. It uses a communication sparsity algorithm to reduce the interaction frequency between nodes and adjusts the interaction priority based on node degree centrality or connection weight to determine the target load balancing distribution state. The residual detection and path correction module is used to detect whether there is residual imbalance in the target load balance distribution state. If so, the connection state of the building group is redefined through the state-action space mapping algorithm, and the flow path is corrected by heuristic search or path planning algorithm to output a fast balance distribution result.

[0234] It is important to emphasize that there are inseparable synergistic effects among the core steps described above in this invention. Specifically, the logical coupling relationships between nodes and the node degree centrality index obtained through graph topology analysis in step S102 are directly coupled into the communication sparsity algorithm in step S106 as prior knowledge; when performing communication sparsity filtering, for hub nodes with degree centrality higher than the predetermined standard, the system dynamically sets their corresponding sparsity judgment threshold. The system reduces latency. This collaborative mechanism enables the system to significantly reduce invalid communication at network edge nodes and save channel bandwidth through sparsification, while precisely preserving the absolute low-latency interaction of energy flow control signals at core hub nodes. This breaks the technical barrier in traditional microgrid communication where "control response speed and communication system overhead are mutually exclusive."

[0235] As a further preferred embodiment of the method flow of the present invention, in order to clarify the physical correspondence between the technical means and the achieved effect, all preset evaluation thresholds, preset fluctuation ranges, and preset balance thresholds involved in the method are not set statically by humans, but are dynamically determined through adaptive setting rules. Specifically, the system extracts the steady-state energy consumption baseline data of a complete operating cycle in the past and calculates the mathematical expectation of the baseline data. and standard deviation And strictly define the boundaries of the aforementioned preset thresholds and ranges within Within the confidence interval; further, after outputting the fast balance distribution result or calculating the optimized energy flow control vector, the system generates the underlying standard industrial control protocol command based on the above distribution result or control vector, and sends the command to the corresponding building node through the gateway, directly controlling and adjusting the charging and discharging power of the energy storage device, the start and stop status of the flexible load, or the on / off status of the microgrid interconnection switch inside the corresponding building node, thereby completing the energy dispatch execution process in the physical space.

[0236] Example 5: Hardware Control Coordination Based on Hierarchical Adjustment To further overcome the problem of slow load distribution response in existing technologies, this embodiment discloses a dual-closed-loop cooperative control logic. The first-level loop performs global continuous power distribution decisions using the aforementioned MADDPG algorithm; when a residual imbalance exceeds the limit, a second-level emergency reconfiguration mechanism is triggered. Under this mechanism, the system uses a pre-trained DQN model to map continuous state feature vectors into discrete action combinations containing the opening and closing states of microgrid interconnection switches. ,in The gateway, based on the discrete action combinations output, sends hexadecimal control messages to the underlying PLC or relays via the standard Modbus-TCP protocol, forcibly executing the disconnection or reconfiguration of the physical microgrid, thereby achieving millisecond-level rapid balancing control. This hierarchical regulation strategy combines... The adaptive threshold determination of the confidence interval ensures the robustness and real-time performance of the system when dealing with the risk of a surge in demand.

[0237] This invention also discloses an IoT-based method for monitoring and optimizing energy consumption in green buildings. The method collects real-time energy consumption characteristic data of each building through an IoT sensor cluster, extracts the time and frequency domain features of this data, and inputs these features into a local energy consumption prediction model built on each building node using a distributed machine learning architecture. This model analyzes the energy demand fluctuation patterns of different buildings and constructs a spatiotemporal distribution feature matrix of current energy demand. Based on this spatiotemporal distribution feature matrix, a graph topology analysis algorithm is used to identify the physical topology and logical coupling relationships between building clusters, generating a building cluster adjacency matrix. A privacy-preserving parameter exchange mechanism is used to transmit only model gradients or weight update values ​​for global model aggregation and updating. Based on the updated model, the energy consumption prediction values ​​for each building node are output. Based on these energy consumption prediction values, the energy deviation between each node is calculated to obtain a quantitative assessment vector of energy imbalance. If the quantitative evaluation vector exceeds a preset evaluation threshold, a global parameter aggregation algorithm is used to integrate the parameter updates of each node, and a local fine-tuning strategy is combined to optimize the model weights of specific building nodes, generating a multi-dimensional prediction sequence for demand fluctuations. If the threshold is not exceeded, the current model parameters of each building node are maintained, and a regular prediction sequence is generated based on the local energy consumption prediction model as the multi-dimensional prediction sequence. A community-wide load status distribution map is constructed based on the multi-dimensional prediction sequence. A multi-agent reinforcement learning algorithm based on the MADDPG architecture is used to drive multiple agents to execute local energy allocation decisions. The energy flow path is adjusted in real time using an environmental reward function to generate a preliminary load balancing configuration scheme. Operational data of key nodes is extracted from the preliminary load balancing configuration scheme to determine if there is a risk of demand surge. If so, state sharing among agents is achieved through a peer-to-peer information interaction protocol, and a real-time feedback compensation mechanism is introduced to correct prediction deviations. An optimized energy flow control vector is calculated. If not, the control vector corresponding to the preliminary load balancing configuration scheme is directly used as the energy flow control vector. The energy flow control vector is mapped to the spatiotemporal distribution feature matrix for iterative updates. A communication sparsity algorithm is used to reduce the interaction frequency between nodes, and the interaction priority is adjusted according to the node degree centrality or connection weight to determine the target load balance distribution state.The system detects whether there is a residual imbalance in the target load balance distribution state that is greater than a preset balance threshold. If it is, the connection state of the building group is redefined using a state-action space mapping algorithm, and the flow path is corrected using a heuristic search or path planning algorithm to output a fast balance distribution result. If it is not greater, the target load balance distribution state is output as the final balance distribution result. Further, based on the final balance distribution result or the fast balance distribution result, the system generates underlying hardware control commands and sends the commands to the corresponding building nodes through a protocol gateway to drive the corresponding energy storage devices to perform charging and discharging power regulation or drive the physical distribution network interconnection switches to perform opening and closing operations, thus completing the physical layer energy flow closed-loop control.

[0238] The above description of the embodiments is only for the purpose of helping to understand the technical solutions and core ideas of this application; those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A method for monitoring and optimizing energy consumption in green buildings based on the Internet of Things, characterized in that, The method includes: S101. Collect real-time energy consumption characteristic data of each building through an IoT sensor cluster. The real-time energy consumption characteristic data is heterogeneous energy consumption data. Extract the time and frequency domain features of the real-time energy consumption characteristic data and input the extracted features into a local energy consumption prediction model built on each building node based on a distributed machine learning architecture. Analyze the energy demand fluctuation pattern of different buildings and construct the spatiotemporal distribution feature matrix of the current energy demand. S102. Based on the spatiotemporal distribution feature matrix, a graph topology analysis algorithm is used to identify the physical topology and logical coupling relationship between building groups. A privacy-preserving parameter exchange mechanism is used to transmit only the model gradient or weight update value for global model aggregation and update. Based on the updated model, the energy consumption prediction value of each building node is output. Based on the energy consumption prediction value, the energy deviation between each node is calculated to obtain a quantitative evaluation vector of energy imbalance.

2. The method according to claim 1, characterized in that, Also includes: S103. Determine whether the quantized evaluation vector exceeds a preset evaluation threshold. If it does, integrate the parameter updates of each node through a global parameter aggregation algorithm, and optimize the model weights of specific building nodes by combining a local fine-tuning strategy to generate a multi-dimensional prediction sequence of demand fluctuations. If it does not exceed the threshold, maintain the current model parameters of each building node, and generate a regular prediction sequence based on the local energy consumption prediction model as the multi-dimensional prediction sequence. S104. Construct a community-wide load status distribution map based on the multidimensional prediction sequence, use a multi-agent reinforcement learning algorithm (MARL) to drive multiple agents to execute local energy allocation decisions, and combine the environmental reward function to adjust the energy flow path in real time to generate a preliminary load balancing configuration scheme.

3. The method according to claim 2, characterized in that, Also includes: S105. Extract the operating data of key nodes from the preliminary load balancing configuration scheme, determine whether there is a risk of demand surge, if so, realize state sharing among intelligent agents through peer-to-peer (P2P) information interaction protocol, and introduce a real-time feedback compensation mechanism to correct prediction deviation, and calculate the optimized energy flow control vector; if not, extract the expected output setpoint and action command of each node device from the preliminary load balancing configuration scheme to form a preliminary control vector, and use the preliminary control vector directly as the energy flow control vector. S106. The energy flow control vector is mapped to the spatiotemporal distribution feature matrix for iterative updates. A communication sparsity algorithm is used to reduce the interaction frequency between nodes, and the interaction priority is adjusted according to the node degree centrality or connection weight to determine the target load balance distribution state. S107. Detect whether there is a residual imbalance in the target load balance distribution state that is greater than a preset balance threshold. If it is greater, redefine the connection state of the building group through the state-action space mapping algorithm, correct the flow path using heuristic search or path planning algorithm, and output a fast balance distribution result. If it is not greater, output the target load balance distribution state as the final balance distribution result.

4. The method according to claim 1, characterized in that, S101 includes: Real-time energy consumption characteristic data is obtained from the distribution of various building nodes through an IoT sensor cluster and stored as an initial energy consumption dataset. Based on the initial energy consumption dataset, a distributed machine learning architecture is used to build local prediction models on the distribution of each building node to obtain the energy consumption prediction results for each node. For the obtained initial energy consumption dataset, directly extract the time domain features and frequency domain features from the real-time heterogeneous energy consumption data, and combine them to form a feature vector set; Calculate the load fluctuation range or load rate standard deviation of the feature vector set within a set time window to quantify the energy demand fluctuation status in the feature vector set; if the quantified energy demand fluctuation status exceeds a preset threshold, mark the corresponding building energy demand to determine the abnormal fluctuation area. By mapping the spatiotemporal distribution feature matrix of the abnormal fluctuation area, the corresponding building node distribution location is obtained, and potential energy consumption anomalies are identified. Based on energy consumption anomalies and the output of local prediction models, the parameter configuration in the distributed machine learning architecture is adjusted to obtain optimized energy consumption prediction results.

5. The method according to claim 1, characterized in that, S102 includes: Obtain the spatiotemporal distribution feature matrix of the building complex; A graph topology analysis algorithm is used to process the spatiotemporal distribution feature matrix, identify the physical connections and logical coupling relationships between building cluster nodes, and generate a building cluster relationship topology graph. The node set is determined based on the topology of the building group relationship, and a privacy-preserving parameter exchange channel is established between the node sets; The model gradient values ​​and weight update values ​​of each node are transmitted through a privacy-preserving parameter exchange channel; A preset energy calculation model is used to process the model gradient value and weight update value, and to calculate the energy deviation between any two nodes in the node set. By summing the energy deviations of all node pairs, a quantitative assessment vector of energy imbalance is obtained.

6. The method according to claim 2, characterized in that, S103 includes: By analyzing the quantitative evaluation results, the evaluation vector data of each node is obtained, and it is determined whether it exceeds the preset threshold, thus obtaining the preliminary anomaly judgment result. If the judgment result shows that the evaluation vector exceeds the preset threshold, the global parameter aggregation algorithm is used to integrate the parameter updates of each node and generate a unified global parameter set. Based on the integrated global parameter set, the operational status of specific building nodes is analyzed to obtain their local feature data and determine the applicable scope of local fine-tuning. The model weights of specific building nodes are adjusted using a local fine-tuning strategy to generate optimized weight configuration data. Based on the optimized weight configuration data, a multidimensional prediction model is constructed to obtain the predicted sequence output for demand fluctuations; After obtaining the multidimensional prediction sequence, data verification is performed on the fluctuation characteristics of the prediction sequence to determine whether it conforms to the preset fluctuation range, and the final prediction result is obtained. If the prediction results show that the fluctuation characteristics exceed the preset range, the parameters of the multidimensional prediction model are slightly adjusted to generate corrected prediction sequence data.

7. A green building energy consumption monitoring and optimization control system based on the Internet of Things, characterized in that, The system includes: The data acquisition and feature extraction module is used to collect real-time energy consumption feature data of each building through an IoT sensor cluster. The real-time energy consumption feature data is heterogeneous energy consumption data. The module extracts the time and frequency domain features of the real-time energy consumption feature data and inputs the extracted features into a local energy consumption prediction model built on each building node based on a distributed machine learning architecture. The module analyzes the energy demand fluctuation pattern of different buildings and constructs a spatiotemporal distribution feature matrix of the current energy demand. The topology analysis and privacy exchange module is used to identify the physical topology and logical coupling relationship between building groups based on the spatiotemporal distribution feature matrix using a graph topology analysis algorithm, and to transmit only the model gradient or weight update value using a privacy-preserving parameter exchange mechanism. By calculating the energy deviation between each node, a quantitative evaluation vector of energy imbalance is obtained.

8. The system according to claim 7, characterized in that, Also includes: The threshold judgment and aggregation optimization module is used to determine whether the quantized evaluation vector exceeds a preset evaluation threshold. If it exceeds the threshold, the module integrates the parameter updates of each node through a global parameter aggregation algorithm and optimizes the model weights of specific building nodes by combining a local fine-tuning strategy to generate a multi-dimensional prediction sequence of demand fluctuations. If the threshold is not exceeded, the module maintains the current model parameters of each building node and generates a regular prediction sequence based on the local energy consumption prediction model as the multi-dimensional prediction sequence. The load status and allocation decision module is used to construct a community-wide load status distribution map based on the multidimensional prediction sequence, drive multiple agents to perform local energy allocation decisions using a multi-agent reinforcement learning algorithm (MARL), and adjust the energy flow path in real time in conjunction with the environmental reward function to generate a preliminary load balancing configuration scheme.

9. The system according to claim 8, characterized in that, Also includes: The risk detection and compensation correction module is used to extract the operating data of key nodes from the preliminary load balancing configuration scheme, determine whether there is a risk of demand surge, and if so, realize state sharing among intelligent agents through peer-to-peer (P2P) information interaction protocol, introduce a real-time feedback compensation mechanism to correct prediction deviation, and calculate an optimized energy flow control vector; if not, the control vector corresponding to the preliminary load balancing configuration scheme is directly used as the energy flow control vector. The iterative update and priority adjustment module is used to map the energy flow control vector to the spatiotemporal distribution feature matrix for iterative update, use a communication sparsity algorithm to reduce the interaction frequency between nodes, and adjust the interaction priority according to the node degree centrality or connection weight to determine the target load balance distribution state. The residual detection and path correction module is used to detect whether there is a residual imbalance in the target load balance distribution state that is greater than a preset balance threshold. If it is greater, the connection state of the building group is redefined through the state-action space mapping algorithm, and the flow path is corrected by heuristic search or path planning algorithm to output a fast balance distribution result. If it is not greater, the target load balance distribution state is output as the final balance distribution result.

10. An electronic device, comprising: A processor, a memory, and a program stored in the memory and executable on the processor, characterized in that, when executed by the processor, the program implements the method as described in any one of claims 1 to 6.