Adjacency list-based model calculation sequence and algebraic ring judgment method and system
Through the method based on the adjacency table, the problem of identifying algebraic rings is solved, and the determination of model calculation order and algebraic ring recognition is realized, which improves the calculation efficiency and accuracy.
Patent Information
- Application Number
- CN202411697053.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-18
AI Technical Summary
In a model-based engine control system, how to identify algebraic rings when calculating the order of the model and remind model designers to eliminate it is a urgent problem.
Using an adjacency table-based method, the inclusion of the model vertex is calculated by initializing the adjacency table, finding and deleting the model vertex with an entry degree of 0, and updating the adjacency table until there is no model vertex with an entry degree of 0. Then determine whether there are undeleted model vertices. If they exist, it means that there is an algebraic ring. The calculation order of the model is determined according to the order of deleting the model vertices.
Effectively identify and process algebraic rings, determine the calculation order of the model, improve the efficiency and accuracy of the model calculation, and save storage space.
Smart Images

Figure CN119645414A_ABST
Abstract
Description
[0001] Technology Neighborhood
[0002] The present invention relates to a development neighborhood of a model, and in particular to a model calculation sequence based on an adjacency list and an algebraic ring judgment method and system. Background Art
[0003] As a safety-critical complex system, the software of the engine control system is shifting from manual coding to model-based development, which generates code based on the model after designing a graphical model. In model-based code generation and simulation, it is necessary to determine the model dependencies based on the data flow between models, and further determine the model code generation and simulation operation order based on the model dependencies. In addition, if all models are interdependent, that is, the input signal of the model directly depends on the output signal, and the output signal directly depends on the input signal, the data flow between the models is circular, which is called an algebraic loop. However, after the algebraic loop is generated, the calculation order of the model cannot be obtained due to the mutual dependence of the data flow. How to identify this situation when calculating the order of the model and remind the model designer to eliminate the algebraic loop is an urgent problem to be solved. Summary of the invention
[0004] Purpose of the invention: The purpose of the present invention is to provide a model calculation order based on an adjacency list and an algebraic ring judgment method and system.
[0005] Technical solution: The model calculation sequence based on the adjacency list and the algebraic ring judgment method described in the present invention include the following steps:
[0006] (1) Initialize the adjacency list and calculate the in-degree of all model vertices;
[0007] (2) Find the model vertices that need to be deleted this time with an in-degree of 0;
[0008] (3) Delete model vertices and update the adjacency list;
[0009] (4) Repeat steps (2) to (3) until there are no model vertices with in-degree 0;
[0010] (5) Determine whether there are any undeleted model vertices. If so, it means that the remaining model vertices form an algebraic ring;
[0011] (6) The calculation order of the model is determined according to the order in which the model vertices are deleted.
[0012] Furthermore, the adjacency list in step (1) uses models as vertices and data flows between models as edges.
[0013] Furthermore, the data structure of the adjacency list in step (1) includes: the in-degree of each vertex, the graphic position coordinates of the model in the coordinate system, an indicator of whether it has been deleted, and a list of models pointed to by the model output data stream.
[0014] Furthermore, the in-degree of the model in step (1) is calculated by increasing the in-degree of the model by 1 for each input data stream.
[0015] Furthermore, the step (1) includes calculating the in-degree of all model vertices and setting the deletion flag to no.
[0016] Furthermore, the step (2) includes traversing all model vertices and searching for all model vertices with an in-degree of 0. If there is only one model vertex with an in-degree of 0, then the model vertex is the model vertex to be deleted this time. If multiple model vertices with an in-degree of 0 are found, the coordinate values of the model graphic coordinate system are compared in turn according to the priorities of the X-axis and the Y-axis, and the model vertex with the smaller coordinate value is deleted this time.
[0017] Furthermore, the step (3) includes setting a deletion flag in the adjacency list to yes according to searching the model vertex to be deleted, deleting the data flow edge related to the model vertex, and setting the in-degree of the model vertex pointed to by the data flow edge to -1.
[0018] Furthermore, the adjacency list-based model calculation sequence and algebraic ring judgment system described in the present invention includes an initialization module, an algebraic ring module and a sequential calculation module.
[0019] Furthermore, the algebraic ring module is used to determine whether there are undeleted model vertices. If so, it means that the remaining model vertices constitute an algebraic ring. If not, it means that the remaining model vertices do not constitute an algebraic ring.
[0020] Furthermore, the order calculation module is used to determine the calculation order of the model according to the deletion order of the model vertices.
[0021] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages: the present invention uses an adjacency list to store model information, which saves more space than the storage method of an adjacency matrix; the calculation speed for large models is fast; while calculating the model order, it detects whether there is an algebraic ring, and prompts the user with the model that eventually forms the algebraic ring; in the case where the models obtained from the data flow dependency analysis have the same priority, the model order is further determined according to the model graphic coordinates, avoiding the randomness of the calculation order of models with the same priority. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a flow chart of the present invention;
[0023] Figure 2 It is the data structure diagram of the model adjacency list;
[0024] Figure 3 The structure diagram of the model with algebraic rings;
[0025] Figure 4 It is the structure diagram of the model to be sorted;
[0026] Figure 5 This is the data structure diagram of the model adjacency list after one iteration. DETAILED DESCRIPTION
[0027] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0028] like Figure 1 As shown, the model calculation sequence based on the adjacency list and the algebraic ring judgment method described in the present invention include the following steps:
[0029] Step 1: Initialize the adjacency list and calculate the in-degree of all model vertices
[0030] Will be like Figure 4 The model shown is transformed into Figure 2 The data structure shown represents the adjacency list. Taking model 3 as an example, since model 3 has two data flows pointing to model 4 and model 6 respectively, model 3 has two edges marked 4 and 6. Model 3 has a data flow from model 2, so the in-degree of model 3 is 1. At the same time, the deletion flag and coordinates of model 3 are initialized.
[0031] Step 2: Find the model with in-degree 0 that needs to be deleted this time
[0032] Traverse all undeleted models. If there is only one model vertex with in-degree 0, then this model is the model vertex to be deleted. If multiple model vertices with in-degree 0 are found, compare the coordinate values of the model graphic coordinate system according to the priority of the X-axis and Y-axis, and delete the model vertex with the smaller coordinate value. Figure 2 As shown in , since only model 1 exists with an in-degree of 0, the model to be deleted is model 1. Figure 5 As shown, since there are two models with in-degree 0, Model 2 and Model 5, the coordinates of the two models are further compared. Since the X-axis coordinate of Model 2 is smaller, the model to be deleted is Model 2.
[0033] Step 3: Delete the model and update the adjacency list
[0034] like Figure 2 As shown, mark the deletion of model 1 as yes, and according to the two edges 2 and 5 of model 1, reduce the in-degree of model 2 and model 5 by 1 respectively. The updated adjacency table is as follows Figure 5 shown.
[0035] Step 4: Repeat steps 2 to 3 until there are no model vertices with in-degree 0.
[0036] Step 5: Determine whether there are any undeleted model vertices. If so, it means that the remaining model vertices form an algebraic ring, such as Figure 3 Shown is the structure diagram of the model with an algebraic loop.
[0037] Step 6: Determine the calculation order of the model according to the order in which the model vertices are deleted.
[0038] like Figure 4 As shown, the calculation order of the obtained model is 1, 2, 5, 3, 6, 4.
[0039] The model calculation order and algebraic ring judgment system based on the adjacency list of the present invention comprises an initialization module, an algebraic ring module and a sequence calculation module. The algebraic ring module is used to determine whether there are undeleted model vertices. If so, it means that the remaining model vertices constitute an algebraic ring. If not, it means that the remaining model vertices do not constitute an algebraic ring. The sequence calculation module is used to determine the calculation order of the model according to the deletion order of the model vertices.
Claims
1. A model calculation sequence based on an adjacency list and an algebraic ring judgment method, characterized in that: The steps include: (1) Initialize the adjacency list and calculate the in-degree of all model vertices; (2) Find the model vertices that need to be deleted this time with an in-degree of 0; (3) Delete model vertices and update the adjacency list; (4) Repeat steps (2) to (3) until there are no model vertices with in-degree 0; (5) Determine whether there are any undeleted model vertices. If so, it means that the remaining model vertices form an algebraic ring; (6) The calculation order of the model is determined according to the order in which the model vertices are deleted.
2. The model calculation sequence and algebraic ring judgment method based on adjacency list according to claim 1, characterized in that: The adjacency list in step (1) uses models as vertices and data flows between models as edges.
3. The model calculation sequence and algebraic ring judgment method based on adjacency list according to claim 1, characterized in that: The data structure of the adjacency list in step (1) includes: the in-degree of each vertex, the graphic position coordinates of the model in the coordinate system, an indicator of whether it has been deleted, and a list of models pointed to by the model output data stream.
4. The model calculation sequence and algebraic ring judgment method based on adjacency list according to claim 1, characterized in that: The in-degree of the model in step (1) is calculated by adding 1 to the in-degree of the model for each input data stream.
5. The model calculation sequence and algebraic ring judgment method based on adjacency list according to claim 1, characterized in that: The step (1) includes calculating the in-degree of all model vertices and setting the deletion flag to no.
6. The model calculation sequence and algebraic ring judgment method based on adjacency list according to claim 1, characterized in that: The step (2) includes traversing all model vertices and searching for all model vertices with an in-degree of 0. If there is only one model vertex with an in-degree of 0, then the model vertex is the model vertex to be deleted this time. If multiple model vertices with an in-degree of 0 are found, then the coordinate values of the model graphic coordinate system are compared in turn according to the priorities of the X-axis and the Y-axis, and the model vertex with the smaller coordinate value is deleted this time.
7. The model calculation sequence and algebraic ring judgment method based on adjacency list according to claim 1, characterized in that: The step (3) includes searching the model vertex to be deleted, setting a deletion flag in the adjacency list to yes, deleting the data flow edge related to the model vertex, and setting the in-degree of the model vertex pointed to by the data flow edge to -1.
8. A model calculation sequence and algebraic ring judgment system based on adjacency list, characterized in that: It includes initialization module, algebraic loop module and sequential calculation module.
9. The model calculation sequence and algebraic ring judgment system based on adjacency list according to claim 8, characterized in that: The algebraic ring module is used to determine whether there are undeleted model vertices. If so, it means that the remaining model vertices form an algebraic ring. If not, it means that the remaining model vertices do not form an algebraic ring.
10. The model calculation sequence and algebraic ring judgment system based on adjacency list according to claim 8, characterized in that: The order calculation module is used to determine the calculation order of the model according to the deletion order of the model vertices.