multiagent systems a practical approach to MAS construction in Java (using Boris) Simon Lynch [email protected] software architecture synchronisation Language Engine Pragmatic Integration Speech Recognition Working Kn Base synchronisation Speech Synthesis Language Generation LTM Kn Base Dialog Manager Expert System Wigit Input GUI Models Visualiser •distributed •mixed language •concurrent MMD for multiple users Language Engine Pragmatic Integration Speech Recognitio n Language Generation Speech Synthesis Wigit Input Working Kn Base GUI Models Visualiser LTM Kn Base Dialog Manager Language Engine Pragmatic Integration Speech Recognitio n Speech Synthesis Language Generation •dynamic structure Wigit Input GUI Models Visualiser Expert System 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 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 agents – what types? various types... • web based, brokered • small & mobile • larger scale / intelligent ...etc... agents - how? in Java with Boris analogy... • agents & GUI components • GUI events & message events Boris example Panel p = new Panel(); Button b = new Button( text ); b.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { ...code body... } }); p.add( b ); 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 ); 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" ); ... Virtual Networks normally, agents are distributed across • multiple VMs • multi-language VMs • multiple machines Boris uses network concept based on... • Portals • Routers agents, portals, routers & VMs agent agent agent agent agent MAS design... a collection of communicating agents agents, portals & routers agent agent portal agent agent agent portal agent router portal agent shared VM • agents communicate via portals • portals communicate via router(s) agents, portals & routers agent agent portal agent agent agent portal agent router portal agent shared VM • agents who share a portal communicate directly • routers not necessary for single-portal MASs agents, portals & routers agent agent portal agent agent agent portal agent router portal agent shared VM • cross-portal communication requires a router even if portals share a VM connecting portals to routers portal methods • void connectToGrid( • void connectToGrid( • void connectToGrid( • void connectToGrid( InetAddress host, int portNo ) int portNo ) InetAddress host ) ) NB: • connection in separate thread • may take few seconds over internet using the console 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 ); ..... } ..... } tracking activity multiagent systems clones, replies & sessions Simon Lynch [email protected] 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 clones - how new Agent( name, Agent.NON_CLONEABLE ); new Agent( name, Agent.CLONEABLE ); new Agent( name ); 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" ); ... MsgId NB: mostly MsgIds handle themselves, but these methods are supported... MsgId public String getSender() public String getSessionId() public boolean expectsReply() 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(); 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 ); boris - additional timers, scope & brokering Simon Lynch [email protected] timers why, what & how? 1. agent timers 2. countdown timers 3. alarm timers 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(); ... 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(); } 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(); 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(); scope why, what & how? • • • • MAS partitions holons reduced complexity tailored partitions • enhanced security (eg: localised brokers) scope in Boris why, what & how? • • • internal local global - behind portal - behind router - the default scope agent agent portal agent agent agent portal agent router portal agent shared VM scope in Boris why, what & how? portal.addAgent( agent ) portal.addAgent( agent, Portal.INTERNAL ) portal.addAgent( agent, Portal.LOCAL ) 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 starting a router
© Copyright 2026 Paperzz