An energy optimization management method applied to smart microgrid
By classifying and task allocation of devices in the smart microgrid, load balancing of computing resources is achieved, the problem of inconsistent response speed caused by heterogeneous devices is solved, and the efficiency of energy management is improved.
Patent Information
- Application Number
- CN202410936677.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-07-12
AI Technical Summary
In smart microgrids, due to the heterogeneity between different smart meters, the computing resource allocation is uneven, resulting in inefficient equipment processing, resulting in waste of resources and excessive waiting time.
Through device classification, task unloading and redistribution methods, a calculation task allocation plan is established to ensure that the calculation time of strong and weak devices approaches the calculation time of medium devices, realize load balancing, and local training and modeling are carried out through homomorphic encryption technology transmission.
It shortens the computing time of the overall equipment, improves the computing efficiency of energy management, solves the problem of inconsistent response speeds between equipment, and speeds up the global computing speed of the microgrid.
Smart Images

Figure CN118508431B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of energy optimization management, and specifically discloses an energy optimization management method applied to a smart microgrid. Background Art
[0002] The basic components of the power grid, or power system, are power supply, transmission network and load. Among them, microgrid is a power generation solution. The power supply of microgrid is small photovoltaic, small wind power and energy storage, and the transmission network is low voltage. There are multiple microgrids in a smart city environment. Each microgrid consists of a different number of smart homes, and each home is equipped with smart meters and a variety of energy consumption devices.
[0003] The existing smart microgrid has introduced a federated learning architecture to control the microgrid to improve energy efficiency. Under the federated learning architecture, smart meters are used as data sources, and data preprocessing is performed on various data sources to jointly establish a learning model. Therefore, the microgrid can autonomously adjust and manage according to the demand of power load, and can operate independently from the main grid.
[0004] In a federated learning architecture, it usually includes a central server and multiple clients. The central server stores the global control variables and global model parameters obtained by federated learning in each iteration.
[0005] In the existing technology, different smart meters (hereinafter referred to as devices) are heterogeneous, and the data processing capabilities of different devices are different. When applied in the federated learning architecture, the heterogeneity of devices often leads to uneven allocation of computing resources and low device processing efficiency, which can be specifically classified as:
[0006] (1) Waste of training resources: Due to the heterogeneity between different devices used in the microgrid, that is, different smart meters have different computing capabilities. When performing computing tasks with the same computing power, devices with strong computing capabilities have fast computing speeds, while devices with weak computing capabilities have relatively slow computing speeds. There is a time difference. Within this difference range, smart meters with stronger capabilities will no longer perform tasks, resulting in a waste of computing resources.
[0007] (2) Long waiting time: Due to the inconsistency in the speed of task processing between devices with different computing powers, when a device with strong computing power completes its task, the smart microgrid as a whole still needs to wait for the devices with weak computing power to complete their tasks before it can complete all calculations, which affects the implementation of decisions and energy allocation in the smart microgrid.
[0008] In view of this, the inventor provides an energy optimization management method applied to a smart microgrid to solve the above problems. Summary of the invention
[0009] The purpose of the present invention is to solve the problem of inconsistent response speeds among devices in the global response process of the smart microgrid due to heterogeneous differences among different devices in the smart microgrid in the traditional smart microgrid management system using a federated learning architecture.
[0010] In order to achieve the above object, the basic scheme of the present invention provides an energy optimization management method applied to a smart microgrid, comprising the following steps:
[0011] Step A1: Each device collects local energy usage data and performs local model training;
[0012] Step A2: The local model predicts the energy demand of the household and sends it to the central server for aggregation regularly to obtain and update the global model;
[0013] Step A3: Decentralize the updated global model to each device and update the local model, then use the local model to build an energy optimization model and output the energy optimization allocation plan to the central server;
[0014] Step A4: The central server updates the energy flow management strategy according to the optimal energy allocation plan, and implements energy allocation in the microgrid according to the energy flow management strategy;
[0015] In the process of implementing steps A1 to A4, the devices in the microgrid are also equipped with a computing task allocation method according to the following steps:
[0016] Step S1: Classify the devices, divide them into different device type sets and different device clusters according to their types, divide the devices in each device type set into three performance categories according to their computing capabilities: weak devices, medium devices and strong devices, and respectively establish a weak device set, a medium device set and a strong device set belonging to the same device cluster;
[0017] Step S2: Decompose the data of each device to obtain the data volume of the output feature map of each layer of the neural network, and calculate the communication cost of each layer of the neural network according to the data volume;
[0018] Step S3: Identify and divide the normal-cost communication layer and the high-cost communication layer;
[0019] Step S4: determining the optimal task offloading point in the neural network according to the relative ratio of the normal cost communication layer and the high cost communication layer;
[0020] Step S5: Based on the optimal task offloading point of each device, task offloading and task redistribution between strong devices and weak devices belonging to the same device type cluster are performed, so that the computing time of strong devices and weak devices approaches the computing time of medium devices and load balance is achieved.
[0021] Further, in step S1, a mapping function τ(d i ) is used to set the device i Mapped to the performance category to which it belongs, and establish an exponential function δ as the basis for classifying the device into its device cluster. The expression of the exponential function δ is:
[0022] ;
[0023] In the formula, Represents a collection of device types. , S represents a strong device set, U represents a medium device set, and W represents a weak device set;
[0024] Device Cluster It is expressed as:
[0025] .
[0026] Furthermore, in step S3, taking the skewness and kurtosis of the communication cost as a reference, a threshold is established based on the skewness and kurtosis of the communication cost to distinguish between the normal-cost communication layer and the high-cost communication layer.
[0027] Furthermore, in step S3, a multi-parameter function is established based on the skewness, kurtosis and threshold of the communication cost to determine whether the communication cost of the calculated layer lifting network exceeds the threshold, and the neural network layers exceeding the threshold are grouped in a high-cost communication layer set.
[0028] Further, the implementation of step S4 specifically includes the following steps:
[0029] Step S401: Calculate the composite information entropy of each layer of the neural network belonging to the high-cost communication layer;
[0030] Step S402: Determine a selection criterion for the best task unloading point based on the calculated composite information entropy, and select the best task unloading point.
[0031] Further, in step S402, based on the calculated composite information entropy H l Establish a multi-dimensional evaluation function Ω l As the selection benchmark for the best task unloading point, the multi-dimensional evaluation function Ω l The expression is as follows:
[0032] ,
[0033] In the formula, σ T It is T l The standard deviation of l and H jThey represent the composite information entropy of the lth and jth layers of the neural network respectively, and Λ represents the set of neural network layers with high cost communication layers;
[0034] T l Represents the overall characteristics of each layer of the neural network, which is calculated by the composite information entropy and its first-order derivative. The expression is as follows:
[0035] ;
[0036] The optimal task unloading point is selected by maximizing the multi-dimensional evaluation function. The expression of maximizing the multi-dimensional evaluation function is as follows:
[0037] ;
[0038] Where Λ represents the set of neural network layers with high cost communication layers.
[0039] Furthermore, in step S5, during the inter-cluster unloading process of the intra-cluster device, three constraints are introduced to ensure complete unloading of the task, including:
[0040] Constraint 1: Ensure that the workload of each weak device must be fully allocated to the strong device. The expression of constraint function 1 is ;
[0041] In the formula, S represents the set of strong devices, x ij Indicates that from the weak device w i To strong equipments i The amount of assigned tasks, P i Indicates weak device w i The amount of parameters that need to be uninstalled;
[0042] Constraint 2: Ensure that the total amount of tasks assigned to each strong device does not exceed its processing capacity. The expression of constraint function 2 is ,
[0043] Where W represents the weak device set, c j Indicates strong devices j processing capabilities;
[0044] Constraint three: Ensure that the assigned task volume cannot be negative and that all tasks are processed positively. The expression of constraint function three is .
[0045] Further, the implementation of step S5 includes the following steps:
[0046] Step S501: quantify and calculate the parameter unloading amount of the optimal task allocation point;
[0047] Step S502: based on the parameter offloading amount of each device, the parameter amount that each device can accommodate, and the maximum load amount for the strong device, the device clusters are paired to match the weak devices and strong devices that offload tasks and receive tasks from each other.
[0048] The principle and effect of this scheme are:
[0049] 1. Compared with the prior art, the present invention establishes a computing task allocation method during the local model training process of the local device to achieve task unloading and redistribution between local devices in the microgrid, so that the operation processing time of each device tends to be consistent, the computing load between the devices is balanced, and resource compensation is achieved. In this way, the computing time of the entire device is shortened, the overall response time of the microgrid is shortened, and the energy management computing efficiency is improved. This solves the problem of inconsistent response speeds between devices in the smart microgrid during the global response process in the traditional smart microgrid management system that uses a federated learning architecture due to the heterogeneous differences between different devices in the smart microgrid.
[0050] 2. Compared with the prior art, the present invention can also independently divide heterogeneous devices according to different types of devices, and perform task unloading and allocation processes for devices of the same type. It realizes real-time dynamic resource adjustment for heterogeneous devices in the microgrid, speeds up the global computing speed in the microgrid, and unifies and coordinates the computing time of different types of heterogeneous devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0052] Figure 1 A flow chart of an energy optimization management method applied to a smart microgrid proposed in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0053] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation mode, structure, characteristics and effects of the present invention are described in detail below in combination with the accompanying drawings and preferred embodiments.
[0054] An energy optimization management method applied to a smart microgrid, the embodiments of which are as follows:
[0055] To better describe the solution of this embodiment, a brief description is now given of the smart meter carried by the smart home in the smart microgrid in the prior art:
[0056] In the existing technology, the smart meter in each smart home collects local energy usage data, including power consumption, usage of household appliances, etc., and a lightweight neural network model is deployed in the smart meter. The neural network model can predict the energy demand of the smart home and participate in the global energy optimization in federated learning.
[0057] In the existing smart grid, the initial model parameters in each smart meter are uniformly configured by the central server. And in this embodiment, the smart meter deployed in each smart home is collectively referred to as a device.
[0058] In this embodiment, in the microgrid operation process, each microgrid m i Each runs its own local model θ i , and based on its own local data D i After running for a certain period of time, the local model updates of each microgrid are sent to the central server for aggregation and updating of the global model, and further energy management and optimization are carried out based on the updated global model.
[0059] Specifically, the local model θ i Self-training produces new local models , the self-training process is expressed as: ,
[0060] In the formula, represents the gradient of the local loss function, x ij represents the input data of the jth data sample in the i-th microgrid, y ij represents the actual output of the jth data sample in the ith microgrid, R represents the regularization term to prevent overfitting, and α and β represent the learning rate and regularization parameters, respectively.
[0061] After running for a certain period of time, the local model updates of each microgrid are sent to the central server to be aggregated into a global model θ global , the aggregation process is expressed as: ,
[0062] Where M represents the total number of microgrids.
[0063] During the operation of the microgrid, the principle of allocating energy according to energy demand is implemented. Energy allocation mainly includes the following steps:
[0064] Step A1: The neural network model installed in the device collects local energy usage data for local model training;
[0065] Step A2: The local model in the device predicts the energy demand of the household, and regularly sends the local model to the central server for aggregation to obtain and update the global model;
[0066] Step A3: The central server distributes the updated global model to each device in the microgrid, and updates the local model accordingly, performs energy optimization by the updated local model, and establishes an energy optimization allocation plan for transmission to the central server;
[0067] Step A4: The central server updates the energy flow management strategy according to the optimal energy allocation plan, and implements energy allocation in the microgrid according to the energy flow management strategy.
[0068] In the process of self-training of the local model, since the smart meters deployed in each household in the microgrid are different, that is, the deployed devices are different, in the same microgrid, due to the different computing capabilities between multiple heterogeneous devices, the energy optimization model establishment speed and energy optimization model solution speed between heterogeneous devices will be different, and the model update speed will be inconsistent, which will lead to the problem of slow implementation of decision-making and energy allocation in the microgrid. In view of the above problems, the present invention establishes a task allocation method for devices, and the task allocation method includes the following steps:
[0069] Step S1: Set the devices in the microgrid to i Classify and categorize the equipment i Divide into different device type sets according to different device types , group each device type The devices in the system are divided into three performance categories according to their computing capabilities. The three performance categories are weak devices w n , medium equipment and strong equipments m , and establish a weak device set W, a medium device set U and a strong device set S belonging to the same device cluster respectively.
[0070] Specifically, in this embodiment, a device d is also established. i Collection , . And establish a mapping function τ(d i ) is used to transfer the device (d i ) is mapped to the performance category to which it belongs, and the mapping function τ(d i ) is as follows:
[0071] ;
[0072] In the formula, p i Indicates device d i Performance index, T strong 、T mediumThese are the performance thresholds for classifying devices into the “strong device” and “medium device” categories, respectively.
[0073] Based on the mapping function τ(d i ) An exponential function δ is established as the basis for classifying devices into their respective device clusters. The expression of the exponential function δ is:
[0074] ;
[0075] For each device type set , , defines a device cluster that has devices of this type , device cluster is defined as:
[0076] ;
[0077] And the same device type set The number of devices in is expressed as follows:
[0078] ;
[0079] In the formula, The values are S,U,W.
[0080] Step S2: Set each device d i The data constructed under the federated learning architecture is decomposed to obtain the data volume of the output feature map of each layer of the neural network, and the communication cost of each layer of the neural network is calculated based on the data volume.
[0081] Specifically, for a neural network with L layers, the data volume of the output feature map of each layer of the neural network is first calculated. For the lth layer of the neural network, the data volume V of the output feature map is calculated as follows: l :
[0082] ;
[0083] In the formula, S l Represents the step size of the l-th layer of the neural network, which affects the size of the output feature map;
[0084] D l Represents the depth of the output feature map of the l-th layer neural network;
[0085] H k ,W k Respectively represent the height and width of the input feature map of the k-th layer neural network;
[0086] d k represents the sparsity parameter of the k-th layer neural network, which represents the proportion of non-zero elements in the input data;
[0087] γ k The data expansion factor related to the k-th layer of the neural network represents the rate of change of the amount of data during the processing of this layer of the neural network;
[0088] ζ k Represents the compression ratio of the k-th layer of the neural network, which is used to consider the impact of data compression techniques such as pooling on the amount of data;
[0089] ξ l The data normalization factor of the l-th layer neural network is used to adjust the data volume changes caused by batch processing or parallel processing;
[0090] b indicates the bit width of the data type;
[0091] Indicates rounding down. It means rounding upwards, and Π means the multiplication symbol, which means performing multiplication operations on expressions within a given range.
[0092] For the l-th layer of the neural network, its communication cost C l The calculation is as follows:
[0093] ;
[0094] Where R represents the network bandwidth and is measured in bits per second (bps);
[0095] λ, α, and β all represent adjustment parameters and are used to adjust the nonlinear effect of data volume on communication time;
[0096] Ψ(ρ,ω) represents a complex function of the network fixed delay ρ and the network variable parameter ω, where the network fixed delay ρ is a constant determined by the network environment;
[0097] Θ(μ,σ 2 ) represents the average μ and variance σ of network congestion 2 The probability density function of , specifically represents the cost affecting the total communication.
[0098] The specific expression of Ψ(ρ,ω) is:
[0099] ;
[0100] Θ(μ,σ 2 ) The specific expression is:
[0101] .
[0102] Step S3: Identify and divide the normal cost communication layer and the high cost communication layer. Specifically, the skewness S of the communication cost is used. C and kurtosis KC The normal-cost communication layer and the high-cost communication layer are distinguished as a benchmark.
[0103] Among them, the skewness S of the communication cost C The expression is as follows:
[0104] ,
[0105] The kurtosis K of the communication cost C The expression is as follows:
[0106] ;
[0107] In the formula, N represents the number of layers of the neural network. C l The average value, σ C C l The standard deviation of .
[0108] Based on the skewness S C and kurtosis K C The calculation result of is used to set a threshold value θ for distinguishing the normal cost communication layer from the high cost communication layer. The expression of the threshold value θ is:
[0109] ;
[0110] In the formula, f(S C ,K C ) is a function that aims to dynamically adjust the multiple of the standard deviation through skewness and kurtosis. The expression is:
[0111] ;
[0112] Function f(S C ,K C ) specifically refers to adjusting the threshold according to the absolute values of the skewness and kurtosis of the communication cost, thereby reflecting the sensitivity of the skewness and kurtosis of the communication cost to the data distribution.
[0113] In this embodiment, a multi-parameter function Φ is provided based on the obtained skewness and kurtosis thresholds to determine the high-cost communication layer and the normal-cost communication layer. The expression of the multi-parameter function Φ is:
[0114] ;
[0115] The multi-parameter function Φ is a nonlinear function. It combines skewness, kurtosis, and threshold to determine whether the communication cost of the calculated neural network layer exceeds the dynamically calculated threshold θ, and collects the neural network layers that exceed the threshold into the high-cost communication layer set Λ. The expression of Λ is as follows:
[0116] .
[0117] Step S4: Determine the optimal task offloading point in the neural network according to the relative ratio of the normal cost communication layer and the high cost communication layer.
[0118] Specifically, the steps include:
[0119] Step S401: Calculate the composite information entropy of each neural network layer belonging to the high-cost communication layer. For each neural network layer l in the identified high-cost communication layer set Λ, its composite information entropy H l The expression is as follows:
[0120] ;
[0121] In the formula, p k The expression is: , represents the relative ratio of the communication cost of the k-th layer neural network to the communication cost of the j-th layer neural network;
[0122] q k The expression is: , represents the relative ratio of the k-th layer calculation density to the j-th layer calculation density;
[0123] r k The expression is: It represents the relative ratio of the k-th layer data dependency to the j-th layer data dependency.
[0124] Step S402: Determine a selection criterion for the best task unloading point based on the calculated composite information entropy, and select the best task unloading point.
[0125] In this embodiment, a multi-dimensional evaluation function Ω is established based on the calculated composite information entropy. l , with multi-dimensional evaluation function Ω l As a selection benchmark, the multidimensional evaluation function Ω l The expression is as follows:
[0126] ;
[0127] In the formula, σ T It is T l The standard deviation of l and H j They represent the composite information entropy of the lth and jth layers of the neural network respectively, and Λ represents the set of neural network layers with high cost communication layers;
[0128] T l Represents the overall characteristics of each layer of the neural network, which is calculated by the composite information entropy and its first-order derivative. The expression is as follows:
[0129] ;
[0130] The optimal task unloading point is selected by maximizing the multi-dimensional evaluation function. The expression of maximizing the multi-dimensional evaluation function is as follows:
[0131] .
[0132] In this embodiment, during the implementation of steps S2 to S4, each device independently calculates its own optimal task unloading point.
[0133] Step S5: Perform task offloading and task redistribution between devices belonging to the same device type cluster based on the optimal task offloading point of each device.
[0134] Before performing the inter-cluster unloading process of intra-cluster devices, it is also necessary to quantify and calculate the parameter unloading amount of the optimal task allocation point, that is, the unloaded task amount.
[0135] Specifically, when the optimal task allocation point is determined to be the lth layer in the neural network, the number of parameters of the entire lth layer is calculated, including the calculation of the weight and bias of the communication of the lth layer.
[0136] The calculation formula of the parameter quantity is as follows:
[0137] ;
[0138] Where N l-1 is the number of output features of the l-1th layer, that is, the number of input features of the lth layer; N l is the number of output features of the lth layer; κ l is the adjustment coefficient of the lth layer, which is used to dynamically adjust the number of parameters according to the network bandwidth and device processing capability.
[0139] Furthermore, a dynamic adjustment coefficient κ is introduced l , through κ l More accurately reflects the load and communication cost of different layers, κ l Determined by multiple factors, including communication cost, data sparsity, and computational complexity of the layer, κ l The specific expression is as follows:
[0140] ;
[0141] Where V l represents the data volume of the lth layer of the neural network; λ, α, β represent the impact of adjusting the data volume on the communication time; R represents the network bandwidth; Ψ(ρ, ω) represents the complex function of the network fixed delay and network variable parameters; Θ(μ, σ 2) represents the probability density function of network congestion.
[0142] The final calculation formula for parameter uninstall quantity is as follows:
[0143] ;
[0144] Where N l-1 is the number of output features of the l-1th layer, that is, the number of input features of the lth layer; N l is the number of output features of the lth layer; κ l is the adjustment coefficient of the lth layer, which is used to dynamically adjust the number of parameters according to the network bandwidth and device processing capability.
[0145] Furthermore, a dynamic adjustment coefficient κ is introduced l , through κ l More accurately reflects the load and communication cost of different layers, κ l Determined by multiple factors, including communication cost, data sparsity, and computational complexity of the layer, κ l The specific expression is as follows:
[0146] ;
[0147] Where V l represents the data volume of the lth layer of the neural network; λ, α, β represent the impact of adjusting the data volume on the communication time; R represents the network bandwidth; Ψ(ρ, ω) represents the complex function of the network fixed delay and network variable parameters; Θ(μ, σ 2 ) represents the probability density function of network congestion.
[0148] In this embodiment, during the inter-cluster unloading process of intra-cluster devices, three constraints are introduced to ensure complete unloading of tasks.
[0149] Constraint 1: Ensure that the workload of each weak device must be fully allocated to the strong device. The expression of constraint function 1 is ;
[0150] In the formula, x ij Indicates that from the weak device w i To strong equipments i The amount of assigned tasks, P i Indicates weak device w i The amount of parameters to uninstall.
[0151] Constraint 2: Ensure that the total amount of tasks assigned to each strong device does not exceed its processing capacity. The expression of constraint function 2 is ,
[0152] In the formula, c j Indicates strong devices jprocessing capabilities.
[0153] Constraint three: Ensure that the assigned task volume cannot be negative and that all tasks are processed positively. The expression of constraint function three is .
[0154] Based on constraint conditions 1, 2 and 3, the device for implementing inter-cluster task allocation is determined, and an objective function is introduced to determine the device for implementing inter-cluster task allocation. In this embodiment, inter-cluster allocation is only required between weak devices and strong devices.
[0155] The objective function aims to minimize the maximum task processing time in all devices, so that the shortest processing time can be achieved after inter-cluster allocation, and load balancing can be achieved between heterogeneous devices of the same type. The expression of the objective function is as follows:
[0156] ;
[0157] In the formula, and Both represent adjustment factors, which are used to adjust the task completion time of strong and weak devices and make them close to the task completion time of medium devices. s and T w Respectively represent the time for strong equipment and weak equipment to complete a unit task.
[0158] In the process of solving the objective function, that is, in the process of minimizing the maximum task processing time in all devices, an auxiliary variable z is introduced to represent the maximum task allocation in all strong devices. The expression is as follows:
[0159] ;
[0160] In this embodiment, the Lagrange multiplier λ is also introduced. i The constraint of fully offloading each task is relaxed, and μ j The capacity constraint of each device is relaxed and ν is introduced. j The maximum load constraint of each strong device is relaxed. Combining the above constraints and the objective function, a Lagrangian function L is constructed:
[0161] ;
[0162] In the formula, Φ(x) represents the original objective function, λ i and μ j Both represent Lagrange multipliers and correspond to constraints on offloading volume and processing capacity.
[0163] In the process of minimizing the maximum task processing time in all devices, we need to first find the minimum value of L(x,λ,μ) with respect to x, that is, find ▽ x L=0, including the following steps:
[0164] Step D1: The preset objective function Φ(x) is to maximize the minimum time for the device to complete the task. The preset form of Φ(x) is max(x). The gradient calculation is involved in the derivation process. The specific formula is as follows:
[0165] ;
[0166] Among them, considering that Φ(x) may be a nonlinear objective function, we set x ij The relationship between λ and μ is expressed as: ij (λ,μ)=f(α s λ i ,α w μ j ),
[0167] Where f represents a function that reflects the influence of the dual variable.
[0168] Step D2: Define the dual function and maximize the dual function. Specifically, define the dual function g(λ,μ) as
[0169] The minimum value of L(x,λ,μ) with respect to x is expressed as , and insert g(λ,μ) back into L, and then maximize g(λ,μ), that is, maximize the dual function:
[0170] ;
[0171] Step D3: Iterate using the gradient ascent method. For each iteration round k, the update of the Lagrange multipliers λ and μ can be expressed as:
[0172] ;
[0173] In the formula, η represents the learning rate, and Both represent the dual function g with respect to λ i and μ j The gradient of . And, The expression is: ; The expression is ;
[0174] Combined with the actual situation, x ij The expression of (λ,μ) is replaced by , where γ represents a regularization parameter used to ensure the stability of subsequent solutions.
[0175] Step D4: When the convergence condition is met, stop the gradient ascent iteration. In this embodiment, the convergence condition is that the update change of the Lagrange multiplier is very small or reaches the preset maximum number of iterations. The specific expression is as follows:
[0176] ;
[0177] In the formula, Indicates the preset tolerance error threshold.
[0178] Step D5: When the iteration meets the convergence condition, the iteration ends and a set of optimal solutions of λ and μ are obtained. The final task allocation relationship is calculated by λ and μ. ,
[0179] In the formula, All constraints of the original problem are satisfied, and the objective function of the original problem (maximizing the minimum time for the equipment to complete the task) is optimized.
[0180] From then on, the task allocation relationship and task allocation steps are completed between the heterogeneous devices.
[0181] When the task redistribution between devices of the same type is completed, the computing time of strong and weak devices can be unified in the energy forecast and other calculation processes, and the unified computing time can be made close to the computing time required for medium devices. The global computing time in the smart microgrid can be unified, and the computing time of weak devices can be shortened to approach the computing time required for medium devices through task redistribution, thereby shortening the time required for global calculations.
[0182] Based on the resource reallocation principle, the present invention further realizes real-time dynamic resource adjustment for heterogeneous devices in a microgrid, accelerates the global computing speed in the microgrid, and unifies and coordinates the computing time of different types of heterogeneous devices.
[0183] In this embodiment, the device uses homomorphic encryption technology during local training and local training model transmission. Specifically, the following steps are included:
[0184] Step C1: Initialize and encrypt local data of the local device.
[0185] Specifically, when applied in the lth layer of the neural network, W (l) and b (l) Represents the weight and bias of the lth layer in the neural network. Each participating device uses the homomorphic encryption function E to encrypt its local data x and network parameters, as shown below:
[0186] .
[0187] Step C2: Perform encryption training on the local device.
[0188] Specifically, the implementation of encrypted training is achieved by performing forward propagation in each layer of the neural network, and the expression is as follows:
[0189] ;
[0190] For the encrypted activation function σ, use its homomorphic encryption compatible approximation σ enc : .
[0191] Step C3: Encrypt the loss function and perform encryption during the back-propagation process.
[0192] Specifically, through the encrypted loss function L enc , calculate the encrypted output t enc and target y enc The error between:
[0193] L enc =(t enc- y enc ) 2 .
[0194] Calculate the gradient of each layer and update the weights. Considering the limitations of homomorphic encryption, use the approximate representation of the gradient:
[0195] ;
[0196] And update the weights and biases accordingly:
[0197] .
[0198] Step C4: Decrypt the encrypted model and perform global update.
[0199] Specifically, after training is completed, decrypt the updated model parameters:
[0200] .
[0201] Step C5: Perform global model aggregation.
[0202] Specifically, it includes updating the local model, updating the aggregated model, issuing the global model and repeating the iterative process.
[0203] The local model update process is as follows: each device d i Autonomously calculates the update Δθ of its model parameters i , these updates are based on the gradients calculated from the local energy data: Δθ i =Enc(▽Li (θ)), where local energy data includes electricity, time and temperature, etc., where ▽L i (θ) represents the device d i The gradient of the loss function calculated above with respect to the model parameter θ is used, and in this embodiment, homomorphic encryption Enc(·) is used to ensure the privacy of the gradient.
[0204] The aggregate model update process is as follows: the central server collects the encrypted gradient updates sent back by all devices and aggregates them to update the global model. The expression is as follows:
[0205] ;
[0206] In the formula, θ new represents the global model parameters after aggregation, θ old represents the global model parameters before aggregation, N represents the total number of participating devices; Dec(·) represents the decryption operation, which is used to convert the encrypted gradient back to its original form.
[0207] The global model is aggregated and updated to reflect the information collected from all devices.
[0208] The distribution process of the global model is as follows: the aggregated global model parameters θ new is sent back to all participating devices, and all global model parameters θ are adjusted before sending new To encrypt: After receiving the encrypted global model parameters, each device decrypts them for the next round of local training: .
[0209] The iterative process is repeated as follows: the device uses the updated model parameters θ local Continue to perform local training and enter the next training cycle. From then on, the local training and local training model transmission based on homomorphic encryption technology are completed.
[0210] The present invention realizes task unloading and redistribution between local devices in a microgrid by establishing a computing task allocation method during the local device's local model training process, so that the operation processing time of each device tends to be consistent, the computing load between the devices is balanced, and resource compensation is realized. In this way, the computing time of the entire device is shortened, the overall response time of the microgrid is shortened, and the energy management computing efficiency is improved. This solves the problem of inconsistent response speeds between devices in the smart microgrid during the global response process due to the heterogeneous differences between different devices in the smart microgrid in the traditional smart microgrid management system using a federated learning architecture.
[0211] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technical personnel in this field can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any brief modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.
Claims
1. An energy optimization management method applied to a smart microgrid comprises the following steps: Step A1: Each device collects local energy usage data and performs local model training; Step A2: The local model predicts the energy demand of the household and sends it to the central server for aggregation regularly to obtain and update the global model; Step A3: Decentralize the updated global model to each device and update the local model, then use the local model to build an energy optimization model and output the energy optimization allocation plan to the central server; Step A4: The central server updates the energy flow management strategy according to the optimal energy allocation plan, and implements energy allocation in the microgrid according to the energy flow management strategy; It is characterized in that: during the implementation of steps A1 to A4, the equipment in the microgrid is also equipped with a computing task allocation method performed according to the following steps: Step S1: Classify the devices, divide them into different device type sets and different device clusters according to their types, divide the devices in each device type set into three performance categories according to their computing capabilities: weak devices, medium devices and strong devices, and respectively establish a weak device set, a medium device set and a strong device set belonging to the same device cluster; Step S2: Decompose the data of each device to obtain the data volume of the output feature map of each layer of the neural network, and calculate the communication cost of each layer of the neural network according to the data volume; Step S3: Identify and divide the normal-cost communication layer and the high-cost communication layer; In step S3, taking the skewness and kurtosis of the communication cost as a reference, a threshold is established based on the skewness and kurtosis of the communication cost to distinguish between the normal cost communication layer and the high cost communication layer; In step S3, a multi-parameter function is established to determine whether the communication cost of the calculated layer lifting network exceeds the threshold based on the skewness, kurtosis and threshold of the communication cost, and the neural network layers exceeding the threshold are grouped in the high-cost communication layer set; Step S4: determining the optimal task offloading point in the neural network according to the relative ratio of the normal cost communication layer and the high cost communication layer; The implementation of step S4 specifically includes the following steps: Step S401: Calculate the composite information entropy of each layer of the neural network belonging to the high-cost communication layer; Step S402: determining a selection criterion for an optimal task unloading point based on the calculated composite information entropy, and selecting the optimal task unloading point; In step S402, based on the calculated composite information entropy H l Establish a multi-dimensional evaluation function Ω l As the selection benchmark for the best task unloading point, the multi-dimensional evaluation function Ω l The expression is as follows: , In the formula, σ T It is T l The standard deviation of l and H j They represent the composite information entropy of the lth and jth layers of the neural network respectively, and Λ represents the set of neural network layers with high cost communication layers; T l Represents the overall characteristics of each layer of the neural network, which is calculated by the composite information entropy and its first-order derivative. The expression is as follows: ; The optimal task unloading point is selected by maximizing the multi-dimensional evaluation function. The expression of maximizing the multi-dimensional evaluation function is as follows: ; Where Λ represents the set of neural network layers of high-cost communication layers; Step S5: based on the optimal task offloading point of each device, perform task offloading and task redistribution between strong devices and weak devices belonging to the same device type cluster, so that the computing time of the strong devices and weak devices approaches the computing time of the medium device and achieves load balance; In step S5, during the inter-cluster unloading process of the intra-cluster device, three constraints are introduced to ensure complete unloading of the task, including: Constraint 1: Ensure that the workload of each weak device must be fully allocated to the strong device. The expression of constraint function 1 is ; In the formula, S represents the set of strong devices, x ij Indicates that from the weak device w i To strong equipments i The amount of assigned tasks, P i Indicates weak device w i The amount of parameters that need to be uninstalled; Constraint 2: Ensure that the total amount of tasks assigned to each strong device does not exceed its processing capacity. The expression of constraint function 2 is , Where W represents the weak device set, c j Indicates strong devices j processing power, Constraint three: Ensure that the assigned task volume cannot be negative and that all tasks are processed positively. The expression of constraint function three is ; The implementation of step S5 includes the following steps: Step S501: quantify and calculate the parameter unloading amount of the optimal task allocation point; Step S502: based on the parameter offloading amount of each device, the parameter amount that each device can accommodate and the maximum load amount for the strong device, the device clusters are paired to match the weak devices and strong devices that offload tasks and receive tasks from each other.
2. The energy optimization management method applied to a smart microgrid according to claim 1, characterized in that: In step S1, a mapping function τ(d i ) is used to set the device i Mapped to the performance category to which it belongs, and establish an exponential function δ as the basis for classifying the device into its device cluster. The expression of the exponential function δ is: ; In the formula, Represents a collection of device types. , S represents a strong device set, U represents a medium device set, and W represents a weak device set; Device Cluster It is expressed as: 。
