Download presentation
Presentation is loading. Please wait.
1
multiagent systems a practical approach to MAS construction in Java (using Boris) Simon Lynch s.c.lynch@tees.ac.uk
2
software architecture distributed mixed language concurrent
3
MMD for multiple users dynamic structure
4
agents - why? MultiAgent Systems... advanced s/w architectures (dynamic, distributed...) mobility, platform independence design-time autonomy reuse agents can also simplify... concurrency interfacing s/w units
5
agents – what? independent software(?) entities –send & receive messages like objects but... –distributed –autonomous at design & execution –have their own process thread –tighter encapsulation & interfaces –task oriented
6
agents – what types? various types... web based, brokered small & mobile larger scale / intelligent...etc...
7
agents - how? in Java with Boris analogy... agents & GUI components GUI events & message events
8
Boris example Portal p = new Portal( portal-name ); Agent a = new Agent( agent-name ); a.addMessageListener(new MessageListener() { public void messageReceived(String from, String to, String msg, MsgId id) {...code body... } }); p.addAgent( a ); Panel p = new Panel(); Button b = new Button( text ); b.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) {...code body... } }); p.add( b );
9
Sending messages Portal p = new Portal( portal-name ); Agent sue = new Agent( "sue" ); sue.addMessageListener(new MessageListener() { public void messageReceived(String from, String to, String msg, MsgId id) {...code body... } }); p.addAgent( sue ); Agent sam = new Agent( "sam" ); p.addAgent( sam );... sam.sendMessage( "sue", "hello sue" );...
10
Virtual Networks normally, agents are distributed across multiple VMs multi-language VMs multiple machines Boris uses network concept based on... Portals Routers
11
agents, portals, routers & VMs MAS design... a collection of communicating agents
12
agents, portals & routers agents communicate via portals portals communicate via router(s)
13
agents, portals & routers agents who share a portal communicate directly routers not necessary for single-portal MASs
14
agents, portals & routers cross-portal communication requires a router even if portals share a VM
15
connecting portals to routers portal methods void connectToGrid( InetAddress host, int portNo ) void connectToGrid( int portNo ) void connectToGrid( InetAddress host ) void connectToGrid( ) NB: connection in separate thread may take few seconds over internet
16
using the console
17
loading agents import boris.kernel.*;..... public class MyClass {public MyClass( Portal portal, String cmdLine ) {//--- set up agent ---- final Agent agent = new Agent( name ); portal.addAgent( agent );..... }..... }
18
tracking activity
19
multiagent systems clones, replies & sessions Simon Lynch s.c.lynch@tees.ac.uk
20
clones - what non-clones have single instances for all message processing clones run multiple instances NB: –timers always run independently –Java agents are cloneable by default
21
clones - how new Agent( name, Agent.NON_CLONEABLE ); new Agent( name, Agent.CLONEABLE ); new Agent( name );
22
sending replies Portal p = new Portal( portal-name ); Agent sue = new Agent( "sue" ); sue.addMessageListener(new MessageListener() { public void messageReceived(String from, String to, String msg, MsgId id) {... sue.sendReply( id, "hello" + from );... } }); p.addAgent( sue ); Agent sam = new Agent( "sam" ); p.addAgent( sam );... sam.sendMessage( "sue", "hello sue" );...
23
MsgId NB: mostly MsgIds handle themselves, but these methods are supported... MsgId public String getSender() public String getSessionId() public boolean expectsReply()
24
receiving replies - 1 WaitReply sendAndWait( String to, String message ) WaitReply public String getFrom() public String getReply() public MsgId getMfor() public MsgId getId() String reply = sam.sendAndWait( "sue", "hello" ).getReply();
25
receiving replies - 2 sam.addMessageListener(new MessageListener() { public void messageReceived(String from, String to, String msg, MsgId id) {... sam.sendReply( id, message2 );... } }); ReplyListener rl = new ReplyListener() {public void replyReceived( String from, MsgId mfor, String reply, MsgId id ) {... } }; MsgId mid = sue.sendMessage( "sam", message1, rl );
26
boris - additional timers, scope & brokering Simon Lynch s.c.lynch@tees.ac.uk
27
timers why, what & how? 1.agent timers 2.countdown timers 3.alarm timers
28
agent timers Agent a = new Agent( name ); a.addAgentTimerListener( new AgentTimerListener() {public void timerElapsed( Agent a ) {...code body... } }); a.setDelay( delay );... a.start();... a.stop();...
29
the ball example Agent a = new Agent( "anon" ); a.addAgentTimerListener( new AgentTimerListener() {public void timerElapsed( Agent a ) {erase(); x = (x+dx) % bounds; y = (y+dy) % bounds; display(); } }); a.setDelay( delay ); display(); a.start(); }
30
a countdown timer Agent a = new Agent( name ); a.addAgentTimerListener( new AgentTimerListener() {public void timerElapsed( Agent a ) {if( coundown-elapsed ) {a.stop(); switchOff(); } else {...code body... } } }); a.setDelay( delay ); switchOn(); a.start();
31
alarm timer given: Calendar alarmTime... Agent a = new Agent( name ); a.addAgentTimerListener( new AgentTimerListener() {public void timerElapsed( Agent a ) {a.stop(); alarmOn(); } }); long alarmMS = alarmTime.getTime().getTime(); long nowMS = new Date().getTime(); a.setDelay( alarmMS – nowMS ); if (delay > 0 ) a.start(); else alarmOn();
32
scope why, what & how? MAS partitions holons reduced complexity tailored partitions (eg: localised brokers) enhanced security
33
scope in Boris why, what & how? internal- behind portal local- behind router global- the default
34
scope
35
scope in Boris why, what & how? portal.addAgent( agent ) portal.addAgent( agent, Portal.INTERNAL ) portal.addAgent( agent, Portal.LOCAL )
36
Brokers yellow pages agents some are localised (in holons, etc) some keep record of providers need for central service? in boris / java map agents to services services to agents etc
38
starting a router
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.