Package unbbayes.prs

Examples of unbbayes.prs.Node


    EDBUnit states = sNode.get("STATES");
    EDBUnit cpt = sNode.get("CPT");
    EDBUnit info = sNode.get("INFO");
    EDBUnit eq = sNode.get("INFO.EQUATION");
    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
      ArrayMap<Object, Integer> stateIndexMap = new ArrayMap<Object, Integer>();
      int c = 0;
      EDBUnit stateFirst = states.getNext();
      uNode.appendState(stateFirst.getName());
      stateIndexMap.put(stateFirst.getName(),  c++);
      AddNewStatesToBNNode(uNode, stateIndexMap, c, stateFirst.getNext());
       
      //initialize Potential Table
      PotentialTable auxTab = (PotentialTable) ((IRandomVariable) uNode).getProbabilityFunction();
      auxTab.addVariable(uNode);
 
    }else
    if( type.equalsIgnoreCase("Continuous") ){
      //create new Continuous uNode
      uNode = new GmmNodePluginStub();
      uNode.setName(sNode.getName());
      uNode.setDescription(sNode.getName());
    }
      
    //set position
    EDBUnit X = info.get("X");
    EDBUnit Y = info.get("Y");
    uNode.setPosition(X.getDataByDouble(), Y.getDataByDouble());
   
    rede.addNode(uNode);
  }
View Full Code Here


  public void setStatesOfUDB(ProbabilisticNetwork rede, EDBUnit sNode){
    EDBUnit states = sNode.get("STATES");
    EDBUnit cpt = sNode.get("CPT");
    EDBUnit eq = sNode.get("EQUATION");
    String type = sNode.get("INFO.TYPE").getData();
    Node uNode = rede.getNode(sNode.getName());
       
    if( type.equalsIgnoreCase("Discrete") ){
      
      /////////////////////////////////////////////////////////////////////////////////////
      //1. add UnBBayes node information from MathNode information
      // remove all states of the current node
      ((ProbabilisticNode)uNode).removeAllStates();

      /////////////////////////////////////////////////////////////////////////////////////
      //2. add new states of current node
      ArrayMap<Object, Integer> stateIndexMap = new ArrayMap<Object, Integer>();
      int c = 0;
     
      // add first state, because UnBBayes uses a following way to create a first state of a node
      EDBUnit stateFirst = states.getNext();
   
      // set fist state info of unBBayes
      uNode.setStateAt(stateFirst.getName(), 0);
     
      // store index map of states
      stateIndexMap.put( stateFirst.getName(),  c++);
     
      // add second and next states      
      AddNewStatesToBNNode( uNode, stateIndexMap, c, stateFirst.getNext() );
    
      /////////////////////////////////////////////////////////////////////////////////////
      //3. fill zero on table
      PotentialTable auxTab = (PotentialTable) ((IRandomVariable) uNode).getProbabilityFunction();
      int curStateSize = uNode.getStatesSize()
     
      for( INode parent : uNode.getParentNodes() )
        curStateSize *= parent.getStatesSize();
     
      for( int i = 0; i < curStateSize; i++ )
        auxTab.addValueAt(i, 0);
     
      auxTab.setTableSize(curStateSize);
   
      /////////////////////////////////////////////////////////////////////////////////////
      //4. add new values in the states of BN
      // EX]
      // CPT[Isa]parent1.state1{parent1.Name}[Isa]parent2.state1{parent2.Name}[Next]cur.state1[Next]cur.state2
      // ...
      int coord[] = new int[uNode.getParentNodes().size()+1];
      
      AddNewStatesValueToBNNode( cpt, coord, stateIndexMap, auxTab );
     
      ((TreeVariable)uNode).initMarginalList();
      //5. add new scripts of BN
View Full Code Here

   */
  public void createEdgeOfUDB( ProbabilisticNetwork rede, EDBUnit node, EDBUnit nextParent ){
    if( nextParent == null )
      return;
   
    Node uNodeDes = rede.getNode(node.getName());
    Node uNodeSrs = rede.getNode(nextParent.getName());
   
    createEdge( rede, uNodeSrs, uNodeDes );
   
    createEdgeOfUDB( rede, node, nextParent.getNext() );
  }
View Full Code Here

TOP

Related Classes of unbbayes.prs.Node

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.