Similar day retrieval method and device, computer device, storage medium and product

CN121614522BActive Publication Date: 2026-08-11SHANGHAI LUXINGGUANG INTELLIGENT TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-01-30
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0003]相关技术中,通常根据外生变量实现相似日检索,该方法存在准确度不足的问题

Benefits of technology

[0020]第五方面,本申请还提供了一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现本申请第一方面提供的相似日检索方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121614522B_ABST
    Figure CN121614522B_ABST
Patent Text Reader

Abstract

This application relates to a method, apparatus, computer device, storage medium, and product for similar day retrieval. The method includes: inputting a sequence of exogenous variables related to the day-ahead electricity price of a target day into a pre-trained sequence encoder to obtain a feature vector for the target day, wherein the sequence encoder is trained based on exogenous variables and day-ahead electricity prices of multiple historical days; determining, from a pre-constructed database, target feature vectors whose similarity parameter to the feature vector of the target day is greater than a preset similarity threshold; wherein the database includes feature vectors of each historical day; and determining the historical day corresponding to the target feature vector as a similar day to the target day. This method can improve the accuracy of similar day retrieval.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electricity market price forecasting technology, and in particular to a similarity day retrieval method, apparatus, computer equipment, storage medium, and product. Background Technology

[0002] The formation of electricity prices in the current daytime market is influenced by multiple exogenous variables, including system load forecasting, inter-regional tie-line plans, renewable energy output forecasting, bidding-related indicators, and available generating capacity. On the operational side, it is necessary to retrieve "similar days" from historical data that show price trends close to the target daytime price to aid in modeling, parameter transfer, scenario simulation, and strategy evaluation.

[0003] In related technologies, similar date retrieval is usually achieved based on exogenous variables, but this method suffers from insufficient accuracy. Summary of the Invention

[0004] Therefore, it is necessary to provide a similar day retrieval method, apparatus, computer equipment, storage medium, and product that can improve the accuracy of similar day retrieval in response to the above-mentioned technical problems.

[0005] Firstly, this application provides a similar date retrieval method, including:

[0006] The sequence of exogenous variables related to the day-ahead electricity price of the target day is input into a pre-trained sequence encoder to obtain the feature vector of the target day, wherein the sequence encoder is trained based on exogenous variables and day-ahead electricity prices of multiple historical days;

[0007] From a pre-built database, target feature vectors with a similarity parameter greater than a preset similarity threshold with the feature vector of the target day are identified; wherein, the database includes feature vectors of each historical day;

[0008] The historical days corresponding to the target feature vector are determined as similar days to the target day.

[0009] In one embodiment, the training method of the sequence encoder includes: acquiring multi-time period information sequences of multiple historical days, the multi-time period information sequences including exogenous variables and day-ahead electricity prices for each time period; determining an anchor day and the corresponding positive sample day and negative sample day from the multiple historical days; training an initial sequence encoder based on triplet training samples to obtain the sequence encoder; wherein, the triplet training samples include the multi-time period information sequences of the anchor day, the multi-time period information sequences of the positive sample days, and the multi-time period information sequences of the negative sample days.

[0010] In one embodiment, determining the anchor day and the corresponding positive and negative sample days from the plurality of historical days includes: randomly determining three historical days from the plurality of historical days, and determining the anchor day and candidate days from the three historical days; and determining the corresponding positive and negative sample days from the two candidate days based on the similarity parameters between the day-ahead electricity price of the anchor day and the day-ahead electricity prices of the two candidate days.

[0011] In one embodiment, training the initial sequence encoder based on triplet training samples to obtain the sequence encoder includes: acquiring historical similar day pairs; training the initial sequence encoder based on the multi-time period information sequence of the historical similar day pairs and the triplet training samples to obtain the sequence encoder; wherein the loss function used in the training includes a triplet loss function and a similarity constraint loss function.

[0012] In one embodiment, training the initial sequence encoder based on triplet training samples to obtain the sequence encoder includes: performing multi-task training on the initial sequence encoder based on the triplet training samples; in the multi-task training, the output of the initial sequence encoder is simultaneously input into two parallel first branches and second branches, wherein the first branch is used to calculate the triplet loss, and the second branch is used to predict the day-ahead electricity price and calculate the price prediction loss.

[0013] In one embodiment, the exogenous variable sequence corresponding to the target day is input into a pre-trained sequence encoder to obtain the feature vector of the target day. This includes: preprocessing the exogenous variable sequence corresponding to the target day to obtain a preprocessed exogenous variable sequence; wherein the preprocessing includes at least one of missing value processing, outlier detection and processing, and standardization processing; and inputting the preprocessed exogenous variable sequence into the pre-trained sequence encoder to obtain the feature vector of the target day.

[0014] Secondly, this application also provides a similar date retrieval device, comprising:

[0015] The input module is used to input the sequence of exogenous variables related to the day-ahead electricity price of the target day into a pre-trained sequence encoder to obtain the feature vector of the target day, wherein the sequence encoder is trained based on exogenous variables and day-ahead electricity prices of multiple historical days;

[0016] The first determining module is used to determine, from a pre-built database, a target feature vector whose similarity parameter to the feature vector of the target day is greater than a preset similarity threshold; wherein, the database includes feature vectors of each historical day;

[0017] The second determining module is used to determine the historical day corresponding to the target feature vector as a similar day to the target day.

[0018] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the similar date retrieval method provided in the first aspect of this application.

[0019] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the similar date retrieval method provided in the first aspect of this application.

[0020] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the similarity search method provided in the first aspect of this application.

[0021] The aforementioned similar day retrieval method, apparatus, computer equipment, computer-readable storage medium, and computer program product input the exogenous variable sequence related to the day-ahead electricity price of the target day into a pre-trained sequence encoder to obtain the feature vector of the target day. The sequence encoder is trained based on exogenous variables and day-ahead electricity prices from multiple historical days. From a pre-constructed database, target feature vectors with a similarity parameter greater than a preset similarity threshold are identified. The database includes feature vectors from each historical day. The historical day corresponding to the target feature vector is determined as a similar day to the target day. The reason for the low accuracy of similar day retrieval in related technologies that rely solely on exogenous variables is that there is a complex and non-linear mapping relationship between exogenous variables and day-ahead electricity prices, and the relationship is susceptible to interference from random noise, etc. Furthermore, exogenous variables are not equivalent to price trends. The embodiments of this application employ a sequence encoder trained using historical day-ahead electricity prices. This sequence encoder extracts feature vectors strongly correlated with day-ahead electricity prices from the exogenous variable sequence of the target day. The similarity between the feature vectors output by the sequence encoder is used to characterize the similarity between day-ahead electricity prices. Therefore, even if the exogenous variables of two days differ in the original space, as long as the day-ahead electricity prices of these two days are similar or highly similar, their feature vector representations will still be similar. Conversely, two days that appear similar but whose day-ahead electricity prices are not similar or not sufficiently similar will not have similar feature vectors. Thus, similarity retrieval in the vector space can avoid or reduce the interference of exogenous variables, directly capture the essential consistency of price trends, achieve more accurate similar day retrieval, and thereby improve the accuracy of similar days. Attached Figure Description

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

[0023] Figure 1 This is a diagram illustrating the application environment of a similar day retrieval method in one embodiment;

[0024] Figure 2 This is a flowchart illustrating a similar date retrieval method in one embodiment;

[0025] Figure 3 This is a flowchart illustrating a training method for a sequence encoder in one embodiment;

[0026] Figure 4 This is a schematic diagram of the structure of a sequence encoder in one embodiment;

[0027] Figure 5 This is a flowchart illustrating a similarity search method in a specific example.

[0028] Figure 6 This is a structural block diagram of a similar day retrieval device in one embodiment;

[0029] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0031] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0032] Technical research has revealed that related technologies typically rely on exogenous variables to achieve similarity date retrieval. This involves calculating the similarity between historical dates and target dates on the exogenous variable sequence, ranking historical dates based on similarity scores, and using the top-ranked dates as similar dates. However, this method has the following problems:

[0033] (1) Insufficient utilization of features and failure to learn a unified discriminant representation for price similarity, resulting in insufficient retrieval accuracy;

[0034] (2) Retrieval efficiency is limited in large-scale historical databases;

[0035] (3) Insufficient robustness to outliers and seasonal drift.

[0036] Therefore, it is necessary to propose an end-to-end representation learning and efficient retrieval scheme for the sequence of "daily time period information and exogenous variables", which directly learns the vector space structure of "price trend similarity" to achieve a more accurate, efficient and scalable similar day retrieval method.

[0037] To address this, this application proposes a similar day retrieval method. In the learning phase, the method takes daily time-segment information and exogenous variable sequences from the electricity market as input. First, data preprocessing is performed, converting the multi-time-segment, multi-dimensional feature sequences of each natural day into fixed-length vectors. Then, based on the price similarity between historical days, triplet samples of anchor days, positive sample days, and negative sample days are constructed. Triplet loss is used to supervise the learning of the sequence encoder, obtaining a low-dimensional vector representation that can characterize "price trend similarity." In the inference phase, the vector representation of any target day is calculated, and historical dates with similar price trends are retrieved from the vector retrieval index by distance metric. A list of similar days and a similarity score are output. An exemplary description follows.

[0038] The similar date retrieval method provided in this application embodiment can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located on the cloud or other network servers. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0039] In one exemplary embodiment, such as Figure 2 As shown, a similar date retrieval method is provided, which can be applied to... Figure 1 Taking the server in the example, the explanation includes the following steps 201 to 203. Wherein:

[0040] Step 201: Input the sequence of exogenous variables related to the day-ahead electricity price of the target day into a pre-trained sequence encoder to obtain the feature vector of the target day.

[0041] The sequence encoder is trained based on exogenous variables and day-ahead electricity prices from multiple historical days. This sequence encoder can be a neural network model, trained on massive amounts of exogenous variables and day-ahead electricity prices from historical days. It has learned the mapping relationship from the exogenous variable sequence to a low-dimensional vector space related to the day-ahead electricity price pattern, and has the ability to encode the exogenous variable sequence into a fixed-length low-dimensional vector, called the feature vector. The feature vector is used to represent the information related to day-ahead electricity prices in the exogenous variable sequence. The target day refers to a future natural day that needs to be predicted or evaluated in the day-ahead electricity market application scenario, such as the next day. Exogenous variables refer to multidimensional data consisting of predictive or planned key market parameters that change over time and are used to drive and explain the formation of day-ahead electricity prices. These typically include, but are not limited to, system load forecasts, inter-regional tie-line plans, renewable energy output forecasts, bidding-related indicators, and available unit capacity. The exogenous variable sequence related to the day-ahead electricity price of the target date is the exogenous variable data for the target date (such as day A) predicted and released by the power market operator, dispatch center or professional forecasting agency on the day before the target date (such as day A-1). This data is organized in the form of a time series, covering the complete cycle of the target date (usually 24 hours, with intervals of seconds, minutes or hours). Each time period, point in time or moment corresponds to a set of multidimensional exogenous variable data, thus forming the exogenous variable sequence.

[0042] For example, the exogenous variable sequence corresponding to the target day (a future day to be retrieved, such as day A) is first obtained. Then, the exogenous variable sequence is input into a pre-trained sequence encoder. After receiving the exogenous variable sequence, the sequence encoder performs forward inference calculations based on learned price similarity patterns to obtain the feature vector corresponding to the target day. This feature vector is used to characterize the day-ahead electricity price pattern of the target day for subsequent similarity matching. The day-ahead electricity price pattern can be understood as the deep-seated morphological characteristics and changing patterns presented by the day-ahead electricity price curve, such as peak-valley characteristics, volatility and trend characteristics, as well as structural patterns (such as single-peak and double-peak structures) and correlation patterns (such as the relationship between prices in different time periods).

[0043] Step 202: From the pre-built database, determine the target feature vector whose similarity parameter with the feature vector of the target day is greater than a preset similarity threshold; wherein, the database includes feature vectors of each historical day.

[0044] The database stores a massive number of feature vectors for each historical day. Each feature vector is encoded by the same sequence encoder from the exogenous variable sequence of the corresponding historical day. The database can be constructed and optimized using vector indexing technology that supports efficient nearest neighbor search. Each feature vector in the database is associated with a unique corresponding historical day identifier, forming a mapping relationship between historical days and feature vectors. The preset similarity threshold refers to a pre-set and stored standard value based on historical experience, actual needs, or experimental verification, used to determine whether two feature vectors are sufficiently similar. The preset similarity threshold may include a cosine similarity threshold and / or a Euclidean distance threshold.

[0045] For example, after obtaining the feature vector of the target day, a similarity parameter is determined between the feature vector of the target day and the feature vector of each historical day in the database. This similarity parameter is a quantitative measure of the similarity between vectors, such as using cosine similarity or the reciprocal of Euclidean distance. Then, all historical days are sorted according to this similarity parameter, and one or more historical days with a similarity parameter greater than a preset similarity threshold are selected. The feature vectors of these historical days are the target feature vectors.

[0046] Step 203: Determine the historical day corresponding to the target feature vector as the similar day to the target day.

[0047] The number of similar days is at least one, and each similar day can correspond to a different similarity parameter.

[0048] For example, the historical day identifier (e.g., date) and similarity parameter corresponding to each target feature vector are output as a list of similar days for the target day. Optionally, multiple similar days can be arranged in descending order of similarity parameter, and their corresponding similarity scores can be output simultaneously for use by downstream business systems (e.g., price prediction models).

[0049] For example, taking the current day as (day) A-1 and the target day as the future day A (i.e., the next day), on day A-1, the exogenous variable sequence for each time period of day A is predicted, and this exogenous variable sequence is input into a pre-trained sequence encoder to obtain a feature vector representing the day-ahead price pattern of day A. Then, the similarity parameter between the feature vector of day A and the feature vectors of each historical day in the database (tracing back from day A-1 to day An, where n is greater than 2) is determined. If, after calculation and comparison, the cosine similarity parameter between the feature vector of day A and the feature vector of day A-3 is greater than the preset similarity threshold of 0.9, then the day-ahead price trend of day A-3 is determined to be sufficiently similar to that of day A, and day A-3 is thus determined as a similar day to day A.

[0050] In the aforementioned similar day retrieval method, the exogenous variable sequence related to the day-ahead electricity price of the target day is input into a pre-trained sequence encoder to obtain the feature vector of the target day. The sequence encoder is trained based on exogenous variables and day-ahead electricity prices from multiple historical days. From a pre-constructed database, target feature vectors with a similarity parameter greater than a preset similarity threshold are identified. The database includes feature vectors from various historical days. The historical day corresponding to the target feature vector is then determined as a similar day to the target day. The reason for the low accuracy of similar day retrieval in related technologies that rely solely on exogenous variables is that there is a complex and non-linear mapping relationship between exogenous variables and day-ahead electricity prices, and the relationship is susceptible to interference from random noise, etc. Furthermore, exogenous variables are not equivalent to price trends. The embodiments of this application employ a sequence encoder trained using historical day-ahead electricity prices. This sequence encoder extracts feature vectors strongly correlated with day-ahead electricity prices from the exogenous variable sequence of the target day. The similarity between the feature vectors output by the sequence encoder is used to characterize the similarity between day-ahead electricity prices. Therefore, even if the exogenous variables of two days differ in the original space, as long as the day-ahead electricity prices of these two days are similar or highly similar, their feature vector representations will still be similar. Conversely, two days that appear similar but whose day-ahead electricity prices are not similar or not sufficiently similar will not have similar feature vectors. Thus, similarity retrieval in the vector space can avoid or reduce the interference of exogenous variables, directly capture the essential consistency of price trends, achieve more accurate similar day retrieval, and thereby improve the accuracy of similar days.

[0051] The following exemplifies a specific implementation of training a sequence encoder during the offline training phase.

[0052] In one exemplary embodiment, the similarity date retrieval method further includes a sequence encoder training method, such as... Figure 3 As shown, the method includes steps 301 to 303. Wherein:

[0053] Step 301: Obtain multi-period information sequences for multiple historical days. The multi-period information sequences include exogenous variables and day-ahead electricity prices for each period.

[0054] In other words, the multi-period information series includes exogenous variable series and day-ahead electricity price series. Among them, exogenous variables include, but are not limited to, bidding-related indicators, system load forecasts, tie-line plans, renewable energy power forecasts, operating capacity or their derived indicators.

[0055] For example, firstly, a massive amount of multi-period information sequences for historical days are acquired, namely exogenous variables and day-ahead electricity price sequences. Each period of each historical day has an exogenous variable and the corresponding day-ahead electricity price. The multi-period information sequences of historical days cover all periods of that historical day (e.g., 96 periods). Then, the multi-period information sequences of historical days are preprocessed, such as handling missing values, outlier detection, and standardization, converting the multi-period information sequences of historical days into fixed-length feature vectors to simplify subsequent processing. The fixed-length feature vectors of all historical days constitute the historical dataset.

[0056] Step 302: Determine the anchor date and the corresponding positive and negative sample dates from multiple historical dates.

[0057] For example, multiple different historical days (identifiers) are randomly selected from the historical dataset as anchor days. Based on the similarity parameter between the price sequences of the previous day in the multi-period information sequence, one positive sample day and one negative sample day are selected from the remaining historical days for each anchor day. At least one of the two sample days of each anchor day constitutes a triplet consisting of different anchor days and their corresponding positive and negative sample days. The multi-period information sequence of each triplet is obtained to form multiple triplet training samples (i.e., all training samples) for encoder training. Each triplet training sample includes the corresponding multi-period information sequence of the anchor day, the multi-period information sequence of the positive sample day, and the multi-period information sequence of the negative sample day.

[0058] Step 303: Train the initial sequence encoder based on the triplet training samples to obtain the sequence encoder.

[0059] For example, the training process is performed iteratively, which can be achieved by repeatedly executing the following steps: First, a triplet training sample is selected from all training samples and input into the initial sequence encoder to obtain three corresponding feature vectors. Then, based on these three feature vectors and the historical day-ahead price sequence, the triplet loss function value is calculated. This triplet loss function is used to constrain that the distance between the feature vectors of the anchor day and the positive sample day should be less than the distance between the feature vectors of the anchor day and the negative sample day by at least a preset interval hyperparameter. That is, the triplet loss function enables the encoder to learn feature representations consistent with the similarity to the day-ahead price by constraining the distance relationship between the feature vectors. Afterward, the gradient of this loss with respect to the encoder parameters is calculated using the backpropagation algorithm, and all weight parameters of the encoder are updated based on this gradient using an optimization algorithm. The above process iterates over a large number of different triplet training samples. Each time, a triplet training sample is used to drive a parameter update. This process is repeated until the encoder learns to map exogenous variables of historical days with similar (or high) price trends to nearby positions in the vector space, while mapping dissimilar (or low) historical days to distant positions. Finally, the encoder converges to obtain a sequence encoder that can accurately output feature vectors representing the similarity of price patterns before the current day.

[0060] The initial learning objective of the sequence encoder during training is to map the exogenous variable sequences of the anchor day and positive sample days to positions close to each other in the feature vector space, while pushing the mapping results of the anchor day and negative sample days further apart. Through iterative optimization of this objective, the sequence encoder extracts essential features from the exogenous variables that can explain and reflect the differences in day-to-day electricity price similarity, thus learning to associate exogenous variables with deeper price levels. After training, with fixed model parameters, the final sequence encoder is obtained. This sequence encoder learns the mapping relationship from the exogenous variable sequences to low-dimensional feature vectors, and this mapping relationship is optimized to ensure that the proximity between feature vectors in the generated feature vector space directly and effectively reflects the similarity of day-to-day electricity price patterns between corresponding dates. The sequence encoder is then deployed for subsequent online retrieval of similar days.

[0061] The formula for the triplet loss function is as follows:

[0062]

[0063] In the formula, a represents the feature vector of the anchor day, p represents the feature vector of the positive sample day, and n represents the feature vector of the negative sample day. All three are obtained by the sequence encoder through sequence encoding of the exogenous variables; d(·) represents the distance metric function in the vector space, which is calculated using Euclidean distance or cosine similarity; m is a preset interval hyperparameter, which is used to force the minimum difference interval between the positive and negative samples and the anchor day in the feature space. Its value can be between 0.2 and 0.5.

[0064] Therefore, this embodiment uses triplet loss training to obtain a low-dimensional vector representation that can characterize the similarity of price trends, namely the feature vector of each historical day. By training based on triplet loss, the sequence encoder can learn the deep correlation between exogenous variables and day-ahead electricity prices. The model focuses on distinguishing key features of price trends by comparing the relationship between positive and negative samples and anchor days; therefore, the generated feature vectors can more accurately reflect the similarity of price patterns. This effectively overcomes the bias of traditional methods in matching the surface similarity of exogenous variables and improves the accuracy of similar day retrieval.

[0065] In an exemplary embodiment, step 302 includes: randomly selecting three historical days from a plurality of historical days, and selecting an anchor day and candidate days from the three historical days; and selecting positive sample days and negative sample days corresponding to the anchor day from the two candidate days based on the similarity parameters between the day-ahead electricity price of the anchor day and the day-ahead electricity prices of the other two candidate days.

[0066] For example, multiple different historical day groups are randomly selected from the entire training sample. Each historical day group includes three historical days. For each historical day group, one historical day is randomly selected as the anchor day, and the remaining two historical days are selected as candidate days. The similarity parameter between the day-ahead electricity price sequence of the anchor day and the day-ahead electricity price sequences of the two candidate days is calculated. This similarity parameter quantifies the degree of similarity between the two price curves. The candidate day corresponding to the smaller value of the two similarity parameters is designated as the negative sample day, and the candidate day corresponding to the larger value is designated as the positive sample day. This results in multiple triplet days, and the corresponding multi-time period information sequences serve as triplet training samples.

[0067] Optionally, the similarity parameter is measured by calculating the difference between the day-ahead price curve of the anchor date and the day-ahead price curve of the candidate date. This error value directly represents the degree of difference in the overall shape of the two price curves. The smaller the error value, the more similar the price trends are, and the larger the error value, the less similar the price trends are.

[0068] Therefore, this embodiment uniquely determines the triplet consisting of the anchor day, the positive sample day, and the negative sample day from three randomly selected historical days based on an objective price similarity metric. This triplet is directly obtained from the historical price similarity, thus providing high-quality training samples for subsequent model training.

[0069] It should be noted that, in order to improve the robustness of the sequence encoder during actual training, historical similar day pairs can be incorporated into the training of the sequence encoder.

[0070] In one exemplary embodiment, step 303 includes: obtaining historical similar day pairs; training an initial sequence encoder based on the multi-time period information sequence of historical similar day pairs and triplet training samples to obtain a sequence encoder; wherein the loss function used for training includes a triplet loss function and a similarity constraint loss function.

[0071] Among them, historical similar day pairs refer to similar day pairs that have similarity or a high degree of similarity using clustering algorithms or expert annotation.

[0072] For example, a multi-time period information sequence of at least one historical similar day pair is combined with triplet training samples to train the initial sequence encoder. Optionally, the multi-time period information sequence of triplet training samples and historical similar day pairs are used as input to the initial sequence encoder. The initial sequence encoder extracts features from these two types of input sequences to obtain feature vectors for triplet pairs and feature vectors for similar day pairs, respectively. During training, the encoder is iteratively optimized using a combined loss function, which includes a triplet loss function and a similarity constraint loss function. The former enables the encoder to distinguish between dates with similar prices and those that are dissimilar (or have different degrees of similarity), while the latter enables the encoder to map the feature vectors of similar day pairs to neighboring positions in the vector space. The total loss (which can be a weighted sum of the two loss function values) is jointly minimized through backpropagation, and the encoder parameters are updated to finally obtain the sequence encoder.

[0073] Therefore, this embodiment uses the multi-time period information sequence of historical similar day pairs as a weak supervision signal and performs joint training with the triplet training samples. This can improve the robustness under special operating conditions (such as special operating modes, extreme operating conditions and holiday modes, etc.), improve the accuracy of the sequence encoder, and thus further improve the accuracy of similar day retrieval.

[0074] It should be noted that, in order to improve the sensitivity of the sequence encoder to electricity prices during specific training, multi-task price perception training can be performed on the sequence encoder.

[0075] In one exemplary embodiment, step 303 includes: performing multi-task training on the initial sequence encoder based on triplet training samples; in the multi-task training, the output of the initial sequence encoder is simultaneously input into two parallel first branches and second branches, wherein the first branch is used to calculate the triplet loss, and the second branch is used to predict the day-ahead electricity price and calculate the price prediction loss.

[0076] For example, during the learning phase, a price prediction auxiliary task is trained in parallel. The initial sequence encoder is used as a shared encoder. Through joint optimization of the shared encoder and multi-task loss, the feature vectors better reflect price levels and trends. Triple training samples are input into the shared encoder for feature extraction to obtain corresponding feature vectors. These feature vectors are then simultaneously input into two parallel branches: the first branch calculates the triple loss based on these feature vectors to learn the similarity of electricity price patterns; the second branch uses these feature vectors to predict day-ahead electricity prices and calculates the price prediction loss to enhance the sensitivity of the feature vectors to price levels. Subsequently, based on these two losses, such as a weighted summation, a total loss function is constructed. In each iteration, backpropagation is performed based on this total loss to jointly optimize the network parameters of the shared encoder and the two branches, ultimately resulting in a sequence encoder capable of simultaneously perceiving price similarity and price levels.

[0077] Therefore, this embodiment improves the sensitivity of feature vectors to day-ahead electricity prices by training the price similarity discrimination task and the price prediction task in parallel, thereby further improving the quality of similar day retrieval.

[0078] In one possible implementation, to further improve the robustness of the sequence encoder, data augmentation can be performed on the triplet training samples before training to obtain augmented triplet samples, which are then used for training the sequence encoder. The data augmentation process includes at least one of Gaussian perturbation, time shifting, and seasonal transformation. This enhances the generalization ability of the sequence encoder, thereby addressing seasonal drift and outlier data.

[0079] In one possible implementation, such as Figure 4 As shown, the sequence encoder includes a one-dimensional convolutional network 401 and a fully connected layer 402 connected in sequence. The one-dimensional convolutional network 401 contains two convolutional blocks and a global average pooling layer connected in sequence. Each convolutional block contains a one-dimensional convolutional unit, a normalization unit, and an activation unit connected in sequence. The one-dimensional convolutional network 401 is used to extract temporal features from the input sequence and output an intermediate feature vector. The fully connected layer 402 is used to perform dimensionality transformation and feature fusion on the intermediate feature vector and output a feature vector of a specified dimension for similarity measurement.

[0080] The training process of the sequence encoder based on the above structure is as follows: First, the exogenous variable sequences from all training samples are input into a one-dimensional convolutional network 401. This network extracts features through its two convolutional blocks, and then aggregates them using a global average pooling unit to output an intermediate feature vector (e.g., 256-dimensional). Then, a fully connected layer 402 performs feature fusion and dimensionality compression on the intermediate feature vector, outputting a feature vector of a specified dimension (e.g., 128-dimensional). Based on this feature vector, a loss function value (e.g., triplet loss function value) is calculated, and the encoder's weight parameters are updated using a backpropagation algorithm, enabling the sequence encoder to generate highly discriminative feature representations.

[0081] The structure and training method of the sequence encoder have been described above. Then, step 201 is executed, which is to input the exogenous variable sequence corresponding to the target day into the pre-trained sequence encoder to obtain the feature vector of the target day.

[0082] In an exemplary embodiment, step 201 includes: preprocessing the exogenous variable sequence corresponding to the target day to obtain a preprocessed exogenous variable sequence; wherein, the preprocessing includes at least one of missing value processing, outlier detection and processing, and standardization processing; and inputting the preprocessed exogenous variable sequence into a pre-trained sequence encoder to obtain the feature vector of the target day.

[0083] For example, the exogenous variable sequence corresponding to the target date is processed for missing values, outlier detection and processing, and standardization, then converted into a fixed-length feature vector. This fixed-length feature vector is input into a pre-trained sequence encoder to obtain a 128-dimensional feature vector for the target date. This 128-dimensional feature vector is then used to search for the nearest feature vector in a vector retrieval index in a database based on a distance metric. The historical dates corresponding to the retrieved feature vectors are obtained according to a mapping table, thus generating a list of similar days and a similarity score. The distance metric is either Euclidean distance or cosine similarity; Euclidean distance is preferred during vector normalization.

[0084] Therefore, in this embodiment, by preprocessing the exogenous variable sequence of the target day, it is easier to input into the sequence encoder, which can improve the inference performance of the sequence encoder.

[0085] The following example illustrates the similarity search method.

[0086] In a specific example, such as Figure 5 As shown, the similar date retrieval method includes the following steps:

[0087] Step 501: Obtain multi-period information sequences for multiple historical days. The multi-period information sequences include exogenous variables and day-ahead electricity prices for each period.

[0088] Step 502: Preprocess the multi-time period information sequence of historical days;

[0089] Step 503: Determine the anchor day and the corresponding positive and negative sample days from multiple historical days, and construct triplet training samples.

[0090] Step 504: The initial sequence encoder is trained using multi-task training based on triplet training samples and multi-time period information sequences of historical similar day pairs to obtain the sequence encoder;

[0091] Step 505: Preprocess the exogenous variable sequence corresponding to the target date to obtain the preprocessed exogenous variable sequence;

[0092] Step 506: Input the preprocessed exogenous variable sequence into the sequence encoder to obtain the feature vector of the target day;

[0093] Step 507: Select target feature vectors from the pre-built database whose similarity parameter with the feature vector of the target day is greater than a preset similarity threshold;

[0094] Step 508: Determine the historical days corresponding to the target feature vector as similar days to the target day;

[0095] Step 509: Output the identifiers of similar days and the similarity parameters corresponding to the similar days.

[0096] Through the above steps, this similar day retrieval method constructs a triplet of anchor day-positive sample day-negative sample day based on price similarity. It then uses a sequence encoder to convert multi-time period information sequences into low-dimensional vector representations, and achieves efficient similar day retrieval through vector indexing. This realizes end-to-end learning, directly learning the discriminative representation of price trend similarity. It has the following application advantages:

[0097] Accuracy: Directly learning the discriminant representation of price similarity significantly improves retrieval accuracy;

[0098] Efficiency: Vectorized indexes support near nearest neighbor search, returning results with low latency;

[0099] Robustness: Improve adaptability through standardization, anomaly detection, and data augmentation.

[0100] Scalability: The sequence encoder structure and distance metric can be flexibly expanded according to actual needs;

[0101] Interpretability: By constructing triples with the similarity parameter between two sample days, decision-making is facilitated.

[0102] In summary, the similar day retrieval method of this application can achieve efficient, scalable, and robust similar day retrieval under large-scale historical data, providing high-quality prior references for day-ahead electricity price forecasting, load forecasting, and trading strategies. This method constructs a vector space of price similarity through end-to-end representation learning, combined with efficient vector retrieval, achieving a more accurate, efficient, and scalable similar day retrieval scheme.

[0103] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0104] Based on the same inventive concept, this application also provides a similar date retrieval device for implementing the aforementioned similar date retrieval method. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more similar date retrieval device embodiments provided below can be found in the limitations of the similar date retrieval method described above, and will not be repeated here.

[0105] In one exemplary embodiment, such as Figure 6 As shown, a similar date retrieval device is provided, comprising: an input module 601, a first determining module 602, and a second determining module 603, wherein:

[0106] The input module 601 is used to input the sequence of exogenous variables related to the day-ahead electricity price of the target day into a pre-trained sequence encoder to obtain the feature vector of the target day. The sequence encoder is trained based on exogenous variables and day-ahead electricity prices of multiple historical days.

[0107] The first determining module 602 is used to determine, from a pre-built database, a target feature vector whose similarity parameter with the feature vector of the target day is greater than a preset similarity threshold; wherein, the database includes feature vectors of each historical day;

[0108] The second determining module 603 is used to determine the historical day corresponding to the target feature vector as a similar day to the target day.

[0109] In one embodiment, the apparatus further includes an acquisition module, a third determination module, and a training module, wherein: the acquisition module is used to acquire multi-time period information sequences of multiple historical days, the multi-time period information sequences including exogenous variables and day-ahead electricity prices for each time period; the third determination module is used to determine the anchor day and the corresponding positive sample day and negative sample day from the multiple historical days; the training module is used to train the initial sequence encoder based on triplet training samples to obtain the sequence encoder; wherein the triplet training samples include multi-time period information sequences of the anchor day, multi-time period information sequences of the positive sample days, and multi-time period information sequences of the negative sample days.

[0110] In one embodiment, the third determining module is specifically used to: randomly determine three historical days from a plurality of historical days, and determine an anchor day and candidate days from the three historical days; based on the similarity parameters between the day-ahead electricity price of the anchor day and the day-ahead electricity prices of the two candidate days, determine the positive sample day and negative sample day corresponding to the anchor day from the two candidate days.

[0111] In one embodiment, the training module is specifically used to: obtain historical similar day pairs; train the initial sequence encoder based on the multi-time period information sequence of the historical similar day pairs and the triplet training samples to obtain the sequence encoder; wherein the loss function used for training includes the triplet loss function and the similarity constraint loss function.

[0112] In one embodiment, the training module is specifically used to: perform multi-task training on the initial sequence encoder based on triplet training samples; in the multi-task training, the output of the initial sequence encoder is simultaneously input into two parallel first branches and second branches, wherein the first branch is used to calculate the triplet loss, and the second branch is used to predict the day-ahead electricity price and calculate the price prediction loss.

[0113] In one embodiment, the input module 601 is specifically used to: preprocess the exogenous variable sequence corresponding to the target day to obtain a preprocessed exogenous variable sequence; wherein, the preprocessing includes at least one of missing value processing, outlier detection and processing, and standardization processing; and input the preprocessed exogenous variable sequence into a pre-trained sequence encoder to obtain the feature vector of the target day.

[0114] Each module in the aforementioned similar date retrieval device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0115] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores similarity date retrieval data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a similarity date retrieval method.

[0116] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0117] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement a similar day retrieval method.

[0118] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements a similarity search method.

[0119] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements a similar day retrieval method.

[0120] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0121] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0122] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A similar day search method characterized by, The method includes: The sequence of exogenous variables related to the day-ahead electricity price of the target day is input into a pre-trained sequence encoder to obtain the feature vector of the target day. The sequence encoder is trained based on exogenous variables and day-ahead electricity prices of multiple historical days. The feature vector is used to characterize the day-ahead electricity price pattern of the target day. From a pre-built database, target feature vectors with a similarity parameter greater than a preset similarity threshold with the feature vector of the target day are identified; wherein, the database includes feature vectors of each historical day; The historical days corresponding to the target feature vector are determined as similar days to the target day; The training method for the sequence encoder includes: Obtain multi-period information sequences for multiple historical days, wherein the multi-period information sequences include exogenous variables and day-ahead electricity prices for each period; Anchor days are determined from the plurality of historical days, and positive and negative sample days corresponding to the anchor days are determined based on the similarity between the day-ahead electricity price of the anchor day and the day-ahead electricity price of the candidate days. The initial sequence encoder is trained using triplet training samples to obtain the sequence encoder. In the multi-task training, the output of the initial sequence encoder is simultaneously input into two parallel branches, the first branch and the second branch. The first branch is used to calculate the triplet loss, and the second branch is used to predict the day-ahead electricity price and calculate the price prediction loss. The triplet loss and the price prediction loss are weighted and summed to obtain the total loss function value. In each iteration, backpropagation is performed based on the total loss function value to jointly optimize the network parameters of the initial sequence encoder, and finally the sequence encoder is obtained. The triplet training samples include multi-time period information sequences of the anchor day, multi-time period information sequences of the positive sample day, and multi-time period information sequences of the negative sample day.

2. The method of claim 1, wherein, The step of determining the anchor day from the plurality of historical days, and determining the positive and negative sample days corresponding to the anchor day based on the similarity between the day-ahead electricity price of the anchor day and the day-ahead electricity price of the candidate days, includes: Three historical days are randomly selected from multiple historical days, and anchor days and candidate days are determined from these three historical days; Based on the similarity parameters between the day-ahead electricity price of the anchor day and the day-ahead electricity prices of the two candidate days, the positive sample day and the negative sample day corresponding to the anchor day are determined from the two candidate days.

3. The method of claim 1, wherein, The process of training the initial sequence encoder using triplet training samples to obtain the sequence encoder includes: Obtain historical similar day pairs; The initial sequence encoder is trained using multi-task training based on the multi-time period information sequence of the historical similar day pairs and the triplet training samples to obtain the sequence encoder; wherein the loss function used in the multi-task training includes the triplet loss function and the similarity constraint loss function.

4. The method according to any one of claims 1 to 3, characterized in that, The exogenous variable sequence corresponding to the target day is input into a pre-trained sequence encoder to obtain the feature vector of the target day, including: The exogenous variable sequence corresponding to the target date is preprocessed to obtain a preprocessed exogenous variable sequence; wherein, the preprocessing includes at least one of missing value handling, outlier detection and handling, and standardization. The preprocessed exogenous variable sequence is input into a pre-trained sequence encoder to obtain the feature vector of the target day.

5. The method of claim 1, wherein, The exogenous variables include system load forecasts, inter-regional tie-line plans, renewable energy output forecasts, bidding-related indicators, and unit availability.

6. The method of claim 1, wherein, The sequence encoder includes a one-dimensional convolutional network and a fully connected layer connected in sequence. The one-dimensional convolutional network includes two convolutional blocks and a global average pooling layer connected in sequence. Each convolutional block contains a one-dimensional convolutional unit, a normalization unit, and an activation unit connected in sequence.

7. A similar day search apparatus characterized by comprising: The device includes: The input module is used to input the sequence of exogenous variables related to the day-ahead electricity price of the target day into a pre-trained sequence encoder to obtain the feature vector of the target day, wherein the sequence encoder is trained based on exogenous variables and day-ahead electricity prices of multiple historical days; the feature vector is used to characterize the day-ahead electricity price pattern of the target day. The first determining module is used to determine, from a pre-built database, a target feature vector whose similarity parameter to the feature vector of the target day is greater than a preset similarity threshold; wherein, the database includes feature vectors of each historical day; The second determining module is used to determine the historical day corresponding to the target feature vector as a similar day to the target day. The device further includes: The acquisition module is used to acquire multi-period information sequences for multiple historical days. The multi-period information sequences include exogenous variables and day-ahead electricity prices for each period. The third determining module is used to determine the anchor day from the plurality of historical days, and to determine the positive sample day and negative sample day corresponding to the anchor day based on the similarity between the day-ahead electricity price of the anchor day and the day-ahead electricity price of the candidate day; The training module is used to perform multi-task training on the initial sequence encoder based on triplet training samples to obtain the sequence encoder. In the multi-task training, the output of the initial sequence encoder is simultaneously input into two parallel first branches and second branches. The first branch is used to calculate the triplet loss, and the second branch is used to predict the day-ahead electricity price and calculate the price prediction loss. The triplet loss and the price prediction loss are weighted and summed to obtain the total loss function value. In each iteration, backpropagation is performed based on the total loss function value to jointly optimize the network parameters of the initial sequence encoder, and finally the sequence encoder is obtained. The triplet training samples include multi-time period information sequences of anchor days, multi-time period information sequences of positive sample days, and multi-time period information sequences of negative sample days.

8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having stored thereon a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Similar event query method, device and equipment and computer readable storage medium

    CN119202019A

  • Electric power spot price prediction method and system based on similar day probability correction

    CN120410595A