devs m&s tutorial 2 chungman seo [email protected]
TRANSCRIPT
![Page 2: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/2.jpg)
Contents
DEVSJAVA Lib DEVS Interface
Expression of Atomic Model State Diagram
DEVSJAVA code Structure Atomic model Coupled model
Exercise : Fire once neuron
![Page 3: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/3.jpg)
DEVS Interface
DEVS Supporting Interface DEVS Modeling Interface DEVS Simulation Interface
![Page 4: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/4.jpg)
DEVS Supporting Interface
Provide a supporting environment for implementing DEVS implementations Basic data structures
Entity Content Message Port
interface EntityInterface{ String getName();boolean equalName(String name);}
interface Collection extends EntityInterface{ int size();void add(EntityInterface entity);void remove(EntityInterface entity);boolean contains(EntityInterface entity);}
EntityInterface Collection
0:n
![Page 5: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/5.jpg)
Message-related-Interfaces
ContentInterface A Pair of port-value
MessageInterface A collection of conten
tsContentInterface
MessageInterface
Collection
0:n
interface MessageInterface extends Collection{boolean onPort(
PortInterface port, ContentInterface content);
EntityInterface getValOnPort(PortInterface port,ContentInterface content);
}
PortInterface EntityInterface
interface ContentInterface {PortInterface getPort();EntityInterface getValue();boolean onPort(PortInterface port);}
interface PortInterfaceextends EntityInterface{
}
![Page 6: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/6.jpg)
Ensemble-Interface
ensembleBasic
Collection
interface ensembleBasic {void tellAll(Method m, EntityInterface[ ] args); ensembleCollection askAll(Method m); ensembleCollection which(Method m); EntityInterface whichOne(Method m);}
interface ensembleCollection extends ensembleBasic, Collection{public ensembleCollection copy(ensembleCollection ce);}
ensembleCollection
![Page 7: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/7.jpg)
DEVS Modeling Interfaces
IODevs
atomicDevs(optional)
interface basicDevs {void deltext(double e,MessageInterface x);void deltcon(double e,MessageInterface x);void deltint();MessageInterface Out(); double ta();void initialize();}
IOBasicDevs
basicDevs
coupledDevs
AtomicInterfaceCoupledinterface coupledDevs {void add(IODevs d);void addCoupling(IODevs src, Port p1, IODevs dest, Port p2);IODevs getComponentWithName(String nm);ensembleCollection getComponents();ensembleCollection getCouplings(IODevs src, Port p1);}
DevsInterface
interface IODevs {void addInport(String portName);void addOutport(String portName);ensembleCollection getInports();ensembleCollection getOutports();ContentInterface makeContent(PortInterface port,EntityInterface value);boolean messageOnPort(MessageInterface x, PortInterface port, ContentInterface c);}
![Page 8: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/8.jpg)
Extending the “Core” interfaces interface dynamicStructureInterface {
void addCoupling(String srcName, String p1, String destName, String p2);void removeCoupling(String srcName, String p1, String destName, String p2); void addModel(String ModelName); void removeModel(String ModelName); void addInport(String ModelName, String port); void addOutport(String ModelName, String port); void removeInport(String ModelName, String port);
![Page 9: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/9.jpg)
Simulator Interfaces
coreSimulatorInterface
atomicSimulatorInterface
CoupledSimulatorInterface
CoordinatorInterface
CoupledCoordinatorInterface
![Page 10: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/10.jpg)
State Diagram of Atomic Model :Generator
ActiveTa =
interArrivalTime PassiveTa = infinity
! out : Job
? stop
? start
! out
? start
? stop
Message type : Job
Variable : interArrivalTime, count
![Page 11: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/11.jpg)
State Diagram of Atomic Model :Processor
Variable : processing_time
passiveTa = infinity
busyTa =
processing_time
? in
! out : Job
Message type : Job
! out? in
![Page 12: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/12.jpg)
State Diagram of Atomic Model :Transducer
activeTa =
observation_time
? ariv
? solved
passiveTa = infinity
! out : entity
Variable : observation_time
? ariv
? solved
! out
Message type : Job , entity
![Page 13: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/13.jpg)
Mapping state diagram to Atomic DEVS model
ActiveTa =
interArrivalTime PassiveTa = infinity
! out : Job
? stop
? start
! out
? start
? stop
Message type : Job
Variable : interArrivalTime, count
? start? stop
! out
addInport("start");addInport("stop");addOutport("out");
ActiveTa =
interArrivalTime
! out : Job
public void deltint( ) { count = count +1; if(phaseIs("active")) holdIn("active",interArrivalTime); else passivate(); }
public message out( ) { return outputNameOnPort("job" + name+count,"out");}
ActiveTa =
interArrivalTime
PassiveTa = infinity
? stop
public void deltext(double e,message x) { Continue(e); if (phaseIs("passive")&& somethingOnPort(x,"start")) holdIn("active",interArrivalTime); if (phaseIs("active")&& somethingOnPort(x,"stop")) phase = "passive";}
? start
![Page 14: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/14.jpg)
Overall Structure of Atomic DEVS with DEVSJAVA
package gpt;import simView.*;import genDevs.modeling.*;import GenCol.*;public class Genr extends ViewableAtomic{ protected double interArrivalTime; protected int count; public Genr() {this("genr", 20);} public Genr(String name,double interArrivalTime){ super(name); addOutport("out"); addInport("stop"); addInport("start"); this.interArrivalTime = interArrivalTime ; addTestInput("start",new entity("")); addTestInput("stop",new entity("")); } public void initialize(){ holdIn("active", interArrivalTime); count = 0; super.initialize(); } public void deltext(double e,message x) { Continue(e); if (phaseIs("passive")&& somethingOnPort(x,"start")) holdIn("active",interArrivalTime); if (phaseIs("active")&& somethingOnPort(x,"stop")) phase = "passive"; } public void deltint( ) { count = count +1; if(phaseIs("active")) holdIn("active",interArrivalTime); else passivate(); } public void deltcon(double e,message x) { deltint(); deltext(0,x); } public message out( ) { return outputNameOnPort("job" + name+count,"out"); }}
DEVSJAVA LIB
SRC Folder
Class Name & DEVS Interface
Definition of variables
Constructors
Definition & Addition in-out ports
Variable setting
Test Input
Initialize DEVS Model
Definition of Delt external function
Definition of Delt internal function
Definition of Delt Confluent function
Definition of out message
![Page 15: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/15.jpg)
Overall Structure of Coupled DEVS with DEVSJAVA
package gpt;import java.awt.Dimension;import java.awt.Point;import genDevs.modeling.atomic;import genDevs.modeling.digraph;import genDevs.simulation.coordinator;import simView.*;public class Efp extends ViewableDigraph {
public Efp (){super("Efp");atomic proc = new Proc("Proc",25);digraph ef = new Ef("Ef",10,100);add(ef);add(proc);addCoupling(ef,"out",proc,"in");addCoupling(proc,"out",ef,"in");
}
public static void main(String[] args) {digraph efp = new Efp();coordinator rootCoordinator = new
coordinator(efp);rootCoordinator.initialize();rootCoordinator.simulate(Integer.MAX_VALUE);
}
/** * Automatically generated by the SimView program. * Do not edit this manually, as such changes will get overwritten. */ public void layoutForSimView() {ComputeLayout = false; preferredSize = new Dimension(760, 402); ((ViewableComponent)withName("Proc")).setPreferredLocation(new Point(590, 149)); ((ViewableComponent)withName("Ef")).setPreferredLocation(new Point(64, 30)); }}
SRC Folder
DEVSJAVA LIB
Class Name & DEVS Interface
Constructors
Definition of DEVS Models
Addition of DEVSModel instances
Addition of Coupling Info
Running DEVS Coupled Model
without SimView
![Page 16: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/16.jpg)
Exercise : Fire-Once Neuron
receptive refractInput
fireFiring delay >0
Out Fire-once Neuron
ta = ∞ ta = ∞
![Page 17: DEVS M&S Tutorial 2 Chungman Seo cseo@email.arizona.edu](https://reader030.vdocuments.mx/reader030/viewer/2022013115/56649f395503460f94c56864/html5/thumbnails/17.jpg)
State Diagram : Fire-Once Neuron
receptiveTa = infinity
fireTa = firing_delay
! out : entity
? Input
! out?Input
Message type : entity
Variable : firing_delay
refractTa = infinity