我无法在JADE实现的JADE中部署代理,有什么替代方案吗?
package package1;
import jade.core.Agent;
public class JadePFE extends Agent {
@Override
protected void setup() {
System.out.println("Hello agent 007");
}
}
答案 0 :(得分:1)
我认为你的意思是启动JADE平台,这是我发布整个事物的主要方法的内容。希望它有所帮助
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] args1 = new String[3];
args1[0] = "-gui";
args1[1] = "-agents";
args1[2] = "agentName:package.agentClassName";
jade.Boot.main(args1);
}
}
答案 1 :(得分:0)
如果我理解,您想知道如何直接从代码部署代理(并且可能启动平台)。
我告诉你如何:
import jade.core.Runtime;
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.wrapper.*;
public class Start {
public static void main(String args[]) throws InterruptedException, StaleProxyException {
// Get a hold on JADE runtime
Runtime runTime = Runtime.instance();
// Exit the JVM when there are no more containers around
runTime.setCloseVM(true);
// Create a profile and the main container and start RMA
Profile mainProfile = new ProfileImpl(true);
AgentContainer mainContainer = runTime.createMainContainer(mainProfile);
AgentController rma = mainContainer.createNewAgent("rma", "jade.tools.rma.rma", null);
rma.start();
Thread.sleep(500);
// Create a Sniffer
AgentController sniffer = mainContainer.createNewAgent(
"mySniffer", "jade.tools.sniffer.Sniffer",
new Object[]{"BuyerAgent1;BuyerAgent2;ShipperAgent1;ShipperAgent2"});
sniffer.start();
Thread.sleep(500);
// Create a Introspector
AgentController introspector = mainContainer.createNewAgent(
"myIntrospector", "jade.tools.introspector.Introspector",
null);
introspector.start();
Thread.sleep(500);
// Prepare for create and fire new agents:
Profile anotherProfile;
AgentContainer anotherContainer;
AgentController agent;
/* Create a new profile and a new non-main container, connecting to the
default main container (i.e. on this host, port 1099)
NB. Two containers CAN'T share the same Profile object: create a new one. */
anotherProfile = new ProfileImpl(false);
anotherContainer = runTime.createAgentContainer(anotherProfile);
System.out.println("Starting up a BuyerAgent...");
agent = anotherContainer.createNewAgent("BuyerAgent1", "transfersimulation.BuyerAgent", new Object[0]);
agent.start();
Thread.sleep(900);
anotherProfile = new ProfileImpl(false);
anotherContainer = runTime.createAgentContainer(anotherProfile);
System.out.println("Starting up a BuyerAgent...");
agent = anotherContainer.createNewAgent("BuyerAgent2", "transfersimulation.BuyerAgent", new Object[0]);
agent.start();
Thread.sleep(900);
anotherProfile = new ProfileImpl(false);
anotherContainer = runTime.createAgentContainer(anotherProfile);
System.out.println("Starting up a ShipperAgent...");
agent = anotherContainer.createNewAgent("ShipperAgent1", "transfersimulation.ShipperAgent", new Object[0]);
agent.start();
Thread.sleep(900);
return;
}
}
如果没有其他JADE平台正在运行,则此方法有效。