26
Jinni: Intelligent Jinni: Intelligent Mobile Agent Mobile Agent Programming at the Programming at the Intersection of Java Intersection of Java and Prolog and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas & BinNet Corporation

Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

Embed Size (px)

Citation preview

Page 1: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

Jinni: Intelligent Mobile Jinni: Intelligent Mobile Agent Programming at Agent Programming at the Intersection of Java the Intersection of Java and Prologand Prolog

Copyright © 1999, BinNet Corp.

Paul TarauUniversity of North Texas

&BinNet Corporation

Page 2: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

other talk: Blackboard other talk: Blackboard Constraints in Jinni Constraints in Jinni http://www.binnetcorp.chttp://www.binnetcorp.comom

Copyright © 1999, BinNet Corp.

Paul TarauUniversity of North Texas

&BinNet Corporation

Page 3: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 4: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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.

Page 5: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 6: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 7: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 8: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

Architecture of Jinni - Architecture of Jinni - details -details -

• high level networking operations: code and high level networking operations: code and compoutation mobility, remote executioncompoutation 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

• hyothetical reasoning, backtrackable hyothetical reasoning, backtrackable assumptions, Assumption Grammarsassumptions, Assumption Grammars

Page 9: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 10: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 11: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 12: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

Coordination with Coordination with Blackboard Constraints Blackboard Constraints

• ?- ?- notify_about(stock_offer(nscp,29)).notify_about(stock_offer(nscp,29)).

• ?-wait_for(stock_offer(nscp,Price), ?-wait_for(stock_offer(nscp,Price), less(Price,30)).less(Price,30)).

Page 13: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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))

) ).) ).

Page 14: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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))

).).

Page 15: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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,_).

Page 16: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 17: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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))

Page 18: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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), ……….……….

Page 19: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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.

Page 20: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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).

Page 21: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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 localy or remotelyrun localy or remotely

• fault tolerance - move->run->come fault tolerance - move->run->come backback

Page 22: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 23: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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))).

Page 24: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

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

Page 25: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

Ongoing WorkOngoing Work

• Day trader: reactive agent, using Internet Day trader: reactive agent, using Internet data mining for quotes and user defined data mining for quotes and user defined rules beyond conventional rules beyond conventional limit/stop/market transactionslimit/stop/market transactions

• Network monitoring: new Internet2 Network monitoring: new Internet2 infrastructure at UNT, experiments with infrastructure at UNT, experiments with mobile agents on Gigabit networksmobile agents on Gigabit networks

• Visual Jinni, educational agentsVisual Jinni, educational agents

Page 26: Jinni: Intelligent Mobile Agent Programming at the Intersection of Java and Prolog Copyright © 1999, BinNet Corp. Paul Tarau University of North Texas

ConclusionConclusion

• Synergy between Logic Programming and Synergy between Logic Programming and Java based distributed programmingJava based distributed programming

• Integrated infrastructure for builting Integrated infrastructure for builting Internet aware, GUI-eanbled, networked Internet aware, GUI-eanbled, networked Agent componentsAgent components

• High level software patterns for High level software patterns for productivity, reusabilty, quick prototypingproductivity, reusabilty, quick prototyping