Behavior of coupled DEVS
# Behavior of coupled DEVS

In theoretical computer science, DEVS is closed under coupling [Zeigper84] [ZPK00]. In other words, given a coupled DEVS model $N$, its behavior is described as an atomic DEVS model $M$. For a given coupled DEVS $N$, once we have an equivalent atomic DEVS $M$, behavior of $M$ can be referred to behavior of atomic DEVS which is based on Timed Event System.

Similar to behavior of atomic DEVS, behavior of the Coupled DEVS class is described depending on definition of the total state set and its handling as follows.

## View1: Total states = states * elapsed times

Given a coupled DEVS model $N=<X,Y,D,\{M_{i}\},C_{xx},C_{yx},C_{yy},Select>$, its behavior is described as an atomic DEVS model $M=<X,Y,S,s_{0},ta,\delta _{ext},\delta _{int},\lambda >$

where

* $X$ and $Y$ are the input event set and the output event set, respectively.
* $S={\underset {i\in D}{\times }}Q_{i}$ is the partial state set where $Q_{i}=\{(s_{i},t_{ei})|s_{i}\in S_{i},t_{ei}\in (\mathbb {T} \cap [0,ta_{i}(s_{i})])\}$ is the total state set of component $i\in D$ (Refer to View1 of Behavior of DEVS), where $\mathbb {T} =[0,\infty )$ is the set of non-negative real numbers.
* $s_{0}={\underset {i\in D}{\times }}q_{0i}$ is the initial state set where $q_{0i}=(s_{0i},0)$ is the total initial state of component $i\in D$.
* $ta:S\rightarrow \mathbb {T} ^{\infty }$ is the time advance function, where $\mathbb {T} ^{\infty }=[0,\infty ]$ is the set of non-negative real numbers plus infinity. Given $s=(\ldots ,(s_{i},t_{ei}),\ldots )$, $ta(s)=\min\{ta_{i}(si)-t_{ei}|i\in D\}.$
* $\delta _{ext}:Q\times X\rightarrow S$ is the external state function. Given a total state $q=(s,t_{e})$ where $s=(\ldots ,(s_{i},t_{ei}),\ldots ),t_{e}\in (\mathbb {T} \cap [0,ta(s)])$, and input event $x\in X$, the next state is given by $\delta _{ext}(q,x)=s'=(\ldots ,(s_{i}',t_{ei}'),\ldots )$

where

$(s_{i}',t_{ei}')={\begin{cases}(\delta _{ext}(s_{i},t_{ei},x_{i}),0)&{\text{if }}(x,x_{i})\in C_{xx}\\(s_{i},t_{ei})&{\text{otherwise}}.\end{cases}}$

Given the partial state $s=(\ldots ,(s_{i},t_{ei}),\ldots )\in S$, let $IMM(s)=\{i\in D|ta_{i}(s_{i})=ta(s)\}$ denote the set of imminent components. The firing component $i^{*}\in D$ which triggers the internal state transition and an output event is determined by

$i^{*}=Select(IMM(s)).$

* $\delta _{int}:S\rightarrow S$ is the internal state function. Given a partial state $s=(\ldots ,(s_{i},t_{ei}),\ldots )$, the next state is given by $\delta _{int}(s)=s'=(\ldots ,(s_{i}',t_{ei}'),\ldots )$

where

$(s_{i}',t_{ei}')={\begin{cases}(\delta _{int}(s_{i}),0)&{\text{if }}i=i^{*}\\(\delta _{ext}(s_{i},t_{ei},x_{i}),0)&{\text{if }}(\lambda _{i^{*}}(s_{i^{*}}),x_{i})\in C_{yx}\\(s_{i},t_{ei})&{\text{otherwise}}.\end{cases}}$

* $\lambda :S\rightarrow Y^{\phi }$ is the output function. Given a partial state $s=(\ldots ,(s_{i},t_{ei}),\ldots )$, $\lambda (s)={\begin{cases}\phi &{\text{if }}\lambda _{i^{*}}(s_{i^{*}})=\phi \\C_{yy}(\lambda _{i^{*}}(s_{i^{*}}))&{\text{otherwise}}.\end{cases}}$

## View2: Total states = states * lifespan * elapsed times

Given a coupled DEVS model $N=<X,Y,D,\{M_{i}\},C_{xx},C_{yx},C_{yy},Select>$, its behavior is described as an atomic DEVS model $M=<X,Y,S,s_{0},ta,\delta _{ext},\delta _{int},\lambda >$

where

* $X$ and $Y$ are the input event set and the output event set, respectively.
* $S={\underset {i\in D}{\times }}Q_{i}$ is the partial state set where $Q_{i}=\{(s_{i},t_{si},t_{ei})|s_{i}\in S_{i},t_{si}\in \mathbb {T} ^{\infty },t_{ei}\in (\mathbb {T} \cap [0,t_{si}])\}$ is the total state set of component $i\in D$ (Refer to View2 of Behavior of DEVS).
* $s_{0}={\underset {i\in D}{\times }}q_{0i}$ is the initial state set where $q_{0i}=(s_{0i},ta_{i}(s_{0i}),0)$ is the total initial state of component $i\in D$.
* $ta:S\rightarrow \mathbb {T} ^{\infty }$ is the time advance function. Given $s=(\ldots ,(s_{i},t_{si},t_{ei}),\ldots )$, $ta(s)=\min\{t_{si}-t_{ei}|i\in D\}.$
* $\delta _{ext}:Q\times X\rightarrow S\times \{0,1\}$ is the external state function. Given a total state $q=(s,t_{s},t_{e})$ where $s=(\ldots ,(s_{i},t_{si},t_{ei}),\ldots ),t_{s}\in \mathbb {T} ^{\infty },t_{e}\in (\mathbb {T} \cap [0,t_{s}])$, and input event $x\in X$, the next state is given by $\delta _{ext}(q,x)=((\ldots ,(s_{i}',t_{si}',t_{ei}'),\ldots ),b)$

where

$(s_{i}',t_{si}',t_{ei}')={\begin{cases}(s_{i}',ta_{i}(s_{i}'),0)&{\text{if }}(x,x_{i})\in C_{xx},\delta _{ext}(s_{i},t_{si},t_{ei},x_{i})=(s_{i}',1)\\(s_{i}',t_{si},t_{ei})&{\text{if }}(x,x_{i})\in C_{xx},\delta _{ext}(s_{i},t_{si},t_{ei},x_{i})=(s_{i}',0)\\(s_{i},t_{si},t_{ei})&{\text{otherwise}}\end{cases}}$

and

$b={\begin{cases}1&{\text{if }}\exists i\in D:(x,x_{i})\in C_{xx},\delta _{ext}(s_{i},t_{si},t_{ei},x_{i})=(s_{i}',1)\\0&{\text{otherwise}}.\end{cases}}$

Given the partial state $s=(\ldots ,(s_{i},t_{si},t_{ei}),\ldots )\in S$, let $IMM(s)=\{i\in D|t_{si}-t_{ei}=ta(s)\}$ denote the set of imminent components. The firing component $i^{*}\in D$ which triggers the internal state transition and an output event is determined by

$i^{*}=Select(IMM(s)).$

* $\delta _{int}:S\rightarrow S$ is the internal state function. Given a partial state $s=(\ldots ,(s_{i},t_{si},t_{ei}),\ldots )$, the next state is given by $\delta _{int}(s)=s'=(\ldots ,(s_{i}',t_{si}',t_{ei}'),\ldots )$

where

$(s_{i}',t_{si}',t_{ei}')={\begin{cases}(s_{i}',ta_{i}(s_{i}'),0)&{\text{if }}i=i^{*},\delta _{int}(s_{i})=s_{i}',\\(s_{i}',ta_{i}(s_{i}'),0)&{\text{if }}(\lambda _{i^{*}}(s_{i^{*}}),x_{i})\in C_{yx},\delta _{ext}(s_{i},t_{si},t_{ei},x_{i})=(s',1)\\(s_{i}',t_{si},t_{ei})&{\text{if }}(\lambda _{i^{*}}(s_{i^{*}}),x_{i})\in C_{yx},\delta _{ext}(s_{i},t_{si},t_{ei},x_{i})=(s',0)\\(s_{i},t_{si},t_{ei})&{\text{otherwise}}.\end{cases}}$

* $\lambda :S\rightarrow Y^{\phi }$ is the output function. Given a partial state $s=(\ldots ,(s_{i},t_{si},t_{ei}),\ldots )$, $\lambda (s)={\begin{cases}\phi &{\text{if }}\lambda _{i^{*}}(s_{i^{*}})=\phi \\C_{yy}(\lambda _{i^{*}}(s_{i^{*}}))&{\text{otherwise}}.\end{cases}}$

## Time passage

Since in a coupled DEVS model with non-empty sub-components, i.e., $|D|>0$, the number of clocks which trace their elapsed times are multiple, so time passage of the model is noticeable.

### For View1

Given a total state $q=(s,t_{e})\in Q$ where $s=(\ldots ,(s_{i},t_{ei}),\ldots )$

If unit event segment $\omega$ is the null event segment, i.e. $\omega =\epsilon _{[t,t+dt]}$, the state trajectory in terms of Timed Event System is

$\Delta (q,\omega )=((\ldots ,(s_{i},t_{ei}+dt),\ldots ),t_{e}+dt).$

### For View2

Given a total state $q=(s,t_{s},t_{e})\in Q$ where $s=(\ldots ,(s_{i},t_{si},t_{ei}),\ldots )$

If unit event segment $\omega$ is the null event segment, i.e. $\omega =\epsilon _{[t,t+dt]}$, the state trajectory in terms of Timed Event System is

$\Delta (q,\omega )=((\ldots ,(s_{i},t_{si},t_{ei}+dt),\ldots ),t_{s},t_{e}+dt).$

## Remarks

* The behavior of a couple DEVS network whose all sub-components are deterministic DEVS models can be non-deterministic if $Select(IMM(s))$ is non-deterministic.
