Model development framework, method and device for parallel discrete event simulation scheduling
Through the model development framework for parallel discrete event simulation scheduling, it solves the problems of low efficiency and difficult maintenance in the development of simulation engine models, realizes dynamic loading of models and event scheduling, and improves development efficiency and reusability.
Patent Information
- Application Number
- CN202410904572.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-08
AI Technical Summary
The existing simulation engine model development has problems such as low function development efficiency, difficulty in code maintenance, and cumbersome debugging process, which results in limited system use.
Design a model development framework for parallel discrete event simulation scheduling, including model method and structure definition module, model library information registration function module, model local data management module, model request simulation business interface function module and exception information maintenance and processing function module. Realize dynamic loading of models, event scheduling and data access through unified constraints and specifications.
It improves model development efficiency, increases code reusability and debugging efficiency, reduces code maintenance costs, and realizes secondary development and debugging support for model library business functions.
Smart Images

Figure CN118444905B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of implementing simulation processes by simulation engines, and in particular to a model development framework, method and device for parallel discrete event simulation scheduling. Background Art
[0002] In simulation business, each simulation model unit is generally developed independently in the early stage, and then a unified integrated joint debugging test is carried out after the development is completed; when the simulation is initialized, the model needs to be registered so that the engine can recognize different models, and different model entities need to be initialized separately; during the simulation operation, each model entity itself and between entities need to frequently perform event planning, interactive sending, attribute update, attribute access and other operations; this has resulted in a large number of problems such as single interaction function between models and engines, difficult interface unification, poor scalability, low code reuse rate, complex simulation process, high integration and joint debugging communication cost, and low simulation operation efficiency, resulting in various restrictions on the use of the entire system.
[0003] In summary, the current problems in the development of various simulation engine models include: 1) In the development process of model-related functions, the lack of unified specifications and constraints leads to low development efficiency of model-related functions; 2) Secondary development of model library business functions requires manual modification and adjustment of codes, which increases the difficulty and cost of code maintenance; 3) The model debugging process is cumbersome and there is no suitable debugging method.
[0004] Therefore, higher requirements are put forward for designing a reasonable model development framework for parallel discrete event simulation scheduling. Summary of the invention
[0005] Based on this, it is necessary to provide a model development framework, method and device for parallel discrete event simulation scheduling to address the above technical issues.
[0006] A model development framework for parallel discrete event simulation scheduling, the framework includes:
[0007] The model method and structure definition module is used to uniformly define the model base class, model inherent properties, and model inherent methods.
[0008] The model library information registration function module is used to implement the model library export function. When the engine loads the model library, the export function is called to generate an object pointer, and the model registration function is called according to the object pointer.
[0009] The model local data management module is used to locally save the information after the model entity attribute assignment operation, and finally submit it to the engine blackboard.
[0010] The model request simulation business interface function module is used to query and update object data, plan events and interactions, query simulation time, control simulation acceleration ratio, service requests, and dynamically create and delete entities during the simulation process based on the inherent properties of the model.
[0011] The exception information maintenance and processing function module is used to capture exception information during the simulation process, analyze and locate the location where the exception information occurs, and throw out error information.
[0012] In one embodiment, the model intrinsic attributes include model class name, entity identifier, engine identifier, and entity status.
[0013] Model-intrinsic methods include model entity initialization and model entity data recovery.
[0014] The model method and structure definition module is also used for secondary development of the model based on the model base class. When the secondary development model is developed, the model base class is inherited to implement pure virtual methods not defined in the model base class, and new properties and methods are added according to preset needs.
[0015] In one of the embodiments, the model library information registration function module is also used to create a model library registration information function class, declare corresponding properties and methods in the model library registration information function class, create a model library export function in the model, and call the model library export function to generate an object pointer when the engine loads the model library. According to the object pointer, the registered model creation function, the registered model destruction function, the registered interaction event processing function, the registered planning event processing function or the registered interest subscription function are called to complete the creation and destruction of the model entity. At the same time, according to the model event type, the corresponding registered planning event or interaction event is added to the corresponding container, and the interest subscription is added. The callback information after the registration is completed can be used in the subsequent process.
[0016] In one of the embodiments, a model creation function is registered to call a constructor of a model to create a model entity.
[0017] Register the model destruction function, which is used to call the model's destructor to destroy the model entity.
[0018] Register the interaction event processing function, which is used when the subscribed interaction type sends an interaction, and the engine will call back the interaction processing function.
[0019] Register a planned event processing function to plan the model's own events. When the event execution time arrives, call back the registered function for execution.
[0020] Register interest subscription function, which is used by simulation entities to subscribe and query data according to their own needs.
[0021] In one of the embodiments, the model local data management module is also used to synchronously create a blackboard object when the engine creates a model entity, and assign the base address of the object to the member of the local attribute copy of the model entity. After the engine creates the model entity, it calls back the InitModel interface to initialize the model entity and completes the assignment of initial values to the object attributes of each model entity. The assignment is performed through the local object subscript operation. The location where the blackboard attributes are stored can be located through the local object. After the assignment is completed, it will be saved in the local object first, and the information will be submitted to the engine blackboard in a unified manner when the update is finally submitted.
[0022] In one of the embodiments, the model request simulation business interface function module is also used to create the interface required by the model request simulation engine. When the engine creates a model entity, it simultaneously creates a callback interface class instance and assigns the instance object pointer to the member callback pointer of the entity; the interface function is called according to the callback pointer, and then according to the interface function called by the model, the engine calls and executes the corresponding method to complete the corresponding function and promote the simulation operation.
[0023] In one embodiment, the interface function includes:
[0024] Model object data update function, used to submit the information of entity attributes submitted to the local attribute copy to the engine blackboard.
[0025] The object data query function is used to query object information and find out whether the object information exists on the engine blackboard.
[0026] The sending planning event function is used to add the planning event to the event queue. When the engine advances the time to the corresponding event execution time, the corresponding registered planning function is called back and the planning event is executed.
[0027] Send interaction event function, which is used to add interaction events to the event queue. When the engine advances time to the time for the corresponding event to be executed, the corresponding registered interaction event function is called back and the interaction event is executed.
[0028] The simulation time query function is used to query the simulation time during the simulation process.
[0029] The simulation acceleration ratio control function is used to set the corresponding simulation acceleration ratio according to different situations.
[0030] The request service function is used to request the corresponding extended simulation service during the execution of the model, return the calculation results, and promote the model simulation operation; the model call engine service interface includes: synchronous request extended simulation service interface and asynchronous request extended simulation service interface.
[0031] Dynamically create entity functions, used to create model entities based on a set of input entity IDs, or to create model entities based on an input entity ID as a prefix.
[0032] Dynamically delete entity function, used to delete model entity according to the input model entity ID.
[0033] In one of the embodiments, the exception information maintenance and processing function module is also used to define exception classes, standardize error information, and feedback corresponding declared error details in the form of log records based on errors occurring during program execution; it is also used to capture exception error information, capture exceptions thrown during program execution, and record and display the exception information in the form of logs.
[0034] A model development method for parallel discrete event simulation scheduling is applicable to model development using the above-mentioned model development framework for parallel discrete event simulation scheduling; the method comprises:
[0035] The model business function development is implemented by inheriting the model base class, and then the inherent properties and inherent methods of the model base class are standardized. At the same time, new properties are added in the development model according to the characteristics of the development model.
[0036] Implement the model library export function. When the engine loads the model library, it calls the export function to generate an object pointer, and calls the corresponding model registration function according to the object pointer. By registering the corresponding function, when the event execution time comes, the engine calls back the corresponding event function to execute the event.
[0037] When the engine creates a model entity, it also creates an engine blackboard and initializes the model entity. The initialized model entity attributes are first saved in the local object, and the information is uniformly submitted to the engine blackboard when the update is finally submitted.
[0038] According to the inheritance and implementation of the interface required by the model request simulation engine, the engine creates a callback interface class instance synchronously when creating the model entity, and assigns the instance object pointer to the member callback pointer of the entity, and accesses the simulation business through the callback pointer.
[0039] Declare exception information, capture and process exception information that occurs during operation.
[0040] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned model development method for parallel discrete event simulation scheduling when executing the computer program.
[0041] The above-mentioned model development framework, method and equipment for parallel discrete event simulation scheduling, the framework includes a model method and structure definition module, a model library information registration function module, a model local data management module, a model request simulation business interface function module and an exception information maintenance and processing function module. Through the constraints and specifications of the model method and inherent data structure, the model registration interaction and event callback method, and the model calling the engine to the simulation business request, the engine can more conveniently and efficiently realize the functions of dynamic loading of the model, dynamic creation of the model, event scheduling of the model, and access to the model entity data in the simulation process, as well as the supporting auxiliary functions of the secondary development and debugging of the model library business function, thereby greatly increasing the model development efficiency and improving the reusability. Compared with the existing technology, the present application has the following benefits: through unified constraints and specifications, the engine can more conveniently and efficiently realize the development of model-related functions; when the model is updated and optimized, the corresponding interface is realized by inheriting the base class, and the corresponding development is completed, which improves the reusability of the code and reduces the difficulty and cost of code maintenance; improves the efficiency of model debugging, and through a perfect debugging method, more intuitively understands the parameters and states in the model debugging process. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A schematic diagram of a model development framework for parallel discrete event simulation scheduling in one embodiment;
[0043] Figure 2 A schematic diagram of the workflow of a model method and a structure definition module in one embodiment;
[0044] Figure 3 A schematic diagram of the workflow of a model library information registration function module in one embodiment;
[0045] Figure 4 A schematic diagram of the workflow of a model local data management module in another embodiment;
[0046] Figure 5 A schematic diagram of a workflow of a model request simulation business interface function module in another embodiment;
[0047] Figure 6 A schematic diagram of the workflow of an abnormal information maintenance and processing functional module in one embodiment;
[0048] Figure 7 A schematic flow chart of a model development method for parallel discrete event simulation scheduling in one embodiment;
[0049] Figure 8 A schematic diagram of the internal structure of a computing device in one embodiment. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0051] The model development framework for parallel discrete event simulation scheduling proposed in this application aims to achieve standardization of model development process, unified management of model registration and initialization, and convenient model requests for simulation business-related interfaces. In this way, the model development efficiency can be improved when there are many types of models, complex model structure and functions, and large system scale, and the portability of integrated joint debugging can be improved, so that the simulation engine can more conveniently and efficiently realize the functions of dynamic model loading, dynamic model creation, model event scheduling, and model entity data access during the simulation process, as well as support and auxiliary functions for secondary development and debugging of model library business functions, and complete interactive transmission and reception and attribute access between models; at the same time, the model development efficiency is greatly increased and the reusability of the model is improved.
[0052] In one embodiment, Figure 1 As shown, a model development framework for parallel discrete event simulation scheduling is provided, which includes:
[0053] The model method and structure definition module 1 is used to uniformly define the model base class, model inherent properties and model inherent methods.
[0054] Specifically, the model method and structure definition module 1 unifies the definition of the inherent attributes and inherent methods of the model. When the model library creates a model for the second time, the model inherits the model base class and implements the inherent attributes and inherent methods of the model. The inherent attributes include: model class name, model entity identifier, model engine identifier, model entity state, etc.; the inherent methods include: model entity initialization method, model entity data recovery method; at the same time, new attributes and methods are extended according to the specific characteristics of the entity model.
[0055] The model library information registration function module 2 is used to implement the model library export function. When the engine loads the model library, the export function is called to generate an object pointer, and the model registration function is called according to the object pointer.
[0056] Specifically, the model library information registration function module 2 implements the model library export function. When the engine loads the model library, it will call the export function RegisterModel to generate a ModelReg object pointer, and use the object pointer to call the registration model creation function, registration model destruction function, registration interaction event processing function, registration planning event processing function, and registration interest subscription function. The registration model creation function is used to call the model constructor to create a model entity; the registration model destruction function is used to call the model destructor to destroy the model entity; the registration interaction event processing function is used when the subscribed interaction type sends an interaction, and the engine will call back the interaction processing function; the registration planning event processing function is used to plan the model itself. When the event execution time arrives, the engine calls back the planning event function to execute the event. The function name for executing the planning event can be defined by the user, and there is no limit on the number and type of parameters passed in; the registration interest subscription function is used for the simulation entity to subscribe to and query data according to its own needs; by registering the corresponding function, the corresponding event is executed.
[0057] The model local data management module 3 is used to locally save the information after the model entity attribute assignment operation, and finally submit it to the engine blackboard.
[0058] Specifically, the model local data management module 3 saves the model entity information locally. When the engine creates a model entity, it simultaneously creates a blackboard object and assigns the base address of the object to the member of the local attribute copy of the entity. After the model entity is created, the InitModel interface will be called back to initialize the model entity and complete the initial value assignment of the object attributes of each model entity. The assignment is performed through the local object subscript operation. During the assignment operation, the value of the entity attribute initialization will first be submitted to the local attribute copy local object. The location where the blackboard attribute is stored can be located through the local object. After the assignment is completed, the entity attribute information will be uniformly submitted to the target location of the engine blackboard when the update is finally submitted.
[0059] The model request simulation business interface function module 4 is used to query and update object data, plan events and interactions, query simulation time, control simulation acceleration ratio, service requests, and dynamically create and delete entities during the simulation process based on the inherent properties of the model.
[0060] Specifically, the model request simulation business interface function module 4 is used for model request simulation business. Define the interface required by the model request simulation engine, which is used to callback the functions provided by the engine and standardize the development of the model request business; when the engine creates a model entity, it synchronously creates a callback interface class instance, and assigns the instance object pointer to the member callback pointer of the entity. The implementation class of the interface adds new attributes: engine ID, model class name, entity ID. When the model is created, the corresponding values are assigned to the newly added attributes, which can constrain the corresponding model entity to access data, thereby realizing the authority management of the model entity. According to the corresponding interface, the model can call the model object data update function, object data query function, send planning event function, send interaction event function, query simulation time function, control simulation acceleration ratio function, request service function, dynamic entity creation function, and dynamic entity deletion function through the pointer; according to the function called by the model, the engine calls and executes the corresponding method to complete the corresponding function and promote the simulation operation.
[0061] The abnormal information maintenance and processing function module 5 is used to capture abnormal information during the simulation process, analyze and locate the location where the abnormal information occurs, and throw out error information.
[0062] Specifically, the exception information maintenance and processing function module 5 realizes the collection, analysis and processing of exception information. Common existing error information is declared to provide clear error prompts, better understand and handle exceptions, collect relevant exception information when the program is running, analyze and identify the exception type, cause and scope of impact based on the received exception information, take corresponding processing measures after identifying the exception information, and feed back the collected information to relevant personnel in the form of logs to help track problems, debug and optimize.
[0063] Figure 1The logical associations among the five modules in the model development framework for parallel discrete event simulation scheduling are given: model method and structure definition module 1, model library information registration function module 2, model local data management module 3, model request simulation business interface function module 4, and exception information maintenance and processing function module 5. The model development framework for parallel discrete event simulation scheduling mainly revolves around these parts. Model method and structure definition module 1 improves the efficiency of model development, reduces duplicate code, and is more extensible; model library information registration function module 2 implements the model library export function, which will be called when the engine loads the model library; model local data management module 3 implements the initial value of model attributes when the model is initialized, which will first be saved in the local local object and uniformly submitted to the engine blackboard when the update is finally submitted, so that data access can be performed between models; model request simulation business interface function module 4 unifies the model request simulation business interface, making it more convenient to call and more flexible to use, and improving the overall maintainability; exception information maintenance and processing function module 5 declares common existing error messages, provides clear error prompts, better handles exceptions, and helps with problem tracking, debugging and optimization.
[0064] In the above-mentioned model development framework for parallel discrete event simulation scheduling, the framework includes a model method and structure definition module, a model library information registration function module, a model local data management module, a model request simulation business interface function module, and an exception information maintenance and processing function module. Through the constraints and specifications of the model method and inherent data structure, the model registration interaction and event callback method, and the model calling the engine to the simulation business request, the engine can more conveniently and efficiently realize the functions of model dynamic loading, model dynamic creation, model event scheduling, model entity data access in the simulation process, and realize the supporting auxiliary functions of secondary development and debugging of model library business functions, thereby greatly increasing the model development efficiency and improving reusability. Compared with the existing technology, the present application has the following benefits: through unified constraints and specifications, the engine can more conveniently and efficiently realize the development of model-related functions; when the model is updated and optimized, the corresponding interface is realized by inheriting the base class, the corresponding development is completed, the reusability of the code is improved, and the difficulty and cost of code maintenance are reduced; the model debugging efficiency is improved, and the parameters and states in the model debugging process are more intuitively understood through a perfect debugging method.
[0065] In one embodiment, the model intrinsic attributes include model class name, entity identifier, engine identifier, and entity status.
[0066] Model-intrinsic methods include model entity initialization and model entity data recovery.
[0067] The model method and structure definition module is also used for secondary development of the model based on the model base class. When secondary developing the model, the model base class is inherited to implement pure virtual methods not defined in the model base class, and new properties and methods are added according to preset needs.
[0068] like Figure 2 As shown, the workflow of the model method and structure definition module includes:
[0069] Step 201: Create a unified model base class.
[0070] Step 202: Implement unified management of the inherent attributes of the model. The inherent attributes have the characteristics of commonality, stability, and inheritance. The inherent attributes of the model include: model class name, model entity identifier, model engine identifier, model entity status, etc.
[0071] Step 203: realizing unified management of the inherent methods of the model. The inherent methods have the characteristics of commonality, stability and inheritance. The inherent methods of the model include: model entity initialization method and model entity data recovery method.
[0072] Step 204: The model secondary development inherits the model base class and implements the pure virtual methods not defined in the base class.
[0073] Step 205: When the model is secondary developed, it is necessary to inherit the model base class, add new properties and methods according to specific needs, and enrich the model features.
[0074] Step 206: Model creation is completed.
[0075] In one of the embodiments, the model library information registration function module is also used to create a model library registration information function class, declare corresponding properties and methods in the model library registration information function class, create a model library export function in the model, and call the model library export function to generate an object pointer when the engine loads the model library. According to the object pointer, the registered model creation function, the registered model destruction function, the registered interaction event processing function, the registered planning event processing function or the registered interest subscription function are called to complete the creation and destruction of the model entity. At the same time, according to the model event type, the corresponding registered planning event or interaction event is added to the corresponding container, and the interest subscription is added. The callback information after the registration is completed can be used in the subsequent process.
[0076] like Figure 3 As shown in the figure, the workflow of the model library information registration function module includes:
[0077] Step 301: Create a model library registration information function class.
[0078] Step 302: Declare corresponding properties and methods in the class.
[0079] Step 303: Create a RegisterModel(const std::string&className) model library export function in the model. The export function will be called when the engine loads the model library.
[0080] Step 304: Create a ModelReg object in the export function, and use the object to call the registration function in the model library registration function class.
[0081] Step 305: The object can be used to call the registered model creation function, which is used to call the model constructor to create a model entity.
[0082] Step 306: The object can be used to call the registered model destruction function, which is used to call the destructor of the model to destroy the model entity.
[0083] Step 307: The object can be used to call the registered interaction event processing function, which is used when the subscribed interaction type sends an interaction, and the engine will call back the interaction processing function.
[0084] Step 308: The object can be used to call the registered planning event processing function to plan the model's own events, and when the event execution time arrives, the registered function is called back for execution.
[0085] Step 309: The object can be used to call the registration interest subscription function, which is used for the simulation entity to subscribe to and query data according to its own needs.
[0086] Step 310: Return the ModelReg object after completing the corresponding registration.
[0087] Step 311: The model library registration function is created.
[0088] In one of the embodiments, a model creation function is registered to call a constructor of a model to create a model entity.
[0089] Register the model destruction function, which is used to call the model's destructor to destroy the model entity.
[0090] Register the interaction event processing function, which is used when the subscribed interaction type sends an interaction, and the engine will call back the interaction processing function.
[0091] Register a planned event processing function to plan the model's own events. When the event execution time arrives, call back the registered function for execution.
[0092] Register interest subscription function, which is used by simulation entities to subscribe and query data according to their own needs.
[0093] In one of the embodiments, the model local data management module is also used to synchronously create a blackboard object when the engine creates a model entity, and assign the base address of the object to the member of the local attribute copy of the model entity. After the engine creates the model entity, it calls back the InitModel interface to initialize the model entity and completes the assignment of initial values to the object attributes of each model entity. The assignment is performed through the local object subscript operation. The location where the blackboard attributes are stored can be located through the local object. After the assignment is completed, it will be saved in the local object first, and the information will be submitted to the engine blackboard in a unified manner when the update is finally submitted.
[0094] like Figure 4 As shown in the figure, the workflow of the model local data management module includes:
[0095] Step 401: The engine creates a model entity.
[0096] Step 402: When creating a model entity, a blackboard object is synchronously created, and the base address of the object is assigned to a member of the local attribute copy of the entity.
[0097] Step 403: After the model entity is created, the InitModel interface is called back to initialize the model entity.
[0098] Step 404: Model initialization assigns initial values to the object attributes of each model entity.
[0099] Step 405: The initialized value of the entity attribute is first submitted to the local attribute local copy, and the local location information and the target location information of the entity attribute information are located by calculation.
[0100] Step 406: After the local object completes the attribute assignment, the updateObjectInfo interface will be called when submitting the entity object information for update, and the entity attribute information will be uniformly submitted to the target location of the engine blackboard.
[0101] Step 407: Model entity initialization is completed.
[0102] In one of the embodiments, the model request simulation business interface function module is also used to create the interface required by the model request simulation engine. When the engine creates a model entity, it simultaneously creates a callback interface class instance and assigns the instance object pointer to the member callback pointer of the entity; the interface function is called according to the callback pointer, and then according to the interface function called by the model, the engine calls and executes the corresponding method to complete the corresponding function and promote the simulation operation.
[0103] like Figure 5 As shown, the workflow of the model request simulation business interface function module includes:
[0104] Step 501: Create an interface class for a model to request a simulation engine service.
[0105] Step 502.: Declare corresponding properties and methods in the interface class.
[0106] Step 503: Inherit the interface class, implement the pure virtual methods in the interface class, and add new attributes: m_modelName, m_InstanceID, m_engineID, etc., and implement the authority management of the model entity through these attributes.
[0107] Step 504: When creating a model entity, a callback interface class instance is synchronously created, and the instance object pointer is assigned to the member callback pointer m_pSvr of the entity.
[0108] Step 505: Call the interface function through the pointer m_pSvr.
[0109] Step 506: Call the model object data update function and the object data query function. The update function is used to update local data to the engine blackboard, and the query function can query object information.
[0110] Step 507: Call the dynamic entity creation function and the dynamic entity deletion function to dynamically create and delete entities.
[0111] Step 508: calling the send planning event function and the send interaction event function, so as to send the entity's own planning events and the interaction events between entities.
[0112] Step 509: calling the simulation time query function and the simulation acceleration ratio control function, so as to query the simulation time during the simulation process and control the acceleration ratio during the simulation process.
[0113] Step 510: calling the request service function, during the execution of the model, the model may request the corresponding extended simulation service.
[0114] Step 511: The model calls the corresponding interface, completes the corresponding function, returns the corresponding result, and advances the simulation progress.
[0115] Step 512: The model requests the simulation service to be completed.
[0116] In one embodiment, the interface function includes:
[0117] Model object data update function, used to submit the information of entity attributes submitted to the local attribute copy to the engine blackboard.
[0118] The object data query function is used to query object information and find out whether the object information exists on the engine blackboard. At the same time, object queries can be based on: model type name query. During the simulation process, users can query the corresponding entity information on the blackboard according to the entity type; entity ID query. During the simulation process, users can query the corresponding entity information on the blackboard according to the entity ID; custom query. During the simulation process, the user queries the interface to obtain the reflection object class set, and passes it to the filter function of the reflection object class set according to the custom lamda expression.
[0119] The sending planning event function is used to add the planning event to the event queue. When the engine advances the time to the corresponding event execution time, the corresponding registered planning function is called back and the planning event is executed.
[0120] Send interaction event function, which is used to add interaction events to the event queue. When the engine advances time to the time for the corresponding event to be executed, the corresponding registered interaction event function is called back and the interaction event is executed.
[0121] The simulation time query function is used to query the simulation time during the simulation process.
[0122] The simulation acceleration ratio control function is used to set the corresponding simulation acceleration ratio according to different situations.
[0123] The request service function is used to request the corresponding extended simulation service during the execution of the model, return the calculation results, and promote the model simulation operation; the model call engine service interface includes: synchronous request extended simulation service interface and asynchronous request extended simulation service interface.
[0124] Dynamically create entity function, used to create model entities based on the input entity ID set, or create model entities based on the input entity ID as a prefix;
[0125] Dynamically delete entity function, used to delete model entity according to the input model entity ID.
[0126] In one of the embodiments, the exception information maintenance and processing function module is also used to define exception classes, standardize error information, and feedback corresponding declared error details in the form of log records based on errors occurring during program execution; it is also used to capture exception error information, capture exceptions thrown during program execution, and record and display the exception information in the form of logs.
[0127] like Figure 6 As shown, the workflow of the abnormal information maintenance and processing function module includes:
[0128] Step 601: Create an exception information maintenance class.
[0129] Step 602: Standardize and define common error messages.
[0130] Step 603: If an exception occurs during program execution, the exception information is captured.
[0131] Step 604: Classify the abnormal information according to the type of the abnormal information.
[0132] Step 605: Record the exception information in the log, including the exception type, occurrence time, and exception description information.
[0133] Step 606: Analyze according to the type of abnormal information and process according to the severity of the abnormal information.
[0134] In one embodiment, Figure 7 As shown, a model development method for parallel discrete event simulation scheduling is provided, which is suitable for model development using the above-mentioned model development framework for parallel discrete event simulation scheduling; the method comprises the following steps:
[0135] Step S1: Develop and implement the model business functions by inheriting the model base class, then standardize the inherent properties and inherent methods of the model base class, and at the same time, add new properties in the development model according to the characteristics of the development model.
[0136] Specifically, this step includes:
[0137] S1.1) Realize unified management of the inherent attributes of the model. The inherent attributes are public, stable, and inherited. The inherent attributes of the model include: model class name, model entity identifier, model engine identifier, model entity status, etc.
[0138] S1.2) Realize the unified management of model-intrinsic methods. The inherent methods are public, stable, and inherited. The model-intrinsic methods include: model entity initialization method and model entity data recovery method.
[0139] S1.3) When performing secondary development of a model based on a model base class, it is necessary to inherit the model base class and implement pure virtual methods that are not defined in the base class.
[0140] S1.4) When performing secondary development of a model based on the model base class, it is necessary to inherit the model base class and add new properties and methods according to specific needs.
[0141] Step S2: Implement the model library export function. When the engine loads the model library, it calls the export function to generate an object pointer, and calls the corresponding model registration function according to the object pointer. By registering the corresponding function, when the event execution time arrives, the engine calls back the corresponding event function to execute the event.
[0142] Specifically, this step includes:
[0143] S2.1) After the model class function is implemented, the model library export function is implemented. When the engine loads the model library, it will call the export function to generate a model registration object pointer.
[0144] S2.2) Model entities can be created and destroyed by calling the registered model creation function and the registered model destruction function according to the model registration object pointer. The registered model creation function calls the model constructor to create the model entity, and the registered model destruction function calls the model destructor.
[0145] S2.3) The planned events of the model entity itself and the interaction events between model entities can call the registered interaction event processing function and the registered planned event processing function according to the model registration object pointer. When the event execution time arrives, the engine calls back the planned event or interaction event and executes the event. The function name for executing the planned event can be defined by the user, and there is no restriction on the parameters, number and type passed in.
[0146] S2.4) The register interest subscription function can also be called according to the object pointer. The register interest subscription function is used for the simulation entity to subscribe to and query the data of interest according to its own needs.
[0147] S2.5) Complete the creation and destruction of model entities, and add corresponding registered planning events or interaction events to the corresponding container according to the model event type.
[0148] S2.6) After the model is registered, its callback information will be stored in the corresponding location and can be used in subsequent simulation processes.
[0149] Step S3: When the engine creates a model entity, it simultaneously creates an engine blackboard and initializes the model entity. The initialized model entity attributes are first saved in the local object, and the information is uniformly submitted to the engine blackboard when the update is finally submitted.
[0150] Specifically, this step includes:
[0151] S3.1) When the engine creates a model entity, it synchronously creates a blackboard object and assigns the base address of the object to the member of the local attribute copy of the entity.
[0152] S3.2) After the model entity is created, the InitModel interface will be called back to initialize the model entity.
[0153] S3.3) Model initialization completes the assignment of initial values to the object attributes of each model entity. The assignment is performed through the local object subscript operation. The storage location of the accessed attribute in the blackboard can be located through the local object;
[0154] S3.4) During the assignment operation, the initialized value of the entity attribute will first be submitted to the local attribute copy, and the source location information of the entity attribute information and the target location information to be submitted to the engine blackboard will be located locally through operation.
[0155] S3.5) After the assignment is completed, the entity object information will eventually be submitted to the target location of the engine blackboard when the entity attribute information is submitted for update.
[0156] Step S4: According to the interface required by the model request simulation engine, the engine creates a callback interface class instance synchronously when creating the model entity, and assigns the instance object pointer to the member callback pointer of the entity, and accesses the simulation service through the callback pointer.
[0157] Specifically, this step includes:
[0158] S4.1) Define the interfaces required by the model request simulation engine, which are used to implement the functions provided by the model request simulation engine and standardize the development of the model request business.
[0159] S4.2) When the engine creates a model entity, it synchronously creates a callback interface class instance and assigns the instance object pointer to the member callback pointer of the entity.
[0160] S4.3) According to the inheritance and implementation of the interface, by adding new attributes: engine ID, model class name, entity ID, assigning corresponding values to the newly added attributes when the model is created, the model entity's access to data can be restricted, thereby realizing the permission management of the model entity.
[0161] S4.4) The query and update of model object data can be called through pointers to the model object data update function and object data query function. Model object data update function: used to submit the information submitted by the entity attribute to the local attribute copy to the engine blackboard; object data query function: used to query object information and find out whether the object information exists on the engine blackboard. At the same time, object data query can be based on: model type name query, during the simulation process, users can query the corresponding entity information on the blackboard according to the entity type; entity ID query, during the simulation process, users can query the corresponding entity information on the blackboard according to the entity ID; custom query, during the simulation process, the user query interface obtains the reflection object class set, and passes it to the filter function of the reflection object class set according to the custom lamda expression.
[0162] S4.5) Dynamic creation and deletion of entities can be done by calling dynamic entity creation function and dynamic entity deletion function through pointers; Dynamic entity creation function: used to dynamically create entities, can create model entities through the input entity ID set, and can create model entities through the input entity ID as a prefix; Dynamic entity deletion function: used to dynamically delete entities, can delete model entities through the input model entity ID.
[0163] S4.6) Sending events can be done by calling the send planning event function and the send interaction event function through pointers;
[0164] According to the type of event, a planned event or an interactive event is sent. The sent event will be added to the corresponding event queue. When the engine advancement time reaches the execution time of the corresponding event, the corresponding registered function will be called back and executed.
[0165] S4.7) To query the simulation time and control the simulation speed, you can call the simulation time query function and the simulation acceleration ratio control function through the pointer; the simulation time query function: query the simulation time during the simulation process; the simulation acceleration ratio control function; the corresponding simulation acceleration ratio can be set according to different situations.
[0166] S4.8) The request service can call the request service function through a pointer; the request service function is used to request the corresponding extended simulation service of the model during the execution process, return the calculation results, and promote the model simulation operation; the model call engine service interface includes: synchronous request extended simulation service interface and asynchronous request extended simulation service interface.
[0167] S4.9) According to the model, the corresponding interface is called, the engine executes the corresponding method, completes the corresponding function, returns the corresponding result, and promotes the simulation operation.
[0168] Step S5: declare abnormal information, capture and process the abnormal information that occurs during the operation.
[0169] Specifically, this step includes:
[0170] S5.1) Define exception classes, standardize common error messages, and provide detailed error information for the corresponding statements in the form of log records based on errors that occur during program execution.
[0171] S5.2) Capture exception error information. Capture the exception thrown during program execution, record and display the exception information in the form of a log, and analyze the cause of the exception.
[0172] It should be understood that although Figure 7The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 7 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0173] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a model development method for parallel discrete event simulation scheduling is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0174] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0175] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above-mentioned model development method embodiment for parallel discrete event simulation scheduling when executing the computer program.
[0176] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0177] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A model development framework system for parallel discrete event simulation scheduling, characterized in that: The system comprises: Model method and structure definition module, used to uniformly define model base classes, model inherent properties, and model inherent methods; The model library information registration function module is used to implement the model library export function. When the engine loads the model library, the export function is called to generate an object pointer, and the model registration function is called according to the object pointer; The model local data management module is used to locally store the information after the model entity attribute assignment operation, and finally submit it to the engine blackboard; The model request simulation business interface function module is used to query and update object data, plan events and interactions, query simulation time, control simulation acceleration ratio, service requests, and dynamically create and delete entities during the simulation process based on the inherent attributes of the model; The exception information maintenance and processing function module is used to capture exception information during the simulation process, analyze and locate the location where the exception information occurs, and throw out error information; The model inherent attributes include model class name, entity identifier, engine identifier and entity status; The model inherent method includes model entity initialization and model entity data recovery; The model method and structure definition module is also used to perform secondary development of the model according to the model base class. When the model is secondary developed, the model base class is inherited to implement pure virtual methods not defined in the model base class, and new properties and methods are added according to preset needs. The model local data management module is also used to synchronously create a blackboard object when the engine creates a model entity, and assign the base address of the object to the member of the local attribute copy of the model entity. After the engine creates the model entity, it calls back the InitModel interface to initialize the model entity and completes the assignment of initial values to the object attributes of each model entity. The assignment is performed through the local local object subscript operation. The location where the blackboard attributes are stored can be located through the local object. After the assignment is completed, it will be saved in the local object first, and the information will be uniformly submitted to the engine blackboard when the update is finally submitted.
2. The system according to claim 1, characterized in that The model library information registration function module is also used to create a model library registration information function class, declare corresponding properties and methods in the model library registration information function class, create a model library export function in the model, and call the model library export function to generate an object pointer when the engine loads the model library. According to the object pointer, the registered model creation function, the registered model destruction function, the registered interaction event processing function, the registered planning event processing function or the registered interest subscription function are called, and the registration function is called according to the object pointer to complete the creation and destruction of the model entity. At the same time, according to the model event type, the corresponding registered planning event or interaction event is added to the corresponding container, and the interest subscription is added. The callback information after registration is completed can be used in subsequent processes.
3. The system according to claim 2, characterized in that The registered model creation function is used to call the model constructor to create a model entity; The registered model destruction function is used to call the destructor of the model to destroy the model entity; The registered interaction event processing function is used for the engine to call back the interaction processing function when the subscribed interaction type sends an interaction; The registered planning event processing function is used to plan the model's own events, and when the event execution time arrives, the registered function is called back for execution; The registered interest subscription function is used to simulate entities to subscribe to and query data according to their own needs.
4. The system according to claim 1, characterized in that The model request simulation business interface function module is also used to create the interface required by the model request simulation engine. When the engine creates a model entity, it simultaneously creates a callback interface class instance and assigns the instance object pointer to the member callback pointer of the entity; the interface function is called according to the callback pointer, and then according to the interface function called by the model, the engine calls and executes the corresponding method to complete the corresponding function and promote the simulation operation.
5. The system according to claim 4, characterized in that The interface function includes: Model object data update function, used to submit the information of entity attributes submitted to the local attribute copy to the engine blackboard; The object data query function is used to query object information and find out whether the object information exists on the engine blackboard; Send planning event function, which is used to add planning events to the event queue. When the engine advances to the time when the corresponding event is executed, the corresponding registered planning function is called back and the planning event is executed. Send interaction event function, which is used to add interaction events to the event queue. When the engine advances time to the time when the corresponding event is executed, the corresponding registered interaction event function is called back and the interaction event is executed. The simulation time query function is used to query the simulation time during the simulation process; Control simulation acceleration ratio function, used to set corresponding simulation acceleration ratio according to different situations; The request service function is used to request the corresponding extended simulation service during the execution of the model, return the calculation results, and promote the model simulation operation; the model call engine service interface includes: synchronous request extended simulation service interface and asynchronous request extended simulation service interface; Dynamically create entity function, used to create model entities based on the input entity ID set, or create model entities based on the input entity ID as a prefix; Dynamically delete entity function, used to delete model entity according to the input model entity ID.
6. The system according to claim 1, characterized in that The exception information maintenance and processing functional module is also used to define exception classes, standardize error information, and feedback the corresponding declared error details in the form of log records based on the errors occurring during program execution; it is also used to capture exception error information, capture the exceptions thrown during program execution, and record and display the exception information in the form of logs.
7. A model development method for parallel discrete event simulation scheduling, characterized in that: The method is applicable to model development using the model development framework system for parallel discrete event simulation scheduling as described in any one of claims 1 to 6; the method comprises: The model business function is developed and implemented by inheriting the model base class, and then the inherent attributes and inherent methods of the model base class are standardized. At the same time, in the development model, new attributes are added according to the characteristics of the development model; Implement the model library export function. When the engine loads the model library, it calls the export function to generate an object pointer, and calls the corresponding model registration function according to the object pointer. By registering the corresponding function, when the event execution time comes, the engine calls back the corresponding event function to execute the event. When the engine creates a model entity, it also creates an engine blackboard and initializes the model entity. The initialized model entity attributes are first saved in the local object, and the information is uniformly submitted to the engine blackboard when the update is finally submitted. According to the inheritance and implementation of the interface required by the model request simulation engine, the engine synchronously creates a callback interface class instance when creating the model entity, and assigns the instance object pointer to the member callback pointer of the entity, and accesses the simulation service through the callback pointer; Declare exception information, capture and process exception information that occurs during operation.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method according to claim 7 is implemented.
