Power system-oriented test scene generation method and device, equipment and medium
By generating diverse test scenarios for power systems using natural language processing and fuzz testing techniques, this approach addresses the problem of insufficient test scenario generation in existing technologies, thereby improving the robustness of the model and the test coverage.
Patent Information
- Application Number
- CN202510832795.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-10-28
AI Technical Summary
Existing technologies lack sufficient test scenario generation for artificial intelligence models of power systems, making it difficult to cover extreme scenarios and power-specific interference, resulting in insufficient model robustness.
Key information is extracted using natural language processing technology, and test scenarios are generated by combining retrieval enhancement generation technology and fuzz testing technology. Diverse test scenarios are generated through pre-trained artificial intelligence models and random mutation processing.
It improves the efficiency and accuracy of test scenario generation, ensures coverage of more extreme cases and boundary conditions, and enhances the robustness of artificial intelligence models.
Smart Images

Figure CN120849583A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart grid technology, and in particular to a method, apparatus, equipment and medium for generating test scenarios for power systems. Background Art
[0002] With the rapid development of artificial intelligence (AI) technology, many power systems have integrated AI model services, such as wildfire detection, smoke recognition, and safety helmet detection during construction. The robustness of these AI models has become a key factor affecting system performance. Currently, testing of existing AI models largely relies on manually collected real images, which struggles to cover extreme scenarios, such as dense smoke obscuring wildfires or strong light interfering with safety helmet recognition. Furthermore, general image enhancement techniques cannot simulate the specific interferences of power scenarios, such as reflections from high-voltage equipment and background interference from transmission towers. Therefore, the testing scenarios for these models are limited.
[0003] Therefore, how to solve the problem of insufficient test scenario generation in existing technologies has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0004] This invention provides a method, apparatus, equipment, and medium for generating test scenarios for power systems, addressing the problem of insufficient test scenario generation in existing technologies.
[0005] To address the aforementioned technical problems, the first aspect of this invention provides a method for generating test scenarios for power systems, comprising: Acquire scenario demand data for the power system, and use natural language processing technology to process the scenario demand data to extract key information from the scenario demand data and generate scenario description text; Based on retrieval-enhanced generation technology, the scene description text is processed through a collaborative optimization mechanism of knowledge retrieval and text generation to obtain optimized scene description text; The optimized text describing the scenario is input into a pre-trained artificial intelligence model for processing to generate a preliminary test scenario. The preliminary test scenario is then processed by fuzz testing techniques that introduce random mutations and abnormal inputs to obtain the final test scenario.
[0006] As one preferred embodiment, the step of using natural language processing technology to process the scene requirement data to extract key information from the scene requirement data and generate scene description text includes: The scenario requirement data is cleaned by text, and the cleaned scenario requirement data is segmented by a word segmentation tool to obtain the word segmentation results for part-of-speech tagging. Named entity recognition technology is used to identify entities in the labeled word segmentation results in order to extract device status and external environmental factors and generate key information. Analyze the relationships between the key information and integrate the relationships with the key information to match them with multiple predefined scene description templates to obtain a target template; Based on the target template and the key information, a scene description text is generated using natural language processing technology.
[0007] As one preferred embodiment, the retrieval-enhanced generation technology processes the scene description text through a collaborative optimization mechanism of knowledge retrieval and text generation to obtain optimized scene description text, including: The scene description text is converted into a scene vector using word embedding technology, and target knowledge fragments that match the scene vector are retrieved from a pre-built power knowledge base. The target knowledge fragments are fused with the scene description text using a large language model to generate optimized scene description text.
[0008] As one preferred embodiment, the power knowledge base includes knowledge fragments and several external environment identification models. The knowledge fragments at least include equipment types, equipment parameters, equipment fault characteristics, fault levels, and fault handling rules. The step of retrieving target knowledge fragments that match the scene vector from a pre-built power knowledge base includes: processing the scene vector based on each of the external environment identification models to obtain external environment data that affects the normal operation of the power system; A quantization-based vector retrieval algorithm is used to semantically cluster the knowledge fragments in the power knowledge base according to equipment type and fault level, resulting in several candidate clusters; A hierarchical navigable small-world network algorithm is applied within each candidate cluster to construct a multi-layer graph structure, and a greedy search strategy is used to process the multi-layer graph structure to obtain preliminary knowledge fragments. The external environment data and the initially selected knowledge fragments are fused using a causal model constructed using a Bayesian network to obtain the target knowledge fragment.
[0009] As one preferred embodiment, retrieving the target knowledge fragment matching the scenario vector from a pre-built power knowledge base further includes: The knowledge fragments in the power knowledge base are encoded using a pre-trained BERT model to obtain knowledge semantic vectors; the similarity between the knowledge semantic vectors and the scene vectors is calculated, and knowledge semantic vectors with a similarity higher than a preset similarity threshold are selected as the first knowledge fragments based on the similarity calculation results. A topic model is used to model the knowledge semantic vector and the scene vector, and the topic similarity between the two is calculated, so as to extract the second knowledge fragment from the power knowledge base based on the topic similarity calculation result; The temporal correlation between the knowledge semantic vector and the scene vector is quantified, and knowledge semantic vectors that are higher than the preset correlation threshold are selected as the third knowledge fragment based on the correlation quantification results. The first knowledge fragment, the second knowledge fragment, the third knowledge fragment, and the external environment data are fused together to obtain the target knowledge fragment.
[0010] As one preferred embodiment, the step of inputting the optimized text of the scene description into a pre-trained artificial intelligence model for processing to generate a preliminary test scene includes: The scene description optimized text is transformed into low-dimensional vector features through graph embedding algorithm, and the external environment data is encoded through time series model to obtain time series change features; A cross-modal attention mechanism is used to align the low-dimensional vector features and the temporal variation features to generate joint features; the joint features are then input into a pre-trained hierarchical conditional generation network model to perform adaptive scene generation, resulting in a coarse-grained test scene that includes at least device topology, fault type distribution, fault occurrence time, and impact range. Causal verification is performed on the coarse-grained test scenarios based on the causal model. Then, based on the reward function constructed with the rationality of the scenario and the compliance of the processing rules, the Monte Carlo tree search algorithm and the deep Q-learning algorithm are used to optimize the coarse-grained test scenarios that have passed the causal verification, resulting in several fine-grained test scenarios. A discriminator using a pre-trained generative adversarial network is used to evaluate the realism of each fine-grained test scenario, and the fine-grained test scenarios that pass the evaluation are output as the initial test scenarios.
[0011] As one preferred embodiment, the preliminary test scenario is processed by introducing random mutations and anomalous inputs through fuzz testing techniques to obtain the final test scenario, including: Fuzzy testing technology is used to simulate various abnormal environments, and the results of evaluating the continuous impact of each abnormal environment on the power system are combined with the external environment identification model. By labeling each abnormal environment and its corresponding environmental parameters using the continuous impact result data, environmental adjustment data is obtained; Based on the actual operating data of the power system, the equipment parameters in the preliminary test field are randomly varied to obtain parameter adjustment data; The initial test scenario is adjusted using the environmental adjustment data and the parameter adjustment data to generate several adjusted test scenarios, which are then combined to obtain the final test scenario.
[0012] A second aspect of the present invention provides a test scenario generation device for power systems, comprising: The text generation module is used to acquire scenario demand data for the power system and process the scenario demand data using natural language processing technology to extract key information from the scenario demand data and generate scenario description text. The text optimization module is used to process the scene description text based on retrieval enhancement generation technology and through a collaborative optimization mechanism of knowledge retrieval and text generation to obtain optimized scene description text. The scene generation module is used to input the optimized text of the scene description into a pre-trained artificial intelligence model for processing, and generate a preliminary test scene. The scenario supplementation module is used to process the preliminary test scenario by introducing fuzz testing techniques with random mutations and abnormal inputs to obtain the final test scenario.
[0013] A third aspect of the present invention provides an electronic device including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the test scenario generation method for power systems as described above.
[0014] A fourth aspect of the present invention provides a computer-readable storage medium comprising a stored computer program, wherein when the device containing the computer-readable storage medium executes the computer program, it implements the test scenario generation method for power systems as described above.
[0015] Compared with the prior art, the beneficial effects of the embodiments of the present invention are at least one of the following: (1) In the process of generating test scenarios, RAG technology and artificial intelligence models in machine learning technology were adopted. By optimizing natural language descriptions and generating diverse scenarios, manual intervention and complex operations were reduced, the efficiency of test scenario generation was improved, and the performance of the model when processing large-scale power system data was optimized. (2) The generated test scenarios are supplemented by fuzzing testing technology. By introducing random mutations and abnormal inputs, the test scenarios are further enriched and improved to ensure coverage of more extreme cases and boundary conditions, thereby comprehensively evaluating the robustness of the artificial intelligence model. (3) By combining natural language processing technology, RAG technology, machine learning technology and fuzzing technology, a complete automated test scenario generation process has been formed, which provides rich and complete test scenarios for the robustness evaluation of artificial intelligence models of power systems and provides a theoretical basis for further automated detection and analysis. Attached Figure Description
[0016] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of a test scenario generation method for power systems provided in a certain embodiment of the present invention; Figure 2 This is a structural diagram of a test scenario generation device for power systems provided in a certain embodiment of the present invention; Figure 3 This is a structural diagram of an electronic device provided in a certain embodiment of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings and examples. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0019] In the description of this application, the terms "first," "second," "third," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined with "first," "second," "third," etc., may explicitly or implicitly include one or more of that feature. In the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0020] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to the internal communication between two components. The terms "vertical," "horizontal," "left," "right," "upper," "lower," and similar expressions used herein are for illustrative purposes only and do not indicate or imply that the system or component referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as limiting the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.
[0021] In the description of this application, it should be noted that, unless otherwise defined, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this specification is merely for describing specific embodiments and is not intended to limit the invention. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0022] In one embodiment, if Figure 1 As shown, the first aspect of the present invention provides a method for generating test scenarios for power systems, comprising: S1. Obtain scenario demand data for the power system, and use natural language processing technology to process the scenario demand data to extract key information from the scenario demand data and generate scenario description text. S2. Based on the retrieval enhancement generation technology, the scene description text is processed through a collaborative optimization mechanism of knowledge retrieval and text generation to obtain optimized scene description text; S3. Input the optimized text of the scene description into a pre-trained artificial intelligence model for processing to generate a preliminary test scene; S4. Process the preliminary test scene by introducing fuzzy testing technology with random mutation and abnormal input to obtain the final test scene.
[0023] To address the reliability verification needs of artificial intelligence models in the power system field, this invention proposes a test scenario generation method for robustness evaluation of artificial intelligence models in power systems. This method is based on Natural Language Processing (NLP), Retrieval-augmented Generation (RAG), machine learning, and fuzzing techniques. It automates the generation of power system-specific test scenarios to solve the problems of insufficient test scenario generation in existing technologies and the inability of existing technologies to cover all possible anomalies, especially in the complex environment of power systems where the diversity and complexity of test scenarios are extremely high. The method specifically includes: The system acquires user-input scenario requirements data related to power system services, i.e., specific business requirements or problem scenarios of the power system. This data may include text, tables, diagrams, etc. Natural language processing technology is then used to process this data for entity recognition, relationship extraction, etc., thereby extracting key information from the user's scenario requirements data. This includes at least equipment-related data such as equipment type, equipment status, equipment fault type, and equipment fault level, as well as external environmental factors affecting the normal operation of the power system. This key information and the relationships between them are then filled into a predefined scenario description template to generate scenario description text.
[0024] For the scenario description text, this invention employs a retrieval-enhanced generation technique, which combines knowledge retrieval and text generation. It retrieves relevant information from a pre-built power knowledge base, thereby acquiring professional knowledge related to the scenario description text. This professional knowledge is then integrated with the original scenario description text to obtain an optimized scenario description text, ensuring that the generated test scenario conforms to the actual operating conditions of the power system. The optimized scenario description text not only contains professional knowledge but also related external environmental data. This is achieved by collecting data covering various aspects of the power system, including equipment technical parameters, fault cases and their solutions, operating procedures, and industry standards (including textual data). The collected data (documents, drawings, video materials, etc.) are processed according to data type through structured representation, unstructured representation, and semi-structured representation to obtain several knowledge fragments. Then, a knowledge index is constructed for each knowledge fragment to form a power knowledge base. The index information includes keywords, topic tags, semantic vectors, etc. In addition, the power knowledge base also includes several external environment recognition models, such as wildfire models (NDDRCNN or InceptionV3, etc.) and smoke recognition models (YOLOv5, YOLOv8, etc.). These models are trained on the collected data and are used to process external environmental factors related to power system business.
[0025] The scene descriptions optimized by RAG technology are embedded into the input space of the pre-trained artificial intelligence model, and then converted into a vector form that the model can process through word embedding technology. Subsequently, the artificial intelligence model (such as Transformer, BERT, PowerGrid-GPT, GPT-4, etc.) generates a variety of preliminary test scenarios based on the input vectors, covering different types of power grid faults, power supply stability under abnormal weather conditions, and emergency response strategies.
[0026] To further enhance the comprehensiveness and diversity of test scenarios, especially for the complex needs of power business systems, this invention employs fuzzing technology to deepen, improve, and supplement the initial test scenarios generated by the artificial intelligence model. Fuzzing technology simulates various complex and changing environments to adjust the initial test scenarios, and random mutations are applied to equipment parameters within the initial test scenarios. By introducing random mutations and abnormal inputs, the test scenarios are further enriched and improved, ensuring coverage of more extreme cases and boundary conditions. Finally, the resulting multiple final test scenarios are formatted using structured output technology for easy subsequent automated processing and analysis. This solves the problems of inconsistent output formats and difficulty in automated processing in traditional methods, improving the usability and scalability of the test scenarios. Furthermore, data verification steps can be performed on the final test scenarios to ensure their accuracy and completeness. It should be noted that the models used in this invention are all trained using historical equipment failure data or commonly used datasets, and various preset values are determined based on historical data and expert experience; specific numerical limitations are not specified here.
[0027] This invention combines natural language processing, RAG, machine learning, and fuzzing technologies to form a complete automated test scenario generation process. It solves the problem of insufficient test scenario generation in existing technologies, avoids test scenario deviations caused by inaccurate descriptions, and enriches and improves test scenarios to ensure coverage of more extreme cases and boundary conditions.
[0028] In one embodiment, the step of using natural language processing technology to process the scene requirement data to extract key information from the scene requirement data and generate scene description text includes: The scenario requirement data is cleaned by text, and the cleaned scenario requirement data is segmented by a word segmentation tool to obtain the word segmentation results for part-of-speech tagging. Named entity recognition technology is used to identify entities in the labeled word segmentation results in order to extract device status and external environmental factors and generate key information. Analyze the relationships between the key information and integrate the relationships with the key information to match them with multiple predefined scene description templates to obtain a target template; Based on the target template and the key information, a scene description text is generated using natural language processing technology.
[0029] Specifically, this invention cleans the scenario requirement data, removing irrelevant characters, and uses word segmentation tools (such as Jieba and HanLP) to segment the data. Then, it calls part-of-speech tagging APIs (such as LTP and StanfordNLP) to add part-of-speech tags to the segmentation results, focusing on identifying power system business-related terms such as "transformer," "transmission line," and "electricity meter," ensuring accurate extraction of key information and formatting it into a unified structured text. Finally, it uses pre-trained NER models (such as BERT-CRF and SpaCy) to identify entity types, such as equipment status (normal, abnormal, etc.), equipment model, fault code, and environmental factors (temperature, humidity, etc.). The key information is then combined and used to construct a knowledge graph or rule engine to define the association rules between device status and environmental factors (such as high temperature causing device overheating). Association rule mining algorithms (such as Apriori) are used to analyze the relationships between key information, and the relationships and key information are integrated and encapsulated into structured data to match multiple predefined scene description templates. Then, string matching or machine learning models (such as TF-IDF, BERT) are used to calculate the similarity between key information and templates, and the template with the highest score is selected as the target template. Finally, the key information is filled into the target template, and a large language model (such as GPT, T5) is used to polish the generated text to obtain the scene description text.
[0030] This invention uses natural language processing technology to generate scene description text, which can generate diverse scene descriptions to adapt to different business needs, accurately extract device status and external environmental factors, avoid errors from manual parsing, has a high degree of process automation, supports large-scale data processing, and can expand application scenarios by adding new templates.
[0031] In one embodiment, step S2 includes: The scene description text is converted into a scene vector using word embedding technology, and target knowledge fragments that match the scene vector are retrieved from a pre-built power knowledge base. The target knowledge fragments are fused with the scene description text using a large language model to generate optimized scene description text; wherein, the power knowledge base includes knowledge fragments and several external environment recognition models, and the knowledge fragments include at least equipment type, equipment parameters, equipment fault characteristics, fault level and fault handling rules.
[0032] Specifically, this invention employs an embedding layer of a large language model (such as Qwen-32b) or a Transformer-based pre-trained model (such as BERT, GPT, etc.) to transform the scene description text into vector form to capture its semantic context (e.g., "wildfire caused power line tripping" implies equipment status and geographical risks). This allows the artificial intelligence model to better analyze the specific power business context involved and uses retrieval algorithms to search for knowledge fragments related to the input description from a pre-built power knowledge base (e.g., tripping recovery procedures related to wildfires, smoke concentration threshold rules, etc.). This includes fault mode analysis, equipment parameter settings, and potential impacts. External environmental factors affecting the normal operation of the power system are considered, including the impact of external factors such as wildfires and dense smoke. Then, a large language model (such as Deepseek-R1) is used to fuse the retrieved target knowledge fragments with the original input description. This aligns the retrieved professional knowledge (such as equipment status and fault handling rules) with the vague expressions in the original description, generating a more accurate and detailed scenario description. This description not only covers specific equipment status and operating parameters but also considers the impact of external factors on the power system. Finally, the generated results are validated for consistency based on knowledge base rules, ultimately outputting a comprehensive, realistic, and applicable optimized scenario description text.
[0033] The scenario descriptions generated by RAG technology in this invention provide a comprehensive and detailed foundation for the subsequent generation of test scenarios, ensuring that the final generated test scenarios are both realistic and highly relevant. Through RAG's retrieval enhancement mechanism, it ensures that the generated content strictly follows power system specifications, avoiding logical deviations caused by the lack of domain knowledge in large language models. This helps to more accurately test the robustness of business models, solving the test scenario deviation problem caused by inaccurate descriptions in traditional methods and improving the accuracy of test scenarios.
[0034] In one embodiment, retrieving the target knowledge fragment matching the scene vector from a pre-built power knowledge base includes: The scene vectors are processed based on the external environment identification models to obtain external environment data that affects the normal operation of the power system. A quantization-based vector retrieval algorithm is used to semantically cluster the knowledge fragments in the power knowledge base according to equipment type and fault level, resulting in several candidate clusters; A hierarchical navigable small-world network algorithm is applied within each candidate cluster to construct a multi-layer graph structure, and a greedy search strategy is used to process the multi-layer graph structure to obtain preliminary knowledge fragments. The external environment data and the initially selected knowledge fragments are fused using a causal model constructed using a Bayesian network to obtain the target knowledge fragment.
[0035] Specifically, this invention inputs scene vectors into various external environment recognition models for processing, in order to output external environment data that affects the operation of the power system extracted from the scene vectors and the degree of continuous impact of this data on the normal operation of the power system. The external environment data is normalized to ensure that it is consistent with the semantic dimension of subsequent knowledge fragments.
[0036] Then, a quantization-based vector retrieval algorithm (such as product quantization PQ or residual quantization RQ) is used to compress the high-dimensional vectors of knowledge fragments into low-dimensional codebooks to reduce storage and computational overhead. Then, a clustering algorithm (such as K-means or DBSCAN) is used to semantically cluster the compressed vectors according to equipment type (such as transformer, transmission line) and fault level (such as minor, severe) to form several candidate clusters. Each cluster is labeled with equipment type and fault level labels.
[0037] Next, the knowledge fragment vectors within each candidate cluster are used as nodes. A hierarchical graph structure is constructed based on the similarity between the fragment vectors. High-level nodes represent global approximations, and low-level nodes represent local exact connections. Starting from the high-level graph, a greedy search strategy is used to gradually approach the target node. Finally, the most similar knowledge fragment is located in the low-level graph to obtain the initial selected knowledge fragments.
[0038] Subsequently, the nodes (such as environmental variables and knowledge fragments) and edges (used to describe the causal relationships between variables, which can be generated based on expert knowledge in the power field, such as the increased probability of conductor galloping when wind speed increases, thus recommending anti-galloping knowledge) of the Bayesian network are defined. Prior probabilities are determined using historical fault statistics, and a conditional probability table is learned from operation and maintenance logs using the EM algorithm. Then, external environmental data is used as evidence nodes to input into the causal model constructed by the Bayesian network. The posterior probabilities of knowledge fragment nodes are updated using a message passing algorithm (such as Junction Tree), and the knowledge fragment with the highest probability ranking is selected as the target result. The target knowledge fragment that integrates causal relationships is then output.
[0039] This invention combines vector retrieval and semantic clustering techniques to quickly locate knowledge fragments that match specific scenarios, improving retrieval efficiency and accuracy. It employs a quantized vector retrieval algorithm and a hierarchical navigable small-world network algorithm to achieve semantic clustering and multi-layer graph structure construction of the knowledge base, significantly reducing the computational complexity of large-scale data retrieval. Furthermore, it utilizes a causal model built with Bayesian networks to integrate external environmental data with initially selected knowledge fragments, revealing causal relationships between variables and providing more interpretable and reliable decision support for power system operation and maintenance.
[0040] In one embodiment, retrieving the target knowledge fragment matching the scene vector from a pre-built power knowledge base further includes: The knowledge fragments in the power knowledge base are encoded using a pre-trained BERT model to obtain knowledge semantic vectors; the similarity between the knowledge semantic vectors and the scene vectors is calculated, and knowledge semantic vectors with a similarity higher than a preset similarity threshold are selected as the first knowledge fragments based on the similarity calculation results. A topic model is used to model the knowledge semantic vector and the scene vector, and the topic similarity between the two is calculated, so as to extract the second knowledge fragment from the power knowledge base based on the topic similarity calculation result; The temporal correlation between the knowledge semantic vector and the scene vector is quantified, and knowledge semantic vectors that are higher than the preset correlation threshold are selected as the third knowledge fragment based on the correlation quantification results. The first knowledge fragment, the second knowledge fragment, the third knowledge fragment, and the external environment data are fused together to obtain the target knowledge fragment.
[0041] Specifically, this invention uses a pre-trained BERT model to encode knowledge fragments in the power knowledge base, transforming the text fragments in the power knowledge base into high-dimensional semantic vectors to generate knowledge semantic vectors; then, the cosine similarity formula is used to calculate the similarity between these knowledge semantic vectors and scene vectors, so as to select knowledge semantic vectors with a similarity higher than a preset threshold as the first knowledge fragment.
[0042] Then, LDA topic model is applied to the knowledge semantic vector and scene vector respectively to generate topic distribution. The difference of topic distribution is quantified by KL divergence or JS divergence, or the cosine similarity between topic vectors is directly quantified. Based on the topic similarity, the segment with the highest similarity is extracted as the second knowledge segment.
[0043] Next, time information or timestamps based on scene vectors are extracted from the knowledge fragments to calculate the time interval between the current time and the timetamp. An exponential decay function is then used to calculate the relevance score of the interval, and knowledge semantic vectors that are higher than the preset relevance threshold are selected as the third knowledge fragment.
[0044] Finally, the semantic vectors, topic distributions, and temporal relevance scores of all knowledge fragments are aligned with the external environment data, and weights are assigned to each dimension (the weight values can be determined based on historical data) to calculate a comprehensive score. Then, based on business rules, the target knowledge fragments are selected (e.g., if temporal relevance > 0.8 and topic similarity > 0.7, they are given priority recommendation), and the fused target knowledge fragments are output.
[0045] This invention comprehensively evaluates the matching degree between knowledge fragments and scene vectors from three dimensions: semantics, topic, and time, through BERT encoding, topic modeling, and temporal relevance quantification, avoiding the limitations of single-dimensional matching. The hierarchical filtering mechanism based on similarity and relevance thresholds can flexibly adjust the retrieval accuracy to adapt to the needs of different scenarios for knowledge fragments. By combining external environmental data, knowledge fragments from the semantic, topic, and time dimensions are integrated to generate target knowledge fragments with more contextual relevance, thereby improving the comprehensiveness and reliability of decision-making.
[0046] In one embodiment, step S3 includes: The scene description optimized text is transformed into low-dimensional vector features through graph embedding algorithm, and the external environment data is encoded through time series model to obtain time series change features; A cross-modal attention mechanism is used to align the low-dimensional vector features and the temporal variation features to generate joint features; the joint features are then input into a pre-trained hierarchical conditional generation network model to perform adaptive scene generation, resulting in a coarse-grained test scene that includes at least device topology, fault type distribution, fault occurrence time, and impact range. Causal verification is performed on the coarse-grained test scenarios based on the causal model. Then, based on the reward function constructed with the rationality of the scenario and the compliance of the processing rules, the Monte Carlo tree search algorithm and the deep Q-learning algorithm are used to optimize the coarse-grained test scenarios that have passed the causal verification, resulting in several fine-grained test scenarios. A discriminator using a pre-trained generative adversarial network is used to evaluate the realism of each fine-grained test scenario, and the fine-grained test scenarios that pass the evaluation are output as the initial test scenarios.
[0047] Specifically, this invention uses entities in the scene description text as nodes and relationships between entities as edges to parse it into a knowledge graph. GraphSAGE is then used to embed nodes into the graph, generate node vectors, and aggregate them to obtain a global vector representation of the scene graph, which is a low-dimensional vector feature. The external environment data is then encoded using the Transformer temporal model to obtain temporal change features.
[0048] Next, common attention weight calculation methods, such as dot product attention, are used to quantify the attention weights of low-dimensional vector features and temporal change features. The quantized weights are then used to sum the two in a weighted manner to align them and generate joint features. Then, a hierarchical conditional generation network is used, which takes the joint features as input and outputs a coarse-grained test scene including device topology, fault type distribution, fault occurrence time and impact range. The hierarchical conditional generation network includes a hierarchical structure and a decoder. The first layer (graph neural network) in the hierarchical structure generates the device topology, the second layer (conditional variational autoencoder) generates the fault type distribution, and the third layer (recurrent neural network, long short-term memory network, etc.) generates the fault occurrence time. The decoder is a Transformer decoder, which generates scene elements layer by layer, conditionally depending on the output of the previous layer.
[0049] Then, the causal model constructed using DoWhy is used to verify the causal relationship of the coarse-grained test scenarios. For the coarse-grained test scenarios that pass the verification, the parameters of the coarse-grained test scenarios (such as failure probability and scope of influence) are used as the state, the adjustment of parameters (such as increasing / decreasing failure probability) is used as the action, and the reward function is constructed based on the rationality of the scenario and the compliance of the processing rules. The scenario space is explored through the MCTS algorithm to generate candidate scenarios, and the DQN algorithm is used to select the optimal scenario parameters based on the reward function to obtain several fine-grained test scenarios.
[0050] Finally, a pre-trained GAN discriminator (such as WGAN-GP) is used to score the realism of fine-grained test scenarios, and only fine-grained test scenarios with realism scores higher than a preset score threshold (such as 0.8) are retained as initial test scenarios.
[0051] This invention employs graph embedding algorithms and temporal models to achieve complementary fusion of structured text and unstructured temporal data, and enhances the comprehensiveness and robustness of feature representation through a cross-modal attention mechanism. It generates test scenarios through a hierarchical conditional generation network, utilizing its hierarchical structure to explicitly model dependencies between different levels, thus enhancing the interpretability of the generated scenarios. Based on a causal model, it eliminates unreasonable scenarios to ensure they conform to physical laws. A Monte Carlo tree search algorithm is used to explore the scenario space, and DQN is used to optimize scenario parameters based on a reward function, generating fine-grained test scenarios that better meet actual needs. It not only considers specific equipment in the power system but also incorporates external environmental factors to simulate different operating scenarios. Through this integration of complex information, it can generate diverse preliminary test scenarios, including but not limited to different types of power grid faults, power supply stability under abnormal weather conditions, and emergency response strategies. This automates test scenario generation, reduces manual intervention, and significantly improves the efficiency and coverage of scenario generation.
[0052] In one embodiment, step S4 includes: Fuzzy testing technology is used to simulate various abnormal environments, and the results of evaluating the continuous impact of each abnormal environment on the power system are combined with the external environment identification model. By labeling each abnormal environment and its corresponding environmental parameters using the continuous impact result data, environmental adjustment data is obtained; Based on the actual operating data of the power system, the equipment parameters in the preliminary test field are randomly varied to obtain parameter adjustment data; The initial test scenario is adjusted using the environmental adjustment data and the parameter adjustment data to generate several adjusted test scenarios, which are then combined to obtain the final test scenario.
[0053] Specifically, this invention employs fuzzing testing technology to adjust, expand, and supplement the initially generated test scenarios through randomization and mutation, generating more diverse and complex test scenarios, as follows: Fuzzy testing technology is used to input various abnormal data into a power system model to simulate various abnormal environments such as equipment failure, network attack, and natural disaster. The simulated abnormal environment data is then input into an external environment identification model, which can analyze the impact of abnormal environments on the power system, such as voltage fluctuations, frequency changes, and load imbalances. Through the calculation and analysis of these identification models, the impact data of each abnormal environment on the continuity of the power system, including equipment operating status, are obtained.
[0054] Then, based on the continuous impact data, each abnormal environment and its corresponding environmental parameters are labeled. For example, for faulty equipment in a wildfire, the type, location, degree of failure, abnormal environment type, scope and consequences of the abnormal environment (i.e., wildfire) are labeled. The labeled environmental parameters are then compiled into environmental adjustment data for subsequent test scenario adjustments.
[0055] Collect actual operating data of the power system, such as equipment operating status, load conditions, and environmental parameters. Based on this actual operating data, randomly mutate the equipment parameters in the initial test scenario, such as randomly changing the output power of the generator, the turns ratio of the transformer, and the resistance and reactance of the line, to simulate the performance of the equipment under different operating conditions. Then, through random mutation, generate multiple different combinations of equipment parameters to obtain parameter adjustment data.
[0056] Finally, the environmental adjustment data and parameter adjustment data are applied to the preliminary test scenario to adjust the abnormal environment and equipment parameters in the preliminary test scenario. For example, specific abnormal environments are set according to the environmental adjustment data, and the operating parameters of the equipment are modified according to the parameter adjustment data. Through different combinations of environmental and parameter adjustments, several adjustment test scenarios are generated, each representing a specific abnormal situation and equipment operating state. Then, the generated multiple adjustment test scenarios are combined to obtain the final test scenario and output it in a structured format, which covers all possible abnormal situations and equipment operating states to ensure comprehensive and in-depth testing of the power system.
[0057] To further enhance the comprehensiveness and diversity of test scenarios, especially addressing the complex needs of power business systems, this invention employs fuzzing testing technology to deepen, refine, and supplement the generated initial scenarios. In the operational environment of power systems, fuzzing technology not only focuses on traditional parameters such as grid load levels and power plant output power, but also emphasizes the impact of environmental factors and external events on power operations. For example, when considering the potential impact of natural disasters (such as wildfires) on the power system, fuzzing technology can simulate different fire intensities and spread rates, and combine wildfire models to assess the impact of these changes on the continuity of power facilities and services. By using environmental and parameter adjustment data to adjust the initial test scenarios, multiple adjusted test scenarios are generated and combined into the final test scenario. This covers more possible anomalies, improving the comprehensiveness of the test. Furthermore, combining test scenarios improves testing efficiency and reduces testing time and costs.
[0058] This application addresses the problem of insufficient test scenario generation in existing technologies by designing a test scenario generation method for power systems. It employs natural language processing (NLP) technology to preprocess user-inputted power system operation scenarios and extract key information. Through a retrieval-enhanced generation framework, relevant information is retrieved from a power system domain knowledge base, and the user-inputted NLP description is optimized to ensure that the generated test scenarios conform to the actual operation of the power system. This achieves optimization and semantic enhancement of the test scenario description and avoids test scenario deviations caused by inaccurate descriptions. A preliminary test scenario is generated using a pre-trained artificial intelligence (AI) model. Fuzzing technology is used to introduce random mutations and anomalous inputs to further enrich and improve the test scenario, ensuring coverage of more extreme cases and boundary conditions, thereby comprehensively evaluating the robustness of the AI model. This method solves the problem of insufficient test scenario generation in existing technologies, particularly in covering complex operating conditions and extreme conditions, and has high practical value and innovation.
[0059] It should be noted that although the steps in the flowchart above are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order requirement for the execution of these steps, and they can be executed in other orders.
[0060] In another embodiment, such as Figure 2 As shown, a second aspect of the present invention provides a test scenario generation device for power systems, comprising: The text generation module 10 is used to acquire scenario demand data for the power system and process the scenario demand data using natural language processing technology to extract key information from the scenario demand data and generate scenario description text. Text optimization module 20 is used to process the scene description text based on retrieval enhancement generation technology through a collaborative optimization mechanism of knowledge retrieval and text generation to obtain optimized scene description text; The scene generation module 30 is used to input the optimized text of the scene description into a pre-trained artificial intelligence model for processing to generate a preliminary test scene; The scenario supplementation module 40 is used to process the preliminary test scenario by introducing fuzz testing techniques with random mutations and abnormal inputs to obtain the final test scenario.
[0061] It should be noted that each module in the aforementioned power system test scenario generation 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. For specific limitations regarding the power system test scenario generation device, please refer to the limitations of the power system test scenario generation method described above; both have the same function and role, and will not be repeated here.
[0062] A third aspect of the present invention provides an electronic device comprising: Processor, memory, and bus; The bus is used to connect the processor and the memory; The memory is used to store operation instructions; The processor is configured to execute operations corresponding to a test scenario generation method for power systems as shown in the first aspect of this application by invoking the operation instructions.
[0063] In one alternative embodiment, an electronic device is provided, such as Figure 3 As shown, Figure 3The illustrated electronic device 5000 includes a processor 5001 and a memory 5003. The processor 5001 and the memory 5003 are connected, for example, via a bus 5002. Optionally, the electronic device 5000 may also include a transceiver 5004. It should be noted that in practical applications, the transceiver 5004 is not limited to one type, and the structure of this electronic device 5000 does not constitute a limitation on the embodiments of this application.
[0064] Processor 5001 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA, or other programmable logic device, transistor logic device, hardware component, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 5001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0065] Bus 5002 may include a path for transmitting information between the aforementioned components. Bus 5002 may be a PCI bus or an EISA bus, etc. Bus 5002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0066] The memory 5003 may be a ROM or other type of static storage device capable of storing static information and instructions, RAM or other type of dynamic storage device capable of storing information and instructions, or it may be an EEPROM, CD-ROM or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.
[0067] The memory 5003 is used to store application code that executes the scheme of this application, and its execution is controlled by the processor 5001. The processor 5001 is used to execute the application code stored in the memory 5003 to implement the content shown in any of the foregoing method embodiments.
[0068] Among them, electronic devices include, but are not limited to: mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and in-vehicle terminals (such as in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers.
[0069] The fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a test scenario generation method for power systems as shown in the first aspect of this application.
[0070] Another embodiment of this application provides a computer-readable storage medium storing a computer program that, when run on a computer, enables the computer to execute the corresponding content in the aforementioned method embodiments.
[0071] Furthermore, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0072] In summary, this invention relates to the field of smart grid technology and discloses a method, apparatus, equipment, and medium for generating test scenarios for power systems. The method includes acquiring scenario requirement data for the power system and processing the scenario requirement data using natural language processing (NLP) technology to extract key information and generate scenario description text; processing the scenario description text using a retrieval-enhanced generation technology and a collaborative optimization mechanism of knowledge retrieval and text generation to obtain optimized scenario description text; inputting the optimized scenario description text into a pre-trained artificial intelligence model for processing to generate a preliminary test scenario; processing the preliminary test scenario using fuzzy testing technology that introduces random mutations and abnormal inputs to obtain a final test scenario; and using NLP, RAG, machine learning, and fuzzing technologies to generate test scenarios, thereby improving the diversity and complexity of test scenarios.
[0073] The various embodiments in this specification are described in a progressive manner. For directly identical or similar parts among the embodiments, refer to each other. Each embodiment focuses on its differences from other embodiments. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple; refer to the description of the method embodiments for relevant details. It should be noted that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
[0074] The embodiments described above are merely preferred embodiments of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various improvements and substitutions without departing from the technical principles of this invention, and these improvements and substitutions should also be considered within the scope of protection of this application. Therefore, the scope of protection of this patent application should be determined by the scope of the claims.
Claims
1. A method for generating test scenarios for power systems, characterized in that, include: Acquire scenario demand data for the power system, and use natural language processing technology to process the scenario demand data to extract key information from the scenario demand data and generate scenario description text; Based on retrieval-enhanced generation technology, the scene description text is processed through a collaborative optimization mechanism of knowledge retrieval and text generation to obtain optimized scene description text; The optimized text describing the scenario is input into a pre-trained artificial intelligence model for processing to generate a preliminary test scenario; The initial test scenario is processed by introducing fuzz testing techniques involving random mutations and abnormal inputs to obtain the final test scenario.
2. The method for generating test scenarios for power systems according to claim 1, characterized in that, The step of using natural language processing technology to process the scenario requirement data to extract key information and generate scenario description text includes: The scenario requirement data is cleaned by text, and the cleaned scenario requirement data is segmented by a word segmentation tool to obtain the word segmentation results for part-of-speech tagging. Named entity recognition technology is used to identify entities in the labeled word segmentation results in order to extract device status and external environmental factors and generate key information. Analyze the relationships between the key information and integrate the relationships with the key information to match them with multiple predefined scene description templates to obtain a target template; Based on the target template and the key information, a scene description text is generated using natural language processing technology.
3. The method for generating test scenarios for power systems according to claim 1, characterized in that, The retrieval-enhanced generation technology processes the scene description text through a collaborative optimization mechanism of knowledge retrieval and text generation to obtain optimized scene description text, including: The scene description text is converted into a scene vector using word embedding technology, and target knowledge fragments that match the scene vector are retrieved from a pre-built power knowledge base. The target knowledge fragments are fused with the scene description text using a large language model to generate optimized scene description text.
4. The method for generating test scenarios for power systems according to claim 3, characterized in that, The power knowledge base includes knowledge fragments and several external environment identification models. The knowledge fragments at least include equipment type, equipment parameters, equipment fault characteristics, fault levels, and fault handling rules. The step of retrieving target knowledge fragments that match the scenario vector from a pre-built power knowledge base includes: The scene vectors are processed based on the external environment identification models to obtain external environment data that affects the normal operation of the power system. A quantization-based vector retrieval algorithm is used to semantically cluster the knowledge fragments in the power knowledge base according to equipment type and fault level, resulting in several candidate clusters; A hierarchical navigable small-world network algorithm is applied within each candidate cluster to construct a multi-layer graph structure, and a greedy search strategy is used to process the multi-layer graph structure to obtain preliminary knowledge fragments. The external environment data and the initially selected knowledge fragments are fused using a causal model constructed using a Bayesian network to obtain the target knowledge fragment.
5. The method for generating test scenarios for power systems according to claim 4, characterized in that, The step of retrieving target knowledge fragments that match the scenario vector from a pre-built power knowledge base also includes: The knowledge fragments in the power knowledge base are encoded using a pre-trained BERT model to obtain knowledge semantic vectors; the similarity between the knowledge semantic vectors and the scene vectors is calculated, and knowledge semantic vectors with a similarity higher than a preset similarity threshold are selected as the first knowledge fragments based on the similarity calculation results. A topic model is used to model the knowledge semantic vector and the scene vector, and the topic similarity between the two is calculated, so as to extract the second knowledge fragment from the power knowledge base based on the topic similarity calculation result; The temporal correlation between the knowledge semantic vector and the scene vector is quantified, and knowledge semantic vectors that are higher than the preset correlation threshold are selected as the third knowledge fragment based on the correlation quantification results. The first knowledge fragment, the second knowledge fragment, the third knowledge fragment, and the external environment data are fused together to obtain the target knowledge fragment.
6. The method for generating test scenarios for power systems according to claim 4, characterized in that, The step of inputting the optimized scene description text into a pre-trained artificial intelligence model for processing to generate a preliminary test scene includes: converting the optimized scene description text into low-dimensional vector features through a graph embedding algorithm, and encoding the external environment data through a time series model to obtain time series change features; A cross-modal attention mechanism is used to align the low-dimensional vector features and the temporal variation features to generate joint features; The joint features are input into a pre-trained hierarchical conditional generation network model to generate adaptive scenarios, resulting in coarse-grained test scenarios that include at least device topology, fault type distribution, fault occurrence time and impact range. Causal verification is performed on the coarse-grained test scenarios based on the causal model. Then, based on the reward function constructed with the rationality of the scenario and the compliance of the processing rules, the Monte Carlo tree search algorithm and the deep Q-learning algorithm are used to optimize the coarse-grained test scenarios that have passed the causal verification, resulting in several fine-grained test scenarios. A discriminator using a pre-trained generative adversarial network is used to evaluate the realism of each fine-grained test scenario, and the fine-grained test scenarios that pass the evaluation are output as the initial test scenarios.
7. The method for generating test scenarios for power systems according to claim 4, characterized in that, The preliminary test scenario is processed by introducing random mutations and abnormal inputs to obtain the final test scenario, including: Fuzzy testing technology is used to simulate various abnormal environments, and the results of evaluating the continuous impact of each abnormal environment on the power system are combined with the external environment identification model. By labeling each abnormal environment and its corresponding environmental parameters using the continuous impact result data, environmental adjustment data is obtained; Based on the actual operating data of the power system, the equipment parameters in the preliminary test field are randomly varied to obtain parameter adjustment data; The initial test scenario is adjusted using the environmental adjustment data and the parameter adjustment data to generate several adjusted test scenarios, which are then combined to obtain the final test scenario.
8. A test scenario generation device for power systems, characterized in that, include: The text generation module is used to acquire scenario demand data for the power system and to process the scenario demand data using natural language processing technology to extract key information from the scenario demand data and generate scenario description text. The text optimization module is used to process the scene description text based on retrieval enhancement generation technology and through a collaborative optimization mechanism of knowledge retrieval and text generation to obtain optimized scene description text. The scene generation module is used to input the optimized text of the scene description into a pre-trained artificial intelligence model for processing, and generate a preliminary test scene. The scenario supplementation module is used to process the preliminary test scenario by introducing fuzz testing techniques with random mutations and abnormal inputs to obtain the final test scenario.
9. An electronic device, characterized in that, The system includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the test scenario generation method for power systems as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein when the device containing the computer-readable storage medium executes the computer program, it implements the test scenario generation method for power systems as described in any one of claims 1 to 7.
Citation Information
Cited By
Knowledge tracking and evidence labeling combined RAG question and answer system
CN121092675A