Package unbbayes.prs.bn

Examples of unbbayes.prs.bn.PotentialTable


    int areMeetingState = 0;
    ProbabilisticNode parent = (ProbabilisticNode) pn
        .getNode("hasExchangeIllicitCargoPartition_ship1");
    ProbabilisticNode child = (ProbabilisticNode) pn
        .getNode("areMeeting_ship1_ship2");
    PotentialTable table = ((PotentialTable) child.getProbabilityFunction());
    int[] coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    coord[table.getVariableIndex(parent)] = hasExchangeIllicitCargoPartitionState;
    if (Math.random() <= table.getValue(coord))
      areMeetingState = 0;
    else
      areMeetingState = 1;

    // Define if ship has a normal change in destination
    int hasNormalChangeInDestinationState;
    parent = (ProbabilisticNode) pn.getNode("hasTypeOfShip_ship1");
    child = (ProbabilisticNode) pn
        .getNode("hasNormalChangeInDestination_ship1");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    coord[table.getVariableIndex(parent)] = hasTypeOfShipState;
    if (Math.random() <= table.getValue(coord)) {
      hasNormalChangeInDestinationState = 0;
      ship.setHasNormalChangeInDestination(true);
    } else {
      hasNormalChangeInDestinationState = 1;
      ship.setHasNormalChangeInDestination(false);
    }

    // Define if ship has unusual route
    child = (ProbabilisticNode) pn.getNode("hasUnusualRoute_ship1");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("areMeeting_ship1_ship2");
    coord[table.getVariableIndex(parent)] = areMeetingState;
    parent = (ProbabilisticNode) pn.getNode("hasBombingPlan_ship1");
    coord[table.getVariableIndex(parent)] = hasBombingPlanState;
    parent = (ProbabilisticNode) pn
        .getNode("hasNormalChangeInDestination_ship1");
    coord[table.getVariableIndex(parent)] = hasNormalChangeInDestinationState;
    if (Math.random() <= table.getValue(coord)) {
      ship.setOnUnusualRoute(true);
      ship.setOnUsualRoute(false);
    } else {
      ship.setOnUnusualRoute(false);
      ship.setOnUsualRoute(true);
View Full Code Here


    int hasEvasiveBehaviorState = 0;
    ProbabilisticNode parent = (ProbabilisticNode) pn
        .getNode("hasExchangeIllicitCargoPartition_ship1");
    ProbabilisticNode child = (ProbabilisticNode) pn
        .getNode("hasEvasiveBehavior_ship1");
    PotentialTable table = ((PotentialTable) child.getProbabilityFunction());
    int[] coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    coord[table.getVariableIndex(parent)] = hasExchangeIllicitCargoPartitionState;
    if (Math.random() <= table.getValue(coord))
      hasEvasiveBehaviorState = 0;
    else
      hasEvasiveBehaviorState = 1;

    // Define if ship's electronicis is working
    int isElectronicsWorkingState = 0;
    child = (ProbabilisticNode) pn.getNode("isElectronicsWorking_ship1");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    if (Math.random() <= table.getValue(coord)) {
      isElectronicsWorkingState = 0;
      ship.setElectronicsWorking(true);
    } else {
      isElectronicsWorkingState = 1;
      ship.setElectronicsWorking(false);
    }

    // Define if ship has responsive AIS
    child = (ProbabilisticNode) pn.getNode("hasResponsiveAIS_ship1");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("hasEvasiveBehavior_ship1");
    coord[table.getVariableIndex(parent)] = hasEvasiveBehaviorState;
    parent = (ProbabilisticNode) pn.getNode("isElectronicsWorking_ship1");
    coord[table.getVariableIndex(parent)] = isElectronicsWorkingState;
    if (Math.random() <= table.getValue(coord)) {
      ship.setHasResponsiveAIS(true);
    } else {
      ship.setHasResponsiveAIS(false);
    }

    // Define if ship has responsive radio
    child = (ProbabilisticNode) pn.getNode("hasResponsiveRadio_ship1");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("hasEvasiveBehavior_ship1");
    coord[table.getVariableIndex(parent)] = hasEvasiveBehaviorState;
    parent = (ProbabilisticNode) pn.getNode("isElectronicsWorking_ship1");
    coord[table.getVariableIndex(parent)] = isElectronicsWorkingState;
    if (Math.random() <= table.getValue(coord)) {
      ship.setHasResponsiveRadio(true);
    } else {
      ship.setHasResponsiveRadio(false);
    }
  }
View Full Code Here

    int hasErraticBehaviorState = 0;
    ProbabilisticNode parent = (ProbabilisticNode) pn
        .getNode("hasExchangeIllicitCargoPartition_ship1");
    ProbabilisticNode child = (ProbabilisticNode) pn
        .getNode("hasErraticBehavior_ship1");
    PotentialTable table = ((PotentialTable) child.getProbabilityFunction());
    int[] coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    coord[table.getVariableIndex(parent)] = hasExchangeIllicitCargoPartitionState;
    if (Math.random() <= table.getValue(coord))
      hasErraticBehaviorState = 0;
    else
      hasErraticBehaviorState = 1;

    // Define if ship has equipment failure
    int hasEquipmentFailureState = 0;
    child = (ProbabilisticNode) pn.getNode("hasEquipmentFailure_ship1");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    if (Math.random() <= table.getValue(coord)) {
      hasEquipmentFailureState = 0;
      ship.setHasEquipmentFailure(true);
    } else {
      hasEquipmentFailureState = 1;
      ship.setHasEquipmentFailure(false);
    }

    // Define if ship has crew visible
    child = (ProbabilisticNode) pn.getNode("isCrewVisible_ship1");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("hasErraticBehavior_ship1");
    coord[table.getVariableIndex(parent)] = hasErraticBehaviorState;
    parent = (ProbabilisticNode) pn.getNode("hasEquipmentFailure_ship1");
    coord[table.getVariableIndex(parent)] = hasEquipmentFailureState;
    if (Math.random() <= table.getValue(coord)) {
      ship.setCrewVisible(true);
    } else {
      ship.setCrewVisible(false);
    }
View Full Code Here

    // Define if ship has aggressive behavior
    int hasAggressiveBehaviorState = 0;
    ProbabilisticNode child = (ProbabilisticNode) pn
        .getNode("hasAggressiveBehavior_ship1");
    PotentialTable table = ((PotentialTable) child.getProbabilityFunction());
    int[] coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    ProbabilisticNode parent = (ProbabilisticNode) pn
        .getNode("hasExchangeIllicitCargoPartition_ship1");
    coord[table.getVariableIndex(parent)] = hasExchangeIllicitCargoPartitionState;
    parent = (ProbabilisticNode) pn.getNode("hasBombingPlan_ship1");
    coord[table.getVariableIndex(parent)] = hasBombingPlanState;
    float f = table.getValue(coord);
    if (Math.random() <= f){
      ship.setHasAggressiveBehaviorState(true);
      hasAggressiveBehaviorState = 0;
    }
    else{
      ship.setHasAggressiveBehaviorState(false);
      hasAggressiveBehaviorState = 1
    }
   
    // Define if ship weapon visible
    child = (ProbabilisticNode) pn.getNode("hasWeaponVisible_ship1");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("hasAggressiveBehavior_ship1");
    coord[table.getVariableIndex(parent)] = hasAggressiveBehaviorState;
    if (Math.random() <= table.getValue(coord)) {
      ship.setHasWeaponVisible(true);
    } else {
      ship.setHasWeaponVisible(false);
    }

    // Define if ship is jettisoning cargo
    child = (ProbabilisticNode) pn.getNode("isJettisoningCargo_ship1");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("hasAggressiveBehavior_ship1");
    coord[table.getVariableIndex(parent)] = hasAggressiveBehaviorState;
    if (Math.random() <= table.getValue(coord)) {
      ship.setJettisoningCargo(true);
    } else {
      ship.setJettisoningCargo(false);
    }
  }
View Full Code Here

    // Define if person communicates with terrorist
    int communicatesWithTerroristsState = 0;
    ProbabilisticNode child = (ProbabilisticNode) pn
        .getNode("communicatesWithTerrorists_person");
    PotentialTable table = ((PotentialTable) child.getProbabilityFunction());
    int[] coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    ProbabilisticNode parent = (ProbabilisticNode) pn
        .getNode("isTerrorist_person");
    coord[table.getVariableIndex(parent)] = isTerroristState;
    if (Math.random() <= table.getValue(coord)) {
      communicatesWithTerroristsState = 0;
      person.setCommunicatesWithTerrorists(true);
    } else {
      communicatesWithTerroristsState = 1;
      person.setCommunicatesWithTerrorists(false);
    }

    // Define if person uses weblog
    child = (ProbabilisticNode) pn.getNode("usesWeblog_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("communicatesWithTerrorists_person");
    coord[table.getVariableIndex(parent)] = communicatesWithTerroristsState;
    if (Math.random() <= table.getValue(coord)) {
      person.setUsesWeblog(true);
    } else {
      person.setUsesWeblog(false);
    }

    // Define if person uses email
    child = (ProbabilisticNode) pn.getNode("usesEmail_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    coord[table.getVariableIndex(parent)] = communicatesWithTerroristsState;
    if (Math.random() <= table.getValue(coord)) {
      person.setUsesEmail(true);
    } else {
      person.setUsesEmail(false);
    }
   
    // Define if person uses cellular
    child = (ProbabilisticNode) pn.getNode("usesCellular_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    coord[table.getVariableIndex(parent)] = communicatesWithTerroristsState;
    if (Math.random() <= table.getValue(coord)) {
      person.setUsesCellular(true);
    } else {
      person.setUsesCellular(false);
    }
   
    // Define if person uses chatroom
    child = (ProbabilisticNode) pn.getNode("usesChatroom_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    coord[table.getVariableIndex(parent)] = communicatesWithTerroristsState;
    if (Math.random() <= table.getValue(coord)) {
      person.setUsesChatroom(true);
    } else {
      person.setUsesChatroom(false);
    }
  }
View Full Code Here

    // Define if person has terrorist beliefs
    int hasTerroristBeliefsState = 0;
    ProbabilisticNode child = (ProbabilisticNode) pn
        .getNode("hasTerroristBeliefs_person");
    PotentialTable table = ((PotentialTable) child.getProbabilityFunction());
    int[] coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    ProbabilisticNode parent = (ProbabilisticNode) pn
        .getNode("isTerrorist_person");
    coord[table.getVariableIndex(parent)] = isTerroristState;
    if (Math.random() <= table.getValue(coord)) {
      hasTerroristBeliefsState = 0;
      person.setCommunicatesWithTerrorists(true);
    } else {
      hasTerroristBeliefsState = 1;
      person.setCommunicatesWithTerrorists(false);
    }

    // Define if person has kinship to terrorist (none, few, or many)
    child = (ProbabilisticNode) pn.getNode("hasKinshipToTerrorist_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("hasTerroristBeliefs_person");
    coord[table.getVariableIndex(parent)] = hasTerroristBeliefsState;
    float noneUpperBound = table.getValue(coord);
    coord[0] = 1;
    float fewUpperBound = noneUpperBound + table.getValue(coord);
    float randomProbability = (float) Math.random();
    if (randomProbability <= noneUpperBound) {
      person.setHasKinshipToTerrorist(Quantity.None);
    } else if (randomProbability <= fewUpperBound) {
      person.setHasKinshipToTerrorist(Quantity.Few);
    } else {
      person.setHasKinshipToTerrorist(Quantity.Many);
    }

    // Define if person has friendship with terrorist (none, few, or many)
    child = (ProbabilisticNode) pn.getNode("hasFriendshipWithTerrorist_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("hasTerroristBeliefs_person");
    coord[table.getVariableIndex(parent)] = hasTerroristBeliefsState;
    noneUpperBound = table.getValue(coord);
    coord[0] = 1;
    fewUpperBound = noneUpperBound + table.getValue(coord);
    randomProbability = (float) Math.random();
    if (randomProbability <= noneUpperBound) {
      person.setHasFriendshipWithTerrorist(Quantity.None);
    } else if (randomProbability <= fewUpperBound) {
      person.setHasFriendshipWithTerrorist(Quantity.Few);
View Full Code Here

    // Define the cluster partition of a person (CentralStaff, SoutheastAsia,
    // MaghrebArab, CoreArab, or Other)
    int hasClusterPartitionState = 0;
    ProbabilisticNode child = (ProbabilisticNode) pn
        .getNode("hasClusterPartition_person");
    PotentialTable table = ((PotentialTable) child.getProbabilityFunction());
    int[] coord = new int[child.getParents().size() + 1];
    ProbabilisticNode parent = (ProbabilisticNode) pn
        .getNode("isTerrorist_person");
    coord[table.getVariableIndex(parent)] = isTerroristState;
    coord[0] = 0;
    float centralStaffUpperBound = table.getValue(coord);
    coord[0] = 1;
    float southeastAsiaUpperBound = centralStaffUpperBound + table.getValue(coord);
    coord[0] = 2;
    float maghrebArabUpperBound = southeastAsiaUpperBound + table.getValue(coord);
    coord[0] = 3;
    float coreArabUpperBound = maghrebArabUpperBound + table.getValue(coord);
    float randomProbability = (float) Math.random();
    if (randomProbability <= centralStaffUpperBound) {
      hasClusterPartitionState = 0;
      person.setHasClusterPartition(ClusterPartition.CentralStaff);
    } else if (randomProbability <= southeastAsiaUpperBound) {
      hasClusterPartitionState = 1;
      person.setHasClusterPartition(ClusterPartition.SoutheastAsia);
    } else if (randomProbability <= maghrebArabUpperBound) {
      hasClusterPartitionState = 2;
      person.setHasClusterPartition(ClusterPartition.MaghrebArab);
    } else if (randomProbability <= coreArabUpperBound) {
      hasClusterPartitionState = 3;
      person.setHasClusterPartition(ClusterPartition.CoreArab);
    } else {
      hasClusterPartitionState = 4;
      person.setHasClusterPartition(ClusterPartition.Other);
    }

    // Define the person nationality (Egypt, SaudiArabia, etc)
    child = (ProbabilisticNode) pn.getNode("hasNationality_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    parent = (ProbabilisticNode) pn.getNode("hasClusterPartition_person");
    coord[table.getVariableIndex(parent)] = hasClusterPartitionState;
    coord[0] = 0;
    float egyptUpperBound = table.getValue(coord);
    coord[0] = 1;
    float saudiArabiaUpperBound = egyptUpperBound + table.getValue(coord);
    coord[0] = 2;
    float kuwaitUpperBound = saudiArabiaUpperBound + table.getValue(coord);
    coord[0] = 3;
    float jordanUpperBound = kuwaitUpperBound + table.getValue(coord);
    coord[0] = 4;
    float iraqUpperBound = jordanUpperBound + table.getValue(coord);
    coord[0] = 5;
    float sudanUpperBound = iraqUpperBound + table.getValue(coord);
    coord[0] = 6;
    float libyaUpperBound = sudanUpperBound + table.getValue(coord);
    coord[0] = 7;
    float lebannonUpperBound = libyaUpperBound + table.getValue(coord);
    coord[0] = 8;
    float indonesiaUpperBound = lebannonUpperBound + table.getValue(coord);
    coord[0] = 9;
    float malaysiaUpperBound = indonesiaUpperBound + table.getValue(coord);
    coord[0] = 10;
    float singaporeUpperBound = malaysiaUpperBound + table.getValue(coord);
    coord[0] = 11;
    float pakistanUpperBound = singaporeUpperBound + table.getValue(coord);
    coord[0] = 12;
    float philippinesUpperBound = pakistanUpperBound + table.getValue(coord);
    coord[0] = 13;
    float franceUpperBound = philippinesUpperBound + table.getValue(coord);
    coord[0] = 14;
    float algeriaUpperBound = franceUpperBound + table.getValue(coord);
    coord[0] = 15;
    float moroccoUpperBound = algeriaUpperBound + table.getValue(coord);
    coord[0] = 16;
    float syriaUpperBound = moroccoUpperBound + table.getValue(coord);
    coord[0] = 17;
    float tunisiaUpperBound = syriaUpperBound + table.getValue(coord);
    coord[0] = 18;
    float uaeUpperBound = tunisiaUpperBound + table.getValue(coord);
    coord[0] = 19;
    float yemenUpperBound = uaeUpperBound + table.getValue(coord);
    randomProbability = (float) Math.random();
    if (randomProbability <= egyptUpperBound) {
      person.setHasNationality(Nationality.Egypt);
    } else if (randomProbability <= saudiArabiaUpperBound) {
      person.setHasNationality(Nationality.SaudiArabia);
    } else if (randomProbability <= kuwaitUpperBound) {
      person.setHasNationality(Nationality.Kuwait);
    } else if (randomProbability <= jordanUpperBound) {
      person.setHasNationality(Nationality.Jordan);
    } else if (randomProbability <= iraqUpperBound) {
      person.setHasNationality(Nationality.Iraq);
    } else if (randomProbability <= sudanUpperBound) {
      person.setHasNationality(Nationality.Sudan);
    } else if (randomProbability <= libyaUpperBound) {
      person.setHasNationality(Nationality.Libya);
    } else if (randomProbability <= lebannonUpperBound) {
      person.setHasNationality(Nationality.Lebannon);
    } else if (randomProbability <= indonesiaUpperBound) {
      person.setHasNationality(Nationality.Indonesia);
    } else if (randomProbability <= malaysiaUpperBound) {
      person.setHasNationality(Nationality.Malaysia);
    } else if (randomProbability <= singaporeUpperBound) {
      person.setHasNationality(Nationality.Singapore);
    } else if (randomProbability <= pakistanUpperBound) {
      person.setHasNationality(Nationality.Pakistan);
    } else if (randomProbability <= philippinesUpperBound) {
      person.setHasNationality(Nationality.Philippines);
    } else if (randomProbability <= franceUpperBound) {
      person.setHasNationality(Nationality.France);
    } else if (randomProbability <= algeriaUpperBound) {
      person.setHasNationality(Nationality.Algeria);
    } else if (randomProbability <= moroccoUpperBound) {
      person.setHasNationality(Nationality.Morocco);
    } else if (randomProbability <= syriaUpperBound) {
      person.setHasNationality(Nationality.Syria);
    } else if (randomProbability <= tunisiaUpperBound) {
      person.setHasNationality(Nationality.Tunisia);
    } else if (randomProbability <= uaeUpperBound) {
      person.setHasNationality(Nationality.UAE);
    } else if (randomProbability <= yemenUpperBound) {
      person.setHasNationality(Nationality.Yemen);
    } else {
      person.setHasNationality(Nationality.Other);
    }

    // Define the person economic standing (UpperClass, MiddleClass, or
    // LowerClass)
    child = (ProbabilisticNode) pn.getNode("hasEconomicStanding_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    parent = (ProbabilisticNode) pn.getNode("hasClusterPartition_person");
    coord[table.getVariableIndex(parent)] = hasClusterPartitionState;
    coord[0] = 0;
    float upperClassUpperBound = table.getValue(coord);
    coord[0] = 1;
    float middleClassUpperBound = upperClassUpperBound + table.getValue(coord);
    randomProbability = (float) Math.random();
    if (randomProbability <= upperClassUpperBound) {
      person.setHasEconomicStanding(EconomicStanding.UpperClass);
    } else if (randomProbability <= middleClassUpperBound) {
      person.setHasEconomicStanding(EconomicStanding.MiddleClass);
    } else {
      person.setHasEconomicStanding(EconomicStanding.LowerClass);
    }
   
    // Define the person education level (MiddleSchool, HighSchool, College,
    // BA_BS, MA_MS, or PhD)
    child = (ProbabilisticNode) pn.getNode("hasEducationLevel_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    parent = (ProbabilisticNode) pn.getNode("hasClusterPartition_person");
    coord[table.getVariableIndex(parent)] = hasClusterPartitionState;
    coord[0] = 0;
    float middleSchoolUpperBound = table.getValue(coord);
    coord[0] = 1;
    float highSchoolUpperBound = middleSchoolUpperBound + table.getValue(coord);
    coord[0] = 2;
    float collegeUpperBound = highSchoolUpperBound + table.getValue(coord);
    coord[0] = 3;
    float baBsUpperBound = collegeUpperBound + table.getValue(coord);
    coord[0] = 4;
    float maMsUpperBound = baBsUpperBound + table.getValue(coord);
    randomProbability = (float) Math.random();
    if (randomProbability <= middleSchoolUpperBound) {
      person.setHasEducationLevel(EducationLevel.MiddleSchool);
    } else if (randomProbability <= highSchoolUpperBound) {
      person.setHasEducationLevel(EducationLevel.HighSchool);
    } else if (randomProbability <= collegeUpperBound) {
      person.setHasEducationLevel(EducationLevel.College);
    } else if (randomProbability <= baBsUpperBound) {
      person.setHasEducationLevel(EducationLevel.BA_BS);
    } else if (randomProbability <= maMsUpperBound) {
      person.setHasEducationLevel(EducationLevel.MA_MS);
    } else {
      person.setHasEducationLevel(EducationLevel.PhD);
    }
   
    // Define the person occupation (Professional, SemiSkilled, or UnSkilled)
    child = (ProbabilisticNode) pn.getNode("hasOccupation_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    parent = (ProbabilisticNode) pn.getNode("hasClusterPartition_person");
    coord[table.getVariableIndex(parent)] = hasClusterPartitionState;
    coord[0] = 0;
    float professionalUpperBound = table.getValue(coord);
    coord[0] = 1;
    float semiSkilledUpperBound = professionalUpperBound + table.getValue(coord);
    randomProbability = (float) Math.random();
    if (randomProbability <= professionalUpperBound) {
      person.setHasOccupation(Occupation.Professional);
    } else if (randomProbability <= semiSkilledUpperBound) {
      person.setHasOccupation(Occupation.SemiSkilled);
View Full Code Here

    // Define if person has influence partition
    int hasInfluencePartitionState = 0;
    ProbabilisticNode child = (ProbabilisticNode) pn
        .getNode("hasInfluencePartition_person");
    PotentialTable table = ((PotentialTable) child.getProbabilityFunction());
    int[] coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    ProbabilisticNode parent = (ProbabilisticNode) pn
        .getNode("isTerrorist_person");
    coord[table.getVariableIndex(parent)] = isTerroristState;
    if (Math.random() <= table.getValue(coord)) {
      hasInfluencePartitionState = 0;
      person.setHasInfluencePartition(true);
    } else {
      hasInfluencePartitionState = 1;
      person.setHasInfluencePartition(false);
    }
   
    // Define the person family status
    child = (ProbabilisticNode) pn
        .getNode("hasFamilyStatus_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn
        .getNode("hasInfluencePartition_person");
    coord[table.getVariableIndex(parent)] = hasInfluencePartitionState;
    if (Math.random() <= table.getValue(coord)) {
      person.setHasFamilyStatus(FamilyStatus.Married);
    } else {
      person.setHasFamilyStatus(FamilyStatus.Single);
    }
   
    // Define if person has OIF or OEF influence
    int hasOIForOEFInfluenceState = 0;
    child = (ProbabilisticNode) pn
        .getNode("hasOIForOEFInfluence_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn
        .getNode("hasInfluencePartition_person");
    coord[table.getVariableIndex(parent)] = hasInfluencePartitionState;
    if (Math.random() <= table.getValue(coord)) {
      hasOIForOEFInfluenceState = 0;
      person.setHasOIForOEFInfluence(true);
    } else {
      hasOIForOEFInfluenceState = 1;
      person.setHasOIForOEFInfluence(false);
    }

    // Define if person someone kileld in OIF or OEF (none, few, or many)
    child = (ProbabilisticNode) pn.getNode("knowsPersonKilledInOIForOEF_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("hasOIForOEFInfluence_person");
    coord[table.getVariableIndex(parent)] = hasOIForOEFInfluenceState;
    float noneUpperBound = table.getValue(coord);
    coord[0] = 1;
    float fewUpperBound = noneUpperBound + table.getValue(coord);
    float randomProbability = (float) Math.random();
    if (randomProbability <= noneUpperBound) {
      person.setKnowsPersonKilledinOIForOEF(Quantity.None);
    } else if (randomProbability <= fewUpperBound) {
      person.setKnowsPersonKilledinOIForOEF(Quantity.Few);
    } else {
      person.setKnowsPersonKilledinOIForOEF(Quantity.Many);
    }

    // Define if person someone imprisioned in OIF or OEF (none, few, or many)
    child = (ProbabilisticNode) pn.getNode("knowsPersonImprisionedInOIForOEF_person");
    table = ((PotentialTable) child.getProbabilityFunction());
    coord = new int[child.getParents().size() + 1];
    coord[0] = 0;
    parent = (ProbabilisticNode) pn.getNode("hasOIForOEFInfluence_person");
    coord[table.getVariableIndex(parent)] = hasOIForOEFInfluenceState;
    noneUpperBound = table.getValue(coord);
    coord[0] = 1;
    fewUpperBound = noneUpperBound + table.getValue(coord);
    randomProbability = (float) Math.random();
    if (randomProbability <= noneUpperBound) {
      person.setKnowsPersonImprisionedInOIForOEF(Quantity.None);
    } else if (randomProbability <= fewUpperBound) {
      person.setKnowsPersonImprisionedInOIForOEF(Quantity.Few);
View Full Code Here

      // Simulate organization data
      for (OrganizationEntity org : db.getOrganizations()) {
        ProbabilisticNode child = (ProbabilisticNode) pn
            .getNode("isTerroristOrganization_org");
        PotentialTable table = ((PotentialTable) child
            .getProbabilityFunction());
        int[] coord = new int[child.getParents().size() + 1];
        coord[0] = 0;
        ProbabilisticNode parent = (ProbabilisticNode) pn
            .getNode("isTerrorist_person");
        // True if at least one member is a terrorist
        coord[table.getVariableIndex(parent)] = (org.isRelatedToTerrorist()) ? 0
            : 1;
        parent = (ProbabilisticNode) pn
            .getNode("isMemberOfOrganization_person_org");
        // Always true, since we are dealing with members of the organization
        coord[table.getVariableIndex(parent)] = 0;
        if (Math.random() <= table.getValue(coord)) {
          org.setTerroristOrganisation(true);
        } else
          org.setTerroristOrganisation(false);
      }
    }
View Full Code Here

  public void createStates(EDBUnit SNodes, Node UNode){
    EDBUnit SNode = SNodes.get( UNode.getName() );
   
     if( UNode instanceof ProbabilisticNode){
       ProbabilisticNode aux = (ProbabilisticNode) UNode;
      PotentialTable auxTab = aux.getProbabilityFunction();
     
      for( int i = 0; i < UNode.getStatesSize(); i++ ){     
        Float fStateVaule = auxTab.getValue(i);  
        createSTATE(SNode, UNode.getStateAt(i), fStateVaule.toString());
      }
    }
  }
View Full Code Here

TOP

Related Classes of unbbayes.prs.bn.PotentialTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.