Simulation algorithms for atomic DEVS

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 t s [ 0 , ] {\displaystyle t_{s}\in [0,\infty ]} and elapsed time t e [ 0 , ) {\displaystyle t_{e}\in [0,\infty )} by introducing two other time variables, last event time, t l [ 0 , ) {\displaystyle t_{l}\in [0,\infty )} , and next event time t n [ 0 , ] {\displaystyle t_{n}\in [0,\infty ]} with the following relations:

t e = t t l {\displaystyle \,t_{e}=t-t_{l}}

and

t s = t n t l {\displaystyle \,t_{s}=t_{n}-t_{l}}

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

t r = t s t e {\displaystyle \,t_{r}=t_{s}-t_{e}}

is equivalently computed as

t r = t n t {\displaystyle \,t_{r}=t_{n}-t}

, apparently t r [ 0 , ] {\displaystyle t_{r}\in [0,\infty ]} .

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
    
  
    
      
        
          t
          
            l
          
        
      
    
    {\displaystyle t_{l}}
  
     // time of last event
    
  
    
      
        
          t
          
            n
          
        
      
    
    {\displaystyle t_{n}}
  
     // time of next event
    
  
    
      
        A
        =
        (
        X
        ,
        Y
        ,
        S
        ,
        t
        a
        ,
        
          δ
          
            e
            x
            t
          
        
        ,
        
          δ
          
            i
            n
            t
          
        
        ,
        λ
        )
      
    
    {\displaystyle A=(X,Y,S,ta,\delta _{ext},\delta _{int},\lambda )}
  
// the associated Atomic DEVS model 
  when receive init-message(Time 
  
    
      
        t
      
    
    {\displaystyle t}
  
)
     
  
    
      
        
          t
          
            l
          
        
        
        t
        ;
      
    
    {\displaystyle t_{l}\leftarrow t;}
  

     
  
    
      
        
          t
          
            n
          
        
        
        
          t
          
            l
          
        
        +
        t
        a
        (
        s
        )
        ;
      
    
    {\displaystyle t_{n}\leftarrow t_{l}+ta(s);}
  

  when receive star-message(Time 
  
    
      
        t
      
    
    {\displaystyle t}
  
)
     if 
  
    
      
        t
        
        
          t
          
            n
          
        
      
    
    {\displaystyle t\neq t_{n}}
  
 then
        error: bad synchronization;
     
  
    
      
        y
        
        λ
        (
        s
        )
        ;
      
    
    {\displaystyle y\leftarrow \lambda (s);}
  

     send y-message(
  
    
      
        y
        ,
        t
      
    
    {\displaystyle y,t}
  
) to parent;
     
  
    
      
        s
        
        
          δ
          
            i
            n
            t
          
        
        (
        s
        )
      
    
    {\displaystyle s\leftarrow \delta _{int}(s)}
  

     
  
    
      
        
          t
          
            l
          
        
        
        t
        ;
      
    
    {\displaystyle t_{l}\leftarrow t;}
  

     
  
    
      
        
          t
          
            n
          
        
        
        
          t
          
            l
          
        
        +
        t
        a
        (
        s
        )
        ;
      
    
    {\displaystyle t_{n}\leftarrow t_{l}+ta(s);}
  

View 1: total states = states * elapsed times

As addressed in Behavior of Atomic DEVS, when DEVS receives an input event, right calling δ e x t {\displaystyle \delta _{ext}} , the last event time, t l {\displaystyle t_{l}} is set by the current time, t {\displaystyle t} , thus the elapsed time t e {\displaystyle t_{e}} becomes zero because t e = t t l {\displaystyle t_{e}=t-t_{l}} .

  when receive x-message(
  
    
      
        x
        
        X
      
    
    {\displaystyle x\in X}
  
, Time 
  
    
      
        t
      
    
    {\displaystyle t}
  
)
     if 
  
    
      
        (
        
          t
          
            l
          
        
        
        t
      
    
    {\displaystyle (t_{l}\leq t}
  
 and 
  
    
      
        t
        
        
          t
          
            n
          
        
        )
      
    
    {\displaystyle t\leq t_{n})}
  
 == false then
        error: bad synchronization;
     
  
    
      
        s
        
        
          δ
          
            e
            x
            t
          
        
        (
        s
        ,
        t
        
        
          t
          
            l
          
        
        ,
        x
        )
      
    
    {\displaystyle s\leftarrow \delta _{ext}(s,t-t_{l},x)}
  

     
  
    
      
        
          t
          
            l
          
        
        
        t
        ;
      
    
    {\displaystyle t_{l}\leftarrow t;}
  

     
  
    
      
        
          t
          
            n
          
        
        
        
          t
          
            l
          
        
        +
        t
        a
        (
        s
        )
        ;
      
    
    {\displaystyle t_{n}\leftarrow t_{l}+ta(s);}
  

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

Notice that as addressed in Behavior of Atomic DEVS, depending on the value of b {\displaystyle b} return by δ e x t {\displaystyle \delta _{ext}} , last event time, t l {\displaystyle t_{l}} , and next event time, t n {\displaystyle t_{n}} ,consequently, elapsed time, t e {\displaystyle t_{e}} , and lifespan t n {\displaystyle t_{n}} , are updated (if b = 1 {\displaystyle b=1} ) or preserved (if b = 0 {\displaystyle b=0} ).

  when receive x-message(
  
    
      
        x
        
        X
      
    
    {\displaystyle x\in X}
  
, Time 
  
    
      
        t
      
    
    {\displaystyle t}
  
)
     if 
  
    
      
        (
        
          t
          
            l
          
        
        
        t
      
    
    {\displaystyle (t_{l}\leq t}
  
 and 
  
    
      
        t
        
        
          t
          
            n
          
        
        )
      
    
    {\displaystyle t\leq t_{n})}
  
 == false then
        error: bad synchronization;
     
  
    
      
        (
        s
        ,
        b
        )
        
        
          δ
          
            e
            x
            t
          
        
        (
        s
        ,
        t
        
        
          t
          
            l
          
        
        ,
        x
        )
      
    
    {\displaystyle (s,b)\leftarrow \delta _{ext}(s,t-t_{l},x)}
  

     if 
  
    
      
        b
        =
        1
      
    
    {\displaystyle b=1}
  
 then 
        
  
    
      
        
          t
          
            l
          
        
        
        t
        ;
      
    
    {\displaystyle t_{l}\leftarrow t;}
  

        
  
    
      
        
          t
          
            n
          
        
        
        
          t
          
            l
          
        
        +
        t
        a
        (
        s
        )
        ;
      
    
    {\displaystyle t_{n}\leftarrow t_{l}+ta(s);}
  

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.