1 / 19

JACK Execution

JACK Execution. Part I. JACK Execution. BDI Execution Model Tasks with co-operative scheduling under JACK control makes efficient use of Java threads Message-based communication instead of RPC/CORBA (not prohibited) Object constructions through sentinels minimises type casting - faster.

Download Presentation

JACK Execution

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. JACK Execution Part I

  2. JACK Execution • BDI Execution Model • Tasks with co-operative scheduling • under JACK control • makes efficient use of Java threads • Message-based communication • instead of RPC/CORBA (not prohibited) • Object constructions through sentinels • minimises type casting - faster

  3. BDI Execution Model • Conceptually straight-forward and simple: • look for relevant plans • compute applicable plan instances • pick one to run • The evil is in the details: • where to look for plans • how to compute applicable instances • what happens on failure

  4. databases events plans post handle assert retract JACK BDI Execution beliefs desires intentions

  5. databases events plans post handle assert retract select plan (plan choice) JACK BDI Execution observe change beliefs desires intentions observe "environment" messages

  6. databases events plans post handle assert retract select plan (plan choice) JACK BDI Execution observe change beliefs desires intentions observe "environment" step intention messages

  7. Event Posting • Synchronous • In plans: @subtask(..) , @achieve(..) , @test(..) • From Java: Agent.postAndWait(..) • Asynchronous • In plans: @post(..) • From Java: Agent.postEvent(..) • also from database callbacks

  8. Plan Instance Selection • The options: • of plan types that handle the event type, and • are relevant (static method), and • are applicable (plan instance method), and • are not already attempted and failed • The choice is: • first instance of first listed plan type, or • first of highest getInstanceInfo().rank(), or • chosen through PlanChoice event handling

  9. Plan Example plan ComputeFactorialKnown extends Plan { #handles event Computation ev; static boolean relevant(Computation ev) { return ev.n > 1; } #reads database FactorialDB factorial; context() { factorial.get(ev.n, ev.v); } body() { } }

  10. The Plan Header plan ComputeFactorialKnown extends Plan { #handles event Computation ev; static boolean relevant(Computation ev) { return ev.n > 1; } #reads database FactorialDB factorial; context() { factorial.get(ev.n, ev.v); } body() { } } • plan <Type> extends <PlanBase> • becomes a Java class of name <Type> • additional package and import statements as in Java • aos.jack.jak.plan.Plan auto-imported and the only <PlanBase> provided

  11. The Handled Event plan ComputeFactorialKnown extends Plan { #handles event Computation ev; static boolean relevant(Computation ev) { return ev.n > 1; } #reads database FactorialDB factorial; context() { factorial.get(ev.n, ev.v); } body() { } } • #handles event <Type> <ref> ; • the <Type> is looked up through the enclosing Capability structure at initialisation time • the <ref> becomes a plan member that holds the actual event instance being handled

  12. The relevant(..) Method plan ComputeFactorialKnown extends Plan { #handles event Computation ev; static boolean relevant(Computation ev) { return ev.n > 1; } #reads database FactorialDB factorial; context() { factorial.get(ev.n, ev.v); } body() { } } • static boolean relevant( <Type> <ref> ) { ... } • can inspect the event instance (argument) and decide whether or not the plan type is actually relevant for the particular event instance • returns true for relevant, and false otherwise • if omitted, the plan type is relevant

  13. The context(..) Method plan ComputeFactorialKnown extends Plan { #handles event Computation ev; static boolean relevant(Computation ev) { return ev.n > 1; } #reads database FactorialDB factorial; context() { factorial.get(ev.n, ev.v); } body() { } } • context( ) { <cond> ; } • a single expression • “generates” plan instances by providing different bindings for logical variables involved

  14. Plan Instance Execution • Some plan instance is chosen. • Executed as subtask of the event. • The plan succeeds, fails, or throws an exception. • BDI: on plan failure, an alternative plan instance is chosen.

  15. Event Example event Computation extends Event { int n; logical long v; #posted as compute(int n,logical long v) { this.n = n; this.v = v; } }

  16. The Event Header event Computation extends Event { int n; logical long v; #posted as compute(int n,logical long v) { this.n = n; this.v = v; } } • event <Type> extends <EventBase> • becomes a Java class of name <Type> • additional package and import statements as in Java • aos.jack.jak.event.* auto-imported with several <EventBase>: • Event • BDIGoalEvent, BDIFactEvent • MessageEvent, TracedMessageEvent • BDIMessageEvent, TracedBDIMessageEvent • event handling behaviour is tied to event base class

  17. The Event Data Members event Computation extends Event { int n; logical long v; #posted as compute(int n,logical long v) { this.n = n; this.v = v; } } • like normal Java members • maybe logical, maybe bound by handling plan • used for qualifying event instance • “polymorphic”

  18. The Posting Methods event Computation extends Event { int n; logical long v; #posted as compute(int n,logical long v) { this.n = n; this.v = v; } } • #posted as <name> ( <args> ) <body> • for constructing instances off sentinel • usually merely assigns event data members

  19. BDI* Event Bases • Advanced event handling • Failure is not automatic - instead, the agent “keeps trying”, • Applicable set and Failure set • Tuning the event behaviour • “#set behavior <attribute> <value> ;” statements • Plan choice and meta-level reasoning • requiring the PlanChoice event generation (delivered as subtask) for choosing applicable plan instance through meta-level plans

More Related