ebook img

An Introduction to Classic DEVS PDF

0.92 MB·
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview An Introduction to Classic DEVS

An Introduction to Classic DEVS YentlVan Tendeloo∗ Hans Vangheluwe∗†‡ {Yentl.VanTendeloo,Hans.Vangheluwe}@uantwerpen.be Abstract DEVSisapopularformalismformodellingcomplexdynamicsystemsusingadiscrete-eventabstraction. Atthisabstraction 7 level,atimedsequenceofpertinent“events”inputtoasystem(orinternal,inthecaseoftimeouts)causeinstantaneouschanges 1 tothestateofthesystem. Betweenevents,thestatedoesnotchange, resultinginaapiecewiseconstantstatetrajectory. Main 0 advantagesofDEVSareitsrigorousformaldefinition,anditssupportformodularcomposition. 2 ThischapterintroducestheClassicDEVSformalisminabottom-upfashion,usingasimpletrafficlightexample.Thesyntax n andoperationalsemanticsofAtomic(i.e.,non-hierarchical)modelsareintrucedfirst. ThesemanticsofCoupled(hierarchical) a modelsisthengivenbytranslationintoAtomicDEVSmodels. Asthisformal“flattening”isnotefficient,amodular abstract J simulator which operates directly on the coupled model is also presented. Thisis the common basis for subsequent efficient 6 implementations. Wecontinue toactual applicationsof DEVSmodelling andsimulation, asseen inperformance analysisfor 2 queueingsystems. Finally,wepresentsomeoftheshortcomingsintheClassicDEVSformalism,andshowsolutionstothemin theformofvariantsoftheoriginalformalism. ] H 1 Introduction O . s DEVS[17]isapopularformalismformodellingcomplexdynamicsystemsusingadiscrete-eventabstraction.Atthisabstraction c level, a timed sequence of pertinent“events” inputto a system cause instantaneouschanges to the state of the system. These [ eventscanbegeneratedexternally(i.e.,byanothermodel)orinternally(i.e.,bythemodelitselfduetotimeouts).Thenextstateof 1 thesystemisdefinedbasedonthepreviousstateofthesystemandtheevent.Betweenevents,thestatedoesnotchange,resulting v in a piecewise constantstate trajectory. Simulation kernels must only consider states at which events occur, skipping over all 7 intermediate points in time. This is in contrast with discrete time models, where time is incremented with a fixed increment, 9 6 and onlyat these times is the state updated. Discrete eventmodelshave the advantagethat their time granularitycan become 7 (theoretically)unbounded,whereastimegranularityisfixedindiscretetimemodels. Nonetheless,theaddedcomplexitymakes 0 itunsuitedforsystemsthatnaturallyhaveafixedtimestep. . 1 Main advantagesof DEVS comparedto other discrete eventformalismsare its rigoroursformaldefinition, and its supportfor 0 modularcomposition.ComparablediscreteeventformalismsareDESandStatecharts,thoughsignificantdifferencesexist. 7 1 Compared to DES, DEVS offers modularity which makes it possible to nest models inside of components, thus generating : a hierarchy of models. This hierarchy necessitates couplings and (optionally) ports, which are used for all communication v i betweentwocomponents.Incontrast,DESmodelscandirectlyaccessothermodelsandsendthemeventsintheformofmethod X invocation.Additionaly,DEVSoffersacleanersplitbetweenthesimulationmodelandthesimulationkernel. r a ComparedtoStatecharts,DEVSoffersamorerigorousformaldefinitionandadifferentkindofmodularity. Statechartsleaves a lot of room for interpretation, resulting in a wide variety of interpretations[7, 6]. In contrast, DEVS is completely formally defined,andthereisareferencealgorithm(i.e.,anabstractsimulator).WhilebothDEVSandStatechartsaremodularformalisms, Statechartscreateshierarchiesthroughcompositestates,whereasDEVSusescompositemodelsforthispurpose.Bothhavetheir distinctadvantages,makingbothvariantsusefulinpractice. Thischapterprovidesan introductorytextto DEVS (oftenreferredto asClassicDEVS nowadays)throughtheuse of a simple examplemodelinthedomainoftrafficlights. Westartfromasimpleautonomoustrafficlight,whichisincrementallyextended uptoatrafficlightwithpolicemaninteraction.EachincrementservestointroduceanewcomponentoftheDEVSformalismand thecorresponding(informal)semantics.Westartwithatomic(i.e.,non-hierarchical)modelsinSection2,andintroducecoupled (i.e.,hierarchical)modelsinSection3. Anabstractsimulator,definingthereferencealgorithm,iscoveredinSection4. Section5 movesawayfromthetrafficlightexampleandpresentsamodelofasimplequeueingsystem. EventhoughDEVScertainlyhas itsapplications,severalvariantshavespawnedtotacklesomeofitsshortcomings. Thesevariants,togetherwitharationaleand thedifferences,arediscussedinSection6. Finally,Section7summarizesthechapter. ∗UniversityofAntwerp,Belgium †FlandersMake,Belgium ‡McGillUniversity,Montréal,Canada 1 Red 60s Yellow 3s Green 57s e=0 Figure2:ModelgeneratingtraceinFigure1. Figure1: Traceoftheautonomoustrafficlight. 2 Atomic DEVS models We commence our explanation of DEVS with the atomic models. As their name suggests, atomic models are the indivisable buildingblocksofamodel. Throughoutthis section, we build up the complete formalspecification of an atomic model, introducingnew conceptsas they becomerequired.Ineachintermediatestep,weshowandexplaintheconceptsweintroduce,howtheyarepresentintherunning example,andhowthisinfluencesthesemantics.Thedomainwewilluseasarunningexamplethroughoutthischapterisasimple trafficlight. 2.1 AutonomousModel Thesimplestformofatrafficlightisanautonomoustrafficlight. Lookingatitfromtheoutside,weexpecttoseeatracesimilar tothatofFigure1. Visually,Figure2presentsanintuitiverepresentationofamodelthatcouldgeneratethiskindoftrace. TryingtoformallydescribeFigure2,wedistinguishtheseelements: 1. StateSet(S) Themostobviousaspectofthetrafficlightisthestateitisin,whichisindicatedbythethreedifferentcoloursitcanhave. Thesestates are sequential: the trafficlightcanonlybe inone ofthese states atthe sametime1. Theset ofstates is not limitedtoenumerationstyleaspresentedhere,butcancontainanarbitrarynumberofattributes. S:×n S i=1 i 2. TimeAdvance(ta) 1Incontrastto,say,Statecharts. 2 Foreachofthestatesjustdefined,wenoticethetimeoutinthem. Clearly,somestatestakelongertoprocessthanothers. Forexample,whereaswewillstayingreenandredarelativelylongtime,thetimeintheyellowstateisonlybrief. This functionneedstobedefinedforeachandeveryelementofthestate set, andneedstodeterministicallyreturnaduration. The durationcan be any positive real number, includingzero and infinity. A negativetime is disallowed, as this would requiresimulationtogobackintime. DEVSallowsatimeadvanceofexactlyzero,eventhoughthisisimpossibleinreal life. Twousecasesforthisexist:thedelaymightbeverysmallandirrelevanttotheproblemwearemodelling,orthestate isanartificialstate,withoutanyreal-worldequivalent(e.g.,aspartofadesignpattern).NotethatDEVSdoesnotconsider time bases, despite the use of secondsin our visualization. Simulation time is just a realnumber, and the interpretation giventoitisuptotheuser. Whethertheseunitsindicateseconds,years,orevenp seconds,iscompletelyuptotheusers, aslongasitisfixedthroughoutthesimulation. ta:S→R+ 0,+¥ 3. InternalTransition(d ) int Withthestatesandtimeoutsdefined,thefinalpartisthedefinitionofwhichisthenextstatefromagivenstate. Thisisthe joboftheinternaltransitionfunction,whichgivesthenextstateforeachandeverystate. Asitisafunction,everystate hasatmostonenextstate,preventinganypossibleambiguity.Notethatthefunctiondoesnotnecessarilyhavetobetotal, norinjective:somestatesmightnothaveanextstate(i.e.,ifthetimeadvancewasspecifiedas+¥ ),andsomestateshave thesamestateasnextstate. Uptonow,onlytheinternaltransitionfunctionisdescribedaschangingthestate. Therefore, itisnotallowedforotherfunctions(e.g.,timeadvance)tomodifythestate: theirstateaccessisread-only. d :S→S int 4. InitialTotalState(q ) init We also needto definethe initialstate ofthesystem. WhilethisisnotpresentintheoriginalspecificationoftheDEVS formalism,weincludeithereasitisavitalelementofthemodel.Butnotethat,insteadofbeingan“initialstate(s )”,it init isatotalstate. Thismeansthatwenotonlyselecttheinitialstateofthesystem,butalsodefinehowlongwearealreadyin thisstate. Elapsedtimeisthereforeaddedtothedefinitionoftheinitialtotalstate,toallowmoreflexibilitywhenmodelling asystem. Tothesimulator,itwillseemasifthemodelhasalreadybeenintheinitialstateforsometime. q :(s,e)|s∈S,0≤e≤ta(s) init WedescribethemodelinFigure2asa4-tupleofthesethreeelements. hS,q ,d ,tai init int S={GREEN,YELLOW,RED} qinit =(GREEN,0.0) d int ={GREEN→YELLOW, YELLOW→RED, RED→GREEN} ta={GREEN→delaygreen, YELLOW→delayyellow, RED→delayred} Forthissimpleformalism,wedefinethesemanticsasinAlgorithm1. Themodelisinitializedwithsimulationtimesetto0,and thestatesettotheinitialstate(e.g.,GREEN).Simulationupdatesthetimewiththereturnvalueofthetimeadvancefunction,and executestheinternaltransitionfunctiononthecurrentstatetogetthenewstate. 2.2 AutonomousModelWithOutput RecallthatDEVSwasamodularformalism,withonlytheatomicmodelhavingaccesstoitsinternalstate. Thisnaturallyraises aproblemforourtrafficlight:othershavenowayofknowingitscurrentstate(i.e.,itscolour). Wethereforewantthetrafficlighttooutputitscolour,inthiscaseintheformofastring(andnotastheelementofanenumera- tion). Fornow,theoutputistightlylinkedtothesetofstate,butthisdoesnotneedtobethecase: thepossiblevaluestooutput can be completely distinct from the set of states. Our desired trace is shown in Figure 3. We see that we now output events 3 Algorithm1DEVSsimulationpseudo-codeforautonomousmodels. time←0 current_state←initial_state last_time←−initial_elapsed whilenottermination_condition()do time←last_time+ta(current_state) current_state←d (current_state) int last_time←time endwhile indicatingthestartofthespecifiedperiod.Recall,also,thatDEVSisadiscreteeventformalism:theoutputisonlyasingleevent indicatingthetimeandisnotacontinuoussignal.Thereceiveroftheeventthuswouldhavetostoretheeventtoknowthecurrent stateofthetrafficlightatanygivenpointintime. Visually,themodelisupdatedtoFigure4,usingtheexclamationmarkona transitiontoindicateoutputgeneration. Analysingtheupdatedmodel,weseethattwomoreconceptsarerequiredtoallowforoutput. 1. OutputSet(Y) Similarly to defining the set of allowable states, we should also define the set of allowable outputs. This set serves as aninterfacetoothercomponents,definingtheeventstheexpectstoreceive. Eventscanhavecomplexattributesaswell, thoughweagainlimitourselftosimpleeventsfornow.Ifportsareused,eachporthasitsownoutputset. Y :×l Y i=1 i 2. OutputFunction(l ) With the set of allowable events defined, we still need a function to actually generate the events. Similar to the other functions,theoutputfunctionisdefinedonthestate, anddeterministicallyreturnsanevent(ornoevent). Asseeninthe Figureofthemodel,theeventisgeneratedbeforethenewstateisreached. Thismeansthatinsteadofthenewstate, the output function still uses the old state (i.e., the one that is being left). For this reason, the output function needs to be invokedrightbeforetheinternaltransitionfunction. Inthecaseofourtrafficlight,theoutputfunctionneedstoreturnthe nameofthenextstate,insteadofthecurrentstate. Forexample,iftheoutputfunctionreceivestheGREEN stateasinput, itneedstogenerateashow_yellowevent. Similartothetimeadvancefunction,thisfunctiondoesnotoutputanewstate,andthereforestateaccessisread-only.This mightrequiresomeworkarounds:outputtinganeventoftenhassomerepercussionsonthemodelstate,suchasremoving theeventfromaqueueorincreasingacounter. Sincethestatecan’tbewrittento,thesechangesneedtoberemembered andexecutedassoonastheinternaltransitionisexecuted. Notethatitispossiblefortheoutputfunctionnottoreturnanyoutput,inwhichcaseitreturnsf . l :S→Y∪{f } Themodelcanbedescribedasa6-tuple. hY,S,q ,d ,l ,tai init int Y ={show_green,show_yellow,show_red} S={GREEN,YELLOW,RED} qinit =(GREEN,0.0) d int ={GREEN→YELLOW, YELLOW→RED, RED→GREEN} l ={GREEN→show_yellow, YELLOW→show_red, RED→show_green} ta={GREEN→delaygreen, YELLOW→delayyellow, RED→delayred} 4 Red 60s !show_green !show_red Yellow 3s !show_yellow Green 57s e=0 Figure4:ModelgeneratingtraceinFigure3. Figure3:Traceoftheautonomoustrafficlightwithoutput. Thepseudo-codeisslightlyalteredtoincludeoutputgeneration,asshowninAlgorithm2. Recallthatoutputisgeneratedbefore theinternaltransitionisexecuted,sothemethodinvocationhappensrightbeforethetransition. Algorithm2DEVSsimulationpseudo-codeforautonomousmodelswithoutput. time←0 current_state←initial_state last_time←−initial_elapsed whilenottermination_condition()do time←last_time+ta(current_state) output(l (current_state)) current_state←d (current_state) int last_time←time endwhile 2.3 InterruptableModel Ourcurrenttrafficlightspecificationisstillcompletelyautonomous.Whilethisisfineinmostcircumstances,policemightwant to temporarily shut down the traffic lights, when they are managing traffic manually. To allow for this, our traffic light must processexternalincomingevents: theeventfromthepolicemantoshutdownandtostartupagain. Figure5showsthetracewe wishtoobtain.AmodelgeneratingthistraceisshowninFigure6,usingaquestionmarktoindicateeventreception. WeoncemorerequiretwoadditionalelementsintheDEVSspecification. 1. InputSet(X) Similartotheoutputset,weneedtodefinetheeventsweexpecttoreceive.Thisisagainadefinitionoftheinterface,such 5 ?manual Red 60s !show_green ?automatic !show_red Manual ?manual Yellow s 3s (cid:0) !show_yellow ?manual Green e=0 57s Figure 6: Naive model that should generate thetraceinFigure5(butdoesn’t). Figure5: Traceoftheautonomoustrafficlight. thatothersknowwhicheventsareunderstoodbythismodel. X =×m X i=1 i 2. ExternalTransition(d ) ext Similartotheinternaltransitionfunction,theexternaltransitionfunctionisallowedtodefinethenewstateaswell. First andforemost,theexternaltransitionfunctionisstilldependentonthecurrentstate,justliketheinternaltransitionfunction. The externaltransitionfunctionhasaccess to two morevalues: the elapsed time, and the inputevent. The elapsed time indicates how long it has been for this atomic modelsince the last transition (either internal or external). Whereas this numberwasimplicitlyknownintheinternaltransitionfunction(i.e.,thevalueofthetimeadvancefunction),hereitneeds tobepassedexplicitly. Elapsedtimeisanumberintherange[0,ta(s)],withsbeingthecurrentstateofthemodel. Note thatitisinclusiveofboth0andta(s):itispossibletoreceiveaneventexactlyafteratransitionhappened,orexactlybefore aninternaltransitionhappens. Thecombinationofthecurrentstateandtheelapsedtimeisoftencalledthetotalstate(Q) ofthemodel.Wehavepreviouslyseenthetotalstate,inthecontextoftheinitialtotalstate. Thereceivedeventisthefinal parameter to this function. A new state is deterministically defined through the combinationof these three parameters. Sincetheexternaltransitionfunctiontakesmultipleparameters,multipleexternaltransitionsmightbedefinedforasingle state. d :Q×X→S ext Q={(s,e)|s∈S,0≤e≤ta(s)} While we now have all elements of the DEVS specification for atomic models, we are not done yet. When we include the additionalstate MANUAL, wealso needtosendoutanoutputmessageindicatingthatthetrafficlightisoff. Butrecallthatan outputfunctionwas only invokedbeforean internaltransition function, so not beforean externaltransitionfunction. To have an output nonetheless, we need to make sure that an internal transition happens before we actually reach the MANUAL state. This can be done through the introduction of an artificial intermediate state, which times out immediately, and sends out the 6 To !show_red Red Automatic 0s 60s !show_green ?manual ?automatic !show_red Manual Yellow s 3s (cid:0) !show_black !show_yellow ?manual To Green Manual 57s e=0 0s ?manual Figure8:ModelgeneratingtraceinFigure7. Figure7:Traceoftheinterrupttrafficlightwithcorrectedartificialstates. show_blackevent. Insteadofgoingto MANUAL uponreceptionofthemanualevent,wegototheartificialstate TOMANUAL. Thetimeadvanceofthisstate issetto0, sinceitisonlyanartificialstate withoutanymeaninginthedomainunderstudy. Its output function will be triggered immediately due to the time advance of zero, and the show_black outputis generated while transferringtoMANUAL. Similarly,whenwereceivetheautomaticevent,weneedtogotoanartificialTOAUTOMATICstateto generatetheshow_redevent. AvisualizationofthecorrectedtraceandcorrespondingmodelisshowninFigure7andFigure8 respectively. Finally,wegivethefullspecificationofthetrafficlightasanatomicDEVSmodel,definedbya8-tuple. hX,Y,S,q ,d ,d ,l ,tai init int ext 7 X ={automatic,manual} Y ={show_green,show_yellow,show_red,show_black} S={GREEN,YELLOW,RED,TOMANUAL,TOAUTOMATIC,MANUAL} qinit =(GREEN,0.0) d int ={GREEN→YELLOW, YELLOW→RED, RED→GREEN, TOMANUAL→MANUAL, TOAUTOMATIC→RED} d ext ={(GREEN,_,manual)→TOMANUAL (YELLOW,_,manual)→TOMANUAL (RED,_,manual)→TOMANUAL (MANUAL,_,automatic)→TOAUTOMATIC} l ={GREEN→show_yellow, YELLOW→show_red, RED→show_green, TOMANUAL→show_black, TOAUTOMATIC→show_red} ta={GREEN→delaygreen, YELLOW→delayyellow, RED→delayred, MANUAL→+¥ , TOMANUAL→0, TOAUTOMATIC→0} Algorithm 3 presents the complete semantics of an atomic model in pseudo-code. Similar to before, we still have the same simulationloop,butnowwecanbeinterruptedexternally.Ateachtimestep,weneedtodeterminewhetheranexternalinterrupt is scheduled before the internal interrupt. If that is not the case, we simply continue like before, by executing the internal transition.Ifthereisanexternaleventthatmustgofirst,weexecutetheexternaltransition. Algorithm3DEVSsimulationpseudo-codeforinterruptablemodels. time←0 current_state←initial_state last_time←−initial_elapsed whilenottermination_condition()do next_time←last_time+ta(current_state) iftime_next_event≤next_timethen elapsed←time_next_event−last_time current_state←d ((current_state,elapsed),next_event) ext time←time_next_event else time←next_time output(l (current_state)) current_state←d (current_state) int endif last_time←time endwhile 8 3 Coupled DEVS models Whileourtrafficlightexampleisabletoreceiveandoutputevents,therearenootheratomicmodelstocommunicatewith. To combinedifferentatomicmodelstogetherandhavethemcommunicate,wenowintroducecoupledmodels. Thiswillbedonein thecontextofourprevioustrafficlight,whichisconnectedtoapoliceman.Thedetailsofthetrafficlightareexactlylikebefore; thedetailsofthepolicemanareirrelevanthere,aslongasitoutputsautomaticandmanualevents. 3.1 BasicCoupling The first problemwe encounterwith couplingthe trafficlightand policemantogetheris the structure: howdo we define a set of modelsand their interrelations? Thisis the coredefinition of a coupledmodel: it is merelya structuralmodelthatcouples modelstogether. Contrarytotheatomicmodels,thereisnobehaviourwhatsoeverassociatedtoacoupledmodel. Behaviouris theresponsibilityofatomicmodels,andstructurethatofcoupledmodels. Todefinethebasicstructure,weneedthreeelements. 1. Modelinstances(D) Thesetofmodelinstancesdefineswhichmodelsareincludedwithinthiscoupledmodel. 2. Modelspecifications({M}) i Apartfromdefiningthedifferentinstancesofsubmodels,wemustincludetheatomicmodelspecificationofthesemodels. For each element defined in D, we include the 7-tuple specifying the atomic model. By definition, a submodel of the coupled DEVS model always needs to be an atomic model. Later on, we will see how this can be extended to support arbitrarilyhierarchies. {hX,Y,S,q ,d ,d ,l ,tai|i∈D} i i i init,i int,i ext,i i i 3. Modelinfluencees({I}) i Apartfromdefiningthemodelinstancesandtheirspecifications,weneedtodefinetheconnectionsbetweenthem.Connec- tionsaredefinedthroughtheuseofinfluenceesets:foreachatomicmodelinstance,wedefinethesetofmodelsinfluenced by that model. There are some limitations on couplings, to make sure that inconsistent models cannot be created. The followingtwoconstraintsareimposed: • A modelshouldnot influenceitself. This constraintmakessense, as otherwise it would be possible for a modelto influenceitselfdirectly. Whilethereisnosignificantproblemwiththisinitself,itwouldcausethemodeltotrigger bothitsinternalandexternaltransitionsimultaneously. Asitisundefinedwhichoneshouldgofirst,thissituationis notallowed. Inotherwords,amodelshouldnotbeanelementinitsownsetofinfluencees. ∀i∈D:i∈/I i • Only links within the coupled model are allowed. This is another way of saying that connections should respect modularity. Modelsshould notdirectlyinfluencemodelsoutside of the currentcoupledmodel, nor modelsdeeper insideofothersubmodelsatthislevel. Inotherwords,theinfluencedmodelshouldbeasubsetofthesetofmodels inthiscoupledmodel. ∀i∈D:I ⊆D i Notethatthereisnoexplicitconstraintonalgebraicloops(i.e.,aloopofmodelsthathaveatimeadvanceequaltozero, preventingthe progression of simulated time). If this situation is not resolved, it is possible for simulation to get stuck atthatspecific pointintime. Thesituationisonlyproblematicifthe circulardependencynevergetsresolved,causinga livelockofthesimulation. Acoupledmodelcanthusbedefinedasa3-tuple. hD,{M},{I}i i i 3.2 InputandOutput Ourcoupledmodelnowcouplestwoatomicmodelstogether. Andwhileitisnowpossibleforthepolicemantopasstheevent tothetrafficlight,weagainlosttheabilitytosendoutthestateofthetrafficlight. Theeventscan’treachoutsideofthecurrent coupledmodel. Therefore,weneedtoaugmentthecoupledmodelwithinputandoutputevents,whichserveastheinterfaceto thecoupledmodel.ThisaddsthecomponentsX andY tothetuple,respectivelythesetofinputandoutputevents,resulting self self ina5-tuple. hX ,Y ,D,{M},{I}i self self i i 9 Theconstraintsonthecouplingsneedtoberelaxedtoaccomodateforthenewcapabilitiesofthecoupledmodel:amodelcanbe influencedbytheinputeventsofthecoupledmodel,andlikewisethemodelscanalsoinfluencetheoutputeventsofthecoupled model.Thepreviouslydefinedconstraintsarerelaxedtoallowforself,thecoupledmodelitself. ∀i∈D∪{self}:i∈/I i ∀i∈D∪{self}:I ⊆D∪{self} i 3.3 Tie-breaking RecallthatDEVSisconsideredaformalandpreciseformalism. Butwhileallcomponentsarepreciselydefined,theirinterplay is notcompletely definedyet: whathappenswhen the traffic lightchangesits state at exactly the same time as the policeman performs its transition? Would the traffic light switch on to the next state first and then process the policeman’s interrupt, or would it directly respond to the interrupt, ignoring the internal event? While it is a minimal difference in this case, the state reachedafterthetimeoutmightrespondsignificantlydifferenttotheincomingevent. DEVS solvesthisproblembydefininga tie-breakingfunction(select). Thisfunctiontakesallconflictingmodelsandreturns theonethatgetspriorityovertheothers. Aftertheexecutionofthatinternaltransition,andpossiblytheexternaltransitionsthat itcausedelsewhere,itmightbethatthesetofimminentmodelshaschanged. Ifmultiplemodelsarestillimminent,werepeat theaboveprocedure(potentiallyinvokingtheselect functionagainwiththenewsetofimminentmodels). select:2D→D Thisnewadditionchangesthecoupledmodeltoa6-tuple. hX ,Y ,D,{M},{I},selecti self self i i 3.4 TranslationFunctions Finally,inthiscasewehadfullcontroloverbothatomicmodelsthatarecombined. Wemightnotalwaysbethatlucky,asitis possibletoreuseatomicmodelsdefinedelsewhere.Dependingontheapplicationdomainofthereusedmodels,theymightwork withdifferentevents.Forexample,ifourpolicemanandtrafficlightwerebothpredefined,withthepolicemanusinggo_to_work andtake_breakandthetrafficlightlisteningtoautomaticandmanual,itwouldbeimpossibletodirectlycouplethemtogether. While it is possible to define wrapper blocks(i.e., artificial atomic models that take an eventas input and, with time advance equaltozero,outputthetranslatedversion),DEVSprovidesamoreelegantsolutiontothisproblem. Connectionsareaugmentedwithatranslationfunction(Z ),specifyinghowtheeventthatenterstheconnectionistranslated i,j before it is handed over to the endpoint of the connection. The function thus maps output events to input events, potentially modifyingtheircontent. Z :X →X ∀j∈D self,j self j Z :Y →Y ∀i∈D i,self i self Z :Z →X ∀i,j∈D i,j i j Thesetranslationfunctionsaredefinedforeachconnection,includingthosebetweenthecoupledmodel’sinputandoutputevents. {Z |i∈D∪{self},j∈I} i,j i Thetranslationfunctionisimplicitlyassumedtobetheidentityfunctionif itisnotdefined. Incaseaneventneedsto traverse multipleconnections,alltranslationfunctionsarechainedinorderoftraversal. Withtheadditionofthisfinalelement,wedefineacoupledmodelasa7-tuple. hX ,Y ,D,{M},{I},{Z },selecti self self i i i,j 3.5 ClosureUnderCoupling Similartoatomicmodels,weneedtoformallydefinethesemanticsofcoupledmodels. Butinsteadofexplainingthesemantics from scratch, by defining some pseudo-code, we map coupled models to equivalent atomic models. Semantics of a coupled modelisthusdefinedintermsofanatomicmodel.Inaddition,thisflatteningremovestheconstraintofcoupledmodelsthattheir submodelsshouldbeatomicmodels:ifacoupledmodelisasubmodel,itcanbeflattenedtoanatomicmodel. Inessence,foranycoupledmodelspecifiedas <X ,Y ,D,{M},{I},{Z },select> self self i i i,j 10

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.