コード例 #1
0
ファイル: JADEAgent.java プロジェクト: escalope/IDK
 /** To shutdown the agent, it deregisters itself from the address services of the platform */
 protected void takeDown() {
   System.out.println("Killing agent " + this.getName());
   DFAgentDescription[] roles = this.getDescription();
   for (int k = 0; k < roles.length; k++) {
     try {
       jade.domain.DFService.deregister(this, roles[k]);
     } catch (FIPAException fe) {
       //			fe.printStackTrace();
     }
   }
   MSMRepository.getInstance().remove(this.getLocalName());
   MSPRepository.getInstance().remove(this.getLocalName());
 }
コード例 #2
0
ファイル: LearnToTrustTest.java プロジェクト: escalope/IDK
  @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);
  }