jade: agents insights fabiano dalpiaz agent-oriented software engineering (aose) 2009-10
TRANSCRIPT
Java newbies
• The official Java tutorials are those by Sun
– http://java.sun.com/docs/books/tutorial/
– http://java.sun.com/docs/books/tutorial/getStarted/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)
F. Dalpiaz - AOSE 2009
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 BookBuyerAgent.java
java jade.Boot -container buyer:BookBuyerAgent
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
A JADE project in Eclipse step-by-step
1) Create a JAVA project Add http.jar, iiop.jar, jade.jar, jadeTools.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 takeDown() method
F. Dalpiaz - AOSE 2009
Running a new agent
• Start the EJADE RMA
• Run the agent
– right click on the java file
– EJADE->deploy
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 getArguments() method of the Agent class.
– For example, let’s assume that the BookBuyerAgent gets the title of the book to buy as a command line argument.
Terminating an agent
• Agents terminate only when an explicit function is called
• Call an agent’s doDelete() to terminate an agent
• The takeDown() method is invoked just before an agent terminates and is intended to include agent clean-up operations.
Exercise 1: agent basics
• Create an agent MySecondAgent
• 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