Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Executable modeling & dynamic adaptation

346 views

Published on

This talk deals with executable modeling, and then how dynamic adaptation can be tackled

Published in: Software
  • Be the first to comment

  • Be the first to like this

Executable modeling & dynamic adaptation

  1. 1. Olivier Le Goaër olivier.legoaer@univ-pau.fr Séminaire LIRMM Montpellier, 30/09/2016 Executable modelingExecutable modeling && dynamic adaptationdynamic adaptation
  2. 2. 2/31 A short bioA short bio  Positions ● Ph.D in 2009 – AeLoS team, LINA ● Associate Professor since 2010 – MOVIES team, LIUPPA  Research topics ● Software Evolution/Adaptation ● Software Architecture ● Model-Driven Engineering  Hobbies ● Mobile technologies ● Web technologies
  3. 3. 3/31 Domain-specific languages (DSL)Domain-specific languages (DSL)  General Purpose Languages ● Not targeted to a particular kind of problem, but to any kinds of software problem  Domain-Specific Languages ● Targeted to a particular kind of problem – with dedicated notations (textual or graphical), support (editor, checkers, etc.) ● Promises: more « efficient » languages for resolving a set of specific problems in a domain ● Each concern described in its own language – For software developpers (modeling, programming, querying, building, documenting, ...), for software architects (ADL), for statisticians (R), for biologists, for sociologists, ...
  4. 4. 4/31 Shapes for a DSLShapes for a DSL  Internal ● Hosted by a GPL  External ● Stand-alone  Implicit ● API-like C# & Linq SQL Querydsl SQL Java API QCustomer customer; customer = new QCustomer("c"); SQLQuery<?> query = new SQLQuery<Void>(connection); List<String> lastNames = query.select(customer.lastName) .from(customer) .where(customer.firstName.eq("Bob")) .fetch(); System.out.print(lastNames); SELECT lastName FROM customer WHERE firstName = 'Bob'; var queryBobCustomers = from cust in customer where cust.firstName == "Bob" select cust.lastName; foreach (var n in queryBobCustomers) { Console.WriteLine(n); }
  5. 5. 5/31 Shapes for a DSLShapes for a DSL  Internal ● Hosted by a GPL  External ● Stand-alone  Implicit ● API-like C# & Linq SQL Querydsl SQL Java API QCustomer customer; customer = new QCustomer("c"); SQLQuery<?> query = new SQLQuery<Void>(connection); List<String> lastNames = query.select(customer.lastName) .from(customer) .where(customer.firstName.eq("Bob")) .fetch(); System.out.print(lastNames); SELECT lastName FROM customer WHERE firstName = 'Bob'; var queryBobCustomers = from cust in customer where cust.firstName == "Bob" select cust.lastName; foreach (var n in queryBobCustomers) { Console.WriteLine(n); }
  6. 6. 6/31 Models are taking a new roleModels are taking a new role « marauders map » – Harry Potter Model playing a static role (design-time) Model playing a dynamic role (run-time) ● Tells us about the structure of the castle (every classroom, every hallway, and every corner) ● Tells us about moving persons (shows foot prints)
  7. 7. 7/31 Crossing the demarcation lineCrossing the demarcation line Model of a system (conforms to a metamodel) S Running system IN TER PR ETATIO N Running system = model under execution Design-time Run-time C O M PILATIO N </xml> sub{ } MDA ® MM exec(M)exec(M)
  8. 8. 8/31 Executable modeling (xModeling)Executable modeling (xModeling)  Compilation ● Translational semantics – Code generation in a target language  Direct execution (~VM/interpreter) ● Operational semantics – Using an « action » language – Using a M2M transformation (rare in practice)  Breathing life into models ● Simulation, V&V, rapid prototyping... ● Ultimately, skip the implementation stage !
  9. 9. 9/31 Controversies and debatesControversies and debates  Executable models "can be run, tested, debugged, and measured for performance"  UML / fUML as prominent examples ● Is a class diagram executable? Alone ? ● Is a paquage diagram executable? ● Is a sequence diagram executable?  Raises the question of an executable nature ● Behavior of a software system captured by a model M ● Ability to define a current execution state within M ● Ability to compute the next state (aka « step ») within M
  10. 10. 10/31 xModeling built with MDExModeling built with MDE  Meta-models are just a specific OO data structures to represent abstract syntax trees ● Operational semantics = computation steps and runtime data ● A VM/interpreter is a program working with such AST and that implements a given operational semantics  Executable metamodeling ● xMOF (eXecutable MOF) ● Kermeta ● Ecore + body of operation(s) written Java/EMF ● …
  11. 11. 11/31 xModeling's componentsxModeling's components Abstract Syntax Metamodel + Well-formedness rules Concrete Syntax Graphical or textual Semantics How it behaves at runtime ?
  12. 12. 12/31 Modeling with StatechartsModeling with Statecharts --The instance of the finite state machine is unique (root) context StateMachine inv singleStateMachine: StateMachine.allInstances()->size() = 1 and self.container.oclIsUndefined() --All the states are included in composites except the finite state machine herself context State inv containerForAllStates: not self.oclIsTypeOf(StateMachine) implies not self.container.oclIsUndefined()
  13. 13. 13/31 Train Cruise Control ModelTrain Cruise Control Model
  14. 14. 14/31 xModeling with StatechartsxModeling with Statecharts runToCompletion() isActive:boolean 0..1 lastKnownActiveState -- When an history state exists and references a state, the latter must belongs to the composite context CompositeState inv historyInComposite: if self.historyState.oclIsUndefined() then true else if self.historyState.referencedState.oclIsUndefined() then true else self.states->includes(self.historyState.lastKnownActiveState) endif endif
  15. 15. 15/31 xModeling with StatechartsxModeling with Statecharts runToCompletion() isActive:boolean 0..1 lastKnownActiveState -- When an history state exists and references a state, the latter must belongs to the composite context CompositeState inv R3: if self.historyState.oclIsUndefined() then true else if self.historyState.referencedState.oclIsUndefined() then true else self.states->includes(self.historyState.lastKnownActiveState) endif endif //operationnal semantics of UML2 aspect class StateMachine { operation runToCompletion(e : Event) is do // suivre la transition trouvée en activant l'état // cible et en modifiant en conséquence la hiérarchie d'états actifs end } //operationnal semantics of UML2 aspect class StateMachine { operation runToCompletion(e : Event) is do // suivre la transition trouvée en activant l'état // cible et en modifiant en conséquence la hiérarchie d'états actifs end }
  16. 16. 16/31 Running system = exec(Model)Running system = exec(Model)
  17. 17. 17/31 Model@run.timeModel@run.time  Overloaded term ● Deals originally with software adaptation issues at runtime  Advantage ● Provides a reasoning support on a running system  Drawback ● Holding a causal link: M has to remain the strict reflect of S MM SS adaptation ? représentation modification Adaptation loop
  18. 18. 18/31 Model@run.time + xModelingModel@run.time + xModeling  Treats the specific case where the considered running system is a model under execution  Idea : collapsing the adaptation loop ● Solves the causal link issue... ● ...but the merge may leads to a burdened model M'' M S = exec(M')S = exec(M') adaptation ? représentation modification S = exec(M'') adaptation ? modification collapse
  19. 19. 19/31 Non-supervised adaptation (self-*)Non-supervised adaptation (self-*)  Detect a situation requiring adaptation ● Known versus unknown context (e.g. a new signal) – Green runtime event is sometimes ignored (designer's choice at design-time) – White runtime event is actually unknown at design-time  Perform adaptation actions ● CRUD operators on any runtime data  Metamodel specialization unlocks adaptation ● Model (sub)typing : adding new metaclasses and new constraints – Adding new operations accordingly : for (a) detect and (b) perform ● Choosing the right level of specialization is tactful – Domain adaptations are rare but apply on any model instance of the metamodel – Business adaptations are frequent but only apply on some models
  20. 20. 20/31 Subtyped Cruise Control ModelSubtyped Cruise Control Model com pleteness tagged value + Consistency
  21. 21. 21/31 Dynamic adaptation of the modelDynamic adaptation of the model
  22. 22. 22/31 Adaptable xModelingAdaptable xModeling RunToCompletion()* -- Each state must be associated to a transition for each identified event context State def: knownEvents : Set(String) = Set{...}; context State inv Completeness: self.knownEvents -> forAll( e | self.existsTransitionFor(e)) -- A transition tagged with {p, v} leads to a state also tagged with with {p, v} context StateMachine inv Consistency: ... ...
  23. 23. 23/31 Adaptable xModelingAdaptable xModeling RunToCompletion()* -- Each state must be associated to a transition for each identified event context State def: knownEvents : Set(String) = Set{...}; context State inv Completeness: self.knownEvents -> forAll( e | self.existsTransitionFor(e)) -- A transition tagged with {p, v} leads to a state tagged with with {p, v} context StateMachine inv Consistency: ... ... //adaptation operational semantics aspect class StateMachine { operation runToCompletion(e : Event) is do if not e.isKnown() then //introduces the new state and transitions thereof end //same as usual (nominal behavior) end } //adaptation operational semantics aspect class StateMachine { operation runToCompletion(e : Event) is do if not e.isKnown() then //introduces the new state and transitions thereof end //same as usual (nominal behavior) end } aspect class Event { operation isKnown() : Boolean is do //checks if an event is unknown or not end } aspect class Event { operation isKnown() : Boolean is do //checks if an event is unknown or not end }isKnown()*
  24. 24. 24/31 From craft to engineering with MDEFrom craft to engineering with MDE Modeling xModeling Adaptable xModeling Metamodel (static) + [exec. translational semantics] Metamodel (static + dynamic) + exec. operational semantics Metamodel (static + dynamic + adaptative) + adapt. operational semantics
  25. 25. 25/31 Adaptation extends executionAdaptation extends execution  Execution semantics ● Deals with the nominal behavior (known context) ● Operation(s) only apply on the dynamic part (the static part is on read-only mode)  Adaptation semantics ● Is-a-kind-of execution semantics ● Deals with extra-ordinary situation (unknown context) ● Operation(s) may apply on all parts (static, dynamic, adaptation)  The two kinds of semantics are mixed
  26. 26. 26/31 Implementation ChoicesImplementation Choices  Classic programming ● Adaptation is tangled into execution  OO programming ● Adaptation overrides execution (and calls « super »)  Contract-based programming ● Adaptation occurs when a precondition of execution is violated  Aspect-oriented programming ● Adaptation is woven into execution  xModeling ! ● Adaptation is modeled with a DSL and calls back to execution
  27. 27. 27/31 xModeling built without MDExModeling built without MDE  PauWare engine (www.pauware.com) ● Execution engine (VM) for statechart models ● Implements the complete UML2 execution semantics specification ● API written in Java (hence ported effortlessly to Android) JavaJava PauWare APIPauWare API Code/xml that describes the statechart model to be loaded Engine that executes the model loaded (« run-to-completion ») Free implementation of the actions (called by reflection from the engine) Consumes an event for each execution step
  28. 28. 28/31 Android + PauWareAndroid + PauWare SERVICE BROADCAST RECEIVER Android OS ANDROID CONNECTOR e1/foo e1 public void foo() { //do something } public void bar() { //do other thing } A statechart model runs-to-completion starts invokes PauWare Execution Engine Java xmi scxml
  29. 29. 29/31 Supervised adaptationSupervised adaptation  Ability to load a new model on-the-fly ● A model is just a runtime data taken as input of the engine ● Actions' implementation have to stay unchanged SERVICE BROADCAST RECEIVER Android OS ANDROID CONNECTOR events runs-to-completion starts invokes PauWare Execution Engine Model Server Google Cloud Messaging Push Notification Fresh data retrieval Adapter e1/foo public void foo() { //do something } public void bar() { //do other thing }
  30. 30. 30/31 World Wide Modeling (wwm)World Wide Modeling (wwm)  MDE-specific URI ● model://host[:port]/M3/M2/M1 – model://localhost/Ecore/UML2/train – model://localhost/Ecore/OCL/  Commands ● model://host/M3?list ● model://host/M3/M2?info ● model://host/M3/M2/M1#fragment  Getting started (requires ) ● $> npm install wwm ● JavaScript API for client-side and server-side programming
  31. 31. 31/31 Thank you for your attentionThank you for your attention ?

×