0

Java で実装された JADE にエージェントをデプロイできません。代替手段はありますか?

package package1;

import jade.core.Agent;

public class JadePFE extends Agent {
    @Override
    protected void setup() {
        System.out.println("Hello agent 007");
    }

}
4

2 に答える 2

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 プラットフォームがまだ実行されていない場合に機能します。

于 2014-12-24T12:32:26.523 に答える