mde modelling the devs formalism
play

MDE: Modelling the DEVS formalism Yentl Van Tendeloo - PowerPoint PPT Presentation

MDE: Modelling the DEVS formalism Yentl Van Tendeloo Yentl.VanTendeloo@student.ua.ac.be January 24, 2013 1 / 25 The problem: Difficult to comprehend c l a s s Root ( CoupledDEVS ) : def i n i t ( s e l f ) : CoupledDEVS . i n i t ( s e


  1. MDE: Modelling the DEVS formalism Yentl Van Tendeloo Yentl.VanTendeloo@student.ua.ac.be January 24, 2013 1 / 25

  2. The problem: Difficult to comprehend c l a s s Root ( CoupledDEVS ) : def i n i t ( s e l f ) : CoupledDEVS . i n i t ( s e l f ) s e l f . gen = s e l f . addSubModel ( Generator ( ) ) s e l f . seg1 = s e l f . addSubModel ( RoadSegment () ) s e l f . seg2 = s e l f . addSubModel ( RoadSegment () ) s e l f . seg3 = s e l f . addSubModel ( RoadSegment () ) s e l f . c o l = s e l f . addSubModel ( C o l l e c t o r () ) s e l f . connectPorts ( s e l f . gen . Q send , s e l f . seg1 . Q recv ) s e l f . connectPorts ( s e l f . gen . car out , s e l f . seg1 . c a r i n ) s e l f . connectPorts ( s e l f . seg1 . Q sack , s e l f . gen . Q rack ) s e l f . connectPorts ( s e l f . seg1 . Q send , s e l f . seg2 . Q recv ) s e l f . connectPorts ( s e l f . seg1 . car out , s e l f . seg2 . c a r i n ) s e l f . connectPorts ( s e l f . seg2 . Q sack , s e l f . seg1 . Q rack ) s e l f . connectPorts ( s e l f . seg2 . Q send , s e l f . seg3 . Q recv ) s e l f . connectPorts ( s e l f . seg2 . car out , s e l f . seg3 . c a r i n ) s e l f . connectPorts ( s e l f . seg3 . Q sack , s e l f . seg2 . Q rack ) s e l f . connectPorts ( s e l f . seg3 . car out , s e l f . c o l . c a r i n ) 2 / 25

  3. The problem: Difficult to comprehend c l a s s Root ( CoupledDEVS ) : def i n i t ( s e l f ) : CoupledDEVS . i n i t ( s e l f ) s e l f . gen = s e l f . addSubModel ( Generator ( ) ) s e l f . seg1 = s e l f . addSubModel ( RoadSegment () ) s e l f . seg2 = s e l f . addSubModel ( RoadSegment () ) s e l f . seg3 = s e l f . addSubModel ( RoadSegment () ) s e l f . c o l = s e l f . addSubModel ( C o l l e c t o r () ) s e l f . connectPorts ( s e l f . gen . Q send , s e l f . seg1 . Q recv ) s e l f . connectPorts ( s e l f . gen . car out , s e l f . seg1 . c a r i n ) s e l f . connectPorts ( s e l f . seg1 . Q sack , s e l f . gen . Q rack ) s e l f . connectPorts ( s e l f . seg1 . Q send , s e l f . seg2 . Q recv ) s e l f . connectPorts ( s e l f . seg1 . car out , s e l f . seg2 . c a r i n ) s e l f . connectPorts ( s e l f . seg2 . Q sack , s e l f . seg1 . Q rack ) s e l f . connectPorts ( s e l f . seg2 . Q send , s e l f . seg3 . Q recv ) s e l f . connectPorts ( s e l f . seg2 . car out , s e l f . seg3 . c a r i n ) s e l f . connectPorts ( s e l f . seg3 . Q sack , s e l f . seg2 . Q rack ) s e l f . connectPorts ( s e l f . seg3 . car out , s e l f . c o l . c a r i n ) Solution: Graphical representation 2 / 25

  4. The problem: Different simulators i n t main ( int , char ∗∗ argv ) { adevs : : Digraph < Event ∗ > dig ; Generator ∗ gen = new Generator () ; RoadSegment ∗ seg1 = new RoadSegment ( ) ; RoadSegment ∗ seg2 = new RoadSegment ( ) ; RoadSegment ∗ seg3 = new RoadSegment ( ) ; C o l l e c t o r ∗ c o l = new C o l l e c t o r ( ) ; dig . add ( gen ) ; dig . add ( seg1 ) ; dig . add ( seg2 ) ; dig . add ( seg3 ) ; dig . add ( c o l ) ; dig . couple ( gen , gen − > Q send , seg1 , seg1 − > Q recv ) ; dig . couple ( gen , gen − > car out , seg1 , seg1 − > c a r i n ) ; dig . couple ( seg1 , seg1 − > Q sack , gen , gen − > Q rack ) ; dig . couple ( seg1 , seg1 − > Q send , seg2 , seg2 − > Q recv ) ; dig . couple ( seg1 , seg1 − > car out , seg2 , seg2 − > c a r i n ) ; dig . couple ( seg2 , seg2 − > Q sack , seg1 , seg1 − > Q rack ) ; dig . couple ( seg2 , seg2 − > Q send , seg3 , seg3 − > Q recv ) ; dig . couple ( seg2 , seg2 − > car out , seg3 , seg3 − > c a r i n ) ; dig . couple ( seg3 , seg3 − > Q sack , seg2 , seg2 − > Q rack ) ; dig . couple ( seg3 , seg3 − > car out , col , col − > c a r i n ) ; 3 / 25

  5. The problem: Different simulators i n t main ( int , char ∗∗ argv ) { adevs : : Digraph < Event ∗ > dig ; Generator ∗ gen = new Generator () ; RoadSegment ∗ seg1 = new RoadSegment ( ) ; RoadSegment ∗ seg2 = new RoadSegment ( ) ; RoadSegment ∗ seg3 = new RoadSegment ( ) ; C o l l e c t o r ∗ c o l = new C o l l e c t o r ( ) ; dig . add ( gen ) ; dig . add ( seg1 ) ; dig . add ( seg2 ) ; dig . add ( seg3 ) ; dig . add ( c o l ) ; dig . couple ( gen , gen − > Q send , seg1 , seg1 − > Q recv ) ; dig . couple ( gen , gen − > car out , seg1 , seg1 − > c a r i n ) ; dig . couple ( seg1 , seg1 − > Q sack , gen , gen − > Q rack ) ; dig . couple ( seg1 , seg1 − > Q send , seg2 , seg2 − > Q recv ) ; dig . couple ( seg1 , seg1 − > car out , seg2 , seg2 − > c a r i n ) ; dig . couple ( seg2 , seg2 − > Q sack , seg1 , seg1 − > Q rack ) ; dig . couple ( seg2 , seg2 − > Q send , seg3 , seg3 − > Q recv ) ; dig . couple ( seg2 , seg2 − > car out , seg3 , seg3 − > c a r i n ) ; dig . couple ( seg3 , seg3 − > Q sack , seg2 , seg2 − > Q rack ) ; dig . couple ( seg3 , seg3 − > car out , col , col − > c a r i n ) ; Solution: Independent language 3 / 25

  6. Global overview Source: Hongyan Song. Infrastructure for devs modelling and experimentation. Master’s thesis, McGill University, 2006 4 / 25

  7. Overview: Modelling ◮ In AToM 3 ◮ Compliant to a metamodel ◮ Should have a code generation feature ◮ For intermediate language ( Modelica ) ◮ Automatically generated environment! 5 / 25

  8. Intermediate Language: Modelica Modelling language ◮ Relatively mature ◮ Language features for both continuous and discrete models ◮ Standard library ◮ Re-usability 6 / 25

  9. Modelica Example Generator c l a s s extends AtomicDEVS ; DevsPort p out ; output GeneratorState s t a t e ( ) ; f u n c t i o n timeAdvance I n t e g e r timespan ; output algorithm . . . end timeAdvance ; end Generator ; c l a s s Root extends CoupledDEVS ; output DevsPort p out ; P r o c e s s o r i n s 2 ( ) ; equation connect ( i n s 2 . p o u t , p out ) ; end Root ; 7 / 25

  10. Overview: Verification ◮ Use the µ Modelica compiler 1 ◮ Statically check the model ◮ No accesses to inaccessible variables ◮ Possibly perform optimisations ◮ Currently (nearly) no verification happens 1 Weigao Xu. The design and implementation of the modelica compiler. Master’s thesis, McGill University, 2005 8 / 25

  11. Overview: Simulation ◮ Use the PythonDEVS simulator 2 ◮ Save the trace file ◮ Text output ◮ XML output ◮ VCD output 2 Jean-S´ ebastien Bolduc and Hans Vangheluwe. The modelling and simulation package pythondevs for classical hierarchical devs. Technical report, MSDL Technical Report, 2001 9 / 25

  12. Overview: Validation ◮ Compare the output of the simulation to the specifications ◮ Textual simulation traces are unclear ◮ Visualize! 10 / 25

  13. Overview: Validation (example) Source: Hongyan Song. Infrastructure for devs modelling and experimentation. Master’s thesis, McGill University, 2006 11 / 25

  14. Overview: Features ◮ Model reuse ◮ At AToM 3 level ◮ At Modelica level ◮ At PythonDEVS level ◮ Clear boundaries ◮ Open structure 12 / 25

  15. My contribution ◮ Modelling ◮ Updating the existing metamodel ◮ Include experiment data ◮ Verification ◮ Update the µ Modelica compiler ◮ Introduce a flattening phase 13 / 25

  16. Modelling in AToM 3 : metamodel hasState atomicDevsV2 containModelV2 DevsExperiment Actions: Actions: Attributes: coupledDevsV2 Attributes: > connect > connect - name :: String Attributes: - experimentName :: String < disconnect > disconnect - isVisible :: Boolean - name :: String - model :: String - classVariables :: List - isVisible :: Boolean - package :: String - parameters :: List - classVariables :: List - parameters :: Text insDevsV2 - attributes :: List - parameters :: List - end_time :: Float Attributes: DevsState - init :: Text - attributes :: List - verbose :: Boolean - name :: String Attributes: - extTransition :: Text - init :: Text - trace :: Boolean - type :: String - intTransition :: Text - name :: String - isMainModel :: Boolean - parameters :: Text - outputFunc :: Text - attributes :: List - isVisible :: Boolean - timeAdvance :: Text containsPortV2 portDevsV2 containsStateV2 Actions: internalTransitionV2 Attributes: > connect Actions: - name :: String Attributes: < disconnect > connect - portType :: Enum - condition :: Text < disconnect - action :: Text eventDevsV2 stateDevsV2 Attributes: Attributes: externalTransitionV2 - name :: String - name :: String - classVariables :: List Attributes: channelV2 - initial :: Boolean Actions: - parameters :: List - condition :: Text - timeAdvance :: Text > connect - attributes :: List - action :: Text - output :: Text < disconnect - init :: Text - extAction :: Text - str :: Text < checkValidity - intAction :: Text - otherFunc :: Text 14 / 25

Recommend


More recommend