Discrete EVent System specification (DEVS) Bernard Zeigler (1976 “Theory of Modelling and Simulation”) • A formal basis • for (low-level) representation • of all discrete event modelling formalisms (and even others, after approximation) • and simulator implementations Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 1/37
DEVS’s central place in the Formalism Transformation Graph PDE Bond Graph a-causal KTG Cellular Automata DAE non-causal set Process Interaction System Dynamics Discrete Event Bond Graph causal Statecharts Causal Block Diagram Petri Nets 3 Phase Approach Transfer Function DAE causal set Discrete Event Activity Scanning Discrete Event DAE causal sequence (sorted) Event Scheduling Timed Automata Discrete Event DEVS scheduling-hybrid-DAE DEVS&DESS Difference Equations state trajectory data (observation frame) Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 2/37
Event Graphs state trajectory states green red yellow 50 100 15 t to_red to_green to_yellow to_red events Finite State Automaton Event (Scheduling) Graph δ schedule schedule in 15 in 50 green to_green 100 to_red to_green to_yellow green red red 50 to_yellow δ to_red yellow δ schedule 15 in 100 yellow Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 3/37
DEVS without external events (model) s2 δ _int ta 3ΤΙςΕΞΜΣΡΕΠ�7ΙΘΕΡΞΜΓΩ s4 ΖΕςΜΕΦΠΙΩ� ��ΞΜΘΙ�!�� ta ��ΓΨςςΙΡΞΧΩΞΕΞΙ�!�Ω� s1 δ _int ΩΜΘΨΠΕΞΣς� ��[ΛΜΠΙ�8ςΨΙ� �����ΞΜΘΙ��!�ΞΕ�ΓΨςςΙΡΞΧΩΞΕΞΙ� �����ΓΨςςΙΡΞΧΩΞΕΞΙ�!� �����������������ΗΙΠΞΕΧΜΡΞ�ΓΨςςΙΡΞΧΩΞΕΞΙ� Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 4/37
DEVS without external events (trajectories) S s4 ta (s4) s3 δ_ int(s2) δ_ int(s4) s2 ta (s2) s1 t Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 5/37
DEVS with external events (model) δ _int s3 ta δ _ext s2 δ _int X ta 3ΤΙςΕΞΜΣΡΕΠ�7ΙΘΕΡΞΜΓΩ ΖΕςΜΕΦΠΙΩ� s4 ��ΞΜΘΙ�!�� ��ΓΨςςΙΡΞΧΩΞΕΞΙ�!�Ω� ΩΜΘΨΠΕΞΣς� ta ��[ΛΜΠΙ�8ςΨΙ� s1 �����ΡΙ∴ΞΧΞΜΘΙ�!�ΞΜΘΙ���ΞΕ�ΓΨςςΙΡΞΧΩΞΕΞΙ� δ _int �����Μϑ�ΞΜΘΙΧΡΙ∴ΞΧΙ∴ΞΧΙΖ� !�ΡΙ∴ΞΧΞΜΘΙ� ��������ΓΨςςΙΡΞΧΩΞΕΞΙ�!� ����������ΗΙΠΞΕΧΙ∴Ξ��ΓΨςςΙΡΞΧΩΞΕΞΙ��Ι���ΡΙ∴ΞΧΙ∴ΞΧΙΖ� ���������ΞΜΘΙ�!�ΞΜΘΙΧΡΙ∴ΞΧΙ∴ΞΧΙΖ �����ΙΠΩΙ� �������ΞΜΘΙ�!�ΡΙ∴ΞΧΞΜΘΙ �������ΤςΣΗΨΓΙ�ΣΨΞΤΨΞ�ΙΖΙΡΞ�ΠΕΘΦΗΕ�ΓΨςςΙΡΞΧΩΞΕΞΙ� �������ΓΨςςΙΡΞΧΩΞΕΞΙ�!�ΗΙΠΞΕΧΜΡΞ�ΓΨςςΙΡΞΧΩΞΕΞΙ� Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 6/37
DEVS with external events (trajectories) X x φ t tx S (s4,e) e (s4,0) s4 ta(s4) _ext((s4,e),x) δ (s3,0) s3 _int(s2) δ ta(s3) _int(s3) δ (s2,e) (s2,0) e (s2,ta(s2)) (s2,0) Υ!��Ω�Ι� s2 ta(s2) _int(s4) δ s1 t Y λ (s3) y3 λ (s2) y2 y1 φ t Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 7/37
DEVS essence S δ _ext((s,e),x) (s,0) (s,e) s ta(s) δ _int(s) tx T Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 8/37
DEV S = � X, S, Y, δ int , δ ext , λ, ta � T = R time base X input set ω : T → X ∪ { φ } input segment S state set Y output set δ int : S → S internal transition function ta : S → R + time advance function 0 , ∞ Q = { ( s, e ) | s ∈ S, 0 ≤ e ≤ ta ( s ) } total state, e is elapsed time δ ext : Q × X → S external transition function λ : S → Y output function Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 9/37
Traffic Lights G R R M Y M B B M M G A R R Y Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 10/37
trafficDEV S = < X, S, Y, δ int , δ ext , λ, ta > T = R X = { M, A } ω : T → X ∪ { φ } S = { RG, RY, GR, Y R, BB } δ int ( RG ) = RY ; δ int ( RY ) = GR δ int ( GR ) = Y R ; δ int ( Y R ) = RG ta ( RG ) = 60 s ; ta ( RY ) = 10 s ta ( GR ) = 50 s ; ta ( Y R ) = 10 s ta ( BB ) = + ∞ Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 11/37
trafficDEV S = < X, S, Y, δ int , δ ext , λ, ta > δ ext (( RG, e ) , M ) = BB δ ext (( RY, e ) , M ) = BB δ ext (( GR, e ) , M ) = BB δ ext (( Y R, e ) , M ) = BB δ ext (( BB, e ) , A ) = RY Y = { GREY, Y ELLOW, BLINK } λ ( RG ) = λ ( RY ) = λ ( GR ) = GREY λ ( Y R ) = Y ELLOW λ ( BB ) = BLINK Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 12/37
Coupled DEVS coupledDEV S ≡ � X self , Y self , D, { M i } , { I i } , { Z i,j } , select � { M i | i ∈ D } . M i = � S i , ta i , δ int,i , X i , δ ext,i , Y i , λ i � , ∀ i ∈ D. { I i | i ∈ D ∪ { self }} . ∀ i ∈ D ∪ { self } : I i ⊆ D ∪ { self } . ∀ i ∈ D ∪ { self } : i / ∈ I i . I i are the influenc ee sets describing the connection topology Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 14/37
Z i,j output-to-input translation { Z i,j | i ∈ D ∪ { self } , j ∈ I i } , Z self,j : X self → X j , ∀ j ∈ D, Z i,self : Y i → Y self , ∀ i ∈ D, Z i,j : Y i → X j , ∀ i, j ∈ D. Together, I i and Z i,j completely specify the coupling (structure and behaviour) Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 16/37
Tie-breaking among simultaneous events select : 2 D → D Choose a unique component from any non-empty subset E of D : select ( E ) ∈ E. E corresponds to the set of all components having a state transition simultaneously ( collisions ). Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 18/37
Closure under coupling From the coupled DEVS � X self , Y self , D, { M i } , { I i } , { Z i,j } , select � , with all components M i atomic DEVS models M i = � S i , ta i , δ int,i , X i , δ ext,i , Y i , λ i � , ∀ i ∈ D the atomic DEVS � S, ta, δ int , X, δ ext , Y, λ � is constructed. Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 20/37
Closure: state and time-advance S = × i ∈ D Q i , where Q i = { ( s i , e i ) | s ∈ S i , 0 ≤ e i ≤ ta i ( s i ) } , ∀ i ∈ D. ta : S → R + 0 , + ∞ Select the most imminent event time, = smallest time remaining until internal transition, of all the components ta ( s ) = min { σ i = ta i ( s i ) − e i | i ∈ D } . Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 22/37
Dealing with simultaneous events Imminent components: IMM ( s ) = { i ∈ D | σ i = ta ( s ) } . select one component i ∗ of the coupled model 2 D select : → D i ∗ IMM ( s ) → Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 24/37
Output (at internal transition time) λ ( s ) = Z i ∗ ,self ( λ i ∗ ( s i ∗ )) ,if self ∈ I i ∗ , φ ,if self / ∈ I i ∗ . Conceptually, the non-event φ is generated if i ∗ is not connected to the output of the coupled model. Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 26/37
Internal transition function δ int ( s ) = ( . . . , ( s ′ j , e ′ j ) , . . . ) , where ( s ′ j , e ′ j ) = ( δ int,j ( s j ) , 0) , for j = i ∗ , = ( δ ext,j ( s j , e j + ta ( s ) , Z i ∗ ,j ( λ i ∗ ( s i ∗ ))) , 0) , for j ∈ I i ∗ (and Z i ∗ ,j ( λ i ∗ ( s i ∗ )) � = φ = ( s j , e j + ta ( s )) , otherwise . Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 28/37
External transition function δ ext ( s, e, x ) = ( . . . , ( s ′ i , e ′ i ) , . . . ) , where ( s ′ i , e ′ i ) = ( δ ext,i ( s i , e i + e, Z self,i ( x )) , 0) , for i ∈ I self , = ( s i , e i + e ) , otherwise . Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 30/37
Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 31/37
DEVS limitations • a conflict due to simultaneous internal and external events is resolved by ignoring the internal event. It should be possible to explicitly specify behaviour in case of conflicts; • there is limited potential for parallel implementation; • the select function is an artificial legacy of the semantics of traditional sequential simulators based on an event list; • it is not possible to explicitly describe variable structure. Some of these are resolved in parallel DEVS Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 32/37
DEVS Solver • Iterative simulation of DEVS model • Possibly distributed implementation Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: DEVS 33/37
Recommend
More recommend