Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

SPADE: Agents based on XMPP

Smart Python Multi-Agent System
A python platform for developing intelligent multi-agent systems that use XMPP to communicate.

  • Loggen Sie sich ein, um Kommentare anzuzeigen.

SPADE: Agents based on XMPP

  1. 1. Javier Palanca Smart Python Agent Development Environment
  2. 2. SPADE Smart Python Agent Dev Env based on JABBER / XMPP
  3. 3. 3 What is Jabber / XMPP? Jabber is an open protocol based on XML for instant messaging and presence notification. Project started at 1998 by Jeremie Miller. ● First release at 2000. Standardized by IETF and W3C for instant messaging over the Internet. Now is called XMPP for eXtensible Messaging and Presence Protocol
  4. 4. 4 How is Jabber? Open, public and free Standard Tested Decentralized Secure Extensible Flexible romeo@montesco.comjulieta@capuleto.com capuleto.com montesco.com
  5. 5. 5 Jabber in FIPA <x xmlns=”jabber:x:fipa”> Content <message> </message> <body> </body> Content Envelope
  6. 6. 6 Presence Notification Romeo Mercuccio Julieta Mercuccio Romeo XMPP Server Julieta Romeo
  7. 7. What is SPADE? ๏ Agent platform + agent library ๏ An evolution of FIPPER (Aranda G., Palanca J. 2004) ๏ FIPA-compliant ๏ Based on the Jabber/XMPP protocol ๏ Presence notification ๏ Multiplataform and Multilanguage ๏ Web-based interface
  8. 8. Platform XMPP Server AMS DF java agent python agent Host 1 python agent C++ agent Host 2 other agent Host 3 P2P IQ PresenceMessage web user interface (WUI) WUI WUI WUI WUI WUI
  9. 9. The Agent from spade.Agent import Agent class MyAgent(Agent): def _setup(self): print("Hello World") agent = MyAgent(user, passwd) agent.start() Hello World agent = autonomous program libAgent xmpp RPC SL0 RDF P2P Org Content Object Clips Social Network BDI AWUI Agent Web UI
  10. 10. Agent Architecture Mailbox Templates B BB XMPP IQ Manager Social Network Manager IQ Presence Message E Behaviors Events tpl.setPerformative("request") tpl.setFrom(agent_jid) tpl.setContent("any content") tpl.setLanguage("RDF")
  11. 11. Behaviors Cyclic OneShot Periodic FSM TimeOut Event ๏ Threads execute in parallel ๏ Each behavior has its own mailbox ๏ Message Templates (envelope and body) ๏ Interaction Protocols using Templates
  12. 12. Life Cycle Prologue Epilogue Based on Behaviors def onStart(self): def _process(self): msg = self._receive(block=True) reply = msg.createReply() self.myAgent.send(reply) def onEnd(self):
  13. 13. P2P XMPP Server java agent python agent python agent P2P IQ P2P negotiation negotiation negotiation XML object self.myAgent.send(message, method="p2p")
  14. 14. 14 User Interface
  15. 15. 15 User Interface
  16. 16. 16 User Interface
  17. 17. My First Agent https://pythonhosted.org/SPADE/ import spade import time class MyAgent(spade.Agent.Agent): def _setup(self): print("MyAgent starting...") if __name__ == "__main__": a = MyAgent("agent@", "secret") a.start() while True: try: time.sleep(1) except KeyboardInterrupt: break a.stop() $ python configure.py $ runspade.py SPADE 2.3 <jpalanca@gmail.com> - https:// github.com/javipalanca/SPADE Starting SPADE...... [done] [info] WebUserInterface serving at port 8008 $ python myagent.py MyAgent starting...
  18. 18. My First Behavior import spade import time class MyAgent(spade.Agent.Agent): class MyBehav(spade.Behaviour.Behaviour): def onStart(self): print("Starting behaviour…") self.counter = 0 def _process(self): print("Counter:", self.counter) self.counter = self.counter + 1 time.sleep(1) def _setup(self): print("MyAgent starting…") b = self.MyBehav() self.addBehaviour(b, None) if __name__ == "__main__": a = MyAgent("agent@", "secret") a.start() while True: try: time.sleep(1) except KeyboardInterrupt: break a.stop() $ python myagent.py MyAgent starting... Starting behaviour... Counter: 0 Counter: 1 Counter: 2 Counter: 3 Counter: 4 Counter: 5 Counter: 6 Counter: 7 …
  19. 19. Sender and Receiver # Sender Agent import spade class SenderAgent(spade.Agent.Agent): class SendBehav(spade.Behaviour.OneShotBehaviour): def _process(self): receiver = spade.AID.aid(name=“receiver@”, addresses=[“xmpp://”]) self.msg = spade.ACLMessage.ACLMessage() self.msg.setPerformative("inform") self.msg.setOntology("myOntology") self.msg.setLanguage("OWL-S") self.msg.addReceiver(receiver) self.msg.setContent("Hello World") self.myAgent.send(self.msg) def _setup(self): print "MyAgent starting . . ." b = self.SendBehav() self.addBehaviour(b, None) # Receiver Agent import spade import time class RecvAgent(spade.Agent.Agent): class ReceiveBehav(spade.Behaviour.Behaviour): def _process(self): self.msg = None self.msg = self._receive(block=False) # Check wether the message arrived if self.msg: print("I got a message!") else: print("I waited but got no message") time.sleep(1) def _setup(self): rb = self.ReceiveBehav() template = spade.Behaviour.ACLTemplate() template.setOntology("myOntology") mt = spade.Behaviour.MessageTemplate(template) self.addBehaviour(rb, mt)
  20. 20. Periodic Magentix C++ Conclusions xmpp RDF SL0 P2P Orgs Clips Social Network BDI WWW OWL Content Object java python events SIMBA HTTP IQ TimeOut OneShot FSM Cyclic Event behavs RPC
  21. 21. Collaborate with SPADE • Free Software project (LGPL) • Open to collaborations (please PULL REQUEST!) • SPADE 3.0 roadmap: ‣ from scratch, asyncio, simpler, faster… • Contact: • web: http://github.com/javipalanca/spade • email: jpalanca@dsic.upv.es