agent - JADE AchieveREInitiator not working properly. prepareRequests is not called -
agent - JADE AchieveREInitiator not working properly. prepareRequests is not called -
i using jade build agent-based platform solve scheduling problems. case that, defined behaviour extends achievereinitiator doesn't work in specific state of programme. behaviour class:
class acoinitiator extends achievereinitiator { agent myagent; list<schedule> roundschedules; public acoinitiator(agent a, aclmessage msg) { super(a, msg); this.myagent = a; roundschedules = new arraylist<schedule>(); system.out.println(msg.getcontent()); //this printed. // todo auto-generated constructor stub } @override protected vector preparerequests(aclmessage request) { system.out.println(request.getcontent()); //in specific state, not printed. vector v = new vector(1); (int = 1; <= properties.antnum; i++) { aid aaid = new aid("ant" + i, aid.islocalname); request.addreceiver(aaid); aaid = null; } v.addelement(request); homecoming v; } @override protected void handleagree(aclmessage agree) { seek { roundschedules.add((schedule) (agree.getcontentobject())); } grab (unreadableexception e) { // todo auto-generated grab block e.printstacktrace(); } agree = null; } @override protected void handleallresponses(vector responses) { collections.sort(roundschedules); environment.itersolution = roundschedules.get(0); roundschedules = null; environment.setstate(environment.state_iteration_checking); responses = null; myagent.removebehaviour(this); } } when programme executed, next results shown:
generate solution. generate solution. iteration #1: 788.0(0.48s) (new best solution) generate solution. generate solution. iteration #2: 809.0(0.12s) r = 1/2 generate solution. generate solution. iteration #3: 793.0(0.08s) r = 2/2 ...... ----- simulation starts ----- ...... @120 breakdown machines: repaired machines: incoming jobs: 2-5; generate solution. ----- schemes finished ----- this unwanted. apparently, 2 strings printed same. that's why every iteration in solution stage, 2 "generate solution." printed. however, in later simulation stage, 1 "generate solution." printed , programmes goes end. can inferred "preparerequests" method in not auto called, in before stage. i'm new jade , problem has bothered me couple of days. please help if jade programmer.
i'm not sure understand question or problem can see first printout "generate solution" happens in constructor:
public acoinitiator(agent a, aclmessage msg) { -> system.out.println(msg.getcontent())
the sec 1 in prepare requests method:
protected vector preparerequests(aclmessage request) {-> system.out.println(msg.getcontent()) .
also remember when interacting multiple agents initiator behaviour wait response responder behaviours.
hope helps, if not, seek attaching sniffer diagrams.
agent agents-jade
Comments
Post a Comment