Hybrid Coupled Model with Coordinator Functionalities
stored in DEVS_PATH/00-simulator/hybridcoupled.p
Is provided as p-code.
Contents
Based on modified parallel DEVS algorithms (Zeigler, Schwatinski) and wrapper extension (Deatcu). |
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)*, *set_Zid(obj,Zid)* and *set_CZid(obj,CZid)*. |
C. Deatcu 2016 |
Description
Class definition file for a hybrid coupled DEVS model and it's associated coordinator. Extends the discrete associated coordinator and model.
constructor call: obj = hybridcoupled(name,xportnames,yportnames), where xportnames and yportnames are optional
Superclass
coupled
Inherited properties
- sub_of : string, name of the superordinate model --> for debugging purposes
- tnext : float, time of next event
- tlast : float, time of last event
- name : string, (unique) name of this model --> for debugging purposes max. 12 characters for "nice" debug-look ;-)
- x : structure, set of inport name/input value pairs
- y : structure, set of outport name/output value pairs
- debug_flag: 0|1|2|3, no messages|messages|steps|visualize x, y, and s of atomic subcomponents (default 0))
- observe_flag: 0|1, log states of atomic subcomponents or not (default 0)
- Da : cell array of strings, names of atomic subcomponents
- Dc : cell array of strings, names of coupled subcomponents
- Zid : cell array of strings, "i-to-d-matrix" (couplings)
- components: array of objects, subcomponents
- eventlist : matrix with information on future events of subcomponents, eventlist = [a,b,c;...]
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)
Properties
- CZid: cell array of strings, "i-to-d-matrix" (continuous couplings)
Class methods
- i_msg(obj,gt) : initialization message - sets tlast and tnext at all subcomponents and sets matrix eventlist
- s_msg(obj,gt,flag): star message - called when coupled is imminent, sets tlast and tnext
- x_msg(obj,gt) : x message - called, if external event arrives
- y_msg(obj,gt) : inperpellation y message
- [obj,aSimObj,gstatvec,gevveclen,outoffs] = z_msg(obj,gt,soff,eoff): z message - vector configuration of continuous part
- obj = z2_msg(obj,gt,ioffs): z2 message - second run of vector configuration, setting indicies
- [obj,event_flag]=se_msg(obj,te,ye,ie): state event message - called when a state event occurred somewhere in entire model
Methods to Define Components and Couplings
- add_c_component(obj, comps): add one coupled subcomponent
- add_a_component(obj, comps): add one atomic subcomponent
- addcomponents(obj, comps): add one or more subcomponents of any kind ;-)
- set_Zid(obj, Zid): set Zid (one or more Lines)
Set Methods for Flags
- set_debug(obj,debug_flag): set debug flag to 0|1|2|3
- set_observe(obj,observe_flag): set observe flag to 0|1 (for tracking discrete states of atomic subcomponents)
Z_MSG
function [obj,aSimObj,gstatvec,gevveclen,outoffs]=z_msg(obj,gt,soff,eoff)
WHAT HAPPENS IN Z_MSG?
- message for vector configuration (for hybrid simulation only)
- collect references to all atomic subcomponents with continuous states in aSimObj
- collect continuous state variables in gstatvec
- collect number of events per atomic submodel in gevveclen
- collect indices of continuous output variables
Z2_MSG
function obj=z2_msg(obj,gt,ioffs)
WHAT HAPPENS IN Z2_MSG?
- message for vector configuration (for hybrid simulation only)
- second run for calculating and setting the index of local input variables
SE_MSG
function [obj,event_flag]=se_msg(obj,te,ye,ie)
WHAT HAPPENS IN SE_MSG?
- state event message
- is called when a state event occurred somewhere in entire model (for hybrid simulation only)
- send all subcomponents an se_message
- if state event occured in THIS model, set event_flag and calculate t_next
Functions for displaying the coupled objects
- function showxports(obj): display x-ports
- function showyports(obj): display y-ports
- function showsubcomponents(obj): display atomic and coupled subcomponents
- function showcouplings(obj): display coupling matrix
- function showeventlist(obj): display eventlist
- function showall(obj): display the entire object
These functions can be called to get some information during or after simulation.
DEVS Tbx Home Examples Modelbase << Back