Coupled Object with Coordinator Functionalities

stored in DEVS_PATH/00-simulator/coupled.p

Is provided as p-code.

Contents

Based on modified parallel DEVS algorithms (Zeigler, Schwatinski).
User defined coupled models can be created as instances of this class directly or can be derived from it alternatively. For initialization, the modeler has to define input and output portnames. Components and coupling information are defined after instantiation via the methods *addcomponents(obj,comps)* and *set_Zid(obj,Zid)*.
C. Deatcu 2016

Description

Class definition file for a coupled DEVS model and it's associated coordinator

constructor call: obj = coupled(name,xportnames,yportnames), where xportnames and yportnames are optional

Superclass

devs

Inherited properties

Properties

eventlist = [a,b,c;...]
a - time for next transition
b - {1,2} | 1 if atomic DEVS, 2 if coupled DEVS
c - index for eventlist (position in Da or Dc)

Class methods

Simulation Messages

Methods to Define Components and Couplings

Set Methods for Flags

i_MSG

function i_msg(obj,gt)

WHAT HAPPENS IN I_MSG?

eventlist = [a,b,c;...]
a - time for next transition
b - {1,2} | 1 if atomic DEVS, 2 if coupled DEVS
c - index for eventlist (position in Da or Dc)

eventlist is NOT sorted by smallest tnext

S_MSG

function s_msg(obj,gt,flag)

WHAT HAPPENS IN S_MSG?

flag == 1 --> s_msg from ROOT, flag == 0 --> s_msg from other

Y_MSG

function y_msg(obj,gt)
it is an interpellation y_msg

WHAT HAPPENS IN Y_MSG?

X_MSG

function x_msg(obj,gt)

WHAT HAPPENS IN X_MSG?

Methods for Displaying the Coupled Objects

These functions can be called to get some information during or after simulation.

Example: How to Create a Coupled Model

>> newcoupled = coupled('model', {'inport1', 'inport2'}, {'outport1'});% incarnate with portnames

OR

>> newcoupled = coupled('model'); % incarnate without portnames
>> set_x_ports(newcoupled, {'inport1','inport2'}); % set x and y ports
>> set_y_ports(newcoupled, {'outport1'});

then add subcomponents

>> subcomponent1 = coupled('sub1', {'in1','in2'},{'out1'}); % incarnate subcomponents
>> set_Zid(subcomponent1,{'parent','in2','parent','out1'}); % dummy Zid
>> subcomponent2 = coupled('sub2', {'in1'}, {'out1'});
>> set_Zid(subcomponent2,{'parent','in1','parent','out1'}); % dummy Zid
>> addcomponents(newcoupled, {subcomponent1, subcomponent2}); % add components to model

then add couplings

>> Zid = {'parent','inport2','sub1','in1';...   % define Zid
          'parent','inport1','sub2','in1';...
          'sub2','out1','sub1','in2';...
          'sub2','out1','parent','outport1'};
>> set_Zid(newcoupled, Zid);

check your model

>> Check(newcoupled); % check recursively if all names and ports really exist





DEVS Tbx Home      Examples      Modelbase           << Back