Presentation is loading. Please wait.

Presentation is loading. Please wait.

Atomic Model Simulator

Similar presentations


Presentation on theme: "Atomic Model Simulator"— Presentation transcript:

1 Atomic Model Simulator
Every atomic model has a simulator assigned to it which keeps track of the time of the last event, tL and the time of the next event, tN. Initially, the state of the model is initialized as specified by the modeler to a desired initial state, sinit. The event times, tL and tN are set to 0 and ta(sinit), respectively. If there are no external events, the clock time, t is advanced to tN, the output is generated and the internal transition function of the model is executed. The simulator then updates the event times as shown, and processing continues to the next cycle. If an external event is injected to the model at some time, text (no earlier than the current clock and no later than tN), the clock is advanced to text. If text == tN the output is generated. Then the input is processed by the confluent or external event transition function, depending on whether text coincides with tN or not. m timeline (abstract or logica) tL tN inject at time t s =: s init tL =: 0 tN =: ta(sinit) If t == tN generate output  (s) When receive m if m!= null and t < tN, s := ext (s,t-tN,m) if m!= null and t == tN, s := con (s,t-tN,m) if m= null and t == tN, s =: int (s) Legend: m = message s = state t = clock time tL = time of last event tN = time of next event tL =: t tN =: t + ta(s) genDevs. simulation. atomicSimulator

2 Basic DEVS Simulation Protocol
For a coupled model with atomic model components, a coordinator is assigned to it and coupledSimulators are assigned to its components. In the basic DEVS Simulation Protocol, the coordinator is responsible for stepping simulators through the cycle of activities shown. Coupled Model Coordinator: Coordinator sends nextTN to request tN from each of the simulators. All the simulators reply with their tNs in the outTN message to the coordinator Coordinator sends to each simulator a getOut message containing the global tN (the minimum of the tNs) Each simulator checks if it is imminent (its tN = global tN) and if so, returns the output of its model in a message to the coordinator in a sendOut message. Coordinator uses the coupling specification to distribute the outputs as accumulated messages back to the simulators in an applyDelt message to the simulators – for those simulators not receiving any input, the messages sent are empty. 1 nextTN Coupled Model 3 getOut coordinator 5 applyDelt 4 sendOut 2. outTN simulator Component tN tN. tL simulator Component tN tN. tL simulator Component tN tN. tL After each transition tN = t + ta(), tL = t Each simulator reacts to the incoming message as follows: If it is imminent and its input message is empty, then it invokes its model’s inernal transition function If it is imminent and its input message is not empty, it invokes its model’s confluence transition function If is not imminent and its input message is not empty, it invokes its model’s external transition function If is not imminent and its input message is empty then nothing happens.

3 Illustrating The DEVS Simulation Protocol within DEVS itself
The DEVS Simulation Protocol can be illustrated within DEVSJAVA itself as follows: The coupled model, simTrip, represents the simulation of coupled model gpt. We define simulator and sCoordinator subclasses of atomic. The components of simTrip are: 3 instances of the simulator class, one each for g, p, and t 1 instance of the sCoordinator class. SimpArc gpt SimpArc simTrip SimpArc sCoordinator gpt SimpArc simulator

4 DEVS Simulation Protocol as Implemented in DEVSJAVA
simulators. simulators. tellAll tellAll ("initialize“) at start of simulation ("initialize“) genDevs. simulation. coordinator coordinator simulators. simulators. AskAll AskAll (“ (“ nextTN nextTN ”) ”) simulators. simulators. tellAll tellAll (" (" computeInputOutput computeInputOutput “) “) simulators. simulators. tellAll tellAll (" (" sendMessages sendMessages ") ") simulators. simulators. tellAll tellAll (" (" DeltFunc DeltFunc “) “) DEVS cycle message message coupledSimulator coupledSimulator coupledSimulator Atomic Model Atomic Model Atomic Model Atoimc3 genDevs. simulation. coupledSimulator coupling

5 DEVS Simulation Protocol Classes
Stand alone atomic models are assigned to AtomicSimulators Atomic models as components within coupled models are assigned to coupledSimulators Atomic Simulator coupledSimulator coordinator 1:n Coupled models are assigned to coordinators 1:n coupledCoordinator Coupled models as components within coupled models are assigned to coupledCoordinators genDevs. simulation. coupledSimulator genDevs. simulation. coordinator

6 Real-Time Simulator/Executor
Execution in real time of an atomic model is similar to its simulation in logical or abstract time. The difference is that rather than being controlled by an events list within the coordinator, each simulator governs itself according to the host processor system clock. Thus passage of time in the model is identical to that of a wall clock. This difference is seen in the following alteration of the simulator: m real timeline tL tN inject at time t s =: s init tL =: 0 tN =: ta(sinit) If t == tN generate output  (s) sleep for ta(s) When receive m if m!= null and t < tN, s := ext (s,t-tN,m) if m!= null and t == tN, s := con (s,t-tN,m) if m= null and t == tN, s =: int (s) When first entering the state, s, the simulator starts a thread to sleep for a time ta(s) If an external event is injected to the model at some time, text (no earlier than the current clock and no later than tN), the sleeping thread is interrupted and If text == tN the output is generated. Then the input is processed by the confluent or external event transition function, depending on whether text coincides with tN or not. Legend: m = message s = state t = clock time tL = time of last event tN = time of next event tL =: t tN =: t + ta(s) genDevs. simulation.realTime atomicRTSimulator Real time execution of DEVS models is facilitated by the separation of model from simulator which allows the simulator to be “changed out” by one that adheres to a real clock. The ease of migration from simulation to execution enables a designprocess called model-continuity discussed later.


Download ppt "Atomic Model Simulator"

Similar presentations


Ads by Google