System Executor¶
Author: Changbeom Choi (@cbchoi) Copyright (c) 2014-2020 Handong Global University Copyright (c) 2021-2024 Hanbat National University License: MIT. The full license text is available at: https://github.com/eventsim/pyjevsim/blob/main/LICENSE
This module includes SysExecutor, a simulation engine that manages models over time.
- class pyjevsim.system_executor.SysExecutor(_time_resolution, _sim_name='default', ex_mode=ExecutionType.V_TIME, snapshot_manager=None)[source]¶
Bases:
CoreModelSysExecutor managing the execution of models in a simulation.(Simulation Engine)
- EXTERNAL_DST = 'DST'¶
- EXTERNAL_SRC = 'SRC'¶
- coupling_relation(src_obj, out_port, dst_obj, in_port)[source]¶
Related Model’s input/output ports to each other. Related src_obj’s output port to dst_obj’s input port.
- Parameters:
src_obj (BehaviorMdoel or StructuralModel) – Model to relate as output ports
out_port (str) – src_obj’s output port
dst_obj (CoreModel) – Model to relate as input ports
in_port (str) – dst_obj’s input port
- destory_entity(delete_lst)[source]¶
Destroys a list of entities.
- Parameters:
delete_lst (list) – List of entities to delete
- get_entity(model_name)[source]¶
Retrieves entities by model name.
- Parameters:
model_name (str) – The name of the model
- Returns:
List of entities
- Return type:
list
- get_generated_event()[source]¶
Returns the queue of generated events.
- Returns:
The queue of generated events
- Return type:
deque
- get_global_time()[source]¶
Retrieves the current global time.(simulation time)
- Returns:
The current global time
- Return type:
float
- get_model(name)[source]¶
Retrieve Model by name.
- Parameters:
name (str) – The name of the model
- Returns:
Model(BehaviorModel or StructuralModel)
- Return type:
- get_relation()[source]¶
Retrieves the current coupling relations.
- Returns:
The relation map
- Return type:
dict
- handle_external_output_event()[source]¶
Handles external output events and clears the output event queue.
- Returns:
List of output events
- Return type:
list
- insert_custom_external_event(_port, _bodylist, scheduled_time=0)[source]¶
Inserts a custom external event into the simulation.
- Parameters:
_port (str) – The port name / 포트 이름
_bodylist (list) – The list of message bodies
scheduled_time (float, optional) – The scheduled time for the event
- insert_external_event(_port, _msg, scheduled_time=0)[source]¶
Inserts an external event into the simulation.
- Parameters:
_port (str) – port name
_msg (SysMessage or None) – Event message
scheduled_time (float, optional) – The scheduled time for the event
- is_terminated()[source]¶
Checks if the simulation is terminated.
- Returns:
True if terminated, False otherwise
- Return type:
bool
- output_handling(obj, msg_deliver)[source]¶
Handles output messages.
- Parameters:
obj (BehaviorModel or StructuralModel) – Model
msg (SysMessage) – The message
- register_entity(entity, inst_t=0, dest_t=inf, ename='default')[source]¶
Register simulation entity(Model).
- Parameters:
entity (BehaviorModel or StructuralModel) – The entity to register
inst_t (float, optional) – Instance creation time
dest_t (float, optional) – Destruction time
ename (str, optional) – SysExecutor name
- remove_entity(model_name)[source]¶
Removes an entity by model name.
- Parameters:
model_name (str) – The name of the model
- remove_relation(src, out_port, dst, in_port)[source]¶
Removes a coupling relation.
- Parameters:
src_obj (str) – BehaviorMdoel or StructuralModel name, Models that remove relationships as output port
out_port (str) – src_obj’s output port
dst_obj (CoreModel) – Models that remove relationships as input port
in_port (str) – dst_obj’s input port
- simulate(_time=inf, _tm=True)[source]¶
Runs the simulation for a given amount of time.
- Parameters:
_time (float) – The simulation time
_tm (bool) – Whether to use the termination manager
- single_output_handling(obj, msg)[source]¶
Handles a single output message.
- Parameters:
obj (BehaviorModel or StructuralModel) – Model
msg (SysMessage) – The message
Executor Factory¶
Author: Changbeom Choi (@cbchoi) Copyright (c) 2014-2020 Handong Global University Copyright (c) 2021-2024 Hanbat National University License: MIT. The full license text is available at: https://github.com/eventsim/pyjevsim/blob/main/LICENSE
This module contains an ExecutorFactory that decorates an object of type Model into an Executor that is executable by a SysExecutor.
- class pyjevsim.executor_factory.ExecutorFactory[source]¶
Bases:
objectFactory class to create different types of executors.
- create_behavior_executor(_, ins_t, des_t, en_name, model, parent)[source]¶
Create BehaviorModelexecutor
- Parameters:
_ (float) – Unused global time
ins_t (float) – Instance creation time
des_t (float) – Destruction time
en_name (str) – SysExecutor name
model (BehaviorModel) – Behavior model to execute
- Returns:
The created BehaviorModelexecutor
- Return type:
BehaviorModelExecutor
- create_executor(global_time, ins_t, des_t, en_name, model, parent)[source]¶
Creates an executor based on the model type.
- Parameters:
global_time (float) – Global simulation time
ins_t (float) – Instance creation time
des_t (float) – Destruction time
en_name (str) – Engine name
model (ModelType.BEHAVIORAL of ModelType.STRUCTURAL) – The model to execute
- Returns:
The created executor
- Return type:
- create_structural_executor(global_time, ins_t, des_t, en_name, model, parent)[source]¶
Create StructuralModelExecutor
- Parameters:
global_time (float) – Global simulation time
ins_t (float) – Instance creation time
des_t (float) – Destruction time
en_name (str) – SysExecutor name
model (StructuralModel) – StructuralModel to execute
- Returns:
created StructuralModelExecutor
- Return type:
StructuralModelExecutor
Snapshot Factory¶
Author: Changbeom Choi (@cbchoi) Copyright (c) 2014-2020 Handong Global University Copyright (c) 2021-2024 Hanbat National University License: MIT. The full license text is available at: https://github.com/eventsim/pyjevsim/blob/main/LICENSE
- class pyjevsim.snapshot_factory.SnapshotFactory(snapshot_map)[source]¶
Bases:
ExecutorFactoryThe SnapshotManager determines which model you want to take a snapshot of, and sets it to a SnapshotExecutor in a form that the SystemExecutor can execute. And for models that don’t take snapshots, it creates an Executor for each model’s type.
- create_executor(global_time, ins_t, des_t, en_name, model, parent)[source]¶
Creates an executor based on the model type.
- Parameters:
global_time (float) – Global simulation time
ins_t (float) – Instance creation time
des_t (float) – Destruction time
en_name (str) – Engine name
model (ModelType.BEHAVIORAL of ModelType.STRUCTURAL) – The model to execute
- Returns:
The created executor
- Return type:
- create_snapshot_executor(model)[source]¶
Create a SnapshotExecutor for the model you want to snapshot.
- Parameters:
model (BehaviorModel) – _description_
- Returns:
_description_
- Return type:
_type_
Message Catcher¶
Author: Changbeom Choi (@cbchoi) Copyright (c) 2014-2020 Handong Global University Copyright (c) 2021-2024 Hanbat National University License: MIT. The full license text is available at: https://github.com/eventsim/pyjevsim/blob/main/LICENSE
This module contains a default model, DefaultMessageCatcher, for catching uncaught messages.
- class pyjevsim.default_message_catcher.DefaultMessageCatcher(_name)[source]¶
Bases:
BehaviorModelA default model for catching uncaught messages. Receiving and not processing uncaught messages.
- ext_trans(port, msg)[source]¶
Received an uncaught message.
- Parameters:
port (str) – The port name
msg (SysMessage) – The incoming message
Termination Manager¶
Author: Changbeom Choi (@cbchoi) Copyright (c) 2014-2020 Handong Global University Copyright (c) 2021-2024 Hanbat National University License: MIT. The full license text is available at: https://github.com/eventsim/pyjevsim/blob/main/LICENSE
This module contains the TerminatorManager, which manages the simulation termination of the SysExecutor.