45
GORITE Execution 1 GORITE Execution team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal, ... data model Data, Data.Element Relation, Query And, Or, Distinct, ...

GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

Embed Size (px)

DESCRIPTION

GORITE Execution3 Example Capability public class FriendGreeting extends Capability { public Relation friends = new Relation( “friends”, String.class ); public FriendGreeting() { addGoal( new Plan( “say hello”, new Goal [] { new BDIGoal( “say friendly hello” ), new BDIGoal( “review things lent to friend” ) } ) { public Query context(Data d) { return friends.get( d.getValue( “who” ) ); } } ); } } public Relation friends = new Relation( “friends”, String.class ); addGoal( new Plan( “say hello”, new Goal [] { new BDIGoal( “say friendly hello” ), new BDIGoal( “review things lent to friend” ) } ) { public Query context(Data d) { return friends.get( d.getValue( “who” ) ); } } ); plan body plan context

Citation preview

Page 1: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 1

GORITE Execution

team model Performer, Team, Team.TaskTeam, Team.Role

process model Capability, Plan, Goal

SequenceGoal, ParallelGoal, BDIGoal, TeamGoal, ... data model

Data, Data.Element Relation, Query

And, Or, Distinct, ...

Page 2: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 2

Three Model Perspectives

Code

Team Model

Process Model

Data Model

Page 3: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 3

Example Capability

public class FriendGreeting extends Capability {public Relation friends = new Relation( “friends”, String.class );public FriendGreeting() { addGoal( new Plan( “say hello” , new Goal [] { new BDIGoal( “say friendly hello” ), new BDIGoal( “review things lent to friend” ) } ) { public Query context(Data d) { return friends.get( d.getValue( “who” ) ); } } );}

}

public Relation friends = new Relation( “friends”, String.class );

addGoal( new Plan( “say hello” , new Goal [] { new BDIGoal( “say friendly hello” ), new BDIGoal( “review things lent to friend” ) } ) { public Query context(Data d) { return friends.get( d.getValue( “who” ) ); } } );

planbody

plancontext

Page 4: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 4

Example Performer

public class Friendly extends Performer {

public Friendly( String name ) { addCapability( new FriendlyGreeting() );}

public Perceptor hello = new Perceptor( this, “say hello” ) {{ data_name = “who”;}};

}

public Perceptor hello = new Perceptor( this, “say hello” ) {{ data_name = “who”;}};

[Friendly]

hellohello.perceive( ... )

Page 5: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 5

Example Main

new Thread( Executor.getDefaultExecutor() ).start(); // Start GORITE

Performer kevin = new Friendly( “kevin” );

kevin.hello.perceive( “marge” );

Page 6: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 6

[Executor] “[gorite]”

Executor Perspective

[Performer] “kevin”

[TodoGroup]“percepts”

[FriendlyGreeting]

[Plan]“say hello”friends (String)

hello[Perceptor]

goal = “say hello”data= “who”

perceive(“marge”)

run()

[Data]

who=”marge”

BDIGoal(“say hello”).Instance

Page 7: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 7

Process Model Execution

Goal performed by “instantiating” it represents intention Goal.Instance

extension according to goal type keeps state and has progress method

single thread progressing all intentions of all teams step may fail, pass, stop or block Data object

named data elements

Page 8: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 8

BDIGoal Execution

a BDIGoal of given name is performed by: look up the plans of that same name within the

current capability; apply their context queries to determine variants; select one and perform it;

if it fails: restore data context redo procedure, but exclude failed variants

succeed as soon as a plan variant succeeds preserve the plan variant's data context

Page 9: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 9

Current Capability

data element “agent” the current performer (which is a capability)

recursive lookup: all plans in current capability and any sub capability

looking for plans of same name as BDIGoal

Page 10: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 10

Context Query

a “logical query” possibly involving “logical variables” (Ref objects)

Ref $x = new Ref( “$x” ) each valid binding defines a plan variant when selected, the Data is updated with the

selected binding data.getValue( “$x” ) restored on failure, preserved on success

Page 11: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 11

Recall Example Plan

addGoal( new Plan( “say hello” , new Goal [] {new BDIGoal( “say friendly hello” ),new BDIGoal( “review things lent to friend” )} ) { public Query context(Data d) { return friends.get( d.getValue( “who” ) ); }} );

Query without logical variables

Page 12: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 12

Context Method Return

Query object treated as predicate P(x1,..,xn) processed exhaustively to generate plan variants may provide zero variants

null “true”; one variant of the plan

Context.EMPTY “false”; the plan is not applicable

Page 13: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 13

Composite Queries

And( Query... conjuncts ) Or( Query... disjuncts ) Condition()

public boolean condition() { ... } Distinct( Ref... variables ) Snapshot( Query query ) interface Query, class QueryBase

Page 14: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 14

Ref Objects

named new Ref( String name ) name used when context established in Data

void set( Object value ) null means un-set

Object get()

Page 15: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 15

Plan Variants

when / why would you want multiple plan variants simultaneously applicable?

[BDIGoal] “X” [Plan] “X”p(“A”,”B”)

“A”=..“B”=..

[Plan] “X”q(“Z”)

[Plan] “X”

“A”=..“B”=..

“A”=..“B”=..

“Z”=.. “Z”=.. “Z”=.. “Z”=..

Page 16: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 16

Data

goal execution is done with respect to a Data container object

container of named data elements multi-valued (“temporal”) gold-fish mode

transient, dynamic bindings name lookup relative intention

i.e. name “foo” may differ on parallel paths

Page 17: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 17

Recall Example Plan Again

addGoal( new Plan( “say hello” , new Goal [] {new BDIGoal( “say friendly hello” ),new BDIGoal( “review things lent to friend” )} ) { public Query context(Data d) { return friends.get( d.getValue( “who” ) ); }} );

plan body = sub goals

Plan extends SequenceGoal

Page 18: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 18

Example Goal Hierarchy

[Plan] “say hello”{ friends(“who”) }

[BDIGoal]“say friendly hello”

[BDIGoal]“review things lent

to friend”

12

2

Page 19: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 19

SequenceGoal Execution

performs each sub-goal in sequence if sub goal fails, then the SequenceGoal fails if sub goal blocks, then the SequenceGoal blocks

re-enters same sub goal on re-entry if sub goal stops, then the SequenceGoal stops

re-enters same sub goal on re-entry if sub goal passes, then the next sub goal is instantiated and

performed if last sub goal, then the SequenceGoal passes

if sub goal throws exception, the SequenceGoal throws

Page 20: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 20

ParallelGoal Execution

performs all sub goals “in parallel” instantiates all as “branches”, and performs one

if sub goal fails, all other branches are cancelled, and the ParallelGoal fails

if sub goal blocks or stops, the ParallelGoal shifts focus to the next branch

if all sub blocks or stops, the ParallelGoal blocks or stops if sub goal passes, the ParallelGoal shifts focus to next branch

if all have passed, the ParallelGoal passes if sub goal throws exception, all branches are cancelled and the

exception is re-thrown

Page 21: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 21

ConditionGoal Execution

tries sub goals in sequence until one passes on sub goal fail: instantiate and try next on sub goal pass: pass on sub goal block: block on sub goal stop: stop on sub goal exception: cancel and re-throw

Page 22: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 22

... and so forth

SequenceGoal, ParallelGoal, ConditionGoal FailGoal, ControlGoal, RepeatGoal, LoopGoal, EndGoal BDIGoal, TeamGoal Plan, Goal

Page 23: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 23

TeamGoal Execution

find fillers as data element named by role Performer.RoleFilling objects splits into a parallel branch for each filler

BDI style goal processing using the Performer.RoleFilling capability

instaniated to combine Role and Performer Role goals performed by team, focussed on filler otherwise execution is “transferred into performer”

by manipulating the “agent” data element

Page 24: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 24

[Performer][Performer]

[Performer]

[Team]

[Data]

“foo” = {v1,v2,..}“bar” = {a,b,c...}

“fum” = {...}“agent” = {current}

“...” = {...}

Transient Shared Data

Page 25: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 25

[Capability]

The Team Picture

[Performer][TodoGroup]

fum[TodoGroup]bar

Beliefs

Beliefsplans

intention

intentionintention intention intention intention intention

intentionintention

(name)

[Team]

[TaskTeam]

[Role] [Role] [Role]

[TaskTeam]

[Role]

[Role] [Role]

[Role]

Page 26: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 26

GORITE Model - Instantiated

an Executor object that all performers are added to

for executing TodoGroup intentions default

single Executor, automatic, lazily if a Performer lacks an Executor when one is

needed, then the default one is use (created first)

Page 27: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 27

Executor

Executor Perspective

[Performer]Team

Performer

[Performer]Team

Performer

[Performer]Team

Performer[Performer]Team

Performer

Page 28: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 28

Two Execution Entry Points

Perceptor.perceive(Object) asynchronous events model Executor.run()

Performer.performGoal(Goal,String,Data) application main thread model

e.g. closed loop simulation traverses intention tree

down to TodoGroup intentions then, later, into those via Executor

Page 29: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 29

Perceptor = Percept Stream

new Perceptor( Performer, String ) handler goal .. new BDIGoal( “handle percept” ) data name .. “percept” todo group name .. “percepts” performer

perceptor.perceive( perception_data );

Page 30: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 30

[Executor]

Thread Control Picture (In)

[Performer]

[Performer]

percept

run()

performGoal()

EITHER!EITHER!NOT BOTH!NOT BOTH!

perceive( Object )

Page 31: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 31

The Executor

runs through all (its) performers performing their todo groups

each intention until it passes, fails, stops or blocks performGoal(..) uses Executor run() method

implements Runnable usually single Executor

each Executor claims its own “threading sandbox” No Shared Performers !!!

Page 32: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 32

Peformer.TodoGroup

a Performer's named collection of some on-going “intentions” managed together

Goal.Instance objects (sub classed) meta goal invoked to manage todo group

decide which one to progress next only one intention is progressed

new decision on added, completed or blocked intention goals have “group” attribute

progressed by TodoGroup execution

Page 33: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 33

Executor

Connection

Thread Control Picture (Out)

Action.execute

Connector

Connector

[Equipment]

Action.execute

RemoteCoaching

RemoteGoal

RemoteGoal

task goal

Performer

Performer

task goal

initiate connection

check status

Java code1

2

3

Page 34: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 34

Smallest Hello World

new Performer( “ralph” ) . performGoal(new Goal( “say hello” ) { public States execute(Data d) { System.out.println( “hello world” ); return PASSED; }}, null, new Data() );

Performer.performGoal( Goal, String, Data )

Page 35: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 35

Capability and Desire

Performer ralph = new Performer( “ralph” ) {{addGoal( new Goal( “say hello” ) { public States execute(Data d) { System.out.println( “hello world” ); return PASSED; }} );}}

ralph.performGoal( new BDIGoal( “say hello” ), “x”, new Data() );

declaringcapability

raisingdesire

Page 36: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 36

Task Goal

a task goal instance invokes the execute method of the enclosing goal:public States execute(Data d)

returns one ofPASSED, FAILED, BLOCKED, STOPPED, CANCEL

or throws exceptionLoopEndException, ParallelEndException

Page 37: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 37

Action

to represent “equipment interface” one equipment - many actions action goal

a goal that is achieved by performing the action reference to action within goal hierarchy many action goals for the same action (object) input/output data elements named by goal

Data.Element [] ins, Data.Element [] outs

Page 38: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 38

Action Example

public class SteeringSystem {Action turn_left = new Action( “turn left” ) { public States execute( boolean reentry,Data.Element [] ins, Data.Element [] outs ) { ...... }};Action turn_right = new Action( “turn right” ) { public States execute( boolean reentry,Data.Element [] ins, Data.Element [] outs ) { ...... }};}

Page 39: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 39

Action Goals Example

public class Steering extends Capability {

public Steering(SteeringSystem ss) {

addGoal( ss.turn_left.create(

new String [] { “foo”, “bar” }, new String [] { “fum”, “car” } ) );addGoal( ss.turn_right.create(

new String [] { “foo”, “bar” }, new String [] { “fum”, “car” } ) );}

}

Page 40: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 40

Remote Connection

RemoteCoaching( connector ) capability (base class)

RemoteGoal task goal created within a RemoteCoaching

capability invokes the connector.perform method input / output data (service request / response) monitoring progress

Page 41: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 41

Connector Model

Connector manages “channel” to service provider

Connection instantiated for each service use (session)

Page 42: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 42

RemoteCoaching.Connection

cancel() called by RemoteGoal being cancelled

States check() called by RemoteGoal querying completion

fail, pass, stop or block RemoteGoal updates Data on completion

via the Ref objects given to Connector.perform

Page 43: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 43

RemoteCoaching Example

public class Proxy extends Performer {public Proxy(String name) { super( name ); addCapability( new RemoteCoaching( new MultAndCoolyLink() ) {{ addGoal( new RemoteGoal( “service 1”, .... ) ); addGoal( new RemoteGoal( “service 2”, .... ) ); }} ); addCapability( new Capability() {{ .... }} ); }}

Page 44: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 44

GORITE Execution Summary

Perceptor, Executor.run(), performGoal(..) goal instances, todo groups Goal.States, exceptions

pass, fail, stop, block Plan, Context, Query, Relation, Ref objects Data, named data elements equipment modelling, RemoteCoaching

Page 45: GORITE Execution1 team model Performer, Team, Team.TaskTeam, Team.Role process model Capability, Plan, Goal SequenceGoal, ParallelGoal, BDIGoal, TeamGoal,

GORITE Execution 45

Not Covered

actions sequenced by data element readiness plan precedence relation keys trace naming of intentions (x.3:4.5*6:2) dealing with data at intention fork and join blocking and triggering