a simulation tool for tccp programs
play

A simulation tool for tccp programs Leticia Lavado joint work with - PowerPoint PPT Presentation

A simulation tool for tccp programs Leticia Lavado joint work with Laura Panizo Mar a del Mar Gallardo Dept. Lenguajes y Ciencias de la Computaci on Andaluc a Tech, University of M alaga September 13, 2016 Motivation


  1. A simulation tool for tccp programs Leticia Lavado joint work with Laura Panizo Mar´ ıa del Mar Gallardo Dept. Lenguajes y Ciencias de la Computaci´ on Andaluc´ ıa Tech, University of M´ alaga September 13, 2016

  2. Motivation Simulation and Verification of tccp programs Reactive and concurrent systems Application domains: automotive, trains, medical applications. . . Complex to model and analyse Concurrency features Synchronization Critical properties Complex systems ➜ critical applications ➜ need to guarantee software safety and reliability tccp declarative language ➜ lack of simulation and analysis tools Leticia Lavado (University of M´ alaga) September 13, 2016 2 / 24

  3. Our approach A simulation tool Design and implementation a tool for simulating tccp programs Modular design and architecture Based on an mechanism similar to abstract machines Simulation : to define a tccp interpreter based on tccp operational semantics Leticia Lavado (University of M´ alaga) September 13, 2016 3 / 24

  4. Outline Background: The tccp language Architecture of the proposal Implementation issues Evaluation Related Work Conclusions and Future Work Leticia Lavado (University of M´ alaga) September 13, 2016 4 / 24

  5. Background The tccp language (de Boer et al. 2000) tccp is a timed extension of ccp (Saraswat 1993) parametric w.r.t. an underlying constraint system store-as-constraint paradigm computation = parallel execution of agents that add or ask information to/for a monotonic global constraint store x > 0? x > 2 constraint store y = 5 y > 2? time = global discrete clock Leticia Lavado (University of M´ alaga) September 13, 2016 5 / 24

  6. Background The tccp language (de Boer et al. 2000) tccp program P ∶∶= D.A where D ∶∶= ⋃{ p (⃗ x ) ∶− A } A ∶∶= stop ∣ tell ( c ) ∣ ∑ n i = 1 ask ( c i ) → A i ∣ A 1 ∥ A 2 ∣ ∃ xA ∣ p (⃗ x ) ∣ now c then A 1 else A 2 small-step operational behaviour: ⟨ A 1 ,c 1 ⟩ → ⟨ A 2 ,c 2 ⟩ → ⟨ A 3 ,c 3 ⟩ → ⟨ A 4 ,c 4 ⟩ ... → is the transition relation (one-time unit) Leticia Lavado (University of M´ alaga) September 13, 2016 6 / 24

  7. Background Example: modelling a photocopier initialize(MIdle):- ∃ E,C,A,T( tell (A=[free ∣ ])|| tell (T=[MIdle ∣ ]) || tell (E=[off ∣ ]) || system(MIdle,E,C,A,T)). system(MIdle,E,C,A,T):- ∃ E’,C’,A’,T’( tell (E=[ ∣ E’])|| tell (A=[ ∣ A’]) || tell (C=[ ∣ C’]) || tell (T=[ ∣ T’]) || user(C,A) || ask (true) → photocopier(C,A’,MIdle,T,E’) || ask (A’=[free ∣ ]) → system(MIdle,E’,C’,A’,T’))). user(C,A):- ask (A’=[free ∣ ]) → tell (C=[on ∣ ]) || ask (A’=[free ∣ ]) → tell (C=[off ∣ ]) || ask (A’=[free ∣ ]) → tell (C=[c ∣ ]) || ask (A’=[free ∣ ]) → tell (true). Leticia Lavado (University of M´ alaga) September 13, 2016 7 / 24

  8. Background Example: modelling a photocopier photocopier(C,A,MIdle,E,T):- ∃ Aux,Aux’,T’( tell (T=[Aux ∣ T’]) || ask (true) → now(Aux>0) then now(C=[on ∣ ]) then tell (E=[going ∣ ]) || tell (T’=[MIdle ∣ ])|| tell (A=[free ∣ ]) else now(C=[off ∣ ]) then tell (E=[stop ∣ ]) || tell (T’=[MIdle ∣ ])|| tell (A=[free ∣ ]) else now(C=[c ∣ ]) then tell (E=[going ∣ ]) || tell (T’=[MIdle ∣ ]) || tell (A=[free ∣ ]) else tell (Aux’=Aux-1) || tell (T’=[Aux’ ∣ ]) || tell (A=[free ∣ ]) else tell (E=[stop ∣ ]) || tell (A=[free ∣ ]). Leticia Lavado (University of M´ alaga) September 13, 2016 8 / 24

  9. Architecture of the proposal Leticia Lavado (University of M´ alaga) September 13, 2016 9 / 24

  10. Architecture of the proposal Executing scheme Leticia Lavado (University of M´ alaga) September 13, 2016 10 / 24

  11. Architecture of the proposal Abstract Machine instructions Given x ∈ V ar , and A be a tccp agent: A.x ➜ x in the scope of A p. ⃗ x ➜ formal parameters ⃗ x of procedure p is consistent () add variable ( A.x ) x, ⃗ add parameter ( p. ⃗ x ′ ) add constraint ( A.c ) entails ( c ) merge ( local 1 ,local 2 ) Leticia Lavado (University of M´ alaga) September 13, 2016 11 / 24

  12. Architecture of the proposal Agent execution Modifying main memory tell: tell ( c ) is consistent () 1 add constraint ( c ) 2 Return ⟨ global, stop ⟩ 3 Leticia Lavado (University of M´ alaga) September 13, 2016 12 / 24

  13. Architecture of the proposal Agent execution Modifying symbol table hidding: ∃ xA is consistent () 1 add variable ( A.x ) 2 Return execute ( A ) 3 procedure call: p (⃗ x ) ∶ − A is consistent () 1 x,p. ⃗ x ′ ) add parameter ( p. ⃗ 2 Return ⟨ global,A ⟩ 3 Leticia Lavado (University of M´ alaga) September 13, 2016 13 / 24

  14. Architecture of the proposal Agent execution No modifying the store choice: ∑ n i = 1 ask ( c i ) → A i is consistent () 1 If ¬ entails ( c i ) for i = 1 ,...,n , → step 4, else select randomly 2 ask ( c i ) → A i such that entails ( c i ) → step 3 Return ⟨ global,A i ⟩ 3 Return ⟨ global, ∑ n i = 1 ask ( c i ) → A i ⟩ 4 now: now c then A else B is consistent () 1 if entails ( c ) → execute ( A ) , else → execute ( B ) 2 parallel: A 1 ∣∣ A 2 is consistent () 1 execute ( A 1 ) = ⟨ local 1 ,nA 1 ⟩ 2 execute ( A 2 ) = ⟨ local 2 ,nA 2 ⟩ 3 Return ⟨ merge ( local 1 ,local 2 ) ,nA 1 ∣∣ nA 2 ⟩ 4 Leticia Lavado (University of M´ alaga) September 13, 2016 14 / 24

  15. Implementation issues Main elements of the implementation Tools and architecture entities Parsers (ANTLR) Interpreters tccp and agent interpreter (Java) Constraint Solvers (PPL for numeric constraint solver) Store ➜ symbol table and main memory (Java) Leticia Lavado (University of M´ alaga) September 13, 2016 15 / 24

  16. Implementation issues Store implementation Symbol table = scope of agents Tree structure Each node stores the list of variables belong to its scope Contains identifiers and references to main memory Leticia Lavado (University of M´ alaga) September 13, 2016 16 / 24

  17. Implementation issues Store implementation Main memory = information of all variables Available types: constant, discrete variable, expression, functor and reference Data field: depends on the type of element PPL convex polyhedron that keeps the numeric linear constraints Leticia Lavado (University of M´ alaga) September 13, 2016 17 / 24

  18. Implementation issues Problems faced Logic, concurrent and synchronous nature of tccp Store consistency - Constraint solving (logic and numeric constraints) Dynamic generation of fine-grained procedures Dynamic generation of local variables Concurrency in the store - Parallel execution of agents Leticia Lavado (University of M´ alaga) September 13, 2016 18 / 24

  19. Evaluation Running the photocopier program Leticia Lavado (University of M´ alaga) September 13, 2016 19 / 24

  20. Evaluation Photocopier Example: Store state after 7 steps Leticia Lavado (University of M´ alaga) September 13, 2016 20 / 24

  21. Evaluation Performance statistics 30 steps 100 steps 500 steps Symbol Table (nodes) 26 85 417 Global Memory (regiters) 78 239 1169 disc poly (dimensions) 6 6 6 Heap used (MB) 4 4.1 7 Heap allocated (MB) 16.3 16.3 16.3 Parser (ms) 192 196 197 Simulation (ms) 87 192 2,170 Leticia Lavado (University of M´ alaga) September 13, 2016 21 / 24

  22. Related Work Concurrent, declarative and synchronous languages declarative and synchronous character Lustre (SCADE Suite) SIGNAL (POLYCHRONY) concurrent logic programming PARLOG KL1 tccp tools Mozart-Oz tccp Interpreter Leticia Lavado (University of M´ alaga) September 13, 2016 22 / 24

  23. Conclusions and Future Work Contributions An abstract machine for tccp An implementation of a tccp simulator Available tool ➜ http://morse.uma.es/tools/tccp Future work = extend to h y- tccp Extend the abstract machine to h y- tccp Extend tccp model checking algorithms to h y- tccp Analysing reachability, safety and other properties Abstract interpretation based tools for diagnosis and analysis Leticia Lavado (University of M´ alaga) September 13, 2016 23 / 24

  24. Thanks for your attention! Questions? Leticia Lavado (University of M´ alaga) September 13, 2016 24 / 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend