Modelica model compiling method and device, equipment and storage medium

By determining the target model type and component type in Modelica model compilation and performing specific component compilation operations based on these types, the problem of insufficient compilation efficiency in the existing technology is solved, and more efficient model compilation and development is achieved.

CN119847534AActive Publication Date: 2025-04-18SUZHOU TONGYUAN SOFT CONTROL INFORMATION TECH CO LTD

Patent Information

Application Number
CN202510330249.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-20
Publication Date
2025-04-18
Estimated Expiration
2045-03-20

AI Technical Summary

Technical Problem

When compiling Modelica models, the existing technology compiles each instance separately based on a single standard semantic, resulting in insufficient compilation efficiency, affecting model development efficiency and increasing computing resource consumption.

Method used

By determining the target model type of the target Modelica model and the target component type of the component, perform corresponding component compilation operations based on the component type to improve compilation efficiency.

Benefits of technology

It improves the compilation efficiency of Modelica model, reduces the compilation time, reduces the consumption of computing resources, and improves the efficiency of model development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847534A_ABST
    Figure CN119847534A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a Modelica model compiling method and device, equipment and a storage medium, and the method comprises the steps: determining a target model type of a target Modelica model; wherein the target model type comprises a replaceable model or an irreplaceable model; under the condition that the target Modelica model is an irreplaceable model, aiming at each component in the target Modelica model, determining a target component type of the component; wherein the target component type comprises a fixed component, a candidate component or a template component; and based on the target component type of the component, executing a corresponding component compiling operation on the component. According to the technical scheme, the corresponding compiling operation can be executed based on the component type of the component in the Modelica model, and the compiling efficiency of the Modelica model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of industrial software technology, and in particular to a Modelica model compilation method, device, equipment and storage medium. Background Art

[0002] The modification and redeclare mechanisms of the Modelica language make it possible to derive different models and variants from the same model, thus facilitating model reuse. However, these reuse mechanisms bring challenges to model compilation.

[0003] From the language level, Modelica models are types, which are special types that do not need to declare instances. Instances of types are components. From the physical world, types are collections of entities with the same characteristics. For example, a resistor in electricity is a type, which is a collection of various resistor parts, and components are instances of types, corresponding to parts or individuals in the physical world.

[0004] Model reuse is declaring instances of a type and applying variants or re-declarations to change parameters, properties, or components of the type. These reused instances may have identical or different contents. Compiling according to the semantics in the Modelica specification requires processing these instances one by one. However, since Modelica reusable models often contain a large number of instances of the same type, compilation efficiency becomes a key issue. Especially in reusable models of large and complex systems, processing these instances one by one is a time-consuming process, which results in long compilation times that not only affect model development efficiency, but also increase the consumption of computing resources. Summary of the invention

[0005] The embodiments of the present invention provide a Modelica model compilation method, apparatus, device and storage medium. The technical solution of the embodiments of the present invention solves the problem of insufficient compilation efficiency caused by compiling each instance based on a single specification semantics when compiling the Modelica model in the prior art. The corresponding compilation operation can be performed based on the component type of the component in the Modelica model, thereby improving the compilation efficiency of the Modelica model.

[0006] In a first aspect, an embodiment of the present invention provides a Modelica model compilation method, the method comprising: Determine a target model type of a target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; when the target Modelica model is a non-replaceable model, determine a target component type of each component in the target Modelica model; wherein the target component type includes: a fixed component, a candidate component or a template component; based on the target component type of the component, perform a corresponding component compilation operation on the component.

[0007] In a second aspect, an embodiment of the present invention provides a Modelica model compilation device, the device comprising: A model type determination module is used to determine the target model type of a target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; a component type determination module is used to determine the target component type of each component in the target Modelica model when the target Modelica model is a non-replaceable model; wherein the target component type includes: a fixed component, a candidate component or a template component; a component compilation module is used to perform a corresponding component compilation operation on the component based on the target component type of the component.

[0008] In a third aspect, an embodiment of the present invention provides a computer device, the computer device comprising: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the Modelica model compilation method described in any embodiment.

[0009] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the Modelica model compilation method described in any embodiment.

[0010] The technical solution provided by the embodiment of the present invention determines the target model type of the target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; when the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determines the target component type of the component; wherein the target component type includes: a fixed component, a candidate component or a template component; based on the target component type of the component, performs a corresponding component compilation operation on the component. The technical solution of the embodiment of the present invention solves the problem that the prior art compiles each instance based on a single specification semantics when compiling the Modelica model, resulting in insufficient compilation efficiency. The corresponding compilation operation can be performed based on the component type of the component in the Modelica model, thereby improving the compilation efficiency of the Modelica model. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 It is a flow chart of a Modelica model compilation method provided by an embodiment of the present invention; Figure 2 is a structural schematic diagram of a Modelica model provided by an embodiment of the present invention; Figure 3 It is a flow chart of another Modelica model compilation method provided by an embodiment of the present invention; Figure 4 is a flow chart of a compilation operation for a fixed component provided by an embodiment of the present invention; Figure 5 It is a flow chart of compiling operation for template components provided by an embodiment of the present invention; Figure 6 is a flow chart of a compilation operation for a candidate component provided by an embodiment of the present invention; Figure 7 It is a type-specific compilation operation flow chart provided by an embodiment of the present invention; Figure 8 It is a workflow diagram for compiling a Modelica model provided by an embodiment of the present invention; Fig. 9 It is a structural schematic diagram of a Modelica model compilation device provided by an embodiment of the present invention; Fig.10 It is a structural schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0012] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.

[0013] Figure 1 It is a flow chart of a Modelica model compilation method provided by an embodiment of the present invention. The embodiment of the present invention can be applied to the scenario of compiling a Modelica model. The method can be executed by a Modelica model compilation device, and the device can be implemented by software and / or hardware.

[0014] like Figure 1 As shown, the Modelica model compilation method includes the following steps: S110 , determining the target model type of the target Modelica model.

[0015] Among them, the target Modelica model can be a Modelica model that needs to be compiled. The result of Modelica model compilation is DAE (Differential Algebraic Equation) in the mathematical sense, including variables and equations. The variables of DAE are atomic components in the Modelica model. The so-called atomic component means that its type has only a single attribute and cannot be further divided. This type is the atomic type. The equations of DAE come from equations described in three ways in the Modelica model. The first is the ordinary equation in the equation area, which is expressed in the mathematical form of the equation. The second is the connection equation, which is generated by the connection statement in the equation area. The third is the declaration equation, which is defined when the component is declared, and the form is that the variable is always equal to a value. Among them, the ordinary equation and the connection equation cannot be changed during the model reuse process, and the declaration equation can replace the value after the equal sign through the deformation mechanism when reused, and derive new components with different characteristics. The "equations and connections" described below in the embodiment of the present invention include ordinary equations, connection equations and declaration equations.

[0016] For example, Figure 2 is a schematic diagram of the structure of a Modelica model provided by an embodiment of the present invention. The “type” in the first column box represents a Modelica model. Figure 2As shown, the Modelica model can include multiple levels. In the first level, the Modelica model can include multiple components (component 1 to component n), as well as equations and connections associated with the components in this level. Furthermore, the components in the first level can also have corresponding subordinate levels. For example, component 1 can include multiple subcomponents (component 1-1 to component 1-m), as well as equations and connections associated with the subcomponents in this level; the components in the second level can also have corresponding subordinate levels. For example, component 1-m can include multiple subcomponents (component 1-1-1 to component 1-mk), as well as equations and connections associated with the subcomponents in this level; and so on, until the component is an atomic component. Among them, the set consisting of multiple components, equations and connections in the same level can be collectively referred to as "type". In addition, it should be pointed out that the "equations and connections associated with components" mentioned below include equations and connections associated with components in each level. For example, when component 1-m is an atomic component, the equations and connections associated with component 1 include: equations and connections associated with component 1 in the first level, equations and connections associated with component 1 in the second level, and equations and connections associated with component 1 in the third level.

[0017] Furthermore, the target model type may be a type indicating whether the target Modelica model can be differentially compiled. The target model type includes: a replaceable model or a non-replaceable model. When the target model type is a replaceable model, the content in the target Modelica model cannot be differentially compiled; when the target model type is a non-replaceable model, the content in the target Modelica model can be differentially compiled. Specifically, the target Modelica model may be semantically analyzed, and the target model type of the target Modelica model may be determined based on whether the target Modelica model contains preset keywords.

[0018] Exemplarily, the model prefix name of the target Modelica model can be obtained. When the model prefix name does not contain a preset replaceable identifier, the target model type is determined to be a non-replaceable model; when the model prefix name contains a preset replaceable identifier, the target model type is determined to be a replaceable model. The model prefix name can be the file name of the file to which the target Modelica model belongs. The preset replaceable identifier can be set manually. For example, the preset replaceable identifier can be set to "replaceable". If the model prefix name of the target Modelica model contains "replaceable", the target model type is a replaceable model, otherwise it is a non-replaceable model.

[0019] S120 . When the target Modelica model is a non-replaceable model, determine a target component type of each component in the target Modelica model.

[0020] The components may be components included in the target Modelica model. Specifically, the components may include components in each level of the target Modelica model. For example, Figure 2 In the example, each of components 1 to component n, components 1-1 to component 1-m, and components 1-1-1 to component 1-mk may be a component. The target component type may be a type indicating whether the component can be differentially compiled.

[0021] The target component type may include: fixed component, candidate component or template component. For a component marked as a fixed component, the component and the associated fixed equation can be directly copied and connected to the result. If there is a variant of the fixed component anywhere in the component environment information where the component is located, the top-level equation variant is taken. If the component has a replaceable declared equation, the equation variant is used to replace it and added to the result set. Otherwise, the top-level equation variant is added to the result set.

[0022] For a component marked as a template component, if the component is not redeclared using the redeclare keyword in the component environment information where the component is located, the component and the associated template components, equations, and connections are directly copied to the result set. Otherwise, the template components and the template components contained in the template equations and connections are replaced with the redeclared component, and the equations and connections are added to the result set.

[0023] For components marked as candidate components, calculate the value of their conditions in the component environment information where the component is located. If it is false, the component and the associated candidate connection are directly ignored. Otherwise, copy the candidate component to the result set, and the associated candidate connection is copied to the result set.

[0024] The component environment information includes the set of components in the current layer and upper layer components associated with the component. For example, in the layer containing the component and the upper layer components declared in the layer, to the layer of the upper layer components, and so on, all ordered layers and component sets above the component layer are called the component environment information corresponding to the component.

[0025] Furthermore, when determining the target component type of a component, the component prefix name of the component can be obtained. When the component prefix name contains a preset replaceable identifier, the target component type of the component is determined to be a template component; when the component contains a conditional statement, the target component type of the component is determined to be a candidate component; when the component contains an equation variation, the target component type of the component is determined to be a replaceable component.

[0026] Among them, the component prefix name can be the file name of the file to which the component belongs. The preset replaceable identifier here can be consistent with the preset replaceable identifier in step S110. For example, the preset replaceable identifier can be set to "replaceable". If the component prefix name of the component contains "replaceable", the target component type is a replaceable component, otherwise it is a non-replaceable component. Furthermore, the code corresponding to the component can be judged. If the code contains conditional statements, the target component type of the component is determined to be a candidate component; if the code contains equation variations, the target component type of the component is determined to be a replaceable component.

[0027] Optionally, in order to reduce the amount of calculation for determining the target component type of a component, the determination order of different component types may be set in the order of the determination calculation amount from small to large. For example, it may be determined whether the component is a template type first, and if the component is not a template type, it may be determined whether the component is a candidate type, and if the component is not a candidate type, it may be determined whether the component is a fixed type.

[0028] S130. Based on the target component type of the component, perform a corresponding component compilation operation on the component.

[0029] Among them, for components of different target component types, component compilation operations corresponding to the target component types can be executed, thereby realizing the compilation process of the target Modelica model.

[0030] The technical solution provided by the embodiment of the present invention determines the target model type of the target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; when the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determines the target component type of the component; wherein the target component type includes: a fixed component, a candidate component or a template component; based on the target component type of the component, performs a corresponding component compilation operation on the component. The technical solution of the embodiment of the present invention solves the problem that the prior art compiles each instance separately based on a single specification semantics when compiling the Modelica model, resulting in insufficient compilation efficiency. The corresponding compilation operation can be performed based on the component type of the component in the Modelica model, thereby improving the compilation efficiency of the Modelica model.

[0031] Figure 3It is another flow chart of a Modelica model compilation method provided by an embodiment of the present invention. The embodiment of the present invention can be applied to the scenario of compiling a Modelica model. Based on the above embodiment, this embodiment further illustrates how to determine the target model type of the target Modelica model; and how to perform corresponding component compilation operations on the component based on the target component type of the component. The device can be implemented by software and / or hardware and integrated in a computer device with application development function.

[0032] like Figure 3 As shown, the Modelica model compilation method includes the following steps: S210 , determining the target model type of the target Modelica model.

[0033] S220 : When the target Modelica model is a non-replaceable model, determine a target component type of each component in the target Modelica model.

[0034] S230: Obtain component environment information corresponding to the component.

[0035] S240: Perform a corresponding component compilation operation on the component according to the component environment information and the target component type of the component.

[0036] Among them, for components of different target component types, different component compilation operations can be performed on the components according to the component environment information.

[0037] Exemplarily, when the target component type of the component is a fixed component, corresponding component compilation operations are performed on the component according to the component environment information and the target component type, including: when there is a new variant in the component environment information, replacing the original equation of the component based on the equation in the new variant; when there is no new variant in the component environment information and the component has a replaceable equation, replacing the original equation of the component based on the replaceable equation.

[0038] Among them, to determine whether there is a new variation in the component environment information, it can be determined by whether there is a new change in the equation data in the equation component environment information. For example, if "a=5" is recorded in the original equation of the component, and "a=6" is recorded in the equation in the component environment information, it is determined that there is a new variation. Furthermore, in the case where there is a new variation in the component environment information, the original equation of the component can be replaced based on the equation in the component environment information. Optionally, for components whose target component type is a fixed component, the above-mentioned new variation determination can be performed only on the declared equation corresponding to the component, and the fixed equation and connection equation corresponding to the component can be directly copied.

[0039] For example, Figure 4 1 is a flow chart of a compilation operation for a fixed component provided by an embodiment of the present invention. Figure 4 As shown, the compilation operation process of the fixed component includes the following steps: Step 1, copy the component to the result set; Step 2, copy the equations marked as fixed equations and the connections marked as fixed connections associated with the component to the result set; Step 3, search the environment where the component is located, and if there is a variant, use the new variant declaration equation to add it to the result set, otherwise copy the original declaration equation to the result set.

[0040] When the target component type of the component is a template component, the corresponding component compilation operation is performed on the component according to the component environment information and the target component type of the component, including: when there is a preset declaration identifier in the component environment information, the component is replaced based on the component declared in the component environment information, and the equations and connections associated with the component are modified; when there is no preset declaration identifier in the component environment information, the template component is copied. The preset declaration identifier can be an identifier indicating whether to redeclare. During the compilation of the model, the user can edit the data of the Modelica model, and the edited data can be marked with the corresponding preset declaration identifier. Exemplarily, "redeclare" can be selected as the preset declaration identifier.

[0041] For example, Figure 5 1 is a flow chart of a compiling operation for a template component provided by an embodiment of the present invention. Figure 5 As shown, the compilation operation process of the template component includes the following steps: Step 1, search the environment where the component is located. If there is "redeclare", replace the template component with the re-declared component and add it to the result set, and go to step 2, otherwise, go to step 3; Step 2, the template component associated with the template component is marked as template equations and template connections. Replace it with the re-declared component; Step 3, directly copy the template component to the result set, and the equations and connections of the template component remain unchanged and are copied to the result set.

[0042] When the target component type of the component is a candidate component, a corresponding component compilation operation is performed on the component according to the component environment information and the target component type of the component, including: when the condition in the component environment information is true, copying the candidate component and equations and connections associated with the candidate component; when the condition in the component environment information is not true, deleting the candidate component and equations and connections associated with the candidate component. Wherein, the condition being true means that the conditional statement is satisfied.

[0043] For example, Figure 6 is a flow chart of a compilation operation for a candidate component provided by an embodiment of the present invention. Figure 6As shown, the compilation operation process of the candidate component includes the following steps: Step 1, search the environment where the candidate component is located. If the condition of the candidate component is true, copy the candidate component, candidate equation and candidate connection to the result set, otherwise, go to step 2; Step 2, ignore the candidate component, candidate equation and candidate connection.

[0044] Optionally, it is also possible to determine whether the type is redeclared, and then perform a compilation operation based on the determination result. For example, Figure 7 This is a flow chart of a type-specific compilation operation provided by an embodiment of the present invention. Figure 7 As shown, the compilation operation process of the type includes the following steps: search the environment where the type is located, if there is "redeclare", compile the redeclared type, and add the components, equations and connections therein to the result set, otherwise, go to step two; step two, compile the replaceable type, and add the components, equations and connections therein to the result set.

[0045] Optionally, during the compilation of the model, the compilation tasks of components at the same level can be executed in parallel as a single task, but the compilation tasks of components at different levels can only be executed serially from top to bottom.

[0046] For illustrative purposes, in order to better understand the technical solution provided by the present invention, specific embodiments are introduced below. Figure 8 This is a workflow diagram for compiling a Modelica model provided by an embodiment of the present invention. Figure 8 As shown in the figure, the workflow for compiling a Modelica model includes the following steps: (1) Select the target Modelica model as the current type.

[0047] (2) Parse the prefix of the current type. If replaceable is found, mark the model type as a replaceable type and go to (11).

[0048] (3) Select the next component in the current type, parse the prefix of the component, and if it is replaceable, mark the component as a template component. Mark the equations and connections associated with the component as template equations and template connections respectively and transfer to (7).

[0049] (4) Analyze the conditions of the component. If the conditions are met, mark the component as a candidate component. Mark the equations and connections associated with the component as candidate equations and candidate connections respectively and proceed to (7).

[0050] (5) Analyze the variants of the component. If there are any variants, mark the declaration equation of the variant as an interchangeable declaration equation.

[0051] (6) The components are marked as fixed components, and the associated equations and connections are marked as fixed equations and fixed connections, respectively.

[0052] (7) If there is a fixed tag in the equation or connected tag associated with the component and there is also a template or candidate tag, remove the fixed tag.

[0053] (8) Components, equations and connections are converted into internal data representations, and connections are generated to generate local connection graphs.

[0054] (9) Get the type of the component. If the type is not an atomic type, set the component type to the current type and go to (2).

[0055] (10) If the current type still has components, go to (3).

[0056] (11) Type processing ends.

[0057] The technical solution provided by the embodiment of the present invention determines the target model type of the target Modelica model; when the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determines the target component type of the component; obtains the component environment information corresponding to the component; and performs corresponding component compilation operations on the component according to the component environment information and the target component type of the component. The technical solution of the embodiment of the present invention solves the problem that the prior art compiles each instance separately based on a single specification semantics when compiling the Modelica model, resulting in insufficient compilation efficiency. The corresponding compilation operations can be performed based on the component type of the component in the Modelica model, thereby improving the compilation efficiency of the Modelica model.

[0058] Fig. 9 It is a structural diagram of a Modelica model compilation device provided by an embodiment of the present invention. The embodiment of the present invention can be applied to the scenario of compiling the Modelica model. The device can be implemented by software and / or hardware and integrated into a computer device with application development function.

[0059] like Fig. 9 As shown, the Modelica model compilation device includes: a model type determination module 310 , a component type determination module 320 and a component compilation module 330 .

[0060] Among them, the model type determination module 310 is used to determine the target model type of the target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; the component type determination module 320 is used to determine the target component type of the component for each component in the target Modelica model when the target Modelica model is a non-replaceable model; wherein the target component type includes: a fixed component, a candidate component or a template component; the component compilation module 330 is used to perform a corresponding component compilation operation on the component based on the target component type of the component.

[0061] The technical solution provided by the embodiment of the present invention determines the target model type of the target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; when the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determines the target component type of the component; wherein the target component type includes: a fixed component, a candidate component or a template component; based on the target component type of the component, performs a corresponding component compilation operation on the component. The technical solution of the embodiment of the present invention solves the problem that the prior art compiles each instance based on a single specification semantics when compiling the Modelica model, resulting in insufficient compilation efficiency. The corresponding compilation operation can be performed based on the component type of the component in the Modelica model, thereby improving the compilation efficiency of the Modelica model.

[0062] In an optional embodiment, the component type determination module 320 is specifically used to: obtain the component prefix name of the component, and when the component prefix name contains a preset replaceable identifier, determine that the target component type of the component is a template component; when the component contains a conditional statement, determine that the target component type of the component is a candidate component; when the component contains an equation variation, determine that the target component type of the component is a replaceable component.

[0063] In an optional implementation, the model type determination module 310 is specifically used to: obtain the model prefix name of the target Modelica model, and when the model prefix name does not contain a preset replaceable identifier, determine that the target model type is a non-replaceable model; when the model prefix name contains a preset replaceable identifier, determine that the target model type is a replaceable model.

[0064] In an optional embodiment, the component compilation module 330 is specifically used to: obtain component environment information corresponding to the component; wherein the component environment information includes a set of current-layer components and upper-layer components associated with the component; and perform corresponding component compilation operations on the component according to the component environment information and target component type of the component.

[0065] In an optional embodiment, the component compilation module 330 includes: a fixed component compilation unit, which is used to: when there is a new variant in the component environment information, replace the original equation of the component based on the equation in the new variant; when there is no new variant in the component environment information and the component has a replaceable equation, replace the original equation of the component based on the replaceable equation.

[0066] In an optional embodiment, the component compilation module 330 includes: a template component compilation unit, which is used to: when there is a preset declaration identifier in the component environment information, replace the component based on the component declared in the component environment information, and modify the equations and connections associated with the component; when there is no preset declaration identifier in the component environment information, copy the template component.

[0067] In an optional embodiment, the component compilation module 330 includes: a candidate component compilation unit, which is used to: copy the candidate component and the equations and connections associated with the candidate component when the condition in the component environment information is true; and delete the candidate component and the equations and connections associated with the candidate component when the condition in the component environment information is not true.

[0068] The Modelica model compilation device provided in the embodiment of the present invention can execute the Modelica model compilation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0069] Fig.10 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Fig.10 A block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention is shown. Fig.10 The computer device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention. The computer device 12 can be any terminal device with computing capability and can be configured in a Modelica model compilation device.

[0070] like Fig.10As shown, the computer device 12 is in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).

[0071] The bus 18 may be one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. For example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0072] The computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 12, including volatile and non-volatile media, removable and non-removable media.

[0073] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache 32. The computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Fig.10 not shown, usually called a "hard drive"). Although Fig.10 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.

[0074] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.

[0075] The computer device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), one or more devices that enable a user to interact with the computer device 12, and / or any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the computer device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. Fig.10 As shown, the network adapter 20 communicates with other modules of the computer device 12 via the bus 18. It should be understood that although Fig.10 Not shown, other hardware and / or software modules may be used in conjunction with computer device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0076] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, for example, implementing the Modelica model compilation method provided in the embodiment of the present invention, the method comprising: Determine a target model type of a target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; when the target Modelica model is a non-replaceable model, determine a target component type of each component in the target Modelica model; wherein the target component type includes: a fixed component, a candidate component or a template component; based on the target component type of the component, perform a corresponding component compilation operation on the component.

[0077] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the Modelica model compilation method provided by any embodiment of the present invention is implemented, including: Determine a target model type of a target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; when the target Modelica model is a non-replaceable model, determine a target component type of each component in the target Modelica model; wherein the target component type includes: a fixed component, a candidate component or a template component; based on the target component type of the component, perform a corresponding component compilation operation on the component.

[0078] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0079] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0080] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0081] Computer program code for performing the operation of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0082] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0083] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A Modelica model compilation method, characterized in that: include: Determine a target model type of a target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; In the case where the target Modelica model is a non-replaceable model, for each component in the target Modelica model, determining a target component type of the component; wherein the target component type includes: a fixed component, a candidate component, or a template component; Based on the target component type of the component, a corresponding component compilation operation is performed on the component.

2. The method according to claim 1, characterized in that The determining the target component type of the component comprises: Obtaining a component prefix name of the component, and determining that a target component type of the component is a template component when the component prefix name contains a preset replaceable identifier; In the case where the component contains a conditional statement, determining the target component type of the component as a candidate component; In the case where the component contains equation variations, the target component type of the component is determined to be a replaceable component.

3. The method according to claim 1, characterized in that: The step of determining the target model type of the target Modelica model includes: Obtaining a model prefix name of the target Modelica model, and determining that the target model type is a non-replaceable model when the model prefix name does not contain a preset replaceable identifier; In a case where the model prefix name contains a preset replaceable identifier, the target model type is determined to be a replaceable model.

4. The method according to claim 1, characterized in that The performing a corresponding component compilation operation on the component based on the target component type of the component includes: Obtaining component environment information corresponding to the component; wherein the component environment information includes a collection of current layer components and upper layer components associated with the component; According to the component environment information and the target component type of the component, a corresponding component compilation operation is performed on the component.

5. The method according to claim 4, characterized in that In the case where the target component type of the component is a fixed component, performing a corresponding component compilation operation on the component according to the component environment information and the target component type of the component, including: In case there is a new variant in the component environment information, replacing the original equation of the component based on the equation in the new variant; In the case where there is no new variation in the component environment information and the component has a replaceable equation, the original equation of the component is replaced based on the replaceable equation.

6. The method according to claim 4, characterized in that In the case where the target component type of the component is a template component, performing a corresponding component compilation operation on the component according to the component environment information and the target component type of the component includes: In the case where there is a preset declaration identifier in the component environment information, replacing the component based on the component declared in the component environment information, and modifying equations and connections associated with the component; In the case where there is no preset declaration identifier in the component environment information, the template component is copied.

7. The method according to claim 4, characterized in that In a case where the target component type of the component is a candidate component, performing a corresponding component compilation operation on the component according to the component environment information and the target component type of the component includes: If a condition in the component environment information is true, copying the candidate component and equations and connections associated with the candidate component; When the condition in the component environment information is not true, the candidate component and the equations and connections associated with the candidate component are deleted.

8. A Modelica model compilation device, characterized in that: The device comprises: A model type determination module, used to determine a target model type of a target Modelica model; wherein the target model type includes: a replaceable model or a non-replaceable model; A component type determination module is used to determine the target component type of each component in the target Modelica model when the target Modelica model is a non-replaceable model; wherein the target component type includes: a fixed component, a candidate component or a template component; The component compilation module is used to perform corresponding component compilation operations on the component based on the target component type of the component.

9. A computer device, characterized in that: The computer device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the Modelica model compilation method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the Modelica model compilation method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Reusable satellite power supply energy balance simulation system and modeling method thereof

    CN106202681A

  • Function compiling method and device, electronic equipment and computer readable storage medium

    CN113391811A

  • Compiling method and device for hardware description language, equipment, medium and product

    CN117149202A

  • Method, device and equipment for realizing parallel or concurrent simulation of Modelica model

    CN118051296A

Cited By

  • Modelica model state curing method, device, equipment, medium and product

    CN120874414A

  • Power grid table conversion method, device, equipment, storage medium and product

    CN122528243A