240 likes | 316 Views
JACK Agent Language. JAL. Main Concepts. Agent Event Plan Database Capability Class Interface. JACK Programming Style. plan ExamplePlan extends Plan { … # sends event MogulEvent msg ; … body () { @ send (“Mogul”, msg . hello (3,true));
E N D
Main Concepts • Agent • Event • Plan • Database • Capability • Class • Interface
JACK Programming Style planExamplePlan extends Plan { … #sends eventMogulEventmsg; … body() { @send(“Mogul”,msg.hello(3,true)); if (@subtask( …)) @send( … ); } JACK keywords Java
event plan database JACK Programming Concepts event agent plan database capability “has” “uses”
Programming Elements plan EvaluateBid extends Plan { event RequestBid extends MessageEvent { capability Bidder extends Capability { capability Client extends Capability { agent ClientBidder extends Agent { #has capability Client t; #has capability Bidder b; … }
Declarations for Agents • #private database <Type> <ref> ( <args> ) ; • #agent database <Type> <ref> ( <args> ) ; • #shared database <Type> <ref> ( <args> ) ; • #private data <Type> <ref> ( <args> ) ; • #agent data <Type> <ref> ( <args> ) ; • #shared data <Type> <ref> ( <args> ) ; • #handles event <Type> ; • #sends event <Type> { <ref> } ; • #posts event <Type> { <ref> } ; • #uses plan <Type> ; • #has capability <Type> <ref> ; • #uses taskManager <Type> ( <arg> ) ; • aos.jack.jak.agent.Agent • constructor and other methods
Belief Structure Declarations • Declares JACK databases and other data objects that are to be used in plans. • private = each agent instance operates its own data • agent = agents of same type (in a core image) share the data • shared = all agents (in a core image) share the data • #private database <Type> <ref> ( <args> ) ; • #private data <Type> <ref> ( <args> ) ; • #agent database <Type> <ref> ( <args> ) ; • #agent data <Type> <ref> ( <args> ) ; • #shared database <Type> <ref> ( <args> ) ; • #shared data <Type> <ref> ( <args> ) ;
Behaviour Declarations • Declares which events the agent handles, sends and posts (at “top level”) • #handles event <Type> ; • #sends event <Type> { <ref> } ; • #posts event <Type> { <ref> } ; • Declares which plans the agent uses (at “top level”) • #uses plan <Type> ;
Other Declarations • Declares which capabilities the agent has (at “top level”) • #has capability <Type> <ref> ; • Declares which task scheduling policy the agent uses • #uses taskManager <Type> ( <arg> ) ; • Declares its identity etc. • constructor method • other methods • Base class • aos.jack.jak.agent.Agent
Declarations for Events • data members • #posted as <name> ( <pars> ) <body> • #set behavior <Attr> <value> ; • #use behavior <Type> ( <arg> ) ; • aos.jack.jak.event.* • Event • MessageEvent, TracedMessageEvent • BDIGoalEvent, BDIFactEvent • BDIMessageEvent, BDITracedMessageEvent • PlanChoice • other methods
Event Occurrences • Declares the polymorphic range through data members • data members • Events are constructed via their posting methods called on sentinels • #posted as <name> ( <pars> ) <body> • Base type define event handling behaviour • Event • MessageEvent, TracedMessageEvent • BDIGoalEvent, BDIFactEvent • BDIMessageEvent, BDITracedMessageEvent • PlanChoice • BDI* events can be varied in behaviour details • #set behavior <Attr> <value> ; • #use behavior <Type> ( <arg> ) ;
Declarations for Plans • #handles event <Type> <ref> ; • #chooses for event <Type> ... ; • #reads database <Type> <ref> ; • #modifies database <Type> <ref> ; • #posts event <Type> <ref> ; • #sends event <Type> <ref> ; • #uses interface <Type> <ref> ; • #uses agent implementing <Type> <ref> ; • #reasoning method <name> ( <pars> ) <body>
Special for Plans • static boolean relevant( .. ) .. • context() .. • body() • #reasoning method pass( ) <body> • #reasoning method fail( ) <body> • logical variables • aos.jack.jak.plan.PlanInstanceInfo getInstanceInfo() • aos.jack.jak.logic.Signature • aos.jack.jak.plan.Plan
BDI* Plan Selection • Plan type relevance • “#handles event ..” for potential relevance • “relevant(..)” method for actual relevance • Plan instance generation • “context()” query for alternative plan level logical variable bindings • the Signature of a plan instance • Plan instance selection • order as mentioned in agent or its capabilities • “getInstanceInfo().rank()” • PlanChoice handling
Declarations • Events posted and sent • #posts event <Type> <ref> ; • #sends event <Type> <ref> ; • JACK databases used • #reads database <Type> <ref> ; • #modifies database <Type> <ref> ; • Java objects used • #reads data <Type> <ref> ; • #modifies data <Type> <ref> ; • Further access to enclosing capabilities and agent • #uses interface <Type> <ref> ; • #uses agent implementing <Type> <ref> ;
Plan Processing • JACK reasoning methods - translated to FSM’s • body() • #reasoning method <name> ( <pars> ) <body> • #reasoning method pass( ) <body> • #reasoning method fail( ) <body> • Java methods called within plan steps • A plan succeeds, fails or throws exception
Declarations for Databases • #key field <Type> <name> ; • #value field <Type> <name> ; • #indexed query <name> ( <proto> ) ; • #linear query <name> ( <proto> ) ; • callbacks (newfact, addfact, ... )
Field Declarations • Declare which fields • #key field <Type> <name> ; • #value field <Type> <name> ; • Scalar types + String only (extended in v2.0) • Tuples must differ in some key field (positive facts) • Declare which queries to support • #indexed query <name> ( <proto> ) ; • #linear query <name> ( <proto> ) ; • Declare which modifications to capture in callbacks • newfact, addfact, delfact, endfact, modfact, moddb • Java methods and members
Declarations for Capabilities • Most Agent declarations, plus • #imported database <Type> <ref> ( <args> ) ; • #exported database <Type> <ref> ( <args> ) ; • #imported data <Type> <ref> ( <args> ) ; • #exported data <Type> <ref> ( <args> ) ; • #shared data <Type> <ref> ( <args> ) ; • #handles external event <Type> ; • #posts external event <Type> { <ref> } ;
Capability Structure capability A #has capability B b; #has capability C c; #handles event EX; #handles event EY; #handles external event EX; #handles event EY; #posts event EY eyp; #uses plan PlanB; #posts external event EX; #handles external event EY; #posts event EY eyp; #uses plan PlanC; capability B capability C
Reasoning Method #reasoning method fooBar(int x,logical String y) { <Java statement> ; <JACK statement> ; <logical statement> ; // boolean, Cursor, FSM ... }
JACK Statements • Posting events • @subtask( <FSM> ) @post( <FSM> ) • @achieve( <cond> , <FSM> ) @test( <cond> , <FSM> ) • @insist( <cond> , <FSM> ) @determine( <cond> , <FSM> ) • Temporal statements • @wait_for( <cond> , <cond> } • @maintain( <cond> , <FSM> ) • @sleep( <time> ) • Messaging • @send( <name> , <message> ) • @reply( <message> , <message> )
Logical Statements • boolean valued statement • succeeds if true, fails if false • can be negated • Cursor valued statement • succeeds if binding is found, fails otherwise • can be negated - “negation as failure” for ClosedWorld • FSM valued statement • succeeds of the FSM processing succeeds, fails otherwise • can be negated
Logical Conditions • if, while, etc. • boolean, Cursor, or FSM • can be negated • boolean and Cursor only in compound conditions • Java connectives: && ||