Energy control method and device based on heuristic proxy loss function, terminal equipment and storage medium

By constructing a total loss function based on cost-weighted heuristic loss and battery-sensing heuristic loss, and combining automatic differentiation and gradient descent to train the model, the problem of insufficient accuracy of prediction models at critical moments in existing technologies is solved. This enables precise, efficient, and economically optimal control of building energy systems, improving resource utilization efficiency and grid interaction economy.

CN121906534AActive Publication Date: 2026-04-21SHENZHEN UNIV
View PDF 6 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN UNIV
Filing Date
2026-03-23
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In existing technologies, building energy management systems cannot implicitly learn to prioritize ensuring prediction accuracy at critical moments when predicting future operating conditions. This leads to the decoupling of the training objective of the prediction model from the final operating objective of minimizing control costs or regret values. Consequently, they cannot differentiate the impact of energy prediction errors at different times and are difficult to adapt to real-time building control needs.

Method used

We employ a heuristic surrogate loss function approach, which involves collecting heterogeneous data from multiple sources to construct a total loss function that combines cost-weighted heuristic loss and battery-aware heuristic loss. This function is then used in conjunction with automatic differentiation and gradient descent for model training, ensuring that the prediction model achieves an optimal balance between accuracy, cost, and safety with limited computing resources.

Benefits of technology

It achieves precise, efficient, and economically optimal control of building energy systems, improves resource utilization efficiency and grid interaction economy, and ensures high adaptability and optimization effect of the prediction model under actual control requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121906534A_ABST
    Figure CN121906534A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of new energy and micro-grids, and provides an energy control method and device based on a heuristic proxy loss function, terminal equipment and a storage medium, and the method comprises the steps: collecting multi-source heterogeneous data corresponding to a building energy system with a photovoltaic and energy storage battery; inputting the multi-source heterogeneous data into the constructed prediction model to obtain an energy prediction result; wherein the energy prediction result comprises an electricity consumption prediction load and a photovoltaic prediction load; calculating an energy prediction error according to the energy prediction result and the energy actual result; constructing cost weighted heuristic loss and battery sensing heuristic loss based on the energy prediction error; training the prediction model based on the cost weighted heuristic loss and the battery perception heuristic loss to obtain a trained prediction model; and performing energy prediction control on the building energy system based on the trained prediction model. According to the method, accurate, efficient, economical and optimal control over the operation strategy of the building energy storage system is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of new energy and microgrid technology, and particularly relates to energy control methods, devices, terminal equipment and storage media based on heuristic proxy loss functions. Background Technology

[0002] With the increasing demand for building energy conservation, building energy management needs to derive optimal control strategies by predicting future operating conditions (such as energy load and photovoltaic power generation) in order to achieve efficient and economical operation.

[0003] The relevant technology adopts a two-stage method of "prediction first, optimization later". The training objective is to minimize energy prediction errors such as mean square error and mean absolute error. The prediction results are then used for downstream optimization. However, this method cannot implicitly learn to prioritize the prediction accuracy at the most critical moment. This leads to the decoupling of the training objective of the prediction model from the final operational objective of minimizing control costs or regret values. It cannot differentiate the impact of energy prediction errors at different times, making it difficult for the optimization results to adapt to the real-time building control requirements. Summary of the Invention

[0004] This application provides an energy control method, device, terminal equipment, and storage medium based on a heuristic proxy loss function, which enables precise, efficient, and economically optimal control of the operation strategy of building energy storage systems, and provides reliable, low-computation-cost data-driven support for improving the utilization efficiency of building-side flexible resources and the economic efficiency of grid interaction.

[0005] In a first aspect, embodiments of this application provide an energy control method based on a heuristic surrogate loss function, comprising: Collect multi-source heterogeneous data corresponding to building energy systems with photovoltaic and energy storage batteries; among which, the multi-source heterogeneous data includes historical meteorological data, historical operation data and historical time data corresponding to building energy; Multi-source heterogeneous data are input into the constructed prediction model to obtain energy prediction results; the energy prediction results include electricity load prediction and photovoltaic load prediction. Cost-weighted heuristic loss and battery-perception heuristic loss are constructed based on energy forecast results. The cost-weighted heuristic loss is used to characterize the impact of energy forecast results on the operating economic cost of building energy systems, while the battery-perception heuristic loss is used to characterize the impact of energy forecast results on energy storage batteries. The prediction model is trained using cost-weighted heuristic loss and battery-sensing heuristic loss to obtain the trained prediction model. Predictive control of building energy systems is achieved based on the trained predictive model.

[0006] In this embodiment, historical meteorological, operational, and time-related multi-source heterogeneous data are first collected and input into a preset prediction model to obtain predicted electricity consumption and photovoltaic load. Then, the model is jointly trained using cost-weighted heuristic loss (quantifying the economic cost impact of prediction errors) and battery-sensing heuristic loss (quantifying the impact of prediction errors on the safety and operation of energy storage batteries). Finally, the trained model is used to achieve predictive control of the building energy system. This method directly embeds downstream control objectives of economic cost and battery safety into the model training, making the prediction objectives and operational objectives highly unified. This avoids suboptimal results caused by insufficient prediction accuracy during critical periods. Instead of pursuing the "global minimum prediction error," it focuses on the "prediction result with optimal decision-making," achieving the optimal balance of "accuracy-cost-safety" under limited computing resources. This provides an interpretable and easily implementable optimization tool for data-driven building energy management, enabling precise, efficient, and economically optimal control of the building energy storage system's operation strategy.

[0007] In one possible implementation of the first aspect, constructing the cost-weighted heuristic loss and the battery-aware heuristic loss based on the energy prediction results includes: Obtain the actual energy results corresponding to the energy forecast results; wherein, the actual energy results include actual electricity load and actual photovoltaic load; Calculate the energy forecast error based on the energy forecast results and the actual energy results; Based on the energy prediction error, a cost-weighted heuristic loss and a battery-sensing heuristic loss are constructed.

[0008] In this embodiment, by first matching the energy prediction results with the actual results and accurately calculating the prediction error, two types of heuristic losses are constructed based on the error. The construction of cost-weighted heuristic loss and battery-sensing heuristic loss is anchored to the actual prediction deviation, ensuring that the loss can accurately quantify the actual impact of the prediction error on the economic cost of building energy system operation, energy storage battery safety and operating efficiency. This provides an optimization basis for subsequent model training that fits the actual operating scenario, and avoids the model training direction deviating from the actual control target due to the disconnect between the loss construction and the actual error.

[0009] In one possible implementation of the first aspect, the energy prediction error is calculated based on the energy prediction results and the actual energy results, including: Calculate the first difference between the predicted electricity load and the predicted photovoltaic load in the energy forecast results; Calculate the second difference between the actual electricity load and the actual photovoltaic load in the actual energy results; The energy prediction error is obtained by performing difference processing on the first difference and the second difference.

[0010] In this embodiment, the first and second differences related to net load are obtained by first calculating the difference between electricity consumption and photovoltaic load in the predicted and actual dimensions, respectively. Then, the difference between the two is processed to obtain the energy prediction error. The prediction deviations of electricity consumption and photovoltaic load are integrated into a unified error index at the net load level. This accurately anchors the core influencing factors of the interaction between the building energy system and the grid and the charging and discharging decisions of energy storage batteries. This allows the subsequent loss construction to directly target the key deviations of actual operation decisions, avoiding the deviation separation caused by calculating the two types of load errors separately, and ensuring that the loss quantification is highly adapted to the actual control requirements.

[0011] In one possible implementation of the first aspect, the steps of constructing a cost-weighted heuristic loss based on energy forecasting errors include: Based on the state of the second difference and the corresponding electricity price parameters, the energy forecasting error is calculated using a differentiated weighted average to obtain the first cost loss; wherein, the state of the second difference includes positive and negative states; The second cost loss is obtained by weighting the absolute value of the energy forecasting error based on the ratio of the current electricity purchase and sale price difference to the average electricity purchase price. The third cost loss is calculated by weighting the absolute value of the energy forecast error based on the first deviation between the current electricity purchase price and the average electricity purchase price, and the current electricity purchase price. The fourth cost loss is calculated by weighting the absolute value of the energy forecast error based on the sign of the first difference, the sign of the second difference, and the current electricity purchase price. Each of the first cost loss, second cost loss, third cost loss, and fourth cost loss is assigned a corresponding first adjustable weight; The cost-weighted heuristic loss is obtained by weighting and summing each cost loss with its corresponding first adjustable weight.

[0012] In this embodiment, by differentiating the absolute value of energy prediction error according to four core economic impact dimensions—grid interaction status, electricity purchase and sale price difference, electricity purchase price deviation, and the sign matching between prediction and actual net load—four types of cost losses are obtained and integrated to construct a cost-weighted heuristic loss. This cost-weighted heuristic loss can quantify the actual operating economic cost impact of prediction errors in different scenarios in a multi-dimensional and refined manner, accurately matching the economic loss logic of building energy systems under different electricity price and grid interaction states. This allows subsequent model training to specifically optimize the prediction accuracy of high economic impact scenarios, avoiding the one-sidedness of single-dimensional loss in quantifying economic costs, and ensuring that the economic optimization objectives of model training are highly consistent with actual operating needs.

[0013] In one possible implementation of the first aspect, the steps of constructing a battery-aware heuristic loss based on energy prediction error include: The first battery safety loss is obtained by weighting the second deviation value between the first state of charge trajectory and the second state of charge trajectory with the current electricity purchase price; wherein, the first state of charge trajectory is the state of charge trajectory of the energy storage battery derived based on the first difference; and the second state of charge trajectory is the state of charge trajectory of the energy storage battery derived based on the second difference. The second battery safety loss is obtained by weighting the first state of charge trajectory and the safe operating boundary of the energy storage battery with the current electricity purchase price. The third battery safety loss is calculated by weighting the electricity price range, energy forecast error, and current electricity purchase price. The fourth battery safety loss is obtained by weighting the third deviation value between the first grid interaction cost and the second grid interaction cost with the purchase and sale price of electricity; wherein, the first grid interaction cost is the interaction cost with the grid when the energy storage battery performs an approximate operation based on the first difference; the second grid interaction cost is used to characterize the actual interaction cost with the grid when the energy storage battery performs an approximate operation based on the second difference; The fifth battery safety loss is calculated by weighting the rate of change of the first difference, the rate of change of the second difference, and the rate of change of the current electricity purchase price. The sixth battery safety loss is calculated by weighting the deviation between the first arbitrage attractiveness index determined based on the first difference and the second arbitrage attractiveness index determined based on the second difference, and the range of the purchase and sale electricity price; wherein, the arbitrage attractiveness index represents the potential economic value of performing a charging operation at the current moment; Each of the first battery safety loss, the second battery safety loss, the third battery safety loss, the fourth battery safety loss, the fifth battery safety loss, and the sixth battery safety loss is assigned a corresponding second adjustable weight. The battery perception heuristic loss is obtained by weighting and summing the safety losses of each battery with their corresponding second adjustable weights.

[0014] In this embodiment, the impact of prediction errors on energy storage batteries is quantified from six dimensions: SOC trajectory deviation, battery physical boundary constraints, asymmetric error in electricity price range, grid interaction cost mismatch, net load trend consistency, and cross-time arbitrage opportunity loss. Six battery safety losses are obtained through differentiated weighting and then fused into battery-aware heuristic losses by allocating adjustable weights. This multi-dimensional, refined, and flexible quantification of the safety risks, operational efficiency losses, and arbitrage profit losses brought to energy storage batteries by prediction errors not only anchors the core constraints of battery physical operation but also aligns with the actual operational needs of economic arbitrage. The adjustable weights can better adapt to the battery characteristics and operational priorities of different building energy systems, allowing subsequent model training to specifically avoid key risks in battery operation and optimize arbitrage efficiency, ensuring that the battery safety and economic adaptation goals of model training are highly consistent with actual control.

[0015] In one possible implementation of the first aspect, the prediction model is trained based on cost-weighted heuristic loss and battery-aware heuristic loss to obtain a trained prediction model, including: The cost-weighted heuristic loss and the battery-sensing heuristic loss are superimposed to obtain the total loss; If the total loss does not converge, calculate the gradient of the total loss relative to the prediction model; Adjust the parameters of the prediction model in the direction of the gradient until the total loss converges to obtain the trained prediction model.

[0016] In this embodiment, the total loss is obtained by superimposing cost-weighted and battery-aware heuristic losses. When the total loss has not converged, its gradient relative to the model is calculated and the model parameters are iteratively adjusted along the direction of the gradient until the loss converges. The dual objectives of minimizing economic costs and ensuring safe battery operation are integrated into the end-to-end training process of the model. Gradient optimization allows the model parameters to continuously iterate in the direction that conforms to actual control requirements, ensuring that the trained prediction model can simultaneously and accurately adapt to the economic arbitrage of building energy systems and the safe operation requirements of energy storage batteries. This avoids model performance bias caused by single-objective training, and the gradient iteration optimization method can efficiently allow the model to converge to the optimal state, ensuring a high degree of consistency between the model's prediction accuracy and actual control value.

[0017] In one possible implementation of the first aspect, predictive control of building energy systems is performed based on a trained predictive model, including: Collect multi-source heterogeneous data of the target to be predicted; among which, the multi-source heterogeneous data of the target includes meteorological forecast data, current operation data and current time data corresponding to building energy; Feature extraction is performed on the target multi-source heterogeneous data to obtain the feature vector corresponding to the target multi-source heterogeneous data; The feature vectors are input into the trained prediction model to obtain the target electricity load and target photovoltaic load output by the prediction model.

[0018] In this embodiment, by collecting multi-source heterogeneous data to be predicted and extracting feature vectors, the target electricity consumption and photovoltaic predicted load are obtained by inputting them into the trained model. This enables predictive control of the building energy system, allowing the trained model to output accurate energy prediction results based on real-time and comprehensive data to be predicted. This provides a direct and reliable basis for subsequent operational decisions such as energy storage charging and discharging and grid interaction of the building energy system, ensuring the real-time performance and accuracy of predictive control. At the same time, relying on the economic and safety objectives incorporated during model training, the prediction results are naturally adapted to the control requirements of optimal system economy and safe battery operation, thereby improving the overall effect and practical application value of predictive control of the building energy system from the source.

[0019] Secondly, embodiments of this application provide an energy control device based on a heuristic proxy loss function, comprising: The data acquisition module is used to collect multi-source heterogeneous data corresponding to building energy systems with photovoltaic and energy storage batteries; among which, the multi-source heterogeneous data includes historical meteorological data, historical operation data and historical time data corresponding to building energy; The energy forecasting module is used to input multi-source heterogeneous data into the constructed forecasting model to obtain energy forecasting results; among which, the energy forecasting results include electricity load forecasting and photovoltaic load forecasting. The prediction error calculation module is used to calculate the energy prediction error based on the energy prediction results and the actual energy results. The loss construction module is used to construct cost-weighted heuristic loss and battery-aware heuristic loss based on energy forecasting errors. The cost-weighted heuristic loss is used to characterize the impact of energy forecasting errors on the operating economic costs of building energy systems, while the battery-aware heuristic loss is used to characterize the impact of energy forecasting results on energy storage batteries. The model training module is used to train the prediction model based on cost-weighted heuristic loss and battery-aware heuristic loss to obtain the trained prediction model. The model prediction module is used to predict and control the energy of building energy systems based on the trained prediction model.

[0020] Thirdly, embodiments of this application provide a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements an energy control method based on a heuristic proxy loss function as described in any of the first aspects above.

[0021] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements an energy control method based on a heuristic proxy loss function as described in any of the first aspects above.

[0022] Fifthly, embodiments of this application provide a computer program product that, when run on a terminal device, causes the terminal device to execute the energy control method based on a heuristic proxy loss function as described in any of the first aspects above.

[0023] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 This is a flowchart illustrating the energy control method based on a heuristic proxy loss function provided in an embodiment of this application. Figure 2 This is a schematic diagram of the construction flow cost-weighted heuristic loss and battery-aware heuristic loss process provided in the embodiments of this application; Figure 3 This is a schematic diagram of the calculation process for energy prediction error provided in an embodiment of this application; Figure 4 This is a flowchart illustrating the construction cost-weighted heuristic loss provided in an embodiment of this application; Figure 5 This is a schematic diagram of the process for constructing a battery-aware heuristic loss provided in an embodiment of this application; Figure 6 This is a schematic diagram of the training model provided in the embodiments of this application; Figure 7 This is a schematic diagram of the model prediction process provided in the embodiments of this application; Figure 8 This is a schematic diagram of the overall structure of the energy control method based on a heuristic proxy loss function provided in the embodiments of this application; Figure 9 This is a structural block diagram of an energy control device based on a heuristic proxy loss function provided in an embodiment of this application; Figure 10 This is a schematic diagram of the structure of the terminal device provided in the embodiments of this application. Detailed Implementation

[0026] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0027] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0028] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0029] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."

[0030] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0031] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized.

[0032] With the increasing demand for building energy conservation, building energy management needs to derive optimal control strategies by predicting future operating conditions (such as energy load and photovoltaic power generation) in order to achieve efficient and economical operation.

[0033] The relevant technology adopts a two-stage method of "prediction first, optimization later". The training objective is to minimize energy prediction errors such as mean square error and mean absolute error. The prediction results are then used for downstream optimization. However, this method cannot implicitly learn to prioritize the prediction accuracy at the most critical moment. This leads to the decoupling of the training objective of the prediction model from the final operational objective of minimizing control costs or regret values. It cannot differentiate the impact of energy prediction errors at different times, making it difficult for the optimization results to adapt to the real-time building control requirements.

[0034] To address the aforementioned technical issues, this application provides an energy control method based on a heuristic surrogate loss function. By collecting multi-source heterogeneous data, a total loss function is constructed that integrates cost-weighted heuristic loss (including four components such as asymmetric direct cost and price difference-sensitive cost) and battery-sensing heuristic loss (including six components such as state-of-charge trajectory deviation and boundary constraints). This eliminates the need for complex optimization solutions and achieves efficient model training through automatic differentiation and gradient descent. Ultimately, this method enables optimized control of building energy storage systems that reduces operating costs, improves arbitrage efficiency, and conforms to battery physical constraints.

[0035] See Figure 1 This is a flowchart illustrating the energy control method based on a heuristic agent loss function provided in an embodiment of this application. It is intended as an example and not a limitation. The method may include the following steps: S101 collects multi-source heterogeneous data corresponding to building energy systems with photovoltaic and energy storage batteries; among which, the multi-source heterogeneous data includes historical meteorological data, historical operation data and historical time data corresponding to building energy.

[0036] In this application embodiment, for a building energy system equipped with photovoltaic and energy storage batteries, three types of core historical data (weather, operation, and time) are collected to support the training of its optimized control model, laying the data foundation for subsequent key steps such as calculating and predicting net load and constructing heuristic loss functions.

[0037] For example, three types of historical multi-source heterogeneous data are systematically collected through multiple channels such as building energy management systems, weather stations, and grid operator interfaces, such as meteorological data: including historical outdoor dry-bulb temperature, relative humidity, total solar irradiance, and diffuse irradiance.

[0038] Operational data includes historical total electricity load data for buildings and historical power generation data for distributed photovoltaic (PV) systems.

[0039] Time data: The timestamp of data collection.

[0040] External parameters: The local public power grid's time-of-use (ToU) pricing strategy, including the purchase price of electricity for each time period. P buy,t) and grid connection electricity price ( P sell,t ); Physical parameters of the energy storage battery system, including the battery's rated capacity ( E bat ), maximum charge and discharge power ( , ), charge and discharge efficiency ( , and the safe operating range of the state of charge (SOC) SOC mint , SOC max This provides accurate data support for subsequent derivation of predicted net load, calculation of prediction error, and construction of cost-weighted loss functions related to battery perception.

[0041] S102, input the multi-source heterogeneous data into the constructed prediction model to obtain the energy prediction results; among which, the energy prediction results include the predicted electricity load and the predicted photovoltaic load.

[0042] In this embodiment of the application, the collected multi-source heterogeneous data is input into a preset prediction model, and the model is used to output key prediction results that support the optimization and control of the building energy system, namely the predicted electricity load and the predicted photovoltaic load, which lays the foundation for subsequent calculation of net load and construction of loss function.

[0043] Specifically, first, build a prediction model based on deep learning. The model parameters are initialized to θ; then, the previously collected multi-source heterogeneous data (historical meteorological data, historical total building electricity load data, historical power generation data of distributed photovoltaic systems, data collection timestamps, etc.) are preprocessed and integrated to form a standardized feature vector. Then the feature vector The input prediction model performs forward propagation. By learning the temporal patterns in the data, the correlation between meteorological conditions and energy output / load, the model outputs a predicted load sequence for several future time steps. and photovoltaic predicted load series The two sequences will be directly used in subsequent key steps such as predicting net load and calculating prediction errors.

[0044] S103, construct cost-weighted heuristic loss and battery-perception heuristic loss based on energy forecast results; wherein, cost-weighted heuristic loss is used to characterize the impact of energy forecast results on the operating economic cost of building energy system; battery-perception heuristic loss is used to characterize the impact of energy forecast results on energy storage battery.

[0045] In this embodiment, based on the electricity load forecast and photovoltaic load forecast, relevant data (energy forecast results) are derived, and two types of targeted heuristic loss functions are constructed: one focuses on economic costs, quantifying the economic losses caused by energy forecast errors; the other focuses on energy storage batteries, quantifying the impact of the error on battery operating status, physical constraints, and arbitrage potential, providing a "economic + physical" dual-dimensional loss measurement standard for subsequent model training, and helping the model learn better forecast strategies.

[0046] In one embodiment, see Figure 2 This is a schematic diagram of the construction flow cost-weighted heuristic loss and battery-aware heuristic loss process provided in the embodiments of this application, as shown below. Figure 2 As shown, step S103 includes: S201, Obtain the actual energy result corresponding to the energy prediction result; wherein, the actual energy result includes the actual electricity load and the actual photovoltaic load.

[0047] In this application embodiment, real data corresponding to the predicted electricity load and the predicted photovoltaic load, namely the actual electricity load and the actual photovoltaic load, are obtained to provide a real reference benchmark for subsequent calculation of net load, quantification of prediction error, and construction of cost-weighted and battery-sensory heuristic loss functions.

[0048] For example, through the real-time monitoring interface of the building energy management system and the distributed photovoltaic (PV) system, the actual operating data corresponding to the predicted period is collected synchronously: the actual electricity load needs to accurately record the time series data of the building's total electricity consumption in the corresponding period, covering the total energy consumption of all electrical equipment; the actual PV load needs to collect the actual power generation data of the PV system in the same period, ensuring that it is consistent with the time granularity and monitoring scope of the predicted PV load; the two types of actual data need to be strictly aligned with the previously collected predicted data by timestamp to form a "prediction-actual" paired dataset, laying the foundation for subsequent derivation of the actual net load and calculation of prediction error.

[0049] S202, calculate the energy prediction error based on the energy prediction results and the actual energy results.

[0050] In this embodiment, the energy prediction error is calculated by using the energy prediction results (electricity prediction load, photovoltaic prediction load) and the corresponding actual energy results (actual electricity load, actual photovoltaic load), providing a core quantitative basis for the subsequent construction of two types of heuristic loss functions and optimization of model parameters.

[0051] In one embodiment, see Figure 3 This is a flowchart illustrating the calculation of energy prediction error provided in an embodiment of this application, such as... Figure 3 As shown, step S202 includes: S301, calculate the first difference between the predicted electricity load and the predicted photovoltaic load in the energy forecast results.

[0052] In this embodiment, the predicted electricity load from the energy forecast results is subtracted from the predicted photovoltaic load for the same period. The resulting difference is the predicted net load, used to quantify the pure electricity supply and demand gap (or surplus) of the building without considering energy storage. The formula for calculating the predicted net load is: Forecasted net load:

[0053] S302, calculate the second difference between the actual electricity load and the actual photovoltaic load in the actual energy results.

[0054] In this embodiment, the actual net load is obtained by subtracting the actual photovoltaic load from the actual electricity load in the actual energy results. This second difference is used to quantify the true power supply and demand situation (gap or surplus) of a building without considering energy storage. The formula for calculating the actual net load is: Actual net load:

[0055] S303, perform difference processing on the first difference and the second difference to obtain the energy prediction error.

[0056] In this embodiment, the energy prediction error is quantified by calculating the difference between the "predicted net load (first difference)" and the "actual net load (second difference)," providing a core quantitative basis for subsequently constructing cost-weighted and battery-aware heuristic loss functions and guiding model optimization. The formula for calculating the energy prediction error is as follows: Prediction error:

[0057] Net load This represents the building's pure electricity demand without considering energy storage. >0 indicates that the building's own power generation is insufficient and it needs to purchase electricity from the grid; A value less than 0 indicates that there is a surplus of photovoltaic power generation, which can be sold to the grid. (Prediction error) It serves as the fundamental input for calculating all subsequent loss functions.

[0058] In the above method, the first and second differences related to net load are obtained by first calculating the difference between electricity consumption and photovoltaic load in the predicted and actual dimensions, respectively. Then, the difference between the two is processed to obtain the energy prediction error. The prediction deviations of electricity consumption and photovoltaic load are integrated into a unified error index at the net load level. This accurately anchors the core influencing factors of the interaction between the building energy system and the grid and the charging and discharging decisions of energy storage batteries. This allows the subsequent loss construction to directly target the key deviations of actual operation decisions, avoiding the deviation separation caused by calculating the two types of load errors separately, and ensuring that the loss quantification is highly adapted to the actual control requirements.

[0059] S203, construct a cost-weighted heuristic loss and a battery-sensing heuristic loss based on the energy prediction error.

[0060] In this embodiment, two types of heuristic loss functions are constructed using the calculated energy prediction error (the difference between the predicted net load and the actual net load): cost-weighted heuristic loss focuses on quantifying the economic loss caused by the prediction error, and battery-aware heuristic loss focuses on quantifying the impact of the prediction error on the battery operating state, physical constraints and arbitrage potential. This provides a dual-dimensional optimization basis of "economic + physical" for model training, and promotes the model to learn prediction strategies that are more in line with actual needs.

[0061] In the above method, by first matching the energy prediction results with the actual results and accurately calculating the prediction error, two types of heuristic losses are constructed based on the error. The construction of cost-weighted heuristic loss and battery-sensing heuristic loss is anchored to the actual prediction deviation, ensuring that the loss can accurately quantify the actual impact of the prediction error on the economic cost of building energy system operation, energy storage battery safety and operating efficiency. This provides an optimization basis for subsequent model training that fits the actual operating scenario, and avoids the model training direction deviating from the actual control target due to the disconnect between the loss construction and the actual error.

[0062] In one embodiment, see Figure 4 This is a flowchart illustrating the construction cost-weighted heuristic loss provided in an embodiment of this application, such as... Figure 4 As shown, the steps include: S401, based on the state of the second difference and the corresponding electricity price parameters, perform differentiated weighted calculation on the energy prediction error to obtain the first cost loss; wherein, the state of the second difference includes positive and negative states.

[0063] In this embodiment, the energy prediction error is differentiatedly weighted based on the positive or negative state of the actual net load (second difference) (reflecting the actual interaction mode between the building and the power grid) and the corresponding electricity purchase / sale price (electricity price parameter). For example, when the second difference is positive, the absolute value of the energy prediction error is weighted using the current electricity purchase price; when the second difference is negative, the positive part of the energy prediction error is weighted using the current electricity sale price, and the negative part of the energy prediction error is weighted using the current electricity purchase price. This ultimately yields the first cost loss, which quantifies the direct economic loss from the prediction error. The core principle is "penalizing the error with the corresponding electricity price under different interaction states, reflecting the asymmetry of the loss."

[0064] Specifically, if the model makes an incorrect prediction, leading to the purchase of electricity when it should be sold, or the sale of electricity when it should be purchased, such errors will be severely punished. This will be based on the actual net load. The symbols (electricity purchase or electricity sale status) are used respectively based on the electricity purchase price. Or electricity price For prediction error The absolute values ​​are weighted.

[0065] Asymmetric direct costs ( The formula for calculating the first cost loss is:

[0066] when When the net load is >0 (electricity needs to be purchased), both overestimating and underestimating the net load will affect the electricity purchase cost; therefore, the electricity purchase price will be used uniformly. Weighted absolute error; when When the value is less than 0 (electricity can be sold), the impact of the error is asymmetrical: like >0 (i.e., predicted value) If the forecast is larger than the actual value (meaning the predicted surplus is lower), it will lead to less electricity being sold, resulting in a loss of revenue from electricity sales. Therefore, it is used... Weighted; like <0 (i.e., predicted value) Compared to actual value A small surplus (meaning an overestimation of the projected surplus) can lead to misjudgments resulting in over-selling of electricity and unexpected electricity purchases, incurring losses in electricity purchase costs. Therefore, [the text abruptly ends here]. Weighted.

[0067] Here This represents the ReLU function, where if the input x is positive, the output is x (passed as is), and if the input x is negative, the output is 0 (filtered out).

[0068] S402, based on the ratio of the current electricity purchase and sale price difference to the average electricity purchase price, the absolute value of the energy forecast error is weighted and calculated to obtain the second cost loss.

[0069] In this embodiment of the application, the ratio of the current electricity purchase and sale price difference to the average electricity purchase price is used as a dynamic weight to weight the absolute value of the energy prediction error, thereby obtaining the second cost loss that quantifies the "economic loss of prediction error during periods of large price difference". The core is that "the larger the price difference, the heavier the error penalty, forcing the model to focus on the prediction accuracy of periods with high arbitrage value".

[0070] Specifically, the ratio of the current electricity purchase and sale price difference to the average electricity purchase price is calculated and used as a weight to penalize prediction errors, forcing the model to maintain high accuracy during periods of large price differences. When the price difference between buying and selling electricity is large, prediction errors can lead to more serious consequences, so the error weight is amplified in this case.

[0071] Price difference sensitive costs The formula for calculating the second cost loss is as follows:

[0072] This utilizes the current price difference between electricity purchase and sale. With average electricity purchase price The ratio is used as the weight. The larger the price difference, the more expensive the "toll" for grid interaction, and therefore the greater the prediction error at that moment. They need to be punished more severely. To prevent small constants with a denominator of zero.

[0073] S403, the third cost loss is obtained by weighting the absolute value of the energy forecast error based on the current electricity purchase price, the first deviation between the average electricity purchase price and the current electricity purchase price.

[0074] In this embodiment, the "standardized value of the deviation between the current electricity purchase price and the average electricity purchase price" is used as the core weight. Combined with the absolute value of the energy prediction error by the current electricity purchase price, a third cost loss is obtained to quantify the "economic loss of prediction error during peak and valley electricity price periods". The core is that "the more the electricity price deviates from the average level (peak / valley period), the heavier the error penalty, forcing the model to focus on extreme electricity price periods with high arbitrage value".

[0075] Specifically, the model calculates the degree to which the current electricity price deviates from the average electricity price (Z-Score), and uses this score to weight the prediction error, thus strengthening the prediction of peak / off-peak electricity price periods. Missing arbitrage opportunities at the extreme times when electricity prices are highest or lowest (such as not charging at the lowest price) is unforgivable, so the model pays special attention to the accuracy at these times.

[0076] Peak price penalty The formula for calculating the third cost loss is:

[0077] This method uses the Z-Score concept to standardize the deviation of electricity prices. The larger the value, the more likely it is to indicate a period of extremely high or low electricity prices, which is a critical time for energy storage arbitrage. This formula forces the model to focus on the prediction accuracy during peak and off-peak periods by amplifying the error weights for these times. This represents the standard deviation of electricity prices.

[0078] S404, the fourth cost loss is obtained by weighting the absolute value of the energy forecast error based on the sign of the first difference, the sign of the second difference, and the current electricity purchase price.

[0079] In this application embodiment, the core judgment criterion is whether the signs of the predicted net load (first difference) and the actual net load (second difference) are opposite. Combined with whether the absolute value of the actual net load exceeds a preset threshold, the absolute value of the energy prediction error is weighted by the current electricity purchase price to obtain the fourth cost loss that quantifies the "economic loss of misjudgment of energy flow direction". The core is to "severely punish serious errors that are opposite to the predicted energy flow direction and avoid complete misalignment of charging and discharging decisions".

[0080] Specifically, testing (The first difference is the predicted net load) and (The second difference, i.e., the actual net load) is checked for signs that are opposite. If opposite and the absolute value of the actual net load exceeds a preset threshold (e.g., the top 10 percentile), an additional penalty is applied to prevent the model from misjudging the energy flow direction (e.g., misjudging the need to buy electricity as the ability to sell electricity). If the predicted directions are all reversed (e.g., predicting a positive net load as negative), this will lead to a completely reversed operation (the discharge becomes a charge), and such a basic error will be strictly prohibited.

[0081] Symbol mismatch penalty :

[0082] When the predicted value has the opposite sign to the actual value (i.e.) This item is activated. To avoid triggering penalties for minor fluctuations when net load is close to zero, a quantile threshold is introduced. (i.e., the bottom 10 percentile of the absolute value of net load). This aims to eliminate serious prediction errors that lead to directional mistakes in charge and discharge decisions.

[0083] S405 assigns a first adjustable weight to each of the first cost loss, the second cost loss, the third cost loss, and the fourth cost loss.

[0084] In this application embodiment, the first to fourth cost losses (corresponding to) Assign the first adjustable weight ( , , and The principle of "prioritizing economic impact + engineering practicality" should be followed, and adjustments can be made dynamically according to the actual application scenario.

[0085] to It is an adjustable hyperparameter and satisfies This is used to balance the relative importance of different cost components.

[0086] S406. Based on the weighted summation of each cost loss and its corresponding first adjustable weight, the cost-weighted heuristic loss is obtained.

[0087] In this embodiment, by assigning first adjustable weights to the first to fourth cost losses that sum to 1, and then performing a weighted summation of the four cost losses, a cost-weighted heuristic loss is obtained that quantifies the overall economic impact of the prediction error. This provides a core optimization basis for the economic dimension of model training. The aggregation formula is as follows: polymerization:

[0088] By differentiating the absolute value of energy forecasting errors into four types of cost losses based on four core economic impact dimensions—grid interaction status, electricity purchase and sale price difference, electricity purchase price deviation, and the sign matching between forecast and actual net load—a cost-weighted heuristic loss is constructed. This cost-weighted heuristic loss can quantify the actual operational economic cost impact of forecasting errors in different scenarios in a multi-dimensional and refined manner. It accurately matches the economic loss logic of building energy systems under different electricity price and grid interaction states, enabling subsequent model training to specifically optimize the forecasting accuracy in high-economic-impact scenarios. This avoids the one-sidedness of quantifying economic costs from a single-dimensional loss, ensuring that the economic optimization objectives of model training are highly consistent with actual operational needs.

[0089] In one embodiment, see Figure 5 This is a schematic diagram of the process for constructing a battery-aware heuristic loss according to an embodiment of this application, such as... Figure 5 As shown, the steps include: S501, the first battery safety loss is obtained by weighting the second deviation value between the first state of charge trajectory and the second state of charge trajectory with the current electricity purchase price; wherein, the first state of charge trajectory is the state of charge trajectory of the energy storage battery derived based on the first difference; the second state of charge trajectory is the state of charge trajectory of the energy storage battery derived based on the second difference.

[0090] In this embodiment of the application, the core quantitative indicator is the "deviation between the state of charge trajectory (first state of charge trajectory) derived based on prediction error and the state of charge trajectory (second state of charge trajectory) derived based on actual error". This is weighted in conjunction with the current electricity purchase price to obtain the first battery safety loss quantified as "battery power trajectory deviating from the ideal state". The core is to "penalize the cumulative deviation of battery state caused by prediction error and avoid affecting battery safety and arbitrage efficiency due to imbalance in power management".

[0091] Specifically, the first step is to calculate the standardized price signal. and using activation functions The mapping yields an approximate charge / discharge tendency signal (-1 represents discharging, 1 represents charging). This invention does not require complex optimization calculations, but instead uses simple mathematical formulas to simulate the charge / discharge trends of batteries at different prices (low-priced batteries tend to charge, high-priced batteries tend to discharge).

[0092] The charging and discharging trends are similar. :

[0093]

[0094] use- The sigmoid property of the function maps the standardized electricity price signal to the (-1, 1) interval. High electricity prices correspond to... to-1 (prone to discharge), corresponding to low electricity prices to1 (prone to charging). This is a smooth, differentiable approximation of the optimal control strategy.

[0095] Approximate battery action :

[0096]

[0097]

[0098] Based on the projected net energy surplus / deficit and the above-calculated charge / discharge trends. Calculate the approximate charging power and discharge power For example, only when there is an energy surplus ( >0) and low price, tending to charge ( Charging will only occur when the value is greater than 0.

[0099] Combined with projected net load Similarity tendency Given battery power limitations, calculate approximate charge / discharge power. , Based on this, the predicted SOC trajectory is recursively deduced. Similarly, using the actual net load Deducing the actual SOC trajectory .

[0100] SOC (State of Charge) Trajectory Deduction :

[0101]

[0102] Based on approximate actions Battery capacity Ebat and charge / discharge efficiency Recursively calculate the predicted state of charge at each time step. This forms the basis for subsequent calculations of trajectory deviation. The function will value Limited to 0 to 1.

[0103] SOC trajectory deviation penalty That is, the first battery safety loss: calculate the weighted absolute error between the predicted trajectory and the actual trajectory:

[0104] Calculation based on predicted values Trajectory (first charge trajectory) and derivation based on true values The difference between the trajectories (second charge trajectory). The greater the difference, the greater the cumulative impact of the prediction error on the battery state, and a penalty is required. A penalty will be imposed if the prediction results in the battery exceeding physical limits (e.g., overcharging or depleting) or deviating from the ideal charge trajectory.

[0105] S502, based on the first state-of-charge trajectory and the safe operating boundary of the energy storage battery, and weighted by the current electricity purchase price, the second battery safety loss is obtained.

[0106] In this embodiment of the application, the core judgment criterion is whether the first state of charge trajectory (SOC trajectory derived from the prediction results) is close to the safe operation boundary of the energy storage battery. The second battery safety loss, which quantifies the "overcharge / over-discharge risk of the battery", is obtained by weighting the current electricity purchase price. The core is to "avoid the battery from exceeding the safe operation range due to prediction errors by using soft constraint penalties, thereby ensuring the safe operation of the battery".

[0107] Specifically, the second battery safety loss applies a quadratic soft penalty to the portion of the predicted trajectory that is close to the SOC physical boundary (0 or 1) to prevent the prediction result from causing the battery to exceed the limit.

[0108] Boundary constraint penalty That is, the second battery safety loss:

[0109] This is a soft constraint penalty term. The penalty term increases quadratically when the predicted SOC exceeds 0.95 or falls below 0.05. This forces the model to avoid generating extreme predictions that could lead to overcharging or over-discharging of the battery, preserving the battery's buffering capacity.

[0110] S503 calculates the third battery safety loss based on the electricity price range, energy forecast error, and weighted average with the current electricity purchase price.

[0111] In this embodiment, the core judgment criterion is "the current electricity price range (high price / low price)". Combined with the safety operation requirements of energy storage batteries (avoiding missing charging and discharging arbitrage opportunities), differentiated weights are applied to different directions of energy forecasting errors (overestimation / underestimation). Then, the current electricity purchase price is used as the weight to obtain the third battery safety loss, which quantifies the "difference in economic loss of errors in different electricity price ranges". The core is "to focus on punishing underestimation errors during high price periods and to focus on punishing overestimation errors during low price periods, which fits the asymmetric requirements of battery arbitrage strategies".

[0112] Specifically, the economic consequences of "overestimating / underestimating net load" are asymmetrical in different electricity price ranges (high price / low price), so different weights should be applied to errors in different directions during training.

[0113] Asymmetric error penalty within price range That is, the second battery safety loss:

[0114] The risk of underestimating power is even greater during periods of high prices: the optimal strategy during these periods typically leans towards discharging electricity and reducing power purchases. Underestimating net load (predicting that there won't be a severe power shortage) could lead to insufficient discharging or excessive power purchases, resulting in missed opportunities to benefit from high-price discharging or increased costs associated with purchasing electricity at higher prices, leading to greater economic losses.

[0115] Overestimating the power load during low-price periods is a greater risk: the optimal strategy during low-price periods typically leans towards charging and increasing electricity purchases (to prepare for arbitrage during subsequent high-price periods). Overestimating the net load (predicting even greater power shortages) may lead to a strategy biased towards "emergency power supply" rather than "low-price charging," thus missing out on low-price charging opportunities and impacting subsequent arbitrage.

[0116] Therefore, the model will "actively learn" to avoid underestimating prices during high-price periods and overestimating prices during low-price periods, making the distribution of prediction errors more closely match the optimal control requirements driven by electricity prices, thereby improving the economics of subsequent model predictive control (reducing regret), even if the overall MSE is not necessarily the lowest.

[0117] S504, based on the third deviation value between the first grid interaction cost and the second grid interaction cost, and weighted by the purchase and sale price of electricity, the fourth battery safety loss is obtained; wherein, the first grid interaction cost is the interaction cost with the grid when performing approximate action of the energy storage battery based on the first difference; the second grid interaction cost is used to characterize the actual interaction cost with the grid when performing approximate action of the energy storage battery based on the second difference.

[0118] In this embodiment, the core quantitative indicator is the "deviation between the grid interaction cost (first grid interaction cost) of performing approximate charging and discharging actions based on the predicted net load (first difference) and the actual grid interaction cost (second grid interaction cost) of performing the same approximate actions based on the actual net load (second difference). Combined with the impact of electricity purchase and sale prices, the fourth battery safety loss, which is quantified as "the mismatch between actual interaction cost and planned cost caused by prediction error", is obtained. The core is to "penalize the situation where 'the prediction seems reasonable but the actual electricity price deviates greatly', so that the model pays more attention to the prediction deviation that is sensitive to grid settlement costs".

[0119] Specifically, during the training phase, this invention does not actually solve for the optimizer, but instead uses... Approximate battery action. If the forecast is inaccurate, there will be a discrepancy between "the cost of interacting with the grid according to the forecast" and "the cost of performing the same action under actual net load," resulting in a cost surprise.

[0120] Surprising Items in Power Grid Costs That is, the fourth battery safety loss:

[0121]

[0122]

[0123] The principle is to penalize unexpected costs caused by prediction errors resulting from approximations of battery operation.

[0124] This will suppress situations where "the prediction error appears small, but the electricity price difference is significant," making the model pay more attention to prediction biases that are sensitive to grid settlement costs, thereby improving cost stability and engineering controllability.

[0125] S505, the fifth battery safety loss is obtained by weighting the change rate of the first difference, the change rate of the second difference, and the change rate of the current electricity purchase price.

[0126] In this application embodiment, the core judgment criterion is whether the rate of change of the predicted net load (first difference) is opposite to the rate of change of the actual net load (second difference). Combined with the weighted rate of change of the current electricity purchase price, the fifth battery safety loss of "misalignment between the predicted trend and the actual trend" is obtained. The core is to "penalize the error of the net load predicted trend being opposite to the actual trend and avoid misjudgment of charging and discharging timing due to timing phase shift".

[0127] Specifically, model predictive control is highly sensitive to "trends": whether the net load is rising or falling will affect the timing of "early charging / early discharging." A single point of error may not be significant, but if the trend prediction is wrong, it will lead to an overall misalignment of the control timing, especially near the electricity price switching point, which will significantly reduce arbitrage opportunities.

[0128] Time gradient consistency penalty That is, the fifth battery safety loss:

[0129] A first-order time difference mechanism is used to penalize predictions whose temporal gradients have the opposite sign to the actual gradients, especially during price transitions. and If they have the same sign, then If the product is greater than 0, the penalty is 0. If the two have opposite signs, the product is negative. If the value is greater than or equal to 0, a penalty will be imposed.

[0130] This will enhance the shape and timing consistency of the predicted sequence, reduce control strategy mismatch caused by "phase shift" and "reverse prediction at turning points", and thus improve robustness across operating conditions.

[0131] S506, the sixth battery safety loss is obtained by weighting the deviation between the first arbitrage attractiveness index determined based on the first difference and the second arbitrage attractiveness index determined based on the second difference, and the range of the purchase and sale electricity price; wherein, the arbitrage attractiveness index represents the potential economic value of performing a charging operation at the current moment.

[0132] In this application embodiment, the core quantitative indicator is the "cumulative deviation of arbitrage attractiveness derived from the predicted net load (first difference) and the actual net load (second difference) within a preset time period". It is combined with the range of the purchase and sale electricity price (the difference between the maximum purchase price and the minimum purchase price) for weighting to obtain the sixth battery safety loss of "missing cross-time arbitrage opportunities due to prediction errors". The core is "in the scenario of drastic electricity price fluctuations and large arbitrage space, severely punish the misjudgment of arbitrage opportunities and ensure the battery's cross-time profitability".

[0133] Arbitrage opportunity loss The sixth battery safety loss is calculated as follows: the deviation between the predicted arbitrage attractiveness and the actual arbitrage attractiveness is penalized for missed cross-time arbitrage opportunities.

[0134]

[0135]

[0136] The "attractiveness" of charging arbitrage at the current moment is defined as being directly proportional to the current energy surplus and inversely proportional to the current electricity price. Punishment Predictive Attractiveness With actual appeal The deviation between them, multiplied by the electricity price range This means that on days with high price volatility (large arbitrage opportunities), the penalty for misjudging arbitrage opportunities is more severe.

[0137] S507 assigns corresponding second adjustable weights to the safety losses of the first battery, the second battery, the third battery, the fourth battery, the fifth battery, and the sixth battery, respectively.

[0138] In this application embodiment, six battery safety losses are included ( , , The second adjustable weights (β1, β2, β3, β4, β5, β6) should be allocated according to the principle of "physical safety first + economic arbitrage adaptation", such as β1=0.25, β2=0.3, β3=0.15, β4=0.1, β5=0.1, β6=0.1, which can be dynamically fine-tuned according to battery characteristics and electricity pricing mechanism.

[0139] S508 calculates the battery perception heuristic loss by weighting and summing the safety losses of each battery with their corresponding second adjustable weights.

[0140] In this embodiment of the application, the above items ( , , The weighted sums are then used to arrive at the final battery-perceived loss. That is: .

[0141] The above method quantifies the impact of prediction errors on energy storage batteries from six dimensions: SOC trajectory deviation, battery physical boundary constraints, asymmetric error in electricity price range, grid interaction cost mismatch, net load trend consistency, and cross-time arbitrage opportunity loss. Through differentiated weighting, six battery safety losses are obtained and fused into battery-aware heuristic losses by allocating adjustable weights. This multi-dimensional, refined, and flexible quantification of the safety risks, operational efficiency losses, and arbitrage profit losses brought to energy storage batteries by prediction errors not only anchors to the core constraints of battery physical operation but also fits the actual operational needs of economic arbitrage. The adjustable weights can better adapt to the battery characteristics and operational priorities of different building energy systems, allowing subsequent model training to specifically avoid key risks in battery operation and optimize arbitrage efficiency, ensuring that the battery safety and economic adaptation goals of model training are highly consistent with actual control.

[0142] S104. The prediction model is trained based on cost-weighted heuristic loss and battery-sensing heuristic loss to obtain the trained prediction model.

[0143] In this embodiment of the application, the cost-weighted heuristic loss is used. ) + Battery-sensory heuristic loss ( The total loss function, consisting of "" and "), is used to train the pre-set deep learning prediction model end-to-end, allowing the model to simultaneously consider "minimizing economic costs" and "compliance with battery operation safety" during the learning process, ultimately resulting in a post-trained prediction model that can output accurate energy prediction results and directly adapt to downstream optimization and control requirements.

[0144] In one embodiment, see Figure 6 This is a flowchart illustrating the training model provided in an embodiment of this application, as shown below. Figure 6 As shown, the steps include: S601 combines the cost-weighted heuristic loss and the battery-sensing heuristic loss to obtain the total loss.

[0145] In this embodiment of the application, during the training phase, the present invention does not directly seek the "optimal charging and discharging action," but rather trains a prediction model. This allows the output predictions to result in lower operating costs and fewer infeasibility / boundary risks in subsequent optimizations. Therefore, the objective during training is to minimize the total loss function: = + .

[0146] The significance of this step is to convert "prediction error" into "how much more money will be spent".

[0147] S602, calculate the gradient of the total loss relative to the prediction model if the total loss has not converged.

[0148] In the embodiments of this application, the total loss When convergence fails, calculate the gradient of the total loss with respect to the prediction model parameters θ. The core of this approach is to use automatic differentiation technology to reverse-transmit the joint optimization signal of "economic loss + battery safety loss", clarify the direction and degree of the influence of model parameters on the total loss, provide the core basis for subsequent parameter updates, and promote the model to gradually converge toward the goal of "economic optimality + physical safety".

[0149] Specifically, backpropagation calculates a direction that allows the model parameters ( After making a slight adjustment in this direction, It will decrease. The system will tell the model "which internal weights caused 'inaccurate predictions for expensive periods' or 'increased SOC risk,' and how to make changes."

[0150] S603, adjust the parameters of the prediction model in the direction of the gradient until the total loss converges, and obtain the trained prediction model.

[0151] In this embodiment, an optimizer is used to update the model parameters: the model is adjusted little by little in the "suggested direction" so that it is more in line with the goal of "cost-saving and feasible" next time.

[0152] Repeat the above steps until the prediction model converges. Once the model stabilizes, the process stops. Simultaneously, the optimal model parameters are obtained. This means obtaining the trained prediction model.

[0153] The ultimate goal is for the model to "practice repeatedly" through a large number of samples, and eventually learn to be more accurate and more in line with the battery's operating logic during critical periods.

[0154] In the above method, the total loss is obtained by superimposing cost-weighted and battery-aware heuristic losses. When the total loss has not converged, its gradient relative to the model is calculated and the model parameters are iteratively adjusted along the direction of the gradient until the loss converges. The dual objectives of minimizing economic costs and ensuring safe battery operation are integrated into the end-to-end training process of the model. Gradient optimization allows the model parameters to continuously iterate in the direction that conforms to actual control requirements, ensuring that the trained prediction model can simultaneously and accurately adapt to the economic arbitrage of building energy systems and the safe operation requirements of energy storage batteries. This avoids model performance bias caused by single-objective training, and the gradient iteration optimization method can efficiently allow the model to converge to the optimal state, ensuring a high degree of consistency between the model's prediction accuracy and actual control value.

[0155] S105, predictive control of building energy systems based on trained prediction models.

[0156] In this embodiment of the application, based on the trained prediction model (parameter optimized) The core of predictive control of building energy systems is to use the accurate prediction results output by the model to dynamically generate the optimal charging and discharging strategy in real time, so as to achieve the dual goals of "minimizing economic costs and ensuring safe battery operation". At the same time, it adapts to the cross-time arbitrage demand under time-of-use pricing, replacing the suboptimal mode of "predicting first and then optimizing".

[0157] The above method first collects historical meteorological, operational, and time-related multi-source heterogeneous data, inputs them into a preset prediction model to obtain predicted electricity consumption and photovoltaic load. Then, it jointly trains the model using cost-weighted heuristic loss (quantifying the economic cost impact of prediction errors) and battery-sensing heuristic loss (quantifying the impact of prediction errors on the safety and operation of energy storage batteries). Finally, the trained model is used to achieve predictive control of the building energy system. This method directly embeds downstream control objectives of economic cost and battery safety into the model training, making the prediction objectives and operational objectives highly unified. It avoids suboptimal results caused by insufficient prediction accuracy during critical periods. Instead of pursuing the "global minimum prediction error," it focuses on the "prediction result with optimal decision-making," achieving the optimal balance of "accuracy-cost-safety" under limited computing resources. This provides an interpretable and easily implementable optimization tool for data-driven building energy management, enabling precise, efficient, and economically optimal control of building energy storage system operation strategies.

[0158] In one embodiment, see Figure 7 This is a schematic diagram of the model prediction process provided in the embodiments of this application, such as... Figure 7 As shown, the steps include: S701 collects multi-source heterogeneous data of the target to be predicted; among which, the multi-source heterogeneous data of the target includes meteorological forecast data, current operation data and current time data corresponding to building energy.

[0159] In this application embodiment, the collection of multi-source heterogeneous data of the target to be predicted is based on three dimensions: "meteorological forecast data + current operation data + current time data". The core is to accurately collect key data that are strongly related to the operation of the building energy system and photovoltaic output, so as to provide complete input features for the trained prediction model and support the accurate prediction of subsequent electricity load, photovoltaic load and net load.

[0160] S702, extract features from the target multi-source heterogeneous data to obtain the feature vector corresponding to the target multi-source heterogeneous data.

[0161] In this embodiment, feature extraction is performed on target multi-source heterogeneous data (meteorological forecast data, current operating data, and current time data). The core is to transform unstructured / structured data into feature vectors with unified dimensions that can be directly input into the prediction model through four steps: "original feature screening, time-series feature construction, feature standardization, and feature fusion". This retains key information related to energy prediction and supports accurate prediction.

[0162] S703 inputs the feature vector into the trained prediction model to obtain the target electricity load and target photovoltaic load output by the prediction model.

[0163] In this embodiment of the application, the preprocessed feature vector is input into the trained prediction model (with optimized parameters). The model outputs the target electricity load and target photovoltaic load for a specified future time step through forward propagation. Both accurately reflect the core data of the building's future energy supply and demand, providing direct input for subsequent net load calculation and optimization control.

[0164] In the above method, multi-source heterogeneous data to be predicted is collected and feature vectors are extracted. These vectors are then input into the trained model to obtain the target electricity consumption and photovoltaic predicted load. This enables predictive control of the building energy system, allowing the trained model to output accurate energy prediction results based on real-time and comprehensive data. This provides a direct and reliable basis for subsequent operational decisions such as energy storage charging and discharging and grid interaction of the building energy system, ensuring the real-time performance and accuracy of predictive control. At the same time, relying on the economic and safety objectives incorporated during model training, the prediction results are naturally adapted to the control requirements of optimal system economy and safe battery operation, thereby improving the overall effect and practical application value of predictive control of the building energy system from the source.

[0165] See Figure 8 This is a schematic diagram of the overall structure of the energy control method based on a heuristic proxy loss function provided in the embodiments of this application, as shown below. Figure 8 As shown, it includes: Step 1: Obtain training samples (T1) Core action: Collect multi-source data required for training from sources such as building energy systems, weather stations, and power grid operators.

[0166] Data content includes historical meteorological data (temperature, irradiance, etc.), building operation data (electricity load, photovoltaic power, etc.), time data (collection timestamp), and external parameters (time-of-use electricity price, battery physical parameters such as capacity, charge and discharge efficiency, etc.).

[0167] Function: To provide raw data support for model training and ensure that training samples cover real-world operating scenarios.

[0168] Step 2: Forward propagation calculation (T2) The core action is to input the preprocessed feature vector (integrating historical load, photovoltaic, meteorological, and other data) into the initialized deep learning prediction model and perform forward propagation.

[0169] Key outputs: Predicted electricity load and photovoltaic load for multiple future time steps, and then the predicted net load is calculated. Simultaneously, the actual net load is calculated based on actual data. ), and finally the prediction error is obtained ( ).

[0170] Function: To establish the basic link of "input-output-error" and provide the core basis for subsequent loss calculation.

[0171] Step 3: Construct the heuristic proxy loss (T3) Core action: Based on the prediction error, calculate the total loss in two parts ( It integrates economic costs and battery safety constraints.

[0172] Sub-step T3.1: Calculate the cost-weighted heuristic loss ( ): Combining dynamic electricity prices (purchase and sale prices, price difference, peak electricity prices) and grid interaction status (buying / selling electricity), the economic loss of prediction errors is quantified through four components: asymmetric direct costs, price difference sensitive costs, peak price penalties, and sign mismatch penalties.

[0173] Sub-step T3.2: Calculate the battery-sensing heuristic loss ( By approximating the battery charging and discharging trends and extrapolating the SOC trajectory, six components are calculated, including SOC trajectory deviation, physical boundary constraints, and price range asymmetric penalties, to quantify the impact of prediction errors on battery safety and arbitrage efficiency.

[0174] Function: Transform "inaccurate prediction" into "economic loss + safety risk", so that the model training objectives are aligned with actual operational needs.

[0175] Step 4: Backpropagation to calculate the gradient (T4) Core action: Calculate the total loss using automatic differentiation technology. = + The gradient of the model with respect to the model parameters (θ).

[0176] Purpose: To clarify the direction and extent of the influence of model parameters on the total loss, and to provide "optimization guidance" for parameter adjustment—that is, "which parameters cause the loss to increase and how to adjust them."

[0177] Step 5: Update the parameter optimization model (T5) The core operation involves using a gradient descent optimizer (such as Adam or SGD) to iteratively update the model parameters based on the gradients obtained from backpropagation.

[0178] Purpose: To fine-tune model parameters so that the model can reduce total loss in the next prediction and gradually move closer to the goal of "economic optimization + safety and compliance".

[0179] Step 6: Determine convergence and output the optimal model (T6) Core action: Repeat steps T1-T5, continuously iterating the training until the total loss is reached ( It tends to stabilize on the validation set (satisfying the convergence condition).

[0180] Final output: Training stops, and the optimal prediction model with optimized parameters is obtained. This can be used for predictive control of subsequent building energy systems.

[0181] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0182] Corresponding to the energy control method based on the heuristic agent loss function in the above embodiment, Figure 8 This is a structural block diagram of an energy control device based on a heuristic proxy loss function provided in the embodiments of this application. For ease of explanation, only the parts related to the embodiments of this application are shown.

[0183] Reference Figure 9 The device includes: The data acquisition module 91 is used to collect multi-source heterogeneous data corresponding to building energy systems with photovoltaic and energy storage batteries; among which, the multi-source heterogeneous data includes historical meteorological data, historical operation data and historical time data corresponding to building energy; The energy forecasting module 92 is used to input multi-source heterogeneous data into the constructed forecasting model to obtain energy forecasting results; wherein, the energy forecasting results include electricity consumption forecasting load and photovoltaic forecasting load; The loss construction module 93 is used to construct cost-weighted heuristic loss and battery-sensing heuristic loss based on energy forecast results; wherein, the cost-weighted heuristic loss is used to characterize the impact of energy forecast results on the operating economic cost of building energy systems; and the battery-sensing heuristic loss is used to characterize the impact of energy forecast results on energy storage batteries. Model training module 94 is used to train the prediction model based on cost-weighted heuristic loss and battery-aware heuristic loss to obtain the trained prediction model. Model prediction module 95 is used for predictive control of building energy systems based on the trained prediction model.

[0184] Optionally, loss building block 93 is also used for: This is used to construct cost-weighted heuristic loss and battery-sensory heuristic loss based on energy forecast results; wherein, cost-weighted heuristic loss is used to characterize the impact of energy forecast errors on the operating economic cost of building energy systems; and battery-sensory heuristic loss is used to characterize the impact of energy forecast results on energy storage batteries. Optionally, loss building block 93 is also used for: Calculate the first difference between the predicted electricity load and the predicted photovoltaic load in the energy forecast results; Calculate the second difference between the actual electricity load and the actual photovoltaic load in the actual energy results; The energy prediction error is obtained by performing difference processing on the first difference and the second difference.

[0185] Optionally, loss building block 93 is also used for: Based on the state of the second difference and the corresponding electricity price parameters, the energy forecasting error is calculated using a differentiated weighted average to obtain the first cost loss; wherein, the state of the second difference includes positive and negative states; The second cost loss is obtained by weighting the absolute value of the energy forecasting error based on the ratio of the current electricity purchase and sale price difference to the average electricity purchase price. The third cost loss is calculated by weighting the absolute value of the energy forecast error based on the first deviation between the current electricity purchase price and the average electricity purchase price, and the current electricity purchase price. The fourth cost loss is calculated by weighting the absolute value of the energy forecast error based on the sign of the first difference, the sign of the second difference, and the current electricity purchase price. A cost-weighted heuristic loss is constructed based on the first cost loss, the second cost loss, the third cost loss, and the fourth cost loss.

[0186] Optionally, loss building block 93 is also used for: Each of the first cost loss, second cost loss, third cost loss, and fourth cost loss is assigned a corresponding first adjustable weight; The cost-weighted heuristic loss is obtained by weighting and summing each cost loss with its corresponding first adjustable weight.

[0187] Optionally, loss building block 93 is also used for: The first battery safety loss is obtained by weighting the second deviation value between the first state of charge trajectory and the second state of charge trajectory with the current electricity purchase price; wherein, the first state of charge trajectory is the state of charge trajectory of the energy storage battery derived based on the first difference; and the second state of charge trajectory is the state of charge trajectory of the energy storage battery derived based on the second difference. The second battery safety loss is obtained by weighting the first state of charge trajectory and the safe operating boundary of the energy storage battery with the current electricity purchase price. The third battery safety loss is calculated by weighting the electricity price range, energy forecast error, and current electricity purchase price. The fourth battery safety loss is obtained by weighting the third deviation value between the first grid interaction cost and the second grid interaction cost with the purchase and sale price of electricity; wherein, the first grid interaction cost is the interaction cost with the grid when the energy storage battery performs an approximate operation based on the first difference; the second grid interaction cost is used to characterize the actual interaction cost with the grid when the energy storage battery performs an approximate operation based on the second difference; The fifth battery safety loss is calculated by weighting the rate of change of the first difference, the rate of change of the second difference, and the rate of change of the current electricity purchase price. The sixth battery safety loss is calculated by weighting the deviation between the first arbitrage attractiveness index determined based on the first difference and the second arbitrage attractiveness index determined based on the second difference, as well as the range of the purchase and sale electricity price; whereby the arbitrage attractiveness index represents the potential economic value of performing a charging operation at the current moment. Each of the first battery safety loss, the second battery safety loss, the third battery safety loss, the fourth battery safety loss, the fifth battery safety loss, and the sixth battery safety loss is assigned a corresponding second adjustable weight. The battery perception heuristic loss is obtained by weighting and summing the safety losses of each battery with their corresponding second adjustable weights.

[0188] Optional, model training module 94, used for: The cost-weighted heuristic loss and the battery-sensing heuristic loss are superimposed to obtain the total loss; If the total loss does not converge, calculate the gradient of the total loss relative to the prediction model; Adjust the parameters of the prediction model in the direction of the gradient until the total loss converges to obtain the trained prediction model.

[0189] Optional, model prediction module 95, used for: Collect multi-source heterogeneous data of the target to be predicted; among which, the multi-source heterogeneous data of the target includes meteorological forecast data, current operation data and current time data corresponding to building energy; Feature extraction is performed on the target multi-source heterogeneous data to obtain the feature vector corresponding to the target multi-source heterogeneous data; The feature vectors are input into the trained prediction model to obtain the target electricity load and target photovoltaic load output by the prediction model.

[0190] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0191] in addition, Figure 8The energy control device based on the heuristic agent loss function shown can be a software unit, a hardware unit, or a combination of software and hardware built into existing terminal devices. It can also be integrated into the terminal device as an independent component or exist as a standalone terminal device.

[0192] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0193] Figure 10 This is a schematic diagram of the structure of the terminal device provided in the embodiments of this application. For example... Figure 10 As shown, the terminal device 10 of this embodiment includes: at least one processor 100 ( Figure 10 (Only one is shown in the diagram) a processor, a memory 101, and a computer program 102 stored in the memory 101 and executable on the at least one processor 100, wherein the processor 100 executes the computer program 102 to implement the steps in any of the above embodiments of the energy control device method based on the heuristic agent loss function.

[0194] The terminal device may be a desktop computer, laptop, handheld computer, or cloud server, etc. This terminal device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that... Figure 10 This is merely an example of terminal device 10 and does not constitute a limitation on terminal device 10. It may include more or fewer components than shown, or combine certain components, or different components, such as input / output devices, network access devices, etc.

[0195] The processor 100 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0196] In some embodiments, the memory 101 may be an internal storage unit of the terminal device 10, such as a hard disk or memory of the terminal device 10. In other embodiments, the memory 101 may be an external storage device of the terminal device 10, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the terminal device 10. Furthermore, the memory 101 may include both internal and external storage units of the terminal device 10. The memory 101 is used to store the operating system, applications, boot loader, data, and other programs, such as the program code of the computer program. The memory 101 can also be used to temporarily store data that has been output or will be output.

[0197] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps in the above-described method embodiments.

[0198] This application provides a computer program product that, when run on a terminal device, enables the terminal device to implement the steps described in the above-described method embodiments.

[0199] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium can include at least: any entity or device capable of carrying computer program code to a device / terminal equipment, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.

[0200] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0201] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0202] In the embodiments provided in this application, it should be understood that the disclosed apparatus / terminal devices and methods can be implemented in other ways. For example, the apparatus / terminal device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0203] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0204] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. An energy control method based on a heuristic surrogate loss function, characterized in that, The method includes: Collect multi-source heterogeneous data corresponding to building energy systems with photovoltaic and energy storage batteries; wherein, the multi-source heterogeneous data includes historical meteorological data, historical operational data and historical time data corresponding to building energy; The multi-source heterogeneous data is input into the constructed prediction model to obtain energy prediction results; wherein, the energy prediction results include electricity consumption prediction load and photovoltaic prediction load; Based on the energy forecast results, a cost-weighted heuristic loss and a battery-perceived heuristic loss are constructed; wherein, the cost-weighted heuristic loss is used to characterize the impact of the energy forecast results on the operating economic cost of the building energy system; and the battery-perceived heuristic loss is used to characterize the impact of the energy forecast results on the energy storage battery. The prediction model is trained based on the cost-weighted heuristic loss and the battery-aware heuristic loss to obtain the trained prediction model. Predictive control of building energy systems is achieved based on the trained predictive model.

2. The energy control method based on a heuristic surrogate loss function as described in claim 1, characterized in that, The construction of cost-weighted heuristic loss and battery-aware heuristic loss based on the energy prediction results includes: Obtain the actual energy results corresponding to the energy forecast results; wherein, the actual energy results include actual electricity load and actual photovoltaic load; Calculate the energy forecast error based on the energy forecast results and the actual energy results; Based on the energy prediction error, a cost-weighted heuristic loss and a battery-sensing heuristic loss are constructed.

3. The energy control method based on a heuristic surrogate loss function as described in claim 2, characterized in that, The calculation of energy prediction error based on the energy prediction results and actual energy results includes: Calculate the first difference between the predicted electricity load and the predicted photovoltaic load in the energy forecast results; Calculate the second difference between the actual electricity load and the actual photovoltaic load in the actual energy results; The energy prediction error is obtained by performing difference processing on the first difference and the second difference.

4. The energy control method based on a heuristic surrogate loss function as described in claim 3, characterized in that, The steps for constructing a cost-weighted heuristic loss based on the energy prediction error include: Based on the state of the second difference and the corresponding electricity price parameters, the energy prediction error is calculated using a differentiated weighted average to obtain the first cost loss; wherein, the state of the second difference includes positive and negative values. The second cost loss is obtained by weighting the absolute value of the energy forecasting error based on the ratio of the current electricity purchase and sale price difference to the average electricity purchase price. The third cost loss is obtained by weighting the absolute value of the energy prediction error based on the current electricity purchase price, the first deviation between the average electricity purchase price and the current electricity purchase price; The fourth cost loss is obtained by weighting the absolute value of the energy forecast error based on the sign of the first difference, the sign of the second difference, and the current electricity purchase price. Each of the first cost loss, the second cost loss, the third cost loss, and the fourth cost loss is assigned a corresponding first adjustable weight. The cost-weighted heuristic loss is obtained by weighting and summing each cost loss with its corresponding first adjustable weight.

5. The energy control method based on a heuristic surrogate loss function as described in claim 4, characterized in that, The steps for constructing a battery-aware heuristic loss based on the energy prediction error include: The first battery safety loss is obtained by weighting the second deviation value between the first state of charge trajectory and the second state of charge trajectory with the current electricity purchase price; wherein, the first state of charge trajectory is the state of charge trajectory of the energy storage battery derived based on the first difference; and the second state of charge trajectory is the state of charge trajectory of the energy storage battery derived based on the second difference. The second battery safety loss is obtained by weighting the first state of charge trajectory and the safe operating boundary of the energy storage battery with the current electricity purchase price. The third battery safety loss is calculated by weighting the electricity price range, energy forecast error, and current electricity purchase price. The fourth battery safety loss is obtained by weighting the third deviation value between the first grid interaction cost and the second grid interaction cost with the purchase and sale price of electricity; wherein, the first grid interaction cost is the interaction cost with the grid when the energy storage battery performs an approximate operation based on the first difference; the second grid interaction cost is used to characterize the actual interaction cost with the grid when the energy storage battery performs the approximate operation based on the second difference; The fifth battery safety loss is calculated by weighting the rate of change of the first difference, the rate of change of the second difference, and the rate of change of the current electricity purchase price. The sixth battery safety loss is calculated by weighting the deviation between the first arbitrage attractiveness index determined based on the first difference and the second arbitrage attractiveness index determined based on the second difference, and the range of the purchase and sale electricity price; wherein, the arbitrage attractiveness index represents the potential economic value of performing a charging operation at the current moment; Each of the first battery safety loss, the second battery safety loss, the third battery safety loss, the fourth battery safety loss, the fifth battery safety loss, and the sixth battery safety loss is assigned a corresponding second adjustable weight. The battery perception heuristic loss is obtained by weighting and summing the safety losses of each battery with their corresponding second adjustable weights.

6. The energy control method based on a heuristic surrogate loss function as described in claim 5, characterized in that, The process of training the prediction model based on the cost-weighted heuristic loss and the battery-aware heuristic loss to obtain the trained prediction model includes: The cost-weighted heuristic loss and the battery-sensing heuristic loss are superimposed to obtain the total loss; If the total loss does not converge, calculate the gradient of the total loss relative to the prediction model; The parameters of the prediction model in the direction of the gradient are adjusted until the total loss converges, thus obtaining the trained prediction model.

7. The energy control method based on a heuristic surrogate loss function as described in claim 6, characterized in that, The prediction and control of building energy systems based on the trained prediction model includes: Collect multi-source heterogeneous data of the target to be predicted; wherein, the multi-source heterogeneous data of the target includes meteorological forecast data, current operation data and current time data corresponding to building energy; Feature extraction is performed on the target multi-source heterogeneous data to obtain the feature vector corresponding to the target multi-source heterogeneous data; The feature vector is input into the trained prediction model to obtain the target electricity load forecast and the target photovoltaic load forecast output by the prediction model.

8. An energy control device based on a heuristic surrogate loss function, characterized in that, include: The data acquisition module is used to collect multi-source heterogeneous data corresponding to building energy systems with photovoltaic and energy storage batteries; wherein, the multi-source heterogeneous data includes historical meteorological data, historical operating data and historical time data corresponding to building energy; An energy forecasting module is used to input the multi-source heterogeneous data into a constructed forecasting model to obtain energy forecasting results; wherein, the energy forecasting results include electricity consumption forecasting load and photovoltaic forecasting load; A loss construction module is used to construct a cost-weighted heuristic loss and a battery-perceived heuristic loss based on the energy forecast results; wherein, the cost-weighted heuristic loss is used to characterize the impact of the energy forecast results on the operating economic cost of the building energy system; and the battery-perceived heuristic loss is used to characterize the impact of the energy forecast results on the energy storage battery. The model training module is used to train the prediction model based on the cost-weighted heuristic loss and the battery-aware heuristic loss to obtain the trained prediction model. The model prediction module is used to predict and control the energy of building energy systems based on the trained prediction model.

9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Distributed optical storage micro-grid control system based on large model and energy management method

    CN120566532A

  • CNN-LSTM-AM-based microgrid power load prediction and dynamic control method

    CN120613787A

  • Charging and discharging scheduling method and device of energy storage power station and nonvolatile storage medium

    CN120657756A

  • Household charging pile charging strategy generation method and system

    CN121146335A

  • Multi-objective optimization method and system for regional integrated energy system

    CN121212490A