Physics:Simulation algorithms for atomic DEVS

From HandWiki

Given an atomic DEVS model, simulation algorithms are methods to generate the model's legal behaviors which are trajectories not to reach to illegal states. (see Behavior of DEVS). [Zeigler84] originally introduced the algorithms that handle time variables related to lifespan [math]\displaystyle{ t_s \in [0,\infty] }[/math] and elapsed time [math]\displaystyle{ t_e\in [0,\infty) }[/math] by introducing two other time variables, last event time, [math]\displaystyle{ t_l\in [0,\infty) }[/math], and next event time [math]\displaystyle{ t_n\in [0,\infty] }[/math] with the following relations:

[math]\displaystyle{ \, t_e = t - t_l }[/math]

and

[math]\displaystyle{ \, t_s = t_n - t_l }[/math]

where [math]\displaystyle{ t\in [0,\infty) }[/math] denotes the current time. And the remaining time,

[math]\displaystyle{ \,t_r=t_s-t_e }[/math]

is equivalently computed as

[math]\displaystyle{ \, t_r = t_n - t }[/math]

, apparently [math]\displaystyle{ t_r \in [0,\infty] }[/math].

Since the behavior of a given atomic DEVS model can be defined in two different views depending on the total state and the external transition function (refer to Behavior of DEVS), the simulation algorithms are also introduced in two different views as below.

Common parts

Regardless of two different views of total states, algorithms for initialization and internal transition cases are commonly defined as below.

DEVS-simulator
  variables:
    parent // parent coordinator
    [math]\displaystyle{ t_l }[/math]     // time of last event
    [math]\displaystyle{ t_n }[/math]     // time of next event
    [math]\displaystyle{ A=(X,Y,S,ta, \delta_{ext}, \delta_{int}, \lambda)  }[/math]// the associated Atomic DEVS model 
  when receive init-message(Time [math]\displaystyle{ t }[/math])
     [math]\displaystyle{  t_l \leftarrow t; }[/math]
     [math]\displaystyle{  t_n \leftarrow t_l + ta(s);  }[/math]
  when receive star-message(Time [math]\displaystyle{ t }[/math])
     if [math]\displaystyle{  t \ne t_n  }[/math] then
        error: bad synchronization;
     [math]\displaystyle{  y \leftarrow \lambda(s); }[/math]
     send y-message([math]\displaystyle{ y,t }[/math]) to parent;
     [math]\displaystyle{  s \leftarrow \delta_{int}(s) }[/math]
     [math]\displaystyle{  t_l \leftarrow t; }[/math]
     [math]\displaystyle{  t_n \leftarrow t_l + ta(s);  }[/math]

View 1: total states = states * elapsed times

As addressed in Behavior of Atomic DEVS, when DEVS receives an input event, right calling [math]\displaystyle{ \delta_{ext} }[/math], the last event time,[math]\displaystyle{ t_l }[/math] is set by the current time,[math]\displaystyle{ t }[/math], thus the elapsed time[math]\displaystyle{ t_e }[/math] becomes zero because [math]\displaystyle{ t_e = t - t_l }[/math].

  when receive x-message([math]\displaystyle{ x \in X }[/math], Time [math]\displaystyle{ t }[/math])
     if [math]\displaystyle{ ( t_l \le t  }[/math] and [math]\displaystyle{  t \le t_n ) }[/math] == false then
        error: bad synchronization;
     [math]\displaystyle{  s \leftarrow \delta_{ext}(s,t-t_l, x) }[/math]
     [math]\displaystyle{  t_l \leftarrow t; }[/math]
     [math]\displaystyle{  t_n \leftarrow t_l + ta(s);  }[/math]

View 2: total states = states * lifespans * elapsed times

Notice that as addressed in Behavior of Atomic DEVS, depending on the value of [math]\displaystyle{ b }[/math] return by [math]\displaystyle{ \delta_{ext} }[/math], last event time,[math]\displaystyle{ t_l }[/math], and next event time,[math]\displaystyle{ t_n }[/math],consequently, elapsed time, [math]\displaystyle{ t_e }[/math], and lifespan[math]\displaystyle{ t_n }[/math], are updated (if [math]\displaystyle{ b=1 }[/math]) or preserved (if [math]\displaystyle{ b=0 }[/math]).

  when receive x-message([math]\displaystyle{ x \in X }[/math], Time [math]\displaystyle{ t }[/math])
     if [math]\displaystyle{ ( t_l \le t  }[/math] and [math]\displaystyle{  t \le t_n ) }[/math] == false then
        error: bad synchronization;
     [math]\displaystyle{  (s,b) \leftarrow \delta_{ext}(s, t-t_l, x) }[/math]
     if [math]\displaystyle{  b = 1  }[/math] then 
        [math]\displaystyle{  t_l \leftarrow t; }[/math]
        [math]\displaystyle{  t_n \leftarrow t_l + ta(s);  }[/math]

See also

References

  • [Zeigler84] Bernard Zeigler (1984). Multifacetted Modeling and Discrete Event Simulation. Academic Press, London; Orlando. ISBN 978-0-12-778450-2. 
  • [ZKP00] Bernard Zeigler; Tag Gon Kim; Herbert Praehofer (2000). Theory of Modeling and Simulation (second ed.). Academic Press, New York. ISBN 978-0-12-778455-7.