I was trying to implement parallelism amongst 2 agents, by following the procedure provided here.
The output I got (as shown below) is completely different to what is to be expected.
The program prints the name of the agent and the current system time during the action being performed. I tried performing parallelism amongst 2 agents where each agent is supposed to print their own name and current time, but only the latter of the 2 agents is performing its action.
javac test.java
java jade.Boot -agents aaa:test ccc:test
....
Agent container Main-Container@192.168.122.1 is ready.100: ccc
200: ccc
300: ccc
400: ccc
500: ccc
This was the code that I implemented
import jade.core.Agent;
import jade.core.behaviours.*;
public class test extends Agent{
protected void setup(){
addBehaviour(new Looper(this,100));
}
}
class Looper extends SimpleBehaviour
{
static String offset = "";
static long t0 = System.currentTimeMillis();
String tab = "" ;
int n = 1;
long dt;
public Looper( Agent a, long dt) {
super(a);
this.dt = dt;
offset += " " ;
tab = new String(offset) ;
}
public void action()
{
System.out.println( tab +
(System.currentTimeMillis()-t0)/10*10 + ": " +
myAgent.getLocalName() );
block( dt );
n++;
}
public boolean done() { return n>6; }
}
Expected output:
java jade.Boot aa:Agent1 zzzzz:Agent1
0: zzzzz
0: aa
10: zzzzz
10: aa
300: zzzzz
310: aa
510: zzzzz
510: aa
610: zzzzz
610: aa
910: zzzzz
920: aa
1020: zzzzz
1020: aa
1220: zzzzz
1220: aa
1520: zzzzz
1520: aa
1520: zzzzz
1530: aa
2030: zzzzz
2030: aa
2530: zzzzz
2530: aa
It is about "-agents" option which is a semicolon separated list of agent's specifiers. You can replace by this:
java -cp jade.Boot -agents "aaa:test;ccc:test"
or specifying classpath:
java -cp /home/myusername/jadelibpath/libjade-4.3.jar:. jade.Boot -agents "aaa:test;ccc:test"