Package unbbayes.prs.bn

Examples of unbbayes.prs.bn.ProbabilisticNode


    EDBUnit lastCPTISA = lastCPT.getRel("ISA");
     if(lastCPTISA != null && lastCPTISA.map.size() != 0 ){
      for( String str : lastCPTISA.map.keySet() ){
        EDBUnit t = lastCPTISA.map.get(str);
       
        ProbabilisticNode aux = (ProbabilisticNode) UNode;
        PotentialTable auxTab = aux.getProbabilityFunction();
       
        int variableIndex = auxTab.indexOfVariable( t.getData() );
        Node n = (Node)auxTab.getVariableAt(variableIndex);
        coord[variableIndex] = getStateIndexFromBN( n, t.getName() );
       
View Full Code Here


    //create new state of current SNode 
    EDBUnit newLast = lastCPT.createNext(nextNode.getName());  

    //add state value from Unode
    ProbabilisticNode aux = (ProbabilisticNode) UNode;
    PotentialTable auxTab = aux.getProbabilityFunction();  
    coord[0] = getStateIndexFromBN(UNode, newLast.getName());
    
    Float fStateVaule = auxTab.getValue(coord);
    newLast.setData(fStateVaule.toString());
   
View Full Code Here

   * Inserts the desired node inside the network creating default state, symbol and description
   * @param x The x position.
   * @param y The y position.
   */
  public Node insertProbabilisticNode(double x, double y) {
    ProbabilisticNode node = new ProbabilisticNode();
    node.setPosition(x, y);
    node.appendState(resource.getString("firstStateProbabilisticName"));
    node.setName(resource.getString("probabilisticNodeName")
        + singleEntityNetwork.getNodeCount());
    node.setDescription(node.getName());
    PotentialTable auxTabProb = (PotentialTable)(node)
        .getProbabilityFunction();
    auxTabProb.addVariable(node);
    auxTabProb.setValue(0, 1);
    singleEntityNetwork.addNode(node);
View Full Code Here

    btn = addButton(buttonPanel, "Create ProbabilisticNode");
    btn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // Test
        ProbabilisticNode node = new ProbabilisticNode();
        node.setPosition(50, 50);
        node.appendState("State1");
        node.appendState("State2");
        node.appendState("State3");
        node.appendState("State4");
        node
            .setName("longname-longname-longname-longname-longname-longname-longname-longname");
        node.setDescription(node.getName());
        PotentialTable auxTabProb = (PotentialTable)((IRandomVariable) node)
            .getProbabilityFunction();
        auxTabProb.addVariable(node);
        auxTabProb.setValue(0, 1);

        UShapeProbabilisticNode shape = new UShapeProbabilisticNode(
            m_Canvas, (ProbabilisticNode) node, (int) node
                .getPosition().x
                - node.getWidth() / 2,
            (int) node.getPosition().y - node.getHeight() / 2, node
                .getWidth(), node.getHeight());
        m_Canvas.addShape(shape);
        shape.setShapeType(UShapeProbabilisticNode.STYPE_BAR);

        // Test
        ProbabilisticNode node2 = new ProbabilisticNode();
        node2.setPosition(160, 80);
        node2.appendState("firstStateProbabilisticName");
        node2.setName("123456789abcdefghijklmnopqrstuvwxyz");
        node2.setDescription(node2.getName());
        PotentialTable auxTabProb2 =(PotentialTable) ((IRandomVariable) node2)
            .getProbabilityFunction();
        auxTabProb2.addVariable(node2);
        auxTabProb2.setValue(0, 1);

        UShapeProbabilisticNode shape2 = new UShapeProbabilisticNode(
            m_Canvas, (ProbabilisticNode) node2, (int) node2
                .getPosition().x
                - node2.getWidth() / 2, (int) node2
                .getPosition().y
                - node2.getHeight() / 2, node2.getWidth(),
            node2.getHeight());
        m_Canvas.addShape(shape2);

      }
    });
View Full Code Here

        generateDataForBackground(person);
      }

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

    algorithm.setNetwork(discretizedNet);
    algorithm.run()
   
    for (String key : mapEvindeces.keySet()){
      String e = mapEvindeces.get(key);
      ProbabilisticNode findingNode = (ProbabilisticNode)discretizedNet.getNode(key);
      if (e.equalsIgnoreCase("True"))
        findingNode.addFinding(0);
      else
        findingNode.addFinding(1);
      
      if (e.equalsIgnoreCase("85.47197"))
        findingNode.addFinding(4);
      else if (e.equalsIgnoreCase("11.252131"))
        findingNode.addFinding(0)

      if (e.equalsIgnoreCase("54.330338"))
        findingNode.addFinding(4);
      else if (e.equalsIgnoreCase("4.440531"))
        findingNode.addFinding(0);
      
      if (e.equalsIgnoreCase("37.68292"))
        findingNode.addFinding(4);
      else if (e.equalsIgnoreCase("1.1423578"))
        findingNode.addFinding(0);
    }
    
    // propagate evidence
    try {
      discretizedNet.updateEvidences();
        } catch (Exception exc) {
          System.out.println(exc.getMessage());                
        }
    
    time_jt = (System.nanoTime()- time);
    System.out.println("Total JT Time:  " + time_jt + "  nano sec");
   
    ProbabilisticNode resultNode = (ProbabilisticNode)discretizedNet.getNode("isShipOfInterest_ship1");
     System.out.println(resultNode.getDescription());
    for (int i = 0; i < resultNode.getStatesSize(); i++) {
      System.out.println(resultNode.getStateAt(i) + " : " + ((ProbabilisticNode)resultNode).getMarginalAt(i));
    }
   
    System.out.println(" ");
  }
View Full Code Here

    File ASIA_FILE = new File("src/test/resources/testCases/cpslTest.net");
    ProbabilisticNetwork net;
    BaseIO io = new NetIO();
      try {
        net = (ProbabilisticNetwork)io.load(ASIA_FILE);
        ProbabilisticNode n = (ProbabilisticNode)net.getNode("B");
        CPSController w = new CPSController( n );
      } catch (LoadException e) {
        e.printStackTrace();
      } catch (IOException e) {
    }
View Full Code Here

   
    probabilisticNetwork = new ProbabilisticNetwork(mebn.getName());
    SSBN ssbn = new SSBN();
    ssbn.setNetwork(probabilisticNetwork);
   
    speedOBJ1T2 = new ProbabilisticNode();
    speedOBJ1T2.setName(residentSpeed.getName() + "_OBJ1_T2");
    probabilisticNetwork.addNode(speedOBJ1T2);
    SSBNNode ssbnNodeSpeedOBJ1T2 = SSBNNode.getInstance(probabilisticNetwork, residentSpeed, speedOBJ1T2);
    ssbn.getSsbnNodeList().add(ssbnNodeSpeedOBJ1T2);
    ssbnNodeSpeedOBJ1T2.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("obj"), "OBJ1");
    ssbnNodeSpeedOBJ1T2.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("t"), "T2");
   
    // Speed(OBJ1, T0),
//    ProbabilisticNode speedOBJ1T0 = new ProbabilisticNode();
//    speedOBJ1T0.setName(residentSpeed.getName() + "_OBJ1_T0");
//    probabilisticNetwork.addNode(speedOBJ1T0);
//    SSBNNode ssbnNodeSpeedOBJ1T0 = SSBNNode.getInstance(probabilisticNetwork, residentSpeed, speedOBJ1T0);
//    ssbn.getSsbnNodeList().add(ssbnNodeSpeedOBJ1T0);
//    ssbnNodeSpeedOBJ1T0.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("obj"), "OBJ1");
//    ssbnNodeSpeedOBJ1T0.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("tPrev"), "T0");
//    ssbnNodeSpeedOBJ1T2.addParent(ssbnNodeSpeedOBJ1T0, false);  // this should also add the edge
   
    // Speed(OBJ1, T1),
    ProbabilisticNode speedOBJ1T1 = new ProbabilisticNode();
    speedOBJ1T1.setName(residentSpeed.getName() + "_OBJ1_T1");
    probabilisticNetwork.addNode(speedOBJ1T1);
    SSBNNode ssbnNodeSpeedOBJ1T1 = SSBNNode.getInstance(probabilisticNetwork, residentSpeed, speedOBJ1T1);
    ssbn.getSsbnNodeList().add(ssbnNodeSpeedOBJ1T1);
    ssbnNodeSpeedOBJ1T1.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("obj"), "OBJ1");
    ssbnNodeSpeedOBJ1T1.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("tPrev"), "T1");
    ssbnNodeSpeedOBJ1T2.addParent(ssbnNodeSpeedOBJ1T1, false)// this should also add the edge
   
    // TerrainType(RGN1),
    ResidentNode terrainTypeResident = mebn.getDomainResidentNode("TerrainType");
    ProbabilisticNode terrainTypeRGN1 = new ProbabilisticNode();
    terrainTypeRGN1.setName(terrainTypeResident.getName() + "_RGN1");
    probabilisticNetwork.addNode(terrainTypeRGN1);
    SSBNNode ssbnNodeTerrainTypeRGN1 = SSBNNode.getInstance(probabilisticNetwork, terrainTypeResident, terrainTypeRGN1);
    ssbn.getSsbnNodeList().add(ssbnNodeTerrainTypeRGN1);
    ssbnNodeTerrainTypeRGN1.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("rgn"), "RGN1");
    ssbnNodeSpeedOBJ1T2.addParent(ssbnNodeTerrainTypeRGN1,false)// this should also add the edge
   
    // TerrainType(RGN2),
    ProbabilisticNode terrainTypeRGN2 = new ProbabilisticNode();
    terrainTypeRGN2.setName(terrainTypeResident.getName() + "_RGN2");
    probabilisticNetwork.addNode(terrainTypeRGN2);
    SSBNNode ssbnNodeTerrainTypeRGN2 = SSBNNode.getInstance(probabilisticNetwork, terrainTypeResident, terrainTypeRGN2);
    ssbn.getSsbnNodeList().add(ssbnNodeTerrainTypeRGN2);
    ssbnNodeTerrainTypeRGN2.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("rgn"), "RGN2");
    ssbnNodeSpeedOBJ1T2.addParent(ssbnNodeTerrainTypeRGN2,false)// this should also add the edge
   
    // TerrainType(RGN3),
//    ProbabilisticNode terrainTypeRGN3 = new ProbabilisticNode();
//    terrainTypeRGN3.setName(terrainTypeResident.getName() + "_RGN3");
//    probabilisticNetwork.addNode(terrainTypeRGN3);
//    SSBNNode ssbnNodeTerrainTypeRGN3 = SSBNNode.getInstance(probabilisticNetwork, terrainTypeResident, terrainTypeRGN3);
//    ssbn.getSsbnNodeList().add(ssbnNodeTerrainTypeRGN3);
//    ssbnNodeTerrainTypeRGN3.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("rgn"), "RGN3");
//    ssbnNodeSpeedOBJ1T2.addParent(ssbnNodeTerrainTypeRGN3,false);  // this should also add the edge
   
    // ObjectType(OBJ1)
    ResidentNode objectTypeResident = mebn.getDomainResidentNode("ObjectType");
    ProbabilisticNode objectTypeOBJ1 = new ProbabilisticNode();
    objectTypeOBJ1.setName(objectTypeResident.getName() + "_OBJ1");
    probabilisticNetwork.addNode(objectTypeOBJ1);
    SSBNNode ssbnNodeObjectTypeOBJ1 = SSBNNode.getInstance(probabilisticNetwork, objectTypeResident, objectTypeOBJ1);
    ssbn.getSsbnNodeList().add(ssbnNodeObjectTypeOBJ1);
    ssbnNodeObjectTypeOBJ1.addArgument(residentSpeed.getMFrag().getOrdinaryVariableByName("obj"), "OBJ1");
    ssbnNodeSpeedOBJ1T2.addParent(ssbnNodeObjectTypeOBJ1,false)// this should also add the edge
View Full Code Here

    IInferenceAlgorithm algorithm = new JunctionTreeAlgorithm();
    algorithm.setNetwork(pn);
    algorithm.run();
   
    // insert evidence (finding)
    ProbabilisticNode findingNode = (ProbabilisticNode)pn.getNode("isJettisoningCargo_ship1");
    findingNode.addFinding(0);
    findingNode = (ProbabilisticNode)pn.getNode("hasWeaponVisible_ship1");
    findingNode.addFinding(0);
    
    // propagate evidence
    try {
          pn.updateEvidences();
        } catch (Exception exc) {
          System.out.println(exc.getMessage());                
        }
    
    time_jt = (System.nanoTime()- time);
    System.out.println("Total JT Time:  " + time_jt + "  nano sec");
   
    ProbabilisticNode resultNode = (ProbabilisticNode)pn.getNode("isShipOfInterest_ship1");
     System.out.println(resultNode.getDescription());
    for (int i = 0; i < resultNode.getStatesSize(); i++) {
      System.out.println(resultNode.getStateAt(i) + " : " + ((ProbabilisticNode)resultNode).getMarginalAt(i));
    }
   
    System.out.println(" ");
  }
View Full Code Here

    String type = sNode.get("INFO.TYPE").getData();
    Node uNode = null;
   
    if( type.equalsIgnoreCase("Discrete") ){
      //create new Probabilistic uNode
      uNode = new ProbabilisticNode();
      uNode.setName(sNode.getName());
      uNode.setDescription(sNode.getName());
      //reset all states
      ((ProbabilisticNode )uNode).removeAllStates();
       //set states
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.