JADE agents insights Fabiano Dalpiaz AgentOriented Software Engineering
JADE: agents insights Fabiano Dalpiaz Agent-Oriented Software Engineering (AOSE) 2009 -10
Java newbies • The official Java tutorials are those by Sun – http: //java. sun. com/docs/books/tutorial/get. Started/index. html – http: //java. sun. com/docs/books/tutorial/java/index. html • A useful resource is the Java resource portal – https: //javatutorials. dev. java. net/ • Further information can be found by searching in google (e. g. Java classes slides)
My first agent • Creating a JADE agent is as simple as defining a class extending the jade. core. Agent class and implementing the setup() method as shown in the code below. The setup() method is intended to include agent initializations. javac Book. Buyer. Agent. java jade. Boot -container buyer: Book. Buyer. Agent F. Dalpiaz - AOSE 2009
My first agent: output Output F. Dalpiaz - AOSE 2009
Development environment • The development of multi-agent systems with JADE does not require any development environment. . . – … but a dev. environment can make development faster! • JADE does not provide an official tool. . . – … but non-official tools are available – We suggest the usage of Eclipse with the plugin EJADE • Main features (for AOSE course): – 1 -click agent deployment – Launch/Shutdown RMA – Specify startup parameters F. Dalpiaz - AOSE 2009
Development environment • Install the development environment – Download ECLIPSE for JAVA developers • http: //www. eclipse. org/downloads/ – Install ECLIPSE – Download EJADE • http: //disi. unitn. it/~dnguyen/ejade/download. html – Install EJADE: copy the folder it. fbk. sra. ejade_0. 8. 0 folder to the folder eclipse/plugins – Run ECLIPSE A ready-to-use version is provided in the labs F. Dalpiaz - AOSE 2009
How Eclipse+EJADE looks like F. Dalpiaz - AOSE 2009
A JADE project in Eclipse step-bystep 1) Create a JAVA project Add http. jar, iiop. jar, jade. Tools. jar as External Libraries 2) Set source attachments (to get contextual help) – Download http: //disi. unitn. it/~dalpiaz/files/jadesrc. zip Link all the field “Source attachment” to the zip file for all the four external libraries 3) Create a class Extend jade. core. Agent Override the setup() and take. Down() method F. Dalpiaz - AOSE 2009
Creating a new agent in Eclipse F. Dalpiaz - AOSE 2009
Running a new agent • Start the EJADE RMA • Run the agent – right click on the java file – EJADE->deploy F. Dalpiaz - AOSE 2009
F. Dalpiaz - AOSE 2009
Agent lifecycle
Passing arguments to agents • Agents may get start-up arguments specified on the command line. – These arguments can be retrieved, as an array of Object, by means of the get. Arguments() method of the Agent class. – For example, let’s assume that the Book. Buyer. Agent gets the title of the book to buy as a command line argument.
Running an agent with parameters
Terminating an agent • Agents terminate only when an explicit function is called • Call an agent’s do. Delete() to terminate an agent • The take. Down() method is invoked just before an agent terminates and is intended to include agent clean-up operations.
Exercise 1: agent basics • Create an agent My. Second. Agent • Handle parameter passing – Input: two string parameters – Print the first parameter • Terminate the agent at the end of the setup() – The agent prints the second parameter before termination • Execute with EJADE – Separate passed parameters with a space
Exercise 1: agent basics
- Slides: 17