Download presentation
Presentation is loading. Please wait.
Published byWinfred Chandler Modified over 9 years ago
1
JADE: agents insights Fabiano Dalpiaz Agent-Oriented Software Engineering (AOSE) 2009-10
2
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)
3
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
4
F. Dalpiaz - AOSE 2009 My first agent: output Output
5
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
6
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
7
F. Dalpiaz - AOSE 2009 How Eclipse+EJADE looks like
8
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
9
F. Dalpiaz - AOSE 2009 Creating a new agent in Eclipse
10
F. Dalpiaz - AOSE 2009 Running a new agent Start the EJADE RMA Run the agent – right click on the java file – EJADE->deploy
11
F. Dalpiaz - AOSE 2009
12
Agent lifecycle
13
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.
14
Running an agent with parameters
15
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.
16
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
17
Exercise 1: agent basics
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.