Package unbbayes.prs.bn

Examples of unbbayes.prs.bn.ProbabilisticNode


      hasBombingPlanState = 1;
    }

    // Define if ship is meeting another ship
    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;
View Full Code Here


      hasExchangeIllicitCargoPartitionState = 2;
    }

    // Define if ship has evasive behavior
    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;
View Full Code Here

      hasExchangeIllicitCargoPartitionState = 2;
    }

    // Define if ship has erratic behavior
    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;
View Full Code Here

      hasBombingPlanState = 1;
    }

    // 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);
View Full Code Here

   *
   * @param  node
   */
  private void showLikelihood(DefaultMutableTreeNode node) {
   
    ProbabilisticNode auxProbNode = (ProbabilisticNode) objectsMap.get(node);
   
    if (   (auxProbNode != null)
      && (auxProbNode.getInformationType() == Node.DESCRIPTION_TYPE)) {
     
      //Build the panel
      int i;
      JPanel panel = new JPanel();
      JTable table = new JTable(auxProbNode.getStatesSize(), 2);
      for (i = 0; i < auxProbNode.getStatesSize(); i++) {
        table.setValueAt(auxProbNode.getStateAt(i), i, 0);
        table.setValueAt("100", i, 1);
      }
      JLabel label = new JLabel(auxProbNode.toString());
      panel.add(label);
      panel.add(table);
     
      //Ask the user the confirmation
      if (JOptionPane.showConfirmDialog(
          this.netWindow.getRootPane(),
          panel,
          resource.getString("likelihoodName"),
          JOptionPane.OK_CANCEL_OPTION)
            ==
            JOptionPane.OK_OPTION) {
       
        //Get the original probabilities values
        DefaultMutableTreeNode auxNode;

        float[] stateProbabilities = new float[auxProbNode.getStatesSize()];

        try {
          for (i = 0; i < auxProbNode.getStatesSize(); i++) {
            stateProbabilities[i] =
              nf.parse((String) table.getValueAt(i, 1)).floatValue();
          }
        } catch (ParseException e) {
          System.err.println(e.getMessage());
          return;
        }

      //Get the total probability
        float totalProbability = 0;
        for (i = 0; i < auxProbNode.getStatesSize(); i++) {
          totalProbability += stateProbabilities[i];
        }

        if (totalProbability == 0.0) {
          System.err.println("likelihoodException");
          return;
        }

      //Normalize the probabilities values
        // Also verify the state that has the highest probability
        for (i = 0; i < auxProbNode.getStatesSize(); i++) {
          stateProbabilities[i] = stateProbabilities[i] / totalProbability;
        }

//        auxProbNode.addFinding(1);
        auxProbNode.addLikeliHood(stateProbabilities);
       
      //Reset text with the values of probabilities
        String str;
        for (i = 0; i < node.getChildCount(); i++) {
          auxNode = (DefaultMutableTreeNode) node.getChildAt(i);
View Full Code Here

    // Define known states for known parents
    int isTerroristState = (person.isTerrorist()) ? 0 : 1;

    // 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);
View Full Code Here

    // Define known states for known parents
    int isTerroristState = (person.isTerrorist()) ? 0 : 1;

    // 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);
View Full Code Here

    int isTerroristState = (person.isTerrorist()) ? 0 : 1;

    // 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;
View Full Code Here

    // Define known states for known parents
    int isTerroristState = (person.isTerrorist()) ? 0 : 1;

    // 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);
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.ProbabilisticNode

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.