Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modelling DEVS applications The CD++ tool

Similar presentations


Presentation on theme: "Modelling DEVS applications The CD++ tool"— Presentation transcript:

1 Modelling DEVS applications The CD++ tool http://cell-devs.sce.carleton.ca/ http://www.sce.carleton.ca/faculty/wainer/CD++BuilderSetup.exe http://www.sce.carleton.ca/faculty/wainer/setupCDpp.exe

2 n Atomic: lowest level model, contains structural dynamics -- model level modularity n Coupled: composed of one or more atomic and/or coupled models -- hierarchical construction Elements of an atomic model: n input ports n output ports n state variables n state transition functions n output function n time advance function Elements of coupled model: n Components n Couplings –Internal Couplings –External Input Couplings –External Output Couplings Review of the DEVS formalism

3 n Algorithmic languages n State-based languages n DEVS graph –Node : sequential state –Arc : (X  Y  {S})  ta(S) Internal transition External transition out ! y= (s 0 ) Internal Transition (i) ta(s 0 ) (ii) out =  (s 0 ),  int (s 0 )=s 1 External Transition  ext (s 0, t, (x,in))=s 2 DEVS graphs out ! (s 0 ) in ? x,t

4 DEVS graphs definition [modelname] atomic or coupled model name I/O ports: in : inport1 inport2... out : outport1 outport2... Internal transitions: int:source destination [outport!value]* ( { (action;)* } ) (Action: complex function to generate an output). External transitions : ext : source destination EXPRESSION ( { (action;)* } )? value

5 DEVS graphs definition n States (bubbles) n Internal transitions (dotted lines) n Output_port!output_value n External transitions (full lines) Input_port?input_value n I/O ports TL=inf TL=100 s

6 DEVS graphs analytical specification [myAtomic] in: Port1 PortY out: PortX state: Start Process Finish int: Process Finish PortX!1 ext: Start Process Value(Port1)?0 ext: Finish Start Value(PortY)?1 Start: 0:0:10:0 Process: 0:0:10:0 Finish: 0:0:10:0

7 CD++ (1997/98) Basic tool following DEVS formalism. Extension to include Cell-DEVS models. High level specification language.

8 Example: Robot Vehicle Model

9

10 Autonomous Reconnaissance Vehicle n Radar Controller Atomic model

11 Autonomous Reconnaissance Vehicle n Movement Controller

12 n holdIn(state, time) n passivate() n timelast() n timenext() n sendOutput(time, port, value) n state() n distribution().get() CD++ programming services

13 Adding new atomic models n Atomic model definitions  initFunction  externalFunction  outputFunction  internalFunction n Linking with the abstract simulator  registerNewAtomic

14 Generator out zRepresents a generator of impulses represented by consecutive natural numbers. zPeriod between impulses defined by a random function using different distributions (Chi 2, Gamma, Normal, etc.). Generator model: description 0, 1, 2,... f(t) =... Implementing atomic models

15 n External transition function: none (model does not include input ports) n Internal transition function: generates numbers according to a specified probability distribution. n Output function: sends following consecutive natural number through the out port. Transition functions Atomic model Generator Output Port : out 0, 1, 2,...  ext  int Generator: conceptual definition

16 class Generator:public Atomic { public:... protected: Model &initFunction() ; Model &externalFunction(const ExternalMessage &); Model &internalFunction(const InternalMessage &); Model &outputFunction(const InternalMessage&); private: int next; int initial; Port &out ; Distribution *distribution ; }; Generator model: header files

17 CD++ - initFunction Model &initFunction(){ this->next = this->initial; this->holdIn(Atomic::active, Time::Zero) ; return *this ; } Programmed to have an Instantaneous internal trans. Generator: coding example

18 CD++ - internalFunction Model &internalFunction(const InternalMessage &) { this->next++ ; Time t(fabs(this->distribution().get()) ) ; this->holdIn(active, t) ; return *this ; } Reprogrammed for the following internal transition. Obtains the time value by computing a probabilistic function Generator (cont.)

19 CD++ - outputFunction Model &outputFunction(const InternalMessage &msg) { this->sendOutput(msg.time(), this->out, this->next); return *this ; } The output value increments sequentially Generator (cont.)

20 out gen CD++ - Coupling scheme [top] components : gen@Generator out : Myout Link : out@gen Myout [gen] distribution : normal mean : 2 deviation : 1 top Myout Generator: stand-alone testing

21 Description zIt is in charge of computing the number of jobs finished in a given time unit. zIt computes the usage ratio for the server (a CPU in this case). zIt transfers the outputs with a given frequency. Transducer Jobs Transducer model

22 n The external transition function is in charge of record the jobs received and those finished. n The internal transition function should be activated in the following job burst. n The output function will send the metrics through output ports. DEVS Atomic Model Transducer cpuusage  ext  int arrived throughput solved Outputs Inputs Transducer model : conceptual definition

23 CD++ class Transducer: public Atomic { public:. protected: Model &initFunction(); Model &externalFunction(const ExternalMessage&); Model &internalFunction(const InternalMessage&); Model &outputFunction(const InternalMessage&); private: const Port &arrived, &solved ; Port &throughput, &cpuUsage ; Time frec, tUnit ; long procCount, cpuLoad ; JobsList unsolved ; }; Transducer: header files

24 Transducer: coding example CD++ - initFunction Model &initFunction() { cpuLoad = procCount = 0 ; unsolved.erase() ; this->holdIn( active, this->frequence() ) ; return *this ; } The results are sent with a predefined frequency. State variables initialization

25 CD++ - externalFunction Model &externalFunction( const ExternalMessage &msg ) { Time dif = ( msg.time() - this->lastChange() ) ; cpuLoad += dif.asMsecs() * unsolved.size() if( msg.port() == arrived ) unsolved[ msg.value() ] = msg.time() ; if( msg.port() == solved ) { procCount ++ ; unsolved.erase( msg.value() ) ; } return *this ; } Record a non- finished job Update the number of tasks CPU load Transducer (cont.)

26 CD++ - internalFunction Model &internalFunction( const InternalMessage & ) { this->holdIn( active, this->frequence() ) ; return *this ; } Programmed to inform the results with a certain frequency Transducer (cont.)

27 CD++ - outputFunction Model &outputFunction( const InternalMessage &msg ) { long ms = msg.time().asMsecs() ; float t( ms / this->timeUnit().asMsecs() ) ; Time dif = ( msg.time() - this->lastChange() ) ; cpuLoad += dif.asMsecs() * unsolved.size() ) ; this->sendOutput( msg.time(),throughput,procCount/t ); this->sendOutput( msg.time(),cpuUsage, cpuLoad / ms ); return *this ; } Transducer (cont.)

28 CPU model CPU out zA processor running individual tasks in a non preemptive fashion. zExecution time for each tasks defined by a probability distribution chosen by the user. Description 0, 1, 2,... f(t) =... in 0, 1, 2,...

29 CPU: conceptual definition n External transition function starts the processing a task. Internal transition scheduled for the end of the job, defined at random. If model already processing a task, new one is discarded. n Internal transition function finishes processing the job, leaving the model in a passive state waiting for new jobs. n Output function sends the job id trhough the output port out. Atomic Model CPU  ext  int out 0, 1, 2,... in 0, 1, 2,...

30 CPU: header files CD++ class CPU : public Atomic { public:. protected: Model &initFunction() ; Model &externalFunction(const ExternalMessage&); Model &internalFunction(const InternalMessage &); Model &outputFunction(const InternalMessage&); private: int pid; Port &in, &out ; Distribution *distribution ; };

31 CPU: coding example CD++ - initFunction Model &initFunction() { this->passivate() ; return *this ; } Passive state kept while cpu waits for new external events in input ports.

32 CD++ - externalFunction Model &externalFunction(const ExternalMessage &msg) { if( this->state() == passive ) { this->pid = static_cast (msg.value()) ; Time t( fabs(this->distribution().get()) ) ; this->holdIn(active, t) ; } return *this ; } Process Id stored. Schedule internal transition at random using the chosen distribution. CPU (Cont.)

33 CD++ - internalFunction Model &internalFunction( const InternalMessage & ) { this->passivate() ; return *this ; } Task processing finished. Passivate waiting for the following request. CPU (Cont.)

34 CD++ - outputFunction Model &outputFunction( const InternalMessage &msg ) { this->sendOutput(msg.time(), this->out, this->pid); return *this ; } Send Process Id and time associated with end of processing for the present task. CPU (Cont.)

35 CD++ - Coupling specification [top] components : proc@CPU in : in out : out Link : in in@proc Link : out@proc out [proc] distribution : normal mean : 2 deviation : 1 out proc top out in CPU model testing

36 out proc CD++ - External event file (.EV) 00:00:10:00 in 0 00:00:30:00 in 1 00:01:00:00 in 2 00:02:20:00 in 3 top out in Hh:mm:ss:ms Input port used Job Id Input events to test

37 Mensaje I / 00:00:00:000 / Root(00) para top(01) Mensaje I / 00:00:00:000 / top(01) para proc(02) Mensaje D / 00:00:00:000 / proc(02) /... para top(01) Mensaje D / 00:00:00:000 / top(01) /... para Root(00) Mensaje X / 00:00:10:000 / Root(00) / in / 0.000 para top(01) Mensaje X / 00:00:10:000 / top(01) / in / 0.000 para proc(02) Mensaje D / 00:00:10:000 / proc(02) / 00:00:01:348 para top(01) Mensaje D / 00:00:10:000 / top(01) / 00:00:01:348 para Root(00) Mensaje * / 00:00:11:348 / Root(00) para top(01) Mensaje * / 00:00:11:348 / top(01) para proc(02) Mensaje Y / 00:00:11:348 / proc(02) / out / 0.000 para top(01) Mensaje D / 00:00:11:348 / proc(02) /... para top(01) Mensaje Y / 00:00:11:348 / top(01) / out / 0.000 para Root(00) Mensaje D / 00:00:11:348 / top(01) /... para Root(00) Mensaje X / 00:00:30:000 / Root(00) / in / 1.000 para top(01) Mensaje X / 00:00:30:000 / top(01) / in / 1.000 para proc(02) Mensaje D / 00:00:30:000 / proc(02) / 00:00:03:485 para top(01) CD++ - Simulation Log file

38 CD++ - Output file 00:00:11:348 out 0 00:00:33:485 out 1 00:01:00:328 out 2 00:02:21:094 out 3 Hh:mm:ss:ms Output Port Job Id Output file


Download ppt "Modelling DEVS applications The CD++ tool"

Similar presentations


Ads by Google