A coupled model is a DEVS model composed by a combination of atomic, coupled or both models. Like other DEVS models, a coupled model has input and output ports, that have to be connected to the internal components of the coupled model. Each input port will be connected to an input port of a component. Each ouptut port will be connected to one or more output ports of one or several components.
The following images show examples of DEVS coupled models.
Coupled DEVS models can be developed easyly using DEVSlib. The library includes the coupledDraft model that contains the basic structure for a coupled model. The steps to build a new coupled model are:
The following figure shows a simple coupled DEVS model (corresponds to the NetSwitch
model of the library examples).
Due to the design (queues that receive messages) and implementation (external C structures dynamically managed) of the communication mechanism between models in the DEVSLib package, it is not possible to connect the same output port of a component to several input ports of other components.
However, to provide a solution to this restriction, a DEVS model that provides the duplication of messages has been included in the library. This model is included in the AuxModels package, and it is called DUP. The DUP model sends a copy of each received message through its two output ports. If more that two copies of the same message are needed, several DUP models can be nested in multiple levels. (to simplify this procedure a DUP3 model with three output ports has been included in the Auxmodels package).
An example of DUP usage is provided in the testDup model, and is shown in the next figure.
During the construction of coupled models algebraic loops can be created. This problem can be avoided in two ways:
The BreakLoop model breaks the loop by including a "pre" statement in the detection of the incomming messages.
An example of BreakLoop usage is provided in the testSwitch2 model, and is shown in the next figure.