Combined simulation model execution sequence determination method based on improved Tarjan algorithm
Through the improved Tarjan algorithm and weighted two-part graph representation method, the problem of circular dependency processing in strongly coupled multi-model joint simulation is solved, and more efficient and accurate simulation results are achieved.
Patent Information
- Application Number
- CN202510155773.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-12
- Publication Date
- 2025-06-24
AI Technical Summary
When handling strongly coupled multi-model joint simulation, it is difficult to effectively deal with complex circular dependencies, resulting in poor simulation accuracy and efficiency.
Using the improved Tarjan algorithm, by constructing a weighted two-part graph, a multi-level weighted Tarjan algorithm is used to identify strong connected components, and an optimized model execution order is generated by eliminating circular dependence and weighted topological sorting.
It realizes finer granular execution sequence optimization, improves the simulation efficiency and accuracy of large-scale complex systems, and can effectively handle circular dependencies.
Smart Images

Figure CN120197239A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer simulation, and relates to a method for determining the execution order of each model in a strongly coupled multi-model co-simulation system. Background Art
[0002] In the co-simulation of complex systems, multiple models need to work together to simulate the overall behavior of the system. There are usually complex interdependent relationships among these models, forming a strongly coupled system. Determining the appropriate model execution order is crucial for improving simulation accuracy and efficiency.
[0003] In the prior art, common methods for determining the model execution order include: 1. Static sorting based on dependencies. 2. Sorting based on time steps. 3. Sorting based on priorities. However, these methods often do not work well when dealing with strongly coupled systems and cannot effectively handle complex cyclic dependencies.
[0004] As a classic graph theory algorithm, the Tarjan algorithm is often used to detect strongly connected components (SCCs) in directed graphs. In the field of co-simulation, some researchers have tried to apply the Tarjan algorithm to the determination of the model execution order. The original Tarjan algorithm has the following deficiencies when solving the model execution order in strongly coupled multi-model co-simulation:
[0005] 1. Granularity problem: The Tarjan algorithm identifies complete strongly connected components, which may combine a large number of models together, resulting in too large a granularity of the execution order and making it impossible to perform more detailed optimization.
[0006] 2. Weight neglect: The original Tarjan algorithm does not consider the strength of the dependencies between models and treats all edges equally, which may cause minor dependencies to have too much influence on the execution order in actual co-simulation.
[0007] 3. Input / output confusion: The Tarjan algorithm cannot distinguish between input dependencies and output dependencies of models, which may lead to unnecessary restrictions when determining the execution order.
[0008] Therefore, a new method is needed to solve these problems and improve the efficiency and accuracy of co-simulation. Summary of the Invention
[0009] The technical problem solved by the present invention is: overcoming the deficiencies of the prior art, and proposing a method for determining the execution order of a co-simulation model based on an improved Tarjan algorithm, which can better meet the requirements of strongly coupled multi-model co-simulation and effectively determine the execution order of models.
[0010] The technical solution of the present invention is as follows:
[0011] In a first aspect, the present invention provides a method for determining the execution order of a co-simulation model based on an improved Tarjan algorithm. The steps of this method include:
[0012] Step 1: Construct a weighted bipartite graph representing the dependency relationships between co-simulation models;
[0013] Step 2: Apply the multi-level weighted Tarjan algorithm to calculate the weighted bipartite graph, and determine whether there are multi-connected components. If there are, decompose the multi-connected components and proceed to Step 3; otherwise, proceed to Step 4;
[0014] Step 3: Process the multi-connected components to eliminate cyclic dependencies. After processing, update the weighted bipartite graph and return to Step 2;
[0015] Step 4: Perform a weighted topological sort on the weighted bipartite graph. After sorting, identify the critical path and proceed to Step 5;
[0016] Step 5: Generate an optimized model execution order based on the weighted topological sort result and the critical path.
[0017] Preferably, in Step 1, the method for constructing a weighted bipartite graph representing the dependency relationships between co-simulation models is as follows:
[0018] 1.1 Define the bipartite graph G = (V I ∪ V O , E, W), where: is the set of input nodes, is the set of output nodes, E is the set of edges, W is the edge weight function, and n is the total number of co-simulation models;
[0019] 1.2 Create input nodes and output nodes for each model, add internal edges, and calculate the internal edge weights;
[0020] For the i-th model M i , i = 1, 2,..., n, create the input node and the output node Add the internal edge Calculate the internal edge weight: w i = W(e i ) = f internal (M i ), where f internal () is a function based on the model complexity;
[0021] 1.3 Establish the dependency relationships between models. The establishment method is as follows:
[0022] If model Mi The output is model M j is the input, then add an edge
[0023] Calculate the weight of the external edge: w ij = W(e ij ) = f external (d ij , c ij ), where d ij is the data transfer volume from model M i to model M j , and c ij is the calculation dependency between model M i and model M j , and f external () is the weight calculation function.
[0024] Preferably, the implementation method of step 2 is as follows:
[0025] 2.1 Set the weight threshold θ, scale threshold δ, and strongly connected component threshold;
[0026] 2.2 Perform a depth-first search on the weighted bipartite graph to obtain all components that exceed the strongly connected component threshold, and enter step 2.3; if no component that exceeds the strongly connected component size threshold is found after the depth-first search is completed, enter step 4;
[0027] 2.3 Judge each edge e ij in the strongly connected components identified in step 2.2. If W(e ij ) > θ, then e ij is considered a dependent edge, and the two nodes corresponding to this edge are put into the node set SCC. After traversing all strongly connected components, enter step 2.4;
[0028] 2.4 If the size of the node set SCC exceeds δ, then update the weight threshold θ using the formula θ = 1.1 * θ, and repeat steps 2.2 - 2.3 until the size of the node set SCC is less than or equal to δ and end, then enter step 3.
[0029] Preferably, in step 3, the implementation method for processing the multi-connected components to eliminate cyclic dependencies is as follows:
[0030] 3.1 Identify the edge with the smallest weight in the strongly connected component;
[0031] 3.2 Remove the identified edge with the smallest weight;
[0032] 3.2 Repeat steps 3.1 and 3.2 until there are no strongly connected components.
[0033] Preferably, in step 4, the method of weighted topological sorting is as follows:
[0034] 4.1 Initialize the node sorted list L′ for a weighted bipartite graph without multi-connected components;
[0035] 4.2 Traverse all nodes and put the nodes with in-degree 0 into the node sorted list L′;
[0036] 4.3 Select the node v with the largest weight from the node sorted list L′ max , add it to the execution order list, and remove the out-edges of node v max ;
[0037] 4.4 Repeat steps 4.2 and 4.3 until all nodes are added to the execution order list. The order in which the nodes are placed in the execution order list is the weighted topological sort L.
[0038] Preferably, the node v with the largest weight max is the one with the largest weight function W(v max ), where E′ represents the set of edges related to node v max .
[0039] Preferably, in step 4, the method for identifying the critical path is as follows:
[0040] S1 Calculate the earliest start time and the latest start time of each node in the weighted topological sort L;
[0041] S2 Find the set of nodes CP where the earliest start time is the same as the latest start time;
[0042] S3 The nodes in the set CP are the nodes on the critical path.
[0043] Preferably, in step 5, the optimized model execution order O=(o1, o2,..., o n ), where: where L -1 (v) is the position of node v in the topological sort L.
[0044] In a second aspect, the present invention provides a terminal device, including:
[0045] A memory for storing instructions executed by at least one processor;
[0046] A processor for executing the instructions stored in the memory to implement the method described in the first aspect above.
[0047] In a third aspect, the present invention provides a computer-readable storage medium storing computer instructions, which, when run on a computer, cause the computer to execute the method described in the first aspect above.
[0048] The beneficial effects of the present invention compared with the prior art are as follows:
[0049] (1) Multi-level analysis: Through an adjustable threshold and a recursive decomposition mechanism, multi-level identification and processing of strongly connected components are achieved, solving the granularity problem of the original Tarjan algorithm, providing more fine-grained optimization of the execution order, and significantly improving the simulation efficiency of large-scale complex systems.
[0050] (2) Considering weight differences: Edge weights are introduced during the construction and analysis of the dependency graph to reflect the strength of the dependency relationship between models. A weighted topological sorting algorithm is used to generate the execution order, ensuring that important dependency relationships are considered first, and improving the simulation accuracy and efficiency.
[0051] (3) Distinguishing input and output: An innovative bipartite graph representation method is adopted to split the model into input nodes and output nodes, clearly distinguishing the input-output dependency relationships between models, improving the accuracy of dependency analysis, reducing false dependencies, and achieving more flexible and efficient model scheduling. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a flowchart of a method for determining the execution order of a co-simulation model. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0053] The present invention will be further described below in conjunction with embodiments.
[0054] As Figure 1 shown, a method for determining the execution order of a co-simulation model based on an improved Tarjan algorithm according to the present invention includes the following steps:
[0055] 1) Construct a weighted bipartite graph representing the dependency relationships between models;
[0056] 2) Apply a multi-level weighted Tarjan algorithm to the weighted bipartite graph to identify strongly connected components;
[0057] 3) Process the identified strongly connected components to eliminate cyclic dependencies;
[0058] 4) Perform weighted topological sorting on the graph without strongly connected components after processing;
[0059] 5) Conduct critical path analysis;
[0060] 6) Generate an optimized model execution order based on the results of weighted topological sorting and critical path analysis.
[0061] The weighted bipartite graph includes:
[0062] – The set of input nodes representing the input ports of the model;
[0063] – The set of output nodes representing the output ports of the model;
[0064] – The set of edges representing the connection relationships between ports;
[0065] – The set of edge weights representing the connection importance.
[0066] Specifically as follows:
[0067] 1.1 Define the bipartite graph G = (V I ∪ V O , E, W), where: is the set of input nodes, is the set of output nodes, E is the set of edges, W is the edge weight function, and n is the total number of co-simulation models; represents the input nodes of the 1st, 2nd,..., nth input ports of the model. represents the output nodes of the 1st, 2nd,..., nth output ports of the model.
[0068] 1.2 Create input nodes and output nodes for each model, add internal edges, and calculate the internal edge weights;
[0069] For the i-th model M i , i = 1, 2,..., n, create the input node and the output node Add the internal edge Calculate the internal edge weight: w i = W(e i ) = f internal (M i ), where f internal () is a function based on the model complexity;
[0070] 1.3 Establish the dependency relationships between models, and the establishment method is as follows:
[0071] If the output of model M i is the input of model M j , then add the edge
[0072] Calculate the external edge weight: w ij = W(e ij ) = f external (d ij , c ij ), where d ij is the model Mi Data transfer volume to model M j is c ij is model M i and model M j computational dependence degree is f external () is the weight calculation function
[0073] The multi-level weighted Tarjan algorithm includes the following steps
[0074] a) Let θ be the weight threshold for identifying important dependencies, and δ be the scale threshold for controlling the size of each strongly connected component. Set the initial values of θ and δ
[0075] b) Perform a depth-first search to identify strongly connected components
[0076] c) For each edge e in the strongly connected components identified in step b ij ∈E, if W(e ij ) > θ, then consider e ij to represent an important dependency, retain the dependency edge, and put the two nodes corresponding to this edge into the node set SCC
[0077] d) If the size of the node set SCC exceeds δ, then recursively execute steps b) and c) using the new parameter θ′ = 1.1 * θ. End when the size of the node set SCC is less than or equal to δ
[0078] The steps for processing strongly connected components to eliminate cyclic dependencies include: a) For each strongly connected component SCC k , select the edge with the smallest weight
[0079] b) Remove this edge e min , to form a new graph G′
[0080] c) Repeat steps a) and b) until there are no strongly connected components in the newly formed graph G′
[0081] The weighted topological sorting includes the following steps
[0082] a) Initialize the in-degree set InDeg(v) and the node sorting list L′
[0083] b) For each node v ∈ V, if InDeg(v) = 0, then put v into the list L′
[0084] c) Select the node v with the largest weight from L′ max = argmax v∈L′ W(v), where The weight function for each node v, add it to the execution order list, and remove v max The out-edges of the node; the execution order list is topologically sorted according to the principle that the ones put in first are executed first and the ones put in later are executed later;
[0085] d) Recursively execute steps b) and c) until all nodes are added to the execution order list, and the order in which the nodes are put into the execution order list is the weighted topological sort L.
[0086] The critical path analysis includes the following steps:
[0087] a) For each node v, determine its earliest visit time EST(v) on the graph;
[0088] b) For each node v, determine its latest visit time LST(v) on the graph;
[0089] c) Identify the nodes v ∈ CP on the critical path, where CP = {v | EST(v) = LST(v)}.
[0090] The steps for generating an optimized model execution order include:
[0091] Determine the final execution order O = (o1, o2,..., o n )), where: Define L-1v = i as the inverse mapping of the topological sort L, where v is the i-th element in L;
[0092] In the present invention, during the simulation process, according to the change of the inter-model dependency relationship, the weighted bipartite graph is dynamically updated and steps 2) to 6) are re-executed.
[0093] The method of the present invention is applied to a co-simulation system with multiple simulation functional units, where each functional unit has multiple input ports and output ports, each input port is only connected to one output port, and each output port can be connected to multiple input ports.
[0094] The present invention also provides a terminal device, including: a memory for storing instructions executed by at least one processor; a processor for executing the instructions stored in the memory to implement the above method.
[0095] The present invention also provides a computer-readable storage medium, the computer-readable storage medium stores computer instructions, and when the computer instructions run on a computer, the computer is made to execute the above method.
[0096] Embodiment:
[0097] This embodiment takes the co - simulation of an automotive system as the background and details the application process of the method of the present invention.
[0098] I. Overview of the Simulation System
[0099] The co - simulation of the automotive system in this embodiment includes 5 simulation functional units, namely:
[0100] 1. Engine Model (EM)
[0101] 2. Transmission Model (TM)
[0102] 3. Vehicle Dynamics Model (VDM)
[0103] 4. Tire Model (TiM)
[0104] 5. Driver Model (DM)
[0105] Each functional unit has several input and output ports, and the connection relationships between the ports are complex. According to the regulations, each input port can only be connected to one output port, while an output port can be connected to multiple input ports.
[0106] II. Dependency Analysis
[0107] First, we need to analyze the dependency relationships between the functional units. The following are the main input and output ports of each model and their connection relationships:
[0108] 1. Engine Model (EM)
[0109] - Input: Throttle opening (from DM), engine speed (from TM)
[0110] - Output: Engine torque, engine speed
[0111] 2. Transmission Model (TM)
[0112] - Input: Engine torque (from EM), vehicle speed (from VDM), gear selection (from DM)
[0113] - Output: Output shaft torque, engine speed
[0114] 3. Vehicle Dynamics Model (VDM)
[0115] - Input: Output shaft torque (from TM), tire force (from TiM), braking pressure
[0116] (from DM)
[0117] - Output: vehicle speed, wheel speed, vehicle body attitude
[0118] 4. Tire Model (TiM)
[0119] - Input: wheel speed (from VDM), road surface information
[0120] - Output: tire force
[0121] 5. Driver Model (DM)
[0122] - Input: vehicle speed (from VDM), predetermined driving route
[0123] - Output: throttle opening, braking pressure, gear selection
[0124] III. Specific Steps for Applying the Method of the Present Invention
[0125] Step 1: Construct a weighted bipartite dependency graph
[0126] According to the dependency relationship, the present invention constructs a weighted bipartite graph G = (V_I ∪ V_O, E, W):
[0127] · V_I contains all input port nodes of the models
[0128] · V_O contains all output port nodes of the models
[0129] · E represents the connection relationship between ports
[0130] · W represents the weight of the connection (which can be determined based on data flow or computational dependency degree)
[0131] For example, the input nodes of EM can be represented as EM_throttle_in and EM_speed_in, and the output nodes can be represented as EM_torque_out and EM_speed_out.
[0132] Step 2: Apply the multi-level weighted Tarjan algorithm
[0133] Apply the improved multi-level weighted Tarjan algorithm to the constructed graph G:
[0134] 1. Set the initial thresholds θ = 0.5 (weight threshold) and δ = 3 (size threshold)
[0135] 2. Execute the MWSCC(G, θ, δ) function
[0136] 3. For the identified large-scale SCCs, recursively execute MWSCC until the size of all SCCs does not exceed δ or no further decomposition is possible
[0137] In this example, a strong coupling relationship may be found among EM, TM, and VDM, forming an SCC.
[0138] Step 3: Cyclic Dependency Handling
[0139] For the SCCs identified in Step 2, perform cyclic dependency handling:
[0140] 1. Find the edge with the smallest weight in the SCC. For example, it may be the connection from VDM_speed_out to
[0141] TM_speed_in
[0142] 2. Remove this edge and update graph G
[0143] 3. Repeat Steps 2 and 3 until there are no SCCs
[0144] Step 4: Weighted Topological Sorting
[0145] Perform weighted topological sorting on the processed acyclic graph G:
[0146] 1. Calculate the cumulative out-edge weight of each node
[0147] 2. Sort based on the cumulative weights to ensure that nodes with high weights are executed first
[0148] The sorting result may be: DM → EM → TM → VDM → TiM
[0149] Step 5: Critical Path Analysis
[0150] Based on the weighted topological sorting result, perform critical path analysis:
[0151] 1. Calculate the earliest start time and the latest start time of each node
[0152] 2. Identify the critical path. For example, it may be: DM → EM → TM → VDM
[0153] Step 6: Optimize Execution Order
[0154] Based on the critical path and the topological sorting result, generate the final model execution order:
[0155] DM → EM → TM → VDM → TiM
[0156] By applying the method of the present invention, we obtain an optimized execution order for the combined simulation model of the automotive system. This order takes into account the complex dependencies, data flow, and computational dependencies among the models, effectively solves the cyclic dependency problem, and ensures that the models on the critical path are executed first.
[0157] Although the present invention has been disclosed above with preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make possible changes and modifications to the technical solution of the present invention by using the methods and technical contents disclosed above without departing from the spirit and scope of the present invention. Therefore, any simple modifications, equivalent changes and decorations made to the above embodiments based on the technical essence of the present invention without departing from the technical solution of the present invention shall fall within the protection scope of the technical solution of the present invention.
Claims
1. A method for determining the execution order of a joint simulation model based on an improved Tarjan algorithm, characterized in that The steps of the method include: Step 1: Construct a weighted bipartite graph representing the dependencies between joint simulation models; Step 2: Apply the multi-level weighted Tarjan algorithm to calculate the weighted bipartite graph to determine whether there are multi-connected components. If so, decompose the multi-connected components and proceed to step 3, otherwise proceed to step 4; Step 3: Process the multi-connected components to eliminate circular dependencies, update the weighted bipartite graph after processing, and return to step 2; Step 4: Perform weighted topological sorting on the weighted bipartite graph, identify the critical path after sorting, and proceed to step 5; Step 5: Generate an optimized model execution order based on the weighted topological sorting results and the critical path.
2. The method for determining the execution order of a joint simulation model based on an improved Tarjan algorithm according to claim 1, characterized in that: In step 1, the method for constructing a weighted bipartite graph representing the dependency relationship between the joint simulation models is as follows: 1.1 Definition of a bipartite graph G = (V I ∪V O ,E,W), where: is the input node set, is the output node set, E is the edge set, W is the edge weight function, n is the total number of joint simulation models; 1.2 Create input nodes and output nodes for each model, add internal edges, and calculate internal edge weights; For the i-th model M i , i=1,2,...,n, create input nodes and output nodes Add Internal Edges Calculate internal edge weights: w i =W(e i ) = f internal (M i ), where f internal ( ) is a function based on the complexity of the model; 1.3 Establish dependencies between models. The establishment method is as follows: If the model M i The output of the model M j , then add an edge Calculate external edge weight: w ij =W(e ij ) = f external (d ij ,c ij ), where d ij It is model M i To Model M j The data transmission volume, c ij It is model M i With Model M j The computational dependence of f external ( ) is the weight calculation function.
3. The method for determining the execution order of a joint simulation model based on an improved Tarjan algorithm according to claim 1, characterized in that: The implementation method of step 2 is as follows: 2.1 Set the weight threshold θ, scale threshold δ, and strongly connected component threshold; 2.2 Perform a depth-first search on the weighted bipartite graph to obtain all components that exceed the strongly connected component threshold, and proceed to step 2.3; if no components exceeding the strongly connected component size threshold are found after the depth-first search is completed, proceed to step 4; 2.3 For each edge e in the strongly connected component identified in step 2.2 ij Make a judgment, if W(e ij )>θ, then we think that e ij For a dependent edge, put the two nodes corresponding to the edge into the node set SCC, and go to step 2.4 after traversing all strongly connected components; 2.4 If the size of the node set SCC exceeds δ, the weight threshold θ is updated using the formula θ=1.1*θ, and steps 2.2-2.3 are repeated until the size of the node set SCC is less than or equal to δ, and then step 3 is entered.
4. The method for determining the execution order of a joint simulation model based on an improved Tarjan algorithm according to claim 1, characterized in that: In step 3, the implementation method of processing the multi-connected components to eliminate the circular dependency is as follows: 3.1 Identify the edge with the smallest weight in the strongly connected component; 3.2 Remove the identified minimum weight edge; 3.2 Repeat steps 3.1 and 3.2 until there are no strongly connected components.
5. The method for determining the execution order of a joint simulation model based on an improved Tarjan algorithm according to claim 1, characterized in that: In step 4, the weighted topological sorting method is as follows: 4.1 For a weighted bipartite graph without multi-connected components, initialize the node sorting list L′; 4.2 Traverse all nodes and put the nodes with in-degree 0 into the node sorting list L′; 4.3 Select the node v with the largest weight from the node sorting list L′ max , add it to the execution order list, and remove v max Outgoing edges of a node; 4.4 Repeat steps 4.2 and 4.3 until all nodes are added to the execution order list. The order in which the nodes are placed in the execution order list is the weighted topological sort L.
6. The method for determining the execution order of a joint simulation model based on an improved Tarjan algorithm according to claim 5, characterized in that: The node with the largest weight v max That is, the weight function W(v max ) is the largest, among which Represents the node v max The set of related edges.
7. The method for determining the execution order of a joint simulation model based on an improved Tarjan algorithm according to claim 5, characterized in that: In step 4, the method for identifying the critical path is as follows: S1 calculates the earliest start time and the latest start time of each node in the weighted topological sort L; S2 looks for the node set CP whose earliest start time is the same as the latest start time; The nodes in the set CP described in S3 are the nodes on the critical path.
8. The method for determining the execution order of a joint simulation model based on an improved Tarjan algorithm according to claim 7, characterized in that: In step 5, the optimized model execution order O = (o1, o2, ..., o n ),in: Where L -1 (v) is the position of node v in the topological sort L.
9. A terminal device, characterized in that: include: a memory for storing instructions executed by at least one processor; A processor, configured to execute instructions stored in a memory to implement a method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 8.
Citation Information
Cited By
RC circuit health state assessment method
CN120654633A