A multi-level hybrid model flattening compilation method and system for X language
By flattening the multi-level hybrid model in X language and integrating the continuous models at different levels into a unified set of equations, the problem of model compilation complexity is solved, and the compilation is simplified and the simulation efficiency is improved.
Patent Information
- Application Number
- CN202511061455.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-31
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-07-31
AI Technical Summary
Existing technologies are difficult to effectively handle the compilation of multi-level hybrid models in X language, which increases the workload of modelers and the complexity of simulation.
A multi-level hybrid model flattening compilation method is adopted to integrate and flatten the continuous models at different levels in the X language into a unified equation system model. Through recursive processing and merging of continuous connection relationships, a new integrated continuous model is generated.
It simplifies the compilation process of the X language model, improves simulation efficiency, and facilitates the underlying solution and simulation of the model.
Smart Images

Figure CN120560666B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of model compilation, and more particularly to a multi-level hybrid model flattening compilation method and system for X language. Background Art
[0002] Model-Based Systems Engineering (MBSE) refers to a technical system that uses models as a medium for communication during the design process of complex products. Its essence is to combine the abstract system architecture modeling constructed in the early stages of complex product design with physical simulation verification and evaluation to ensure that complex product designs meet design requirements. To support this integrated system architecture modeling and physical property simulation verification, the X language, based on SysML, Modelica, and DEVS, has developed a modeling syntax that integrates system architecture modeling and physical property simulation capabilities.
[0003] When modeling complex systems of this type, the most common type is the continuous-discrete hybrid system model. A hybrid system is a dynamical system that incorporates both continuous and discrete dynamic characteristics, exhibiting both continuous (described by differential equations) and jump (discrete state changes) characteristics. The X language provides a modeling syntax for hybrid systems, describing continuous models based on differential algebraic equations and discrete events. These multi-domain models are coupled together through three types of port connections (normal ports, event ports, and Kirchhoff ports) to form a hybrid system. This approach provides a very convenient hybrid system modeling method for modelers, allowing them to construct system models in the form of mathematical models without having to consider the simulation details of the hybrid system.
[0004] However, to simulate and verify the hybrid system model created in X language, the modeler needs to compile the X language model into an executable simulation file capable of performing continuous-discrete hybrid system simulations. XDEVS is a typical continuous-discrete hybrid system simulation framework. This type of framework simulation requires the modeler to have a professional understanding of the framework's architecture. Furthermore, since these simulation frameworks lack dedicated modeling languages, directly simulating hybrid models using these frameworks increases the workload. However, since hybrid system models built in X language have many layers, solving equation-based models requires flattening all models with equation connections (both ordinary and Kirchhoff) into a unified set of equations for differential solution. Due to the unique event interface features of X language, these models, connected by different interfaces, ultimately form a complex multi-layered hybrid system, with the continuous models modeled by differential algebraic equations residing at different levels of this multi-layered system.
[0005] Therefore, how to provide a flat compilation method and system to compile and process the multi-level complex hybrid model of X language is an urgent problem to be solved by those skilled in the art. Summary of the Invention
[0006] In light of this, the present invention provides a method and system for flattening compilation of multi-level hybrid models in the X language. This method can integrate and flatten continuous models at different levels and with equational connections in a multi-level continuous-discrete hybrid model built using the X language into a unified system of equations, thereby facilitating the underlying solution and simulation of the X language hybrid model.
[0007] In order to achieve the above object, the present invention adopts the following technical solutions:
[0008] In one aspect, the present invention provides a multi-level hybrid model flattening compilation method for X language, comprising the following steps:
[0009] Get the X language coupling model;
[0010] Recursively flattening the coupling model in the X language coupling model;
[0011] The flattening process includes:
[0012] Obtaining a continuous model and a continuous connection relationship in the coupling model;
[0013] grouping the continuous models according to the continuous connection relationship;
[0014] The continuous models within each group are integrated to generate a new continuous system of equations for each group;
[0015] Converting the continuous connection relationships within each group into equations and integrating them into the new continuous equation group to obtain an integrated continuous equation group;
[0016] Combining the integrated continuous equation group and the discrete ports and continuous ports of other models in the group to form a new integrated continuous model;
[0017] Processing the continuous connection relationship in the coupling model and integrating the original connection relationship of the continuous model group into the new integrated continuous model;
[0018] The new integrated continuous model generated by each continuous model group replaces all the continuous models in the group before flattening to obtain the coupled model after flattening.
[0019] Preferably, processing the continuous connection relationship in the coupling model includes:
[0020] Retrieving and traversing continuous models having a continuous connection relationship between the coupled models, and removing the continuous models from the coupled models to which they belong;
[0021] These acquisitions are then merged into this new continuous model as before.
[0022] In another aspect, the present invention provides a multi-level hybrid model flattening compilation system for X language, comprising:
[0023] Input module, used to obtain the X language coupling model;
[0024] A compilation module, configured to recursively flatten the coupling model in the X language coupling model;
[0025] The compilation module specifically includes:
[0026] An extraction unit, configured to obtain a continuous model and a continuous connection relationship in the coupling model;
[0027] a grouping unit, configured to group the continuous models according to the continuous connection relationship;
[0028] The equation integration unit is used to integrate the continuous models in each group, and each group generates a new continuous equation system;
[0029] A connection relationship conversion unit, configured to convert the continuous connection relationships within each group into equations, and integrate the equations into the new continuous equation group to obtain an integrated continuous equation group;
[0030] A model integration unit, configured to combine the integrated continuous equation group and the variables, parameters, discrete ports and continuous ports of other models in the group to form a new integrated continuous model;
[0031] A model relationship conversion unit, configured to process the continuous connection relationship between the coupled models and integrate the original connection relationship of the continuous model group into the new integrated continuous model;
[0032] The output unit is used to replace all continuous models in the group before flattening with the new integrated continuous model generated by each continuous model group to obtain a coupled model after flattening.
[0033] Preferably, the model relationship conversion unit includes:
[0034] A coupled model relationship conversion subunit, configured to merge the equations of the retrieved continuous model and remove the retrieved continuous model from the coupled model to which it belongs;
[0035] The relationship merging subunit is used to convert the continuous connection relationship of the retrieved continuous model into an equation, and merge the equation converted from the continuous connection relationship and the equation of the retrieved continuous model into the new integrated continuous model.
[0036] As can be seen from the above technical solutions, compared to the prior art, the present invention provides a method and system for flattening compilation of a multi-level hybrid model in language X. By flattening continuous models at different levels in language X, continuous models at different levels in a multi-level continuous-discrete hybrid model established using language X, with equational connections established, can be integrated into a large continuous model. This facilitates the compilation and solution of the language X model, making the compilation and use of language X simpler and facilitating the use and promotion of language X. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0038] Figure 1 This is a flow chart of the X language multi-level hybrid model flattening compilation method of the present invention;
[0039] Figure 2 This is a schematic diagram of the X language multi-level hybrid model flattening compilation method of the present invention;
[0040] Figure 3 This is a schematic diagram of an example of the X language multi-level hybrid model flattening compilation method of the present invention;
[0041] Figure 4 This is a schematic diagram of the structure of the X language multi-level hybrid model flat compilation system of the present invention. DETAILED DESCRIPTION
[0042] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0043] The specific structure of the X language multi-level hybrid model compiled in the embodiment of the present invention includes the following: a coupling model, a discrete model, a continuous model, a definition part, a connection part, a parameter element, a variable element, a port element, a component element, a discrete event port, a continuous port, an event port connection, a continuous port connection, an equation port connection, and a Kirchhoff port connection;
[0044] The coupling model is used to model the system composition relationship in the X language, including the definition part and the connection part;
[0045] Discrete models, used to model discrete systems in X language;
[0046] Continuous model, used to model continuous systems described by equations in X language, including definition part and equation part;
[0047] The definition part is used to define the elements included in the system in the X language, including parameter elements, variable elements, port elements and component elements;
[0048] The connection part is used to define the connection relationship between system components in X language, including two types: event port connection and continuous port connection;
[0049] The equation part is used to define the equation constraint behavior of the continuous model in X language;
[0050] Parameter elements are used to define fixed parameters included in the system in the X language;
[0051] Variable elements are used to define variable parameters included in the system in X language;
[0052] Port elements are used to define the port elements included in the system in X language, including event ports and continuous ports;
[0053] Component elements are used to define the system components included in the coupling model in the X language. The component types can be coupling models, discrete models, and continuous models.
[0054] Event port, used to transmit discrete event information between X language models;
[0055] Continuous ports are used to establish constraint equality relationships between X language models. Continuous ports include equality ports and Kirchhoff ports.
[0056] Equation port, which represents a port that transmits continuously changing real number data;
[0057] Kirchhoff port, which represents the port that transmits energy data, including a flow variable and a potential variable;
[0058] An event port connection indicates that both ports on the connection are discrete event ports. When two discrete event ports are connected, information is transmitted between the two ports through discrete events.
[0059] Continuous port connections, used to establish constraint equality relationships between X language models, including equality port connections and Kirchhoff port connections;
[0060] Equality port connection means that both ports are equality ports. In this case, a constraint relationship is established between the two ports that the variables on both sides are equal.
[0061] A Kirchhoff port connection means that both ports are Kirchhoff ports. In this case, an energy conservation constraint relationship is established between the two ports, in which the potential variables are equal and the sum of the flow variables is zero.
[0062] The embodiment of the present invention discloses a multi-level hybrid model flattening compilation method for X language, such as Figure 1 As shown, the following steps are included:
[0063] Get the X language coupling model;
[0064] Recursively flatten the coupling model in the X language coupling model;
[0065] The flattening process includes:
[0066] Obtain the continuous model and continuous connection relationship in the coupled model;
[0067] Grouping continuous models based on their continuous connectivity;
[0068] The continuous models in each group are integrated, and each group generates a new continuous equation group; the integration includes parameter merging, variable merging, event port merging, and equation merging. The created new continuous model stores the merged parameters, variables, event ports, and equations;
[0069] The continuous connection relationship within each group is converted into equations and integrated into a new continuous equation system to obtain an integrated continuous equation system; one of the equality port connections is directly converted into an equation with equal equality variables on both sides, and one Kirchhoff port connection is converted into two equations with equal potential variables in the ports on both sides and the sum of the flow variables being zero.
[0070] Merge the integrated continuous equations and the discrete ports and continuous ports of other models in the group to form a new integrated continuous model;
[0071] Process the continuous connection relationship in the coupled model and integrate the original connection relationship of the continuous model group into the new integrated continuous model;
[0072] The new integrated continuous model generated by each continuous model group replaces all the continuous models in the group before flattening to obtain the coupled model after flattening.
[0073] Specifically, the continuous connection relationship in the coupling model is processed, including:
[0074] Retrieving continuous models having continuous connection relationships between traversing coupled models, merging equations of the retrieved continuous models, and removing the retrieved continuous models from the coupled models to which they belong;
[0075] The continuous connection relations of the retrieved continuous model are then converted into equations, and the equations converted from the continuous connection relations and the equations of the retrieved continuous model are merged into a new integrated continuous model.
[0076] like Figure 2 As shown, in another embodiment, the X language defines three types of ports in the field of continuous-discrete hybrid modeling: event ports, equation ports, and Kirchhoff ports. Event ports are used to transmit discrete event information between models. Equality ports and Kirchhoff ports transmit continuous data between two models. When two equality ports are connected, an equality constraint is established between the two connected ports, meaning that a numerical update to one port will result in the same numerical update to the other port.
[0077] When two Kirchhoff ports are connected, a constraint relationship will be established between the two ports that the potential variables are equal and the sum of the flow variables is zero (the potential variables are equal and the sum of the flow variables is 0). When flattening, all interconnected continuous models will be traversed from the top layer to the bottom, and according to the connection relationship and the conversion relationship between the equations, multiple interconnected continuous models will be integrated into a solvable set of equations. At the same time, in this flattening process, the discrete variable ports for different continuous models to interact with discrete models will be retained. After the traversal is completed, all continuous models that have established continuous port connection relationships will be flattened into a set of equations for solution. Figure 2 As shown, the original continuous models 1 and 2 and continuous models 3, 4, and 5 finally formed two interconnected continuous model groups, which formed new continuous models-12 and continuous models-345 after flattening.
[0078] like Figure 3As shown, the X language model is composed of three layers of coupled models, including four continuous models A, B, C, and D that are continuously connected to each other. Each of the four continuous models defines its own equations, and at the same time, they are connected to each other, and equation connection relationships are formed between the interfaces. These four models are at different levels, and C and D are each connected to the same discrete model. In this embodiment, the flattening of the model will continuously flatten each sub-coupling model from the bottom up. First, at the bottom layer, since there is only one continuous model D, there is no need to group the models, and the flattening of the coupling model of the penultimate layer is directly executed. Similarly, this layer has only one continuous model C, and there is no need to group it. The continuous connection of the model D of the next layer can be directly processed first. After processing, a new continuous model CD is generated at the penultimate layer to store the equations and variables of C and D, as well as the new equations generated by the connection between the two, including . In this way, model CD will include three equations, and the external interfaces of models C and D will also be retained in model CD. In the next step, since all sub-coupled models have been flattened, the top-level model will be flattened. The top level includes two continuous models A and B, and there is a continuous connection between the two. Therefore, the two are directly grouped and merged to obtain a new model AB, which includes the equations and variables of A and B, as well as the equations converted from the continuous connection between the two ( Finally, the continuous connection between the AB and sub-coupling models is processed, CD is flattened and merged into AB, and the two continuous connections between AB and CD are converted into equations. and , ultimately resulting in a continuous model ABCD consisting of eight equations. Four of these equations are composed of the equations in A, B, C, and D, and four of these equations are formed by the connections between them. ABCD also inherits the connections between these four models and the discrete models at different levels, thus completing the flattening process of the coupled model.
[0079] On the other hand, the present invention provides a multi-level hybrid model flat compilation system for X language, such as Figure 4 As shown, including:
[0080] Input module, used to obtain the X language coupling model;
[0081] Compiler module, used to recursively flatten the coupling model in the X language coupling model;
[0082] The compilation modules specifically include:
[0083] An extraction unit, used to obtain the continuous model and continuous connection relationship in the coupling model;
[0084] A grouping unit, used to group continuous models according to continuous connection relationships;
[0085] The equation integration unit is used to integrate the continuous models in each group, and each group generates a new continuous equation system;
[0086] A connection relationship conversion unit is used to convert the continuous connection relationships within each group into equations and integrate them into a new continuous equation group to obtain an integrated continuous equation group;
[0087] Model integration unit, used to combine the variables, parameters, discrete ports and continuous ports of the integrated continuous equation group and other models in the group to form a new integrated continuous model;
[0088] A model relationship conversion unit is used to process the continuous connection relationship between the coupled models and integrate the original connection relationship of the continuous model group into a new integrated continuous model;
[0089] The output unit is used to replace all continuous models in the group before flattening with the new integrated continuous model generated by each continuous model group to obtain a coupled model after flattening.
[0090] Furthermore, the model relationship conversion unit includes:
[0091] A coupled model relationship conversion subunit, configured to merge the equations of the retrieved continuous model and remove the retrieved continuous model from the coupled model to which it belongs;
[0092] The relation merging subunit is used to convert the continuous connection relation of the retrieved continuous model into an equation, and merge the equation converted from the continuous connection relation and the equation of the retrieved continuous model into a new integrated continuous model.
[0093] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.
[0094] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A multi-level hybrid model flattening compilation method for X language, characterized in that: The following steps are involved: Get the X language coupling model; Recursively flattening the coupling model in the X language coupling model; The flattening process includes: Obtaining a continuous model and a continuous connection relationship in the coupling model; grouping the continuous models according to the continuous connection relationship; The continuous models within each group are integrated to generate a new continuous system of equations for each group; Converting the continuous connection relationships within each group into equations and integrating them into the new continuous equation group to obtain an integrated continuous equation group; Combining the integrated continuous equation group and the discrete ports and continuous ports of other models in the group to form a new integrated continuous model; Processing the continuous connection relationship in the coupling model and integrating the original connection relationship of the continuous model group into the new integrated continuous model; The new integrated continuous model generated by each continuous model group replaces all the continuous models in the group before flattening to obtain the coupled model after flattening.
2. A multi-level hybrid model flattening compilation method for X language according to claim 1, characterized in that: Processing the continuous connection relationship in the coupling model includes: Retrieving and traversing continuous models having a continuous connection relationship between the coupled models, merging equations of the retrieved continuous models, and removing the retrieved continuous models from the coupled models to which they belong; The continuous connection relationship of the retrieved continuous model is then converted into an equation, and the equation converted from the continuous connection relationship and the equation of the retrieved continuous model are merged into the new integrated continuous model.
3. A multi-level hybrid model flattened compilation system for X language, characterized by: include: Input module, used to obtain the X language coupling model; A compilation module, configured to recursively flatten the coupling model in the X language coupling model; The compilation module specifically includes: An extraction unit, configured to obtain a continuous model and a continuous connection relationship in the coupling model; a grouping unit, configured to group the continuous models according to the continuous connection relationship; The equation integration unit is used to integrate the continuous models in each group, and each group generates a new continuous equation system; A connection relationship conversion unit, configured to convert the continuous connection relationships within each group into equations, and integrate the equations into the new continuous equation group to obtain an integrated continuous equation group; A model integration unit, configured to combine the integrated continuous equation group and the variables, parameters, discrete ports and continuous ports of other models in the group to form a new integrated continuous model; A model relationship conversion unit, configured to process the continuous connection relationship between the coupled models and integrate the original connection relationship of the continuous model group into the new integrated continuous model; The output unit is used to replace all continuous models in the group before flattening with the new integrated continuous model generated by each continuous model group to obtain a coupled model after flattening.
4. A multi-level hybrid model flattening compilation system for X language according to claim 3, characterized in that: The model relationship conversion unit includes: A coupled model relationship conversion subunit, configured to merge the equations of the retrieved continuous model and remove the retrieved continuous model from the coupled model to which it belongs; The relationship merging subunit is used to convert the continuous connection relationship of the retrieved continuous model into an equation, and merge the equation converted from the continuous connection relationship and the equation of the retrieved continuous model into the new integrated continuous model.