Beispiel #1
0
  public static void main(String args[]) throws Exception {
    IAFProperties.setGraphicsOn(false);

    new Thread() {
      public void run() {
        String[] args1 = new String[4];
        args1[0] = "-port";
        args1[1] = "60000";
        args1[2] = "-file-dir";
        args1[3] = "jade/";
        jade.Boot.main(args1);
      }
    }.start();

    // Get a hold on JADE runtime
    jade.core.Runtime rt = jade.core.Runtime.instance();

    // Exit the JVM when there are no more containers around
    rt.setCloseVM(true);

    // Create a default profile
    Profile p = new ProfileImpl();
    p.setParameter("preload", "a*");
    p.setParameter(Profile.MAIN_PORT, "60000");
    p.setParameter(Profile.FILE_DIR, "jade/");

    // Waits for JADE to start
    boolean notConnected = true;

    while (notConnected) {
      try {
        Socket s = new Socket("localhost", Integer.parseInt("60000"));
        notConnected = false;
      } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {

        System.err.println("Error: " + e.getMessage());
        System.err.println("Reconnecting in one second");
        try {
          Thread.currentThread().sleep(1000);
        } catch (InterruptedException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
      }
    }

    // Create a new non-main container, connecting to the default
    // main container (i.e. on this host, port 1099)
    final jade.wrapper.AgentContainer ac = rt.createAgentContainer(p);

    {
    }
    MainInteractionManager.getInstance().setTitle("node ");
  }
Beispiel #2
0
  public static void main(String args[]) throws Exception {

    // Get a hold on JADE runtime
    jade.core.Runtime rt = jade.core.Runtime.instance();

    // Exit the JVM when there are no more containers around
    rt.setCloseVM(true);

    // Create a default profile
    Profile p = new ProfileImpl();
    p.setParameter("preload", "a*");
    p.setParameter(Profile.MAIN_PORT, "60000");
    p.setParameter(Profile.FILE_DIR, "jade/");

    // Create a new non-main container, connecting to the default
    // main container (i.e. on this host, port 1099)
    final jade.wrapper.AgentContainer ac = rt.createAgentContainer(p);

    {
    }
    MainInteractionManager.getInstance().setTitle("node ");
  }
Beispiel #3
0
  public static void main(String args[]) throws Exception {

    // Get a hold on JADE runtime
    jade.core.Runtime rt = jade.core.Runtime.instance();

    // Exit the JVM when there are no more containers around
    rt.setCloseVM(true);

    // Create a default profile
    Profile p = new ProfileImpl();
    p.setParameter("preload", "a*");
    p.setParameter(Profile.MAIN_PORT, "60000");
    if (args.length == 2 && args[1].equalsIgnoreCase("pause")) {
      ingenias.jade.graphics.MainInteractionManager.goManual();
    }
    if (new File("target/jade").exists() && new File("target/jade").isDirectory())
      p.setParameter(Profile.FILE_DIR, "target/jade/");
    else {
      // from http://stackoverflow.com/questions/617414/create-a-temporary-directory-in-java
      final File temp;
      temp = File.createTempFile("jade", Long.toString(System.nanoTime()));

      if (!(temp.delete())) {
        throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());
      }

      if (!(temp.mkdir())) {
        throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());
      }
      p.setParameter(Profile.FILE_DIR, temp.getAbsolutePath() + "/");
    }

    // Create a new non-main container, connecting to the default
    // main container (i.e. on this host, port 1099)
    final jade.wrapper.AgentContainer ac = rt.createAgentContainer(p);

    {
      // Create a new agent
      final jade.wrapper.AgentController agcGUIAgent_0DeploymentUnitByType0 =
          ac.createNewAgent(
              "GUIAgent_0DeploymentUnitByType0",
              "ingenias.jade.agents.GUIAgentJADEAgent",
              new Object[0]);

      new Thread() {
        public void run() {
          try {
            System.out.println("Starting up GUIAgent_0DeploymentUnitByType0...");
            agcGUIAgent_0DeploymentUnitByType0.start();
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }.start();

      // Create a new agent
      final jade.wrapper.AgentController agcGUIAgent_1DeploymentUnitByType0 =
          ac.createNewAgent(
              "GUIAgent_1DeploymentUnitByType0",
              "ingenias.jade.agents.GUIAgentJADEAgent",
              new Object[0]);

      new Thread() {
        public void run() {
          try {
            System.out.println("Starting up GUIAgent_1DeploymentUnitByType0...");
            agcGUIAgent_1DeploymentUnitByType0.start();
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }.start();

      // Create a new agent
      final jade.wrapper.AgentController agcGUIAgent_2DeploymentUnitByType0 =
          ac.createNewAgent(
              "GUIAgent_2DeploymentUnitByType0",
              "ingenias.jade.agents.GUIAgentJADEAgent",
              new Object[0]);

      new Thread() {
        public void run() {
          try {
            System.out.println("Starting up GUIAgent_2DeploymentUnitByType0...");
            agcGUIAgent_2DeploymentUnitByType0.start();
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }.start();
    }
    MainInteractionManager.getInstance().setTitle("node SampleDeployment");
  }
Beispiel #4
0
  @Test
  public void testDemo() throws Exception {
    // Involved agent local ids for this test are:

    // -AutonomousColaborator_0AutonomousColaboratorDU

    // -SourcesSupervisor_0SourcesSupervisorDU

    // -SourcesSupervisor_1SourcesSupervisorDU

    // -SourcesManager_0SourcesManagerDU

    // -ResearcherAssistant_0ResearcherAssistantDU

    // -SourcesInspector_0SourcesInspectorDU

    // -SourcesAlfaInspector_0SourcesAlfaInspectorDU

    // write here the agent id whose
    // mental state manager you want to get access to
    // MentalStateManager msm = MSMRepository.getInstance().get("MY_AGENT_ID"); // provides access
    // to the
    // For current agents, these are the variables containing their mental states

    int delay = 5000;

    IAFProperties.setGarbageCollectionInterval(100);

    MentalStateManager msmA =
        MSMRepository.getInstance().waitFor("ResearcherAssistant_0ResearcherAssistantDU");
    MentalStateProcessor mspA =
        MSPRepository.getInstance().waitFor("ResearcherAssistant_0ResearcherAssistantDU");
    TestUtils.waitForAgentInitialised(mspA);

    MentalStateManager msmB =
        MSMRepository.getInstance().waitFor("SourcesSupervisor_0SourcesSupervisorDU");
    MentalStateProcessor mspB =
        MSPRepository.getInstance().waitFor("SourcesSupervisor_0SourcesSupervisorDU");
    TestUtils.waitForAgentInitialised(mspB);

    MainInteractionManager.goAutomatic();

    NewIntroducedProposalEvent evento = new NewIntroducedProposalEvent();
    evento.setdata("urn:fuente:3");
    msmA.addMentalEntity(evento);

    TestUtils.doNothing(delay);

    TestUtils.checkExistenceMEWithinMS(
        msmB, "TrustInformation", "SourcesSupervisor_0SourcesSupervisorDU", 1);

    evento = new NewIntroducedProposalEvent();
    evento.setdata("urn:fuente:3");
    msmA.addMentalEntity(evento);

    TestUtils.doNothing(delay);

    evento = new NewIntroducedProposalEvent();
    evento.setdata("urn:fuente:3");
    msmA.addMentalEntity(evento);

    TestUtils.doNothing(delay);

    evento = new NewIntroducedProposalEvent();
    evento.setdata("urn:fuente:3");
    msmA.addMentalEntity(evento);

    TestUtils.doNothing(delay);
    TestUtils.doNothing(delay);
    TestUtils.doNothing(delay);

    TrustInformation vcr = (TrustInformation) msmB.getMentalEntityByType("TrustInformation").get(0);
    ReGreTInfo data = (ReGreTInfo) vcr.getdata();
    assertNotNull("The ReGreTInfo must not be null but it is", data);
    assertNotNull("Outcome database must not be null but it is", data.getOdb());
    assertTrue(
        "There should be an evaluation for ResearcherAssistant_0 and there are " + data.getOdb(),
        data.getOdb().get("ResearcherAssistant_0ResearcherAssistantDU") != null);

    assertTrue(
        "There should be four evaluations of agent ResearcherAssistant_0 and there are the following "
            + data.getOdb().size(),
        data.getOdb().get("ResearcherAssistant_0ResearcherAssistantDU").size() == 4);
    assertTrue(
        "The trust reability in ResearcherAssistant_0 must be greater than 50% but it is "
            + data.getConfianzas()
                .get("ResearcherAssistant_0ResearcherAssistantDU")
                .getSubjectCriteriaGoodQuality()
                .getReliability(),
        data.getConfianzas()
                .get("ResearcherAssistant_0ResearcherAssistantDU")
                .getSubjectCriteriaGoodQuality()
                .getReliability()
            >= 0.5);
    assertTrue(
        "The trust value in AutonomousCollaborator_0 must be less than 0 but it is "
            + data.getConfianzas()
                .get("ResearcherAssistant_0ResearcherAssistantDU")
                .getSubjectCriteriaGoodQuality()
                .getValue(),
        data.getConfianzas()
                .get("ResearcherAssistant_0ResearcherAssistantDU")
                .getSubjectCriteriaGoodQuality()
                .getValue()
            > 0);
  }