A highly scalable integrated modeling and simulation approach
Through highly scalable integrated modeling and simulation methods and lightweight domain-specific languages, the problems of poor model scalability and tight coupling in integrated modeling methods are solved, unified description and automated verification of models are achieved, and cross-domain integration is supported. and flexibility in scene changes.
Patent Information
- Application Number
- CN202210263110.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-17
- Publication Date
- 2024-09-24
- Estimated Expiration
- Not applicable · inactive patent
Smart Images

Figure CN114756216B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of computer modeling and simulation, and in particular to a highly scalable integrated modeling and simulation method. Background Art
[0002] Computer modeling and simulation is an important method and means to simulate the real world by using computer-related software and hardware technologies, thereby exploring, analyzing and predicting the real world. Now, computer modeling and simulation has been widely used in almost all disciplines such as industrial control, environmental monitoring, social sciences and natural sciences.
[0003] With the continuous expansion of application fields, the scale of research problems is increasing, and researchers in different fields have established various simulation models. However, most of the existing simulation models are small in scale, simple in function, and generally used to solve specific problems in the field. Therefore, it is difficult to simulate and study more complex research objects, and it is difficult to grasp the overall properties of the research object and the complex internal interaction mechanism. Therefore, it is often necessary to establish a model that integrates multiple methods across disciplines, time and space scales, in order to deeply, meticulously and comprehensively characterize the research object. Therefore, in the practice of modeling and simulation, it is often necessary to integrate models of different fields, scales and methods into more complex models, called integrated models, to complete the modeling and simulation of complex problems or objects. The process of integrating simple models into complex models is called integrated modeling.
[0004] However, the current integrated modeling has the following problems:
[0005] First, it is difficult to integrate simple models into more complex integrated models because the application fields, development requirements, development environments, operating environments, and operating modes of existing simple models are generally different;
[0006] Second, in traditional integrated modeling methods, the integrated model and the actual application scenario are often tightly coupled, and the scalability of the model is poor;
[0007] Third, when the application scenario changes slightly, the integrated model needs to be rewritten or reconstructed, which is a lot of work;
[0008] Fourth, an integrated model is also a model that may become part of another more complex integrated model. However, the existing model integration methods lack the idea to support such further integration, and the existing integrated modeling environment also lacks the corresponding mechanism, making it difficult to reuse the integrated model. Summary of the invention
[0009] In view of the above-mentioned problems, the present invention proposes a highly scalable integrated modeling and simulation method. Combined with a lightweight integrated modeling and simulation domain-specific language (Domain Specific Language, DSL) proposed by the present invention, it can support integrated modeling and simulation with high scalability and reusable integrated models.
[0010] In order to achieve the above object, the technical solution adopted by the present invention is as follows:
[0011] A highly scalable integrated modeling and simulation method, characterized in that it comprises the following steps:
[0012] Step 1: construct different sub-models according to user input, wherein the sub-models are simple models or integrated models;
[0013] Step 2: For simple models, define a simple model that conforms to the unified view of the model; for integrated models, build its conceptual model;
[0014] Step 3: Define the instantiation model of the conceptual model described in step 2;
[0015] Step 4: Run the integrated instantiated model: first prepare the data according to the execution step defined in the conceptual model, define the data input and output modules according to the simple model definition method in step 2, establish the connection and control with the instantiated model in step 3, run the instantiated model, and finally realize the simulation process.
[0016] Furthermore, the specific operation steps of step 2 include:
[0017] Step 21: for a simple model, implement the simple model through Python or POJO code, and define a simple model that conforms to the unified view of the model by using a reusable integrated modeling domain specific language based on the Python or POJO code;
[0018] Step 22: For the integrated model, first enumerate the sub-models used, then define the control flow, and specify the data flow, connection and relationship between these sub-models, and finally conceptualize the sub-models to construct a conceptual model of the integrated model.
[0019] Furthermore, the specific operation steps of step 3 include:
[0020] Step 31: define the single sub-model enumerated in the conceptual model established in step 22 as a sub-model instance;
[0021] Step 32: Specify the number of models in the same sub-model group according to simulation requirements, and instantiate the connections between the sub-models, so as to construct an instantiation model of the conceptual model.
[0022] Furthermore, the unified model view in step 2 includes a static unified model view based on declaration and a dynamic unified model view used for control at runtime, and the definitions of the two are respectively:
[0023] 1) Static unified view of the model
[0024] M stxic :=<N,P,I,O,F> .
[0025] Where N is the model name, P is the parameter list, I is the input variable list, O is the output variable list, and F is the function;
[0026] 2) Dynamic unified view of the model
[0027] M dycamix :=<N,P,I,O,F,A>
[0028] Where N is the name of the model instance being executed, P is the parameter list, I is the input variable list, O is the output variable list, F is the function, and A is the finite state machine of the model;
[0029] Furthermore, in the integrated model described in step 22, there are finite state machines between the model and its enumerated sub-models to form a hierarchical finite state machine, and the dynamic control of the simulation of the integrated model is realized based on the hierarchical finite state machine. The specific operation steps include:
[0030] Step 221: Set the current instantiation model to the initial state, that is, S 0 state;
[0031] Step 222: traverse the sub-models of the current instantiation model according to the connection relationship with a breadth-first strategy, and set all sub-models to an initial state;
[0032] Step 223: If the sub-model is also an instantiated integrated model, then continue to execute step 222 for the integrated model until there is no more instantiated integrated model;
[0033] Step 224: If the data arrives, enter the corresponding execution state according to the specific model settings, and dynamically determine the execution state of sub-models at different levels according to the sub-model execution results.
[0034] Step 225: If the data ends, set the execution of the current instantiated model to end, and set the execution of all hierarchical sub-models to end in the same manner as steps 222 and 223.
[0035] Furthermore, the data flow described in step 22 includes connectors and links. The connector is an intermediate processing unit of the data flow, which is used to eliminate obstacles caused by different dimensions, scales and even semantics of data between different sub-models during the integration process; the link is a channel for transmitting data between models and connectors, and each link has a source and a target. The source is the output variable of the model or connector, and the target is the input variable of the model or connector.
[0036] Furthermore, the control flow described in step 22 includes sequential control, parallel control, selection control and iterative control, and the integrated model can complete complex tasks by combining the control flow with the data flow;
[0037] The sequence control is implied by the data flow and is executed sequentially;
[0038] The parallel control means that two or more models can be executed in parallel in the same operation cycle, and there is no data flow dependency between the multiple models in parallel control;
[0039] The selection control is used to select one of a group of models to execute according to specific conditions during the simulation process. The selection control allows different models to be selected, or a model can be selected according to different scenarios to see whether it can work;
[0040] The iteration control is used to correspond the multi-step execution of modeling simulation to the one-step of other modeling simulation, that is, when integrating models with different time steps, the model with fewer time steps should be iterated multiple times, while other models are executed only once.
[0041] Furthermore, the relationship between the models includes one-to-one, one-to-many, many-to-one and many-to-many, where:
[0042] A one-to-one relationship means that the output of one model instance is passed to another model instance. This is the default relationship between models, so usually the o2o relationship does not need to be explicitly declared;
[0043] A one-to-many relationship means that the output of one model instance is passed to at least one instance of another model;
[0044] A many-to-one relationship means that the output of at least one model instance is passed to an instance of another model;
[0045] Many-to-many relationships need to be specifically defined when instantiating them according to actual application requirements.
[0046] The beneficial effects of the present invention are:
[0047] First, all models in the present invention, including simple models and integrated models, have a consistent description method, which is a unified view of the model. Under the constraints of the unified view, all models are unified in form except for their functions from the user's perspective, and the usage method is consistent, making the integrated model easy to reuse;
[0048] Second, the present invention decomposes the processes of simple model realization, conceptual model integration, model instantiation and integrated model execution, so that model design, realization and specific simulation application are separated. In particular, the present invention separates conceptual model integration and instantiation, so that integration is no longer bound to specific applications, thereby enhancing the scalability of the model.
[0049] Third, the integrated model execution in the present invention relies on data flow drive and hierarchical finite state machine control. Therefore, strict operational semantics are defined for the data flow and control flow in the integration, and corresponding algorithms are designed, which provides the integrated model environment and runtime environment with the automation capability of the integrated model and the mathematical basis for correctness verification;
[0050] Fourth, the implementation of the simple model in the method proposed by the present invention and each model follows the modular design concept, which improves their scalability and the development efficiency of model integration;
[0051] In summary, the present invention is based on the idea of model-driven development to reduce the complexity of the platform and effectively express domain concepts. It separates conceptual integrated modeling from specific applications. Model integrators only build conceptual models, or models of models (containing only integrated sub-models and the relationships between them), instead of directly building the model instances and empty data flow relationships between instances from the beginning. Until the end user wants to use the model for simulation, they instantiate the sub-models and their relationships, thereby improving the scalability and development efficiency of integrated modeling and simulation. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A graphical representation of the static unified view of the model;
[0053] Figure 2 Graphical example of unified view for modeling and simulation including dynamic features;
[0054] Figure 3 To integrate modeling and simulation processes;
[0055] Figure 4 The organizational structure of the conceptual integration model;
[0056] Figure 5 It is the dependency diagram of each related file in the modeling process;
[0057] Figure 6It is a data flow diagram;
[0058] Figure 7 This is a schematic diagram of reverse connection (backward);
[0059] Figure 8 It is a schematic diagram of the integrated model;
[0060] Fig. 9 It is a schematic diagram of parallel operation;
[0061] Fig.10 Select the control schematic for the model;
[0062] Fig.11 Schematic diagram for selecting operation;
[0063] Fig.12 It is a schematic diagram of model iteration control;
[0064] Fig.13 It is a schematic diagram of iterative operation;
[0065] Fig.14 The result graph of the sub-model that instantiates the o2o relationship;
[0066] Fig.15 The resulting graph instantiated for the o2m relationship;
[0067] Fig.16 The result graph instantiated for the m2o relationship;
[0068] Fig.17 A schematic diagram of a complex modeling and simulation integration, where Fig.17 (a) is the graphical model for simulation integration. Fig.17 (b) Fig.17 (a) Unified view form of simulation integration. DETAILED DESCRIPTION
[0069] In order to enable those skilled in the art to better understand the technical solution of the present invention, the technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0070] 1. Model description method
[0071] All models in the present invention, including simple models and integrated models, have a consistent description method, namely, a unified model view, which includes a static unified model view based on declarations in the design phase and a dynamic unified model view used for control at runtime.
[0072] (1) Static unified view of the model
[0073] The static unified view of the model consists of five parts: model name N, parameter list P, input variable list I, output variable list O and function F, which can be expressed as:
[0074] M static :=<N,P,I,O,F> .
[0075] The name N is used to distinguish each model from other models and can be referenced.
[0076] No matter it is a simple model or an integrated complex model, each model has its simulation function, represented by F.
[0077] The function of a simple model is generally to implement a simple simulation task, such as calculating the sunshine duration at a certain geographic coordinate. The function of an integrated complex model is often a specific combination of the functions of the integrated sub-models, which can complete more complex tasks.
[0078] P is the parameter list of the model. Parameters are inherent properties of the simulation model, and their values often determine the simulation effect of the model. When the model is given, simulation is often used to determine the reasonable values of the parameters.
[0079] I and O represent the input variable list and output variable list of the modeling and simulation, respectively. The parameter list, input variable list and output variable list constitute the interface of the modeling and simulation, where the parameter list and input variable list can be empty, but the output variable list should generally not be empty; and they are defined as:
[0080]
[0081]
[0082] and
[0083] O = {o1, o2, ...}
[0084] Each element in the parameter list, input variable list, and output variable list is a tuple: <name, data, type, constraint>; the name is unique within the same model and is used to bind to the model or model instance name; the constraints are used to define the value range of model parameters and variables.
[0085] The unified view of the model can be used as Figure 1 The graphical method shown is represented. Figure 1 The model named mod shown is<mod,P,I,O,F> , and P = {p 1 , p 2}, I={i 1 ,i 2 ,i 3},O={o1 , o 2}, the arrows in the figure represent the direction of data flow.
[0086] (2) Model execution and model dynamic unified view
[0087] ①Data-driven
[0088] The present invention adopts a data-driven method to control the execution of the model. The model is started under the condition of parameter setting and waits for the arrival of input data. It is executed once after the data arrives, which is called an operation cycle. The operation cycle is preset according to the specific simulation problem. Its functions are realized within the operation cycle, and corresponding outputs are generated, and then the next input is waited for. When the data input module reads the data end mark (such as the file end mark), it is determined that no more data has arrived. At this time, the execution ends and the simulation is completed.
[0089] This execution mode solves the simulation of discrete-time physical processes. Each execution represents a simulation of one time step, and the entire simulation does not require model designers and integrators to additionally deal with the repetitive process.
[0090] ②Process control based on hierarchical finite state machine
[0091] The execution of the model is a dynamic process. During the execution process, different inputs may trigger different simulation processes. Therefore, the present invention uses a finite state machine to describe the dynamic process of the simulation. In the integrated model, since there are finite state machines between the model and the sub-model, a hierarchical finite state machine is formed. The present invention proposes a simulation integration algorithm based on a hierarchical finite state machine, which realizes the dynamic description and automatic control of complex simulation processes.
[0092] ③ Dynamic unified view of the model
[0093] After adding the dynamic description of the execution process, the model can still be described by a unified view during the execution process. The unified view description of the model including dynamic attributes is as follows:
[0094] M dycamix :=<N,P,I,O,F,A>
[0095] N, P, I, O, F have the same meaning as in the static model representation, only N is the name of the model instance being executed.
[0096] The properties of simulation are composed of two parts: P, I, O, and F are the static properties of modeling and simulation, and the finite state machine A is the dynamic property of modeling and simulation.
[0097] Define the state of modeling simulation as:
[0098] S:= <P e , I e , O e , f e >
[0099] Where P e ∈P,I e ∈I,O e ∈O,f e ∈F, the subscript represents that the current state is valid. The valid part refers to the effective part in the current operating state. For example, Pe refers to the effective part of the entire current parameter set, which is a subset of the model parameter set P; and the ineffective part only refers to the ineffective part in the current operating state, which is the part of the set P minus Pe. This part may become a valid part when the model is in other operating states.
[0100] When the state of the modeling simulation changes, it means that a certain related set of the modeling simulation has changed. For example, when the input variables required by the modeling simulation increase, it means that the state of the modeling simulation has changed.
[0101] The states and transitions of modeling and simulation can be defined by the following finite state machine:
[0102] A:= <S,S 0 , T>
[0103] Among them, S is a finite set of states for modeling and simulation, T:S→S is the state transition function, and the initial state Represents that the modeling simulation is activated, where s 0 ∈S and Represents waiting for input.
[0104] Attached Figure 2 A graphical example of the unified view of modeling and simulation including dynamic features is given. Assuming that modeling and simulation m = <N m ,P,I,O,F,A>,P={p 1 , p 2}, I={i 1 ,i 2 ,i 3},O={o 1 , o 2}, F = {f 1 , f 2},A= <S,s 0 , T>, S = {s 0 ,s 1 ,s 2}, and T={(s 0 ,s 1 ), (s 0 ,s2 ), (s 1 ,s 1 ), (s 2 ,s 2 ), (s 1 ,s 2 ), (s 2 ,s 1 )}. In addition 1 = <P e1 , I e1 , O e1 , f 1 >,s 2 = <P e2 , I e2 , O e2 , f 2 >, P e1 =P e2 ={p 1 , p 2}, I e1 ={i 1 ,i 2}, I e2 ={i 1 ,i 3},O e1 ={o 1},O e2 ={o 2};
[0105] 2. Integrated Modeling and Simulation Process
[0106] The modeling and simulation process of the present invention is subdivided into some fine-grained sub-processes, including implementing or rewriting / reconstructing simple models, defining simple models, conceptualizing integrated models, instantiating integrated models, creating simulations, and simulating. The entire process is shown in the attached figure. Figure 3 The specific integrated modeling process includes the following steps:
[0107] Step 1: construct different sub-models according to user input, wherein the sub-models are simple models or integrated models;
[0108] Step 2: Implement the simple model through Python or POJO code, and define a simple model that conforms to the unified view of the model by using a reusable integrated modeling domain specific language based on the Python or POJO code;
[0109] Step 3: Define the integrated model, first enumerate the sub-models used in the integrated modeling, and specify the data flow and connection relationship between these sub-models, and define the control flow, and then conceptualize the sub-models to construct a conceptual model of the integrated model;
[0110] Step 4: define an instantiation model of the conceptual model described in step 3, first define a single sub-model enumerated in the conceptual model as a sub-model instance, specify the number of models in the same sub-model group according to the simulation requirements, and instantiate the connection between the sub-models, so as to construct an instantiation model of the integrated model;
[0111] Step 5: Run the integrated model, which first prepares data according to the model execution step, defines the data input and output modules according to the simple model definition method in step 2, establishes the connection and control with the instantiated model described in step 4, runs the instantiated model, and finally realizes the simulation process.
[0112] Most integrated software have their own methods to define new components and reconstruct legacy software. In order to reduce the difficulty of new model design, development and reconstruction of existing models for professionals in specific fields, the present invention uses basic programming methods similar to Python or simple Java object models (Plain Old Java Object, POJO) to create new models. Modeling is divided into two parts: implementation and definition. First, the new simple model will be implemented with Python or POJO coding, and the legacy such as libraries, executable files, and even Web Services (WS) will be encapsulated in Python or POJO code, and then based on these codes (Python or POJO coding for implementing simple models, legacy such as libraries, executable files, etc.), a simple model that conforms to the unified view of the model is defined in a reusable domain-specific language.
[0113] The definition of a model is divided into two parts: conceptualization and instantiation. Among them, conceptualization is the process of building a conceptual model of the integrated model. In this stage, the sub-models used in the integration are enumerated, the data flow in these sub-models is specified, and the control flow is defined. The number of each type of sub-model is determined by the specific application.
[0114] For specific simulation applications, the conceptual model is instantiated as an instance of the model. In the simulation, the number of each type of model is specified according to the specific application. And some features that are difficult to define in the conceptual model are added. Then the simulation is performed according to the instance of the model, including the necessary input and output allocation and workflow definition. Finally, the simulation is performed according to the input and parameters. In addition, in order to support SOA technology, each model can be published as a service.
[0115] In the present invention, the structures of simple models, conceptual integrated models and model instances are different. Simple models only rely on Python or POJO code files that implement the model. Conceptual integrated models rely on multiple sub-models, control flows, connectors, links and relationships between models. The dependency relationships are shown in the attached figure. Figure 4As shown, the dashed ellipse indicates that it is not an explicit entity and will be replaced by its child nodes in practice.
[0116] Simulation model definition and integration mainly includes three parts, namely simple model definition, integrated conceptual model and integrated model instance. Simple model and integrated model are unified into the same view, and they have the same file name format and file structure. Based on simple model and integrated model, the instance of integrated model is defined in a separate file. The dependencies of these files are as follows Figure 5 shown.
[0117] The data flow glues all sub-models together and transfers necessary information between all sub-models, so as to model more complex phenomena and processes. The data flow consists of two parts: connectors and links. Figure 6 Medium mod 1 and mod 2 There is a data flow between 1 and l 2 It consists of two links and a connector c. The connector and link are introduced below:
[0118] (1) Connector
[0119] A connector is an intermediate processing unit of a data stream. Figure 6 c in . It is used to eliminate the barriers caused by different dimensions, scales and even semantics of data between different sub-models during the integration process. It is similar to the simple model in terms of function and implementation, but simpler and has a certain degree of versatility, so there are two ways to implement the connector. When the connector is more complex, it can be implemented as a simple Python or POJO file similar to the implementation of the simple model, and then the connector can be imported through Python or POJO code using a reusable domain-specific language;
[0120] For simple connectors, such as those that only complete simple data distribution or simple calculations, the basic main arithmetic, mathematical numerical operations and set operations built into the integrated modeling environment are used, declared in the integrated model in the form of expressions, and converted into specific implementations by the runtime environment.
[0121] (2) Link
[0122] A link is a channel for transferring data between a model and a connector. Each link has a source and a target. The source is the output variable of a model or connector, while the target is the input variable of a model or connector. There are two types of links, which we call forward links and backward links, depending on the direction of data flow. During the model operation cycle, if there is a link between a model and a connector, it is called a forward link. Figure 6 l 1 and l 2 .
[0123] like Figure 7 If there are one or more direct or indirect links from model m 1 To model m 2 , such as l', or when a link transfers model m 2 The output data of the last cycle is input to the model m 1 The next cycle is taken as input, such as l 1 , then the link is a backward link (backward), such as Figure 7 l' and l in 1 As can be seen above, reverse linking can only occur between models and connectors.
[0124] (3) Characteristics of connector-related links
[0125] Most connectors handle value-to-value data transfer between models, such as connectors responsible for physical unit conversion of variables. In these connectors, values are received once and then sent out after processing. Therefore, for each input and output, the connector only needs a variable of a simple data type, as shown in the first row of Table 1.
[0126] At the same time, there are many connectors for processing operations on data sets, such as summing, averaging, or equal partitioning. In these connectors, the runtime system will provide composite data type variables for each input or output, as shown in the second row of Table 1.
[0127] Table 1 Characteristics of connector-associated links
[0128]
[0129]
[0130] The value-collection and collection-value links in the second row of Table 1 are used to transfer values to and from the elements of a collection at the input and output of the connector, respectively. On the connector side, the number of elements and data types of the collection are dynamically determined based on the number of functions and links.
[0131] The third row of Table 1 is related to connectors and iteration control. In the connector, the input and output connected to the iteration are responsible for connecting and collecting or distributing data for the iteration control, so that each iteration will produce or require a value, thereby generating a sequence of values.
[0132] In integrated modeling, typical control flows include sequence, parallelism, selection, and iteration. These controls work together with data flows (including connectors and links) to enable integrated models to complete more complex tasks. Since sequence control is implied by data flow, only parallelism, selection, and iteration operations are introduced below.
[0133] (1) Parallel control
[0134] Parallel control means that two or more models can be executed in parallel in the same operation cycle. There is no data flow dependency between the models of parallel control. However, if one of the models fails, the control-based integrated model will also fail. The structure of parallel control and the corresponding integrated model are shown in the attached figure. Figure 8 As shown, the model ex8_mod is obtained by integrating the sub-models mod1 and mod2 through parallel control. The parameters, inputs, outputs and functions of the model ex8_mod are obtained by the integration algorithm of the parallel control according to the integration method described in the following paragraph based on the corresponding characteristics of mod1 and mod2. Parallel control is usually used to integrate multiple parallelizable models to simplify the integration.
[0135] Assume two models m 1 = <P 1 , I 1 , O 1 , F 1 , A 1 > and m 2 = <P 2 , I 2 , O 2 , F 2 , A 2 >, A 1 = 1 ,s 10 , T 1 >, and A 2 = 2 ,s 20 , T 2 >.
[0136] Let m = m 1 ↑m 2 , and m=<P,I,O,F,A> , where ↑ represents parallel control.
[0137] Then P=P 1 ∪P 2 , I=I 1 ∪I 2 , and O=O 1 ∪ O 2 ,in ∪ The outputs of different modeling and simulation are distinguishable. The integration of functions is F = F 1 ⊙F 2 , where ⊙ represents F={f=(f 1 ↑f 2 )|f 1 ∈F 1 , f 2 ∈F 2}, and f=f 1 ↑f 2 represents f 1 and f 2 All are executed successfully. The initial state of the integrated modeling simulation is 0 = 10 ,s 20 >,s 10 and 20 They are m 1 and m 2 The initial state.
[0138] S={s 0}∪(S 1 \{s 10}×S 2 \{s 20}), where S\{s}=(S-{s}). The transfer function T is defined as:
[0139] T=T 1 ×T 2 -s 10 -s 20 · (1)
[0140] Among them, T 1 ×T 2 ={(s 1i s 2l ,s 1j s 2m )|(s 1i ,s 1j )∈T 1 ,(s 2l ,s 2m )∈T 2 ,i,j,l,m≥0},s10·={(s 10 s 2l ,s 1j s 2m )∈T 1 ×T 2 |, j>0, l, m≥0}, and s20 ·={(s 1i s 20 ,s 1j s 2m )∈T 1 ×T 2 |, i>0, l, m≥0}.
[0141] If s i =(s 1j ,s 2k ), P ei =P e1j ∪P e2k , I ei =I e1j ∪I e2k , O ei =O e1j ∪O e2k , i≠0, f e =(f e1 ↑f e2 ). The parallel operation is shown in the attached figure. Fig. 9 .
[0142] (2) Select Control
[0143] Selection controls are used to select one of a set of models to execute during simulation based on specific conditions. Selection controls allow you to select different models, or choose whether a model will work based on different scenarios. For example, Fig.10 Shows model mods by submodel mods 1 and mod 2 By selecting the control for integration, if the discriminator g satisfies, the model mod 1 Works, otherwise mod 2 Work.
[0144] Assume m 1 = <P 1 , I 1 , O 1 , F 1 , A 1 >,m 2 = <P 2 , I 2 , O 2 , F 2 , A 2 >, A 1 = 1 ,s 10 , T 1 >, and A 2 = 2 ,s 20 , T 2 >. If m=<P,I,O,F,A> , m=m 1 ◇m 2 , which means that when judging g 1 When satisfied, m 1 Executed, g 2 and m 2 Similarly, where ◇ represents the selection control. The parameters, inputs, and outputs of the expression are P g , I g , and O g Then P=P 1 ∪P 2 ∪P g1 ∪P g2 , I=I 1 ∪I 2 ∪I g1 ∪I g2 , O=O 1 ∪ O 2 ∪ O g1 ∪ O g2 , F = {g 1 , g 2}×F 1 ∪{g 1 , g 2}×F 2 .
[0145] For a finite state machine, S = {s 10}×S 2 ∪S 1 ×{s 20},s 0 ={s 10 ,s 20}, T = ∪ k i=0 (T 1 ×T 2i0 )∪(∪ k i=0 (T 1i0 ×T 2 )). If s i =(s 1j ,s 20 ), P e =P e1j ∪P g1 ∪P g2 , I e =I e1j ∪I g1 ∪I g2 , O e =O e1j ∪O g1 ∪Og2 , f e =(f g1 , f g2 )&f e1j If i =(s 10 ,s 2j ), then P e =P e2j ∪P g1 ∪P g2 , I e =I e2j ∪I g1 ∪I g2 , O e =O e2j ∪ O g1 ∪ O g2 , f e =(g 1 , g 2 )&f e2j .
[0146] Obviously, m=m 1 ◇m 2 =m 2 ◇m 1 and m=m 1 ◇m 2 ◇m 3 =(m 1 ◇m 2 )◇m 3 =m 1 ◇(m 2 ◇m 3 ). Select the control Fig.11 shown.
[0147] (3) Iteration Control
[0148] To facilitate integration, the simulation is defined as executed in steps (cycles). A modeling simulation generally executes multiple steps, which are similar with only slight differences. Sometimes the multi-step execution of a modeling simulation corresponds to the one-step execution of other modeling simulations. In this case, the multi-step execution of the modeling simulation requires iterative operations.
[0149] A typical scenario is that when ensembling models with different time steps, the model with fewer time steps should be iterated multiple times, while the other models are executed only once. Fig.12 It shows that mod1 is integrated into model mod under iterative control, and mod1 always works when the discriminator g satisfies.
[0150] Assume m 1 = <P 1 ,I1 ,O 1 ,F 1 ,A 1 > and A 1 = 1 ,s 10 ,T 1 >. If m=<P,I,O,F,A> , m = μm 1 , where μ represents the number of model iterations. g is the judgment expression, then P = P g ∪P 1 ,I=I g ∪I 1 ,O=O g ∪ O 1 and F = {g} × F 1 ∪{g}×{f ε}.
[0151] Finite state machine A for modeling simulation <S,s 0 ,T>, we define s 0 =s 10 For ease of management, three iteration states are defined, the initial s f ∈S f ,s f = {P ef ,I ef ,O ef ,f ef}, iterate and run S it , and end e , so S = {s 0 ,s e}∪S f ∪S it , the corresponding transfer is T f ,T it , and T e If (s 10 ,s 1i )∈T f Then (s 10 ,s 1i )∈T 1 .Orders 1i = <P e1i ,I e1i ,O e1i ,f e1i >, then P ef =P e1i ∪P g ,I ef =I e1i ∪I g ,O ef =O e1i ∪ O g , and f ef =g×f e1i For each (s 1i ,s 1j )∈T 1 ,i≠0,there are(s 1i ,s 1j )∈T it . Let s it = <P eit ,I eit ,O eit ,f eit >, then P eit =P e1j ∪P g ,I eit =I e1j ∪I g ,O eit =O e1j ∪ O g , and f eit =g×f e1j For the end state of the iteration, let s e = <P ee ,I ee ,O ee ,f ee >, then P ee =P g ,I ee =I g ,O ee =O g , and f ee = g, Te = {(s i ,s e )|s i ∈S f ∪S it}. Iteration operations such as Fig.13 .
[0152] 3. Integration Model Scalability
[0153] The scalability of traditional integration models is limited by the tight coupling between integration modeling and application scenarios. Specifically, integration models usually consist of a fixed number of model instances in a specific domain; therefore, data flows and control flows are also statically bound to model instances; these models are called statically structured models. Obviously, statically structured models are difficult to extend to new application domains and new scenarios. Similarly, the reusability of the model is also limited.
[0154] In order to improve the scalability and even reusability of the model, the present invention separates the conceptual integration modeling from the specific application. The model integrator only builds the conceptual model, or the model of the model, which only contains the integrated sub-models and the relationship between them, instead of directly building the model instances and the empty data flow relationship between the instances from the beginning. It is not until the end user wants to use the model for simulation that they instantiate the sub-models and their relationships. Specifically:
[0155] 1. Definition of relationships between models
[0156] According to the number of interacting models, the present invention defines four types of relationships between models, which ultimately correspond to at least two links and one connector. The above four types of relationships are one-to-one (o2o, one to one), one-to-many (o2m, one to more), many-to-one (m2o, more to one) and many-to-many (m2m, more to more).
[0157] Among them, the o2o relationship indicates that the output of one model instance is passed to another model instance. This is the default relationship between models, so usually the o2o relationship does not need to be explicitly declared;
[0158] An o2m relationship indicates that the output of one model instance is passed to at least one instance of another model;
[0159] The m2o relationship indicates that the output of at least one model instance is passed to an instance of another model;
[0160] The m2m relationship is relatively complex and needs to be specifically defined according to actual application requirements during instantiation.
[0161] 2. Instantiation of the integrated model
[0162] In the conceptual integration model, the integrated sub-models, connectors, links and relationships between models will be declared. In the instantiation model, the number of instances of all sub-models will be determined according to the actual application scenario, and the data flows (connectors, links) between sub-model instances will also be instantiated.
[0163] For example, for two sub-models that satisfy the o2o relationship, their instantiation models may be as follows Fig.14 Results shown.
[0164] The corresponding instantiation models are defined in the model integration domain specific language as follows:
[0165] When there is only one model instance:
[0166]
[0167] Case with a batch of model instances:
[0168]
[0169] In the latter case, the integration platform will automatically create the i-th connector instance to link the i-th model instances inst_mod1[i] and inst_mod2[i].
[0170] The relationship between o2m, m2o, and m2m is relatively complex, and connectors also work in many different forms. Fig.15 Shows an instantiation of an o2m relationship.
[0171] The corresponding instantiation models are defined in the model integration domain specific language as follows:
[0172]
[0173]
[0174] Sometimes you need to create new connectors for different target model instances, such as Fig.15 (d) In this case, the old connectors and links will be overwritten.
[0175] The instantiation process of m2o relationship is similar to that of o2m relationship, such as Fig.16 shown.
[0176] m2m relationships lack a common pattern, so relationships between models need to be declared separately. During instantiation, links and connectors related to these relationships should be added. In addition, relationships between model instances of the same type also belong to one of the relationship types mentioned above, so their declaration and instantiation are the same as those of different model instances.
[0177] 3. Integrated modeling and simulation
[0178] Integrated modeling and simulation is the process of integrating modeling and simulation software modules. All the above operations can be regarded as modeling and simulation, and modeling and simulation can be regarded as nodes, and the associations between modeling and simulation can be regarded as edges. In this way, the integration of modeling and simulation is actually a graph structure. On the other hand, in order to make the integration reusable, the integrated modeling and simulation should also follow the unified view defined above. Therefore, for Fig.17 (a), we have Fig.17 The unified view representation of (b) is completed through the corresponding underlying operations of Algorithm 1 as follows.
[0179] Algorithm 1 Integrated algorithm for complex modeling and simulation
[0180]
[0181]
[0182]
[0183] 4. Integrated Modeling and Simulation Domain-Specific Language
[0184] The domain-specific language for integrated modeling and simulation is an important tool for model integrators to integrate models. The present invention also provides a lightweight domain-specific language for defining and describing integrated models.
[0185] (1) Simple model implementation
[0186] The implementation of simple models does not belong to the work of special languages in the field of integrated modeling and simulation, but because there is a calling relationship between the two, the present invention has no special requirements for the implementation form of simple models, and can be implemented as software modules, components and services. For example, Python or Java POJO can be used for implementation, because Python's decorator (Decorator) and Java's annotation (Annotation) can facilitate the use of slice-oriented programming methods (Aspect-Oriented Programming, AOP) during simulation to achieve input, output, parameter and model function execution control. For existing models, it is necessary to use the host language for encapsulation.
[0187] (2) Model definition
[0188] In integrated modeling, we first need to define the implementation of a simple model as a unified view of the model. The method for defining a simple model implemented by a POJO is as follows:
[0189]
[0190] As defined in the unified view, each model has a name, such as ex1_bas_mod. The body of the definition imports the POJO that implements the model. Obviously, there is a big difference between the construction of a simple model and the implementation of the model, which greatly frees up the implementation of the model. The basic elements of the model can be automatically extracted from the annotations in the POJO.
[0191] The integrated model is defined based on other sub-models. The specific definition can be as follows:
[0192]
[0193] The ex2_comp_mod model imports two sub-models, mod1 and mod2, whose basic elements should be automatically obtained by the DSL support integration system through the model integration algorithm according to the corresponding control.
[0194] (3) Data flow definition
[0195] The definition of a data flow includes the definition of connectors and the definition of links.
[0196] As described in Section 5, there are two ways to implement connectors in this method. For connectors with complex functions, they are implemented as simple Python or POJO files; then the connector is declared by importing the implementation file.
[0197]
[0198] For connectors with simple functions, they are explicitly defined using expressions during definition, and converted into specific implementations by the runtime environment during execution.
[0199]
[0200] The parameters, inputs, and outputs of connectors are explicitly declared in the integration model and are dynamically typed. Expressions are used to calculate outputs with specific inputs and parameters, and the syntax is similar to arithmetic expressions in Python or Java.
[0201] Links include forward and backward. The structure of links can be defined as follows:
[0202]
[0203]
[0204] (4) Control flow definition
[0205] Control flow definition mainly includes parallel control, selection control and iteration control. Parallel control is described by the following code:
[0206] This method provides two types of selection control structures. The first is the typical if...else if...else... structure:
[0207]
[0208] The second is the multi-instance enumeration method:
[0209]
[0210] This method supports different iteration control structures such as while, for, until and foreach, for example:
[0211]
[0212] (5) Model relationship definition
[0213] Model relationship definition is used to define the concept integration model to facilitate the further expansion of the model. Relationships include one-to-one, one-to-many, many-to-one and many-to-many, as defined below:
[0214] relation o2o(mod1,mod2); / / the relation of mod1 and mod2 is one-to-one relation;
[0215] relation o2m(mod3,mod4); / / one-to-more relation;
[0216] relation m2o(mod5,mod6); / / more-to-one relation;
[0217] relation m2m(mod7,mod8); / / more-to-more relation.
[0218] Example
[0219] The invention of the present invention integrates WOFOST (crop growth model), HYDRUS-1D (unsaturated zone hydrological model) and MODFLOW (groundwater model) to simulate the interaction process between crop growth, unsaturated zone moisture and groundwater, so as to study the mutual influence of groundwater and crops.
[0220] The growth of crops will be affected by the water near the root system. The water in the shallow layer of the ground is also affected by vegetation and groundwater, and the water level of groundwater interacts with the water content in the shallow layer of the ground. WOFOST is a crop growth model, which is generally used to simulate the growth process of crops such as wheat and corn; HYDRUS-1D is an unsaturated zone hydrological model, which is used to simulate the shallow hydrological activities below the surface; MODFLOW is a groundwater model, which is used to simulate groundwater activities. The three models are all existing models, but they are all encapsulated into independent applications. In actual simulation applications, the programs corresponding to the three models can only run independently, and the influence from other models can only be set to fixed values based on experience. This is obviously difficult to reflect the dynamic interaction between the simulated parts, and also brings large errors to the related simulations. Using this method, by reconstructing the three models and integrating them, with one day as the simulation step, the three models can simulate the mutual influence in units of one day, thereby improving the simulation accuracy and simulation capabilities.
[0221] Firstly, the highly scalable integrated modeling method is used to modify the existing modeling programs WOFOST, HYDRUS-1D and MODFLOW, encapsulate them with POJO, and define them as simple models using this method. The corresponding model files are “path_WO”, “path_HY” and “path_MO” respectively.
[0222] Secondly, integration is carried out and the integrated conceptual model ex16_WOHYMO is defined. First, the sub-models to be used are enumerated, namely WOFOST, HYDRUS-1D and MODFLOW, and the model files are specified respectively, namely "path_WO", "path_HY" and "path_MO"; then the control flow and data flow are defined, and the relationship between models is defined; among them, there is a one-to-one relationship between WOFOST and HYDRUS-1D, while there is a many-to-one relationship between HYDRUS-1D and MODFLOW.
[0223] Secondly, the integrated model is instantiated to obtain the instantiated model for the specific task. In order to compare the model performance of different surface area divisions, two instantiation schemes were implemented, namely, the surface crop growth module was divided into 2 and 5 areas respectively, so that there were 2 WOFOST and HYDRUS_1D sub-model instances and 5 WOFOST and HYDRUS_1D sub-model instances respectively, while the MODFLOW model had only one; the data flow and connection relationship were also instantiated accordingly. Thus, two instantiated models were obtained, which can be simulated separately. If the type of surface crops changes, it can be conveniently modified based on the conceptual integrated model without the need to reconstruct the existing instantiated model. The conceptual model is defined as:
[0224]
[0225]
[0226] To compare the model performance for different surface area divisions, the following examples provide instantiation results of two conceptual models, which are divided into 2 and 5 areas respectively, defined as follows:
[0227]
[0228]
[0229] The above shows and describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A highly scalable integrated modeling and simulation method, characterized in that: The following steps are involved: Step 1: construct different sub-models according to user input, wherein the sub-models are simple models or integrated models; Step 2: For simple models, define simple models that conform to the unified view of the model; for integrated models, build their conceptual models; Step 3: Define the instantiation model of the conceptual model described in step 2; Step 4: Run the integrated instantiation model: first prepare the data according to the execution step defined in the conceptual model, define the data input and output modules according to the simple model definition method in step 2, establish the connection and control with the instantiation model in step 3, run the instantiation model, and finally realize the simulation process; The specific operation steps of step 2 include: Step 21: for a simple model, implement the simple model through Python or POJO code, and define a simple model that conforms to the unified view of the model by using a reusable integrated modeling domain specific language based on the Python or POJO code; Step 22: For the integrated model, first enumerate the sub-models used by it, then define the control flow, and specify the data flow, connection and relationship between the sub-models, and finally conceptualize the sub-models to construct a conceptual model of the integrated model; The specific steps of step 3 include: Step 31: define the single sub-model enumerated in the conceptual model established in step 22 as a sub-model instance; Step 32: specifying the number of models in the same sub-model group according to simulation requirements, and instantiating the connections between the sub-models, thereby constructing an instantiated model of the conceptual model; The unified model view in step 2 includes a static unified model view based on declarations and a dynamic unified model view used for control at runtime, and the definitions of the two are: 1) Static unified view of the model M staic :=<N,P,I,O,F> Among them, N is the model name, P is the parameter list, I is the input variable list, O is the output variable list, and F is the function; 2) Dynamic unified view of the model M dymamic :=<N,P,I,O,F,A> Among them, N is the name of the model instance being executed, P is the parameter list, I is the input variable list, O is the output variable list, F is the function, and A is the finite state machine of the model.
2. A highly scalable integrated modeling and simulation method as claimed in claim 1, characterized in that: In the integrated model described in step 22, there are finite state machines between the model and its enumerated sub-models to form a hierarchical finite state machine. The dynamic control of the simulation of the integrated model is realized based on the hierarchical finite state machine. The specific operation steps include: Step 221: setting the current instantiation model to an initial state, i.e., state S0; Step 222: traverse the sub-models of the current instantiation model according to the connection relationship with a breadth-first strategy, and set all sub-models to an initial state; Step 223: If the sub-model is also an instantiated integrated model, then continue to execute step 222 for the integrated model until there is no more instantiated integrated model; Step 224: If the data arrives, enter the corresponding execution state according to the specific model settings, and dynamically determine the execution state of sub-models at different levels according to the sub-model execution results; Step 225: If the data ends, set the execution of the current instantiated model to end, and set the execution of all hierarchical sub-models to end in the same manner as steps 222 and 223.
3. A highly scalable integrated modeling and simulation method as claimed in claim 1, characterized in that: The data flow described in step 22 includes connectors and links. The connector is an intermediate processing unit of the data flow, which is used to eliminate the obstacles caused by the different dimensions, scales and even semantics of data between different sub-models during the integration process; the link is a channel for transmitting data between models and connectors. Each link has a source and a target. The source is the output variable of the model or connector, and the target is the input variable of the model or connector.
4. A highly scalable integrated modeling and simulation method as claimed in claim 1, characterized in that: The control flow described in step 22 includes sequential control, parallel control, selection control and iterative control. The control flow and the data flow work together to enable the integrated model to complete complex tasks. The sequence control is implied by the data flow and is executed sequentially; The parallel control means that two or more models can be executed in parallel in the same operation cycle, and there is no data flow dependency between the multiple models in parallel control; The selection control is used to select one of a group of models to execute according to specific conditions during the simulation process. The selection control allows different models to be selected, or a model can be selected according to different scenarios to see whether it can work; The iteration control is used to correspond the multi-step execution of modeling simulation to the one-step of other modeling simulation, that is, when integrating models with different time steps, the model with fewer time steps should be iterated multiple times, while other models are executed only once.
5. A highly scalable integrated modeling and simulation method as claimed in claim 1, characterized in that: The relationships between the models include one-to-one, one-to-many, many-to-one and many-to-many, where: A one-to-one relationship means that the output of one model instance is passed to another model instance. This is the default relationship between models, so usually the o2o relationship does not need to be explicitly declared; A one-to-many relationship means that the output of one model instance is passed to at least one instance of another model; A many-to-one relationship means that the output of at least one model instance is passed to an instance of another model; Many-to-many relationships need to be specifically defined when instantiating them according to actual application requirements.
