Sunteți pe pagina 1din 4

Intelligent Agent / Lab ‫المرحلة الرابعة‬ ‫ دينا رياض الشيباني‬/ ‫مدرس مساعد‬

1. What is JADE?
JADE - Java Agent DEvelopment Framework is a framework to develop and run multi-agent
systems in compliance with the FIPA specifications.
a. Developed by Telecom Italia @TILab
b. Distributed under LGPL

2. Running JADE Under Eclipse:


JADE can be run under eclipse “Run” as ‘Java Application’. Before you setup the execution
environment for JADE, you should add JADE’s .jar files to your project:
1. Go to Project  Properties
2. move to Java Build Path
3. in the “Libraries” tab, press “Add External JARs” button

Once you setup the class path for JADE, you can create a “Run Configuration”
for running JADE:
1
Intelligent Agent / Lab ‫المرحلة الرابعة‬ ‫ دينا رياض الشيباني‬/ ‫مدرس مساعد‬

1. Go to Run  Run Configurations


2. move to Java Application
3. in the “main” tab
4. specify your project name, and
5. main class is jade.Boot, and
6. check the Include libraries when searching for a main class

In the Tab “argument”, program arguments is the arguments that would be used
in command line, for example: ( -gui ).

2
Intelligent Agent / Lab ‫المرحلة الرابعة‬ ‫ دينا رياض الشيباني‬/ ‫مدرس مساعد‬

3. Running Result
To stop the application, File  Shut down Agent Platform;
Press “Yes” to question “Are you really sure to exit?”
Warning: do not use “X” on the up-right of the window to exit the
application in order to free the default port for running the platform.

4. Jade Programming Examples:


Example 1: Simple Timer
package d;
import jade.core.Agent;
import jade.core.behaviours.Behaviour;
import jade.core.behaviours.TickerBehaviour;

public class timer extends Agent {


int w = 15;

public void setup() {


addBehaviour(new TickerBehaviour(this, 1000) {
protected void onTick() {
if (w > 0) {
System.out.println(w);
w--;
} else {
System.out.println("Timer out");
myAgent.doDelete();
}

}
3
Intelligent Agent / Lab ‫المرحلة الرابعة‬ ‫ دينا رياض الشيباني‬/ ‫مدرس مساعد‬

});
}
}

Example 2: HelloWorld

package c;

import jade.core.Agent;

public class Hello extends Agent {protected void setup()


{
System.out.println("Hello World. ");
System.out.println("My name is "+ getLocalName());
}

Example 3: Complex
package c;
import jade.core.Agent;
import jade.core.behaviours.Behaviour;
import jade.core.behaviours.TickerBehaviour;

public class Complex extends Agent{


long t0 = System.currentTimeMillis();
Behaviour loop;

protected void setup()


{
loop = new TickerBehaviour( this, 300 )
{
/**
*
*/
private static final long serialVersionUID = 1L;

protected void onTick() {


System.out.println( System.currentTimeMillis()-t0 +
": " + myAgent.getLocalName());
}
};

addBehaviour( loop );
}

S-ar putea să vă placă și