Reactive Mobile Agent Programming with Jinni Copyright © 1999, BinNet Corp. Paul Tarau University...
-
Upload
gilbert-hodges -
Category
Documents
-
view
214 -
download
0
Transcript of Reactive Mobile Agent Programming with Jinni Copyright © 1999, BinNet Corp. Paul Tarau University...
Reactive Mobile Agent Programming with Jinni
Copyright © 1999, BinNet Corp.
Paul TarauUniversity of North Texas
&BinNet Corporation
What is Jinni?What is Jinni?
JINNIJINNI: : JJava ava ININference engine and ference engine and NNetworked etworked IInteractor nteractor
• lightweight, multi-threaded lightweight, multi-threaded
• Prolog-style agent scripting language Prolog-style agent scripting language
• knowledge processing components knowledge processing components
• high level, distributed, Java based: high level, distributed, Java based: alternative to RMI, CORBA, KQMLalternative to RMI, CORBA, KQML
MotivationMotivation
• paradigm shift towards networked, paradigm shift towards networked, mobile, ubiquitous computingmobile, ubiquitous computing
• increasingly complex patterns of increasingly complex patterns of interactioninteraction
• reactive and mobile agentsreactive and mobile agents
• inference capabilities, autonomy and inference capabilities, autonomy and self-reliance.self-reliance.
BASIC ONTOLOGY: THE BASIC ONTOLOGY: THE USERS' VIEWUSERS' VIEW
• Things: Things: represented as Prolog termsrepresented as Prolog terms
• Places: Places: server component listening on server component listening on a port + Linda blackboarda port + Linda blackboard
• AgentsAgents: collections of mobile threads: collections of mobile threads
• running a set of goals at set of running a set of goals at set of PlacesPlaces
• transporting and processing transporting and processing ThingsThings
A typical Jinni applicationA typical Jinni application
• a hierarchy of a hierarchy of PlacesPlaces and and AgentsAgents
• Agent threads moving between Agent threads moving between PlacesPlaces
• wait for/produce wait for/produce ThingsThings satisfying satisfying constraintsconstraints
• sensing changes of state, produce and sensing changes of state, produce and react to react to eventsevents
THE ARCHITECTURE OF THE ARCHITECTURE OF JINNIJINNI
• operatorless syntactic subset of Prologoperatorless syntactic subset of Prolog
• multiple engines running on separate multiple engines running on separate threads,threads,
• blackboards to communicate between blackboards to communicate between enginesengines
• Linda coordination, associative searchLinda coordination, associative search
Architecture of Jinni - Architecture of Jinni - details -details -
• high level networking operations: code and high level networking operations: code and computation mobility, remote executioncomputation mobility, remote execution
• Jinni-to-Java translatorJinni-to-Java translator
• ability to load code directly from the Webability to load code directly from the Web
• hypothetical reasoning, backtrackable hypothetical reasoning, backtrackable assumptions, Assumption Grammarsassumptions, Assumption Grammars
The Jinni Kernel: Basic The Jinni Kernel: Basic Linda + Remote Predicate Linda + Remote Predicate CallsCalls• out(X):out(X): puts puts XX on the blackboard on the blackboard
• in(X):in(X): waits until it can take an object waits until it can take an object matchingmatching X X from the blackboard from the blackboard
• all(X,Xs):all(X,Xs): reads the list reads the list XsXs matching matching XX currently on the blackboardcurrently on the blackboard
• the(Pattern,Goal,Answer):the(Pattern,Goal,Answer): runs runs GoalGoal to to produce produce the(Answer) orthe(Answer) or no no => here/there => here/there switch =>switch =>locallocal//remoteremote
Assertional Constraints vs. Assertional Constraints vs. Binding Constrains Binding Constrains
• when nonvar(X) ...when nonvar(X) ...
• when proven(X) …when proven(X) …
• when a_fact(X)… more realisticwhen a_fact(X)… more realistic
• lower granularitylower granularity
• arguably: more appropriate for arguably: more appropriate for distributed programmingdistributed programming
Beyond Linda: Blackboard Beyond Linda: Blackboard Constraint OperationsConstraint Operations
• wait_for(Pattern,Constraint)wait_for(Pattern,Constraint): waits for a : waits for a PatternPattern on the blackboard, such that on the blackboard, such that ConstraintConstraint holds, and when this happens, holds, and when this happens, it removes the result of the match from the it removes the result of the match from the blackboard blackboard
• notify_about(Pattern)notify_about(Pattern): notifies about this : notifies about this PatternPattern one of the blocked threads which one of the blocked threads which waits for it with a matching constraintwaits for it with a matching constraint
Coordination with Coordination with Blackboard Constraints Blackboard Constraints
• ?- notify_about(stock_offer(aol,89)).?- notify_about(stock_offer(aol,89)).
• ?-wait_for(stock_offer(aol,Price), ?-wait_for(stock_offer(aol,Price), less(Price,90)).less(Price,90)).
wait_for(Pattern,Constr)wait_for(Pattern,Constr)
wait_for(P,C):-wait_for(P,C):-
if(if(take_patterntake_pattern(available_for(P),C),(available_for(P),C),
true,true,
and(local_out(waiting_for(P,C)),and(local_out(waiting_for(P,C)),
local_in(holds_for(P,C))local_in(holds_for(P,C))
) ).) ).
notify_about(Pattern,Consnotify_about(Pattern,Constr)tr)
notify_about(P):-notify_about(P):-
if(if(take_patterntake_pattern(waiting_for(P,C),C),(waiting_for(P,C),C),
local_out(holds_for(P,C)),local_out(holds_for(P,C)),
local_out(available_for(P))local_out(available_for(P))
).).
take_pattern/2take_pattern/2
take_pattern(Pattern,Constraint):-take_pattern(Pattern,Constraint):-
local_all(Pattern,Ps),local_all(Pattern,Ps),
member(Pattern,Ps),member(Pattern,Ps),
Constraint,Constraint,
local_cin(Pattern,_).local_cin(Pattern,_).
Mobile thread operationsMobile thread operations
• run_server/0, here/0, there/0, run_server/0, here/0, there/0, where/1where/1
• set_this_host/1, set_this_port/1set_this_host/1, set_this_port/1
• set_that_host/1,set_that_port/1set_that_host/1,set_that_port/1
• move/0, return/0move/0, return/0
• bg/1, bg/2, thread_clone/1bg/1, bg/2, thread_clone/1
BUILDING BEHAVIORS: BUILDING BEHAVIORS: BASIC AGENT BASIC AGENT PROGRAMMING PROGRAMMING CONSTRUCTSCONSTRUCTS• a reactive channel listener a reactive channel listener
• ?-?-listen(fun(_)).listen(fun(_)).
• selective channel publisher selective channel publisher
• ?-?-talk(fun(jokes)).talk(fun(jokes)).
• will not match:will not match:
• ?-talk(stocks(quotes,nasdaq))?-talk(stocks(quotes,nasdaq))
Example: a stock market Example: a stock market trader agenttrader agent
• sell(Who,Stock,AskPrice) :- sell(Who,Stock,AskPrice) :- notify_about(offer(Who,Stock,AskPrice)).notify_about(offer(Who,Stock,AskPrice)).
• buy(Who,Stock,SellingPrice) :- buy(Who,Stock,SellingPrice) :- bg(try_to_buy(Who,Stock,SellingPrice)).bg(try_to_buy(Who,Stock,SellingPrice)).
• try_to_buy(Me,Stock,LimitPrice) :- try_to_buy(Me,Stock,LimitPrice) :- wait_for(offer(You,Stock,YourPrice), wait_for(offer(You,Stock,YourPrice), ……….……….
Examples of Mobile Examples of Mobile ComputationsComputations
• Window 1Window 1: a mobile thread : a mobile thread
• ?-?- there, move, there, move, println(on_server), member(X,println(on_server), member(X,[1,2,3]), return, println(back).[1,2,3]), return, println(back).
• Window 2Window 2: a server : a server
• ?- run_server.?- run_server.
Mobile code vs. RPCs: Mobile code vs. RPCs: move once, compute move once, compute many timesmany times
• ?-for(I,1,1000), ?-for(I,1,1000), remote_run(println(I)), remote_run(println(I)), eq(I,1000). eq(I,1000).
• ?-there, move, for(I,1,1000), ?-there, move, for(I,1,1000), println(I), eq(I,1000).println(I), eq(I,1000).
Mobile code: WHY?Mobile code: WHY?
• Large database, small agent Large database, small agent
• Speed-up: move to a fast processor Speed-up: move to a fast processor and back, transparentlyand back, transparently
• here/there switch: same code can be here/there switch: same code can be run locally or remotelyrun locally or remotely
• fault tolerance - move->run->come fault tolerance - move->run->come backback
Emulating multiple Emulating multiple answer computationsanswer computations
• ?- there, move, ?- there, move, findall(X,for(I,1,3),Xs), return, findall(X,for(I,1,3),Xs), return, member(X,Xs).member(X,Xs).
• X=1;X=1;
• X=2;X=2;
• X=3X=3
Reflective Meta Reflective Meta InterpreterInterpreter
• solve(G):-solve(G):-once(reduce(G,NewG)),NewG.once(reduce(G,NewG)),NewG.
• reduce(G,G):-is_builtin(G).reduce(G,G):-is_builtin(G).
• reduce(','(A,B),','(solve(A),solve(B))).reduce(','(A,B),','(solve(A),solve(B))).
• reduce(G,','(clause(G,Gs),solve(Gs))).reduce(G,','(clause(G,Gs),solve(Gs))).
MUTUAL AGENT/HOST MUTUAL AGENT/HOST SECURITY: THE SECURITY: THE BRING BRING YOUR OWN WINEYOUR OWN WINE PRINCIPLEPRINCIPLE• reflective meta-interpreter: a few lines of reflective meta-interpreter: a few lines of
Prolog - can be Prolog - can be mobilemobile - bring your own! - bring your own!
• a a sandboxsandbox can protect the can protect the Host Host against against the the AgentAgent
• undecidability of a Turing equivalent undecidability of a Turing equivalent meta-interpreter protects the meta-interpreter protects the AgentAgent against theagainst the Host Host
Jinni Agent ClassesJinni Agent Classes
• Java layer: Java layer: – code and type inheritancecode and type inheritance
– reaction to eventsreaction to events
– libraries: Java3D, XML, special devices etc.libraries: Java3D, XML, special devices etc.
• Prolog layerProlog layer– knowledge processingknowledge processing
– reaction to blackboard constraintsreaction to blackboard constraints
– mobile codemobile code
Shared Virtual Reality Shared Virtual Reality AgentsAgents
• Web based: browser+EAI+Java+JinniWeb based: browser+EAI+Java+Jinni
• Jinni Server + Thin Jinni Applet ConnectorJinni Server + Thin Jinni Applet Connector
• NEXT: Java 3D + virtual peer-to-peer NEXT: Java 3D + virtual peer-to-peer Jinni networkJinni network
• new transport layers: Corba, RMI, HMLnew transport layers: Corba, RMI, HML
Stock Market AgentsStock Market Agents
• Day trader: Day trader:
• reactive agentsreactive agents
• Internet data mining for quotesInternet data mining for quotes
• user defined rulesuser defined rules
• far beyond conventional far beyond conventional limit/stop/market transactionslimit/stop/market transactions
Network monitoringNetwork monitoring
• new Internet2 infrastructure at UNTnew Internet2 infrastructure at UNT
• directly running in Java enabled directly running in Java enabled routersrouters
• mobile agents for Gigabit network mobile agents for Gigabit network monitoringmonitoring
• QoS negotiationQoS negotiation
Visual JinniVisual Jinni
• open sourceopen source
• extensibleextensible
• embedding of fast native Prolog embedding of fast native Prolog acceleratoraccelerator
• upcoming Java2D and Java3d upcoming Java2D and Java3d librarieslibraries
Agent Programming with Agent Programming with Controlled Natural Controlled Natural LanguageLanguage
• extension to distfix grammarsextension to distfix grammars
• patterns, backrackable assumptionspatterns, backrackable assumptions
• third party speech I/Othird party speech I/O
• translation from CNL to Kernel translation from CNL to Kernel PrologProlog
Educational agentsEducational agents
• chat, self organizing groupschat, self organizing groups
• alerts triggered by blackboard constraintsalerts triggered by blackboard constraints
• reusable agent hierarchiesreusable agent hierarchies
• student progress evaluationstudent progress evaluation
• Wizard of Oz help desk: combined human Wizard of Oz help desk: combined human and programmed agentsand programmed agents
ConclusionConclusion
• Synergy between Logic Programming and Synergy between Logic Programming and Java based distributed programmingJava based distributed programming
• Integrated infrastructure for building Integrated infrastructure for building Internet aware, GUI-enabled, networked Internet aware, GUI-enabled, networked Agent componentsAgent components
• High level software patterns for High level software patterns for productivity, reusability, quick productivity, reusability, quick prototypingprototyping