1 / 23

Behavioral Programming A review of recent research:

Behavioral Programming A review of recent research: ECOOP’10, ASE’10, ICFP’10, ICPC’11, EMSOFT’11, AGERE’11, ICTAI’11. David Harel , Assaf Marron, Smadar Szekely , Gera Weiss. Weizmann Institute of Science. Ben-Gurion University of the Negev. The Behavioral Programming Vision.

alair
Download Presentation

Behavioral Programming A review of recent research:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Behavioral Programming A review of recent research: ECOOP’10, ASE’10, ICFP’10, ICPC’11, EMSOFT’11, AGERE’11, ICTAI’11 David Harel, Assaf Marron, SmadarSzekely, Gera Weiss Weizmann Institute of Science Ben-Gurion Universityof the Negev

  2. The Behavioral Programming Vision Can complex software be developed from simple threads of behavior by automatic interweaving ?

  3. Humans interweave behavior threads all the time… Driving Directions Daily Schedule … ... Drive for 4 hrs. Stop for Lunch Drive for 5 hrs. … … A 6-day trip from NY to LA … can software be developed this way?

  4. LSC & BPJ: From requirements to code • LSC: A visual language for scenario specification • Dammand Harel2001, Harel and Marelly2003 • Natural yet executable scenario-based specification • Initially for requirement specification, evolved into a programming language • PlayGo – an IDE for programming with LSC • BPJ: A package for programming scenarios in Java (and equivalents for other languages) • Harel, Marron, and Weiss 2010 • Bringing advantages of scenario-based specification to programming • Integrate with & complement other paradigms (OOP, aspects, rule-based, agile, …). class AddHotFiveTimes extends BThread {     public void runBThread() {         for (int i=1; i<=5; i++) { bSync(addHot, none, none);         }     } }

  5. Incremental development in Java with BPJ Behavior Threads Req. 3.1 class AddHotFiveTimes extends BThread {     public void runBThread() {         for (int i=1; i<=5; i++) { bSync(addHot, none, none);         }     } } Req. 5.2.9 class AddColdFiveTimesBThread {     public void runBThread() {         for (int i=1; i<=5; i++) { bSync(addCold, none, none);         }     } } Patch 7.1 class Interleave extends BThread {     public void runBThread() {         while (true) { bSync(none, addHot, addCold); bSync(none, addCold, addHot);        }     } }

  6. Why do we need this? Need to accommodate a cross-cutting requirement? Add a module Need to refine an inter-object scenario?Add a module Need to remove a behavior?Add a module . . .?Add a module A key benefit: incremental development No need to modify existing code

  7. Behavior execution cycle • All behavior threads (b-threads) post declarations: • Requestevents: propose events to be considered for triggering; • Waitfor events: ask to be notified when events are triggered; • Block events: temporarily forbid the triggering of events. • When all declarations are collected: • An event that isrequestedand not blockedis selected. • All b-threadswaitingfor this event can update their declaration

  8. Behavior execution cycle Wait B-s Behavior Threads Request Block

  9. Behavior execution cycle Wait B-s Behavior Threads Request Block

  10. Behavior execution cycle Wait B-s Behavior Threads Request Block

  11. Example: Coding b-threads in Java class AddHotFiveTimes extends BThread {     public void runBThread() {         for (int i=1; i<=5; i++) { bSync(addHot, none, none);         }     } } addHot addHot addHot addHot addHot addHot addHot addHot addHot addHot addColdaddColdaddColdaddColdaddCold addHot addColdaddHot addColdaddHot addCold addHot addCold addHot addCold class AddColdFiveTimesBThread {     public void runBThread() {         for (int i=1; i<=5; i++) { bSync(addCold, none, none);         }     } } class Interleave extends BThread {     public void runBThread() {         while (true) { bSync(none, addHot, addCold); bSync(none, addCold, addHot);        }     } }

  12. Main application: reactive systems Complexity stems from the need to interleave many simultaneous behaviors

  13. Alignment of code modules with requirements • When I put two Xs in a line, you need to put an O in the third square bSync(none, X<1,2>, none); bSync(none, X<2,2>, none); bSync(O<3,1>, none, none);

  14. Each new game rule or strategy is added in a separate b-thread without changing existing code

  15. Some answers to common questions and challenges • What about conflicting requirements? • Model Checking • Incremental development • … • Scalability in terms number of behaviors and interleaving complexity? • Agent oriented architectures • Machine learning for event selection • … • Comprehension of systems constructed by behavior composition? • Trace visualization tool • …

  16. Example: Flying a quadrotor helicopter To correct the angle: requestSpeedUpR1 blockSlowDownR1 blockSpeedUpR4 requestSpeedUpR4 requestSpeedUpR2 requestSpeedUpR2 blockSlowDownR4 Selected event: SpeedUpR2 requestSlowDownR4 blockSlowDownR2 To increase altitude: blockSlowDownR2 requestSpeedUpR3 blockSlowDownR3

  17. Balancing a quadrotor – behaviorally

  18. Challenges and future research • Scalability • Tools for developing many b-threads • Architectures for efficient execution of many b-threads • Dealing with conflicts and under-specification • Model checking • Automatic program repair • Machine learning • Evaluation • Empirical studies • Complex applications • Theoretical advantagesand limitations • And much more…

  19. Summary:The behavioral programming paradigm Create complex software by interweaving simple b-threads Application agnostic mechanism for b-thread interweaving ? Incremental development in Java, LSC, and other languages

  20. Backup Slides

  21. Model-checking behavioral programs “in-vivo” (c.f. Java Path Finder) Transition using standard execution (by the native JVM) Backtrack using Apache javaflow continuations Notations for nondeterministic transitions State matching and search pruning by b-threads State tagging for safety and liveness properties by b-threads

  22. A . . labelNextVerificationState( “A” ); bSync( … ); if( lastEvent == event1 ) { . . . labelNextVerificationState( “B” ); bSync( … ); } if( lastEvent == event2 ) { . . . labelNextVerificationState( “C” ); bSync( … ); } event1 B event2 Behavior Thread States b-thread states at bSync C

  23. Program states are the Cartesian product of b-thread states D A G B H C ADG E I AEG BDG … … … … Behavioral Program State Graph BDH AEI

More Related