Package edu.gmu.seor.prognos.unbbayesplugin.cps.datastructure

Examples of edu.gmu.seor.prognos.unbbayesplugin.cps.datastructure.EDBUnit


  // coord[2] => second parent node's state index
  // ...
  // and then we can use PotentialTable.setValue(coord, 0.5);
  public void AddNewStatesValueToBNNode(EDBUnit lastCPT, int coord[], ArrayMap<Object, Integer> stateIndexMap, PotentialTable auxTab){ 
    //finding last row of CPT            EX) ROOT.NODES.Child.CPT.5.[DATA]:Number.high.[DATA]:Height.
    EDBUnit lastCPTISA = lastCPT.getRel("ISA");
     if(lastCPTISA != null && lastCPTISA.map.size() != 0 ){
      for( String str : lastCPTISA.map.keySet() ){
        EDBUnit t = lastCPTISA.map.get(str)
       
        int variableIndex = auxTab.indexOfVariable( t.getData() );
        Node n = (Node)auxTab.getVariableAt(variableIndex);
        coord[variableIndex] = getStateIndexFromBN( n, t.getName() );
       
        AddNewStatesValueToBNNode( t, coord, stateIndexMap, auxTab);
      }
    }
    else{   
View Full Code Here


       
    AddNewStateValueToSNode( state.getNext(), coord, stateIndexMap, auxTab);
  }
 
  public void createUDBfromSDB(ProbabilisticNetwork rede, EDBUnit sNode){
    EDBUnit states = sNode.get("STATES");
    EDBUnit cpt = sNode.get("CPT");
    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() );
      
    }else
    if( type.equalsIgnoreCase("Continuous") ){
      //create new Continuous uNode
      uNode = new ContinuousNode();
View Full Code Here

    Double dParameter1 = Double.NaN;
    Double dParameter2 = Double.NaN;
      
    //iteration 
    int i = 0;
    EDBUnit ISA = eq.getRel("ISA");
    if( ISA != null )
    for( String str : ISA.getMap().keySet() ){
      EDBUnit child = ISA.map.get(str);
     
      if( i == 0 )
        dParameter1 = getMeanAndSTD( i, child, normalDistribution, functionIndex )
      else
        dParameter2 = getMeanAndSTD( i, child, normalDistribution, functionIndex )
View Full Code Here

       
    return ret;
  }
 
  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") ){
      ArrayMap<Object, Integer> stateIndexMap = new ArrayMap<Object, Integer>();
View Full Code Here

      createUDBfromSDB( rede, node );
    }
    */
 
    //step 1. create new uNodes from sNodes
    EDBUnit nodes = EDB.This().get("ROOT.ENGINES.JT.NODES")
    EDBUnit ISA = nodes.getRel("ISA");
    for( String str : ISA.getMap().keySet() ){
      EDBUnit node = ISA.map.get(str);
      createUDBfromSDB( rede, node );
    }
     
    //step 2. create new edges between sNodes 
    for( String str : ISA.getMap().keySet() ){
      EDBUnit node = ISA.map.get(str);
      EDBUnit parents = node.get("PARENTS");
      createEdgeOfUDB( rede, node, parents.getNext() );
    }
   
    //step 3. set states 
    for( String str : ISA.getMap().keySet() ){
      EDBUnit node = ISA.map.get(str);
      EDBUnit type = node.get("INFO.TYPE");
      EDBUnit description = node.get("INFO.DESCRIPTION");
      EDBUnit evidence = node.get("EVIDENCE");
      EDBUnit parents = node.get("PARENTS");
      EDBUnit children = node.get("CHILDREN");
      EDBUnit cpt = node.getCopied("CPT");
      EDBUnit eq = node.getCopied("EQUATION");
      EDBUnit bel = node.get("BEL");
      setStatesOfUDB( rede, node );
    }
   
    //step 4. set evidences
     for( String str : ISA.getMap().keySet() ){
      EDBUnit node = ISA.map.get(str);
      EDBUnit evidence = node.get("EVIDENCE");
      EDBUnit type = node.get("INFO.TYPE");
      Node uNode = rede.getNode(str);
           
      if( evidence != null ){
        if( type.getData().equalsIgnoreCase("Discrete") ){
          rede.setDescreteEvidence((ProbabilisticNode)uNode, uNode.getState(evidence.getData()));
         
        }else
        if( type.getData().equalsIgnoreCase("Continuous") ){
          rede.setContinuousEvidence((ContinuousNode)uNode, evidence.getDataByDouble());
        }
      } 
     }
    
View Full Code Here

   *
   * @param SNodes the s nodes
   * @param UNode the u node
   */
  public void createSNode( EDBUnit SNodes, Node UNode  ){
    EDBUnit node   = SNodes.create(UNode.getName());
    EDBUnit info   = node.create("INFO");
    node.create("STATES_MEAN");
    node.create("STATES");
    node.create("PARENTS");
    node.create("CHILDREN");
    node.create("CPT");
    node.create("EQUATION");
    node.create("OLD_BEL");
    node.create("BEL");  
    EDBUnit script = node.create("SCRIPT");  
    EDBUnit kind   = info.create("KIND");
    EDBUnit desc   = info.create("DESCRIPTION");
    EDBUnit type   = info.create("TYPE")
    EDBUnit flag   = info.create("SEARCH_FLAG");
    EDBUnit X = info.create("X");
    EDBUnit Y = info.create("Y");
       
    String strScript = CPS.getInstance().getScript(UNode);
    if( strScript != null && strScript.length() > 0 )
      script.setData(strScript);
    else
      script.setData("");
 
    Point2D position = UNode.getPosition();
    Double dx = new Double(position.getX());
    Double dy = new Double(position.getY());
    X.setData(dx.toString());
    Y.setData(dy.toString());
         
    if( UNode instanceof GmmNodePluginStub ){
      type.setData("Continuous");
    }else
    if( UNode instanceof ProbabilisticNode ){
View Full Code Here

   * @param SNode the s node
   * @param parentName the parent name
   * @return the eDB unit
   */
  public EDBUnit createPARENT(EDBUnit SNodes, EDBUnit SNode, String parentName){
    EDBUnit parents   = SNode.get("PARENTS");
    EDBUnit newParent = parents.getNext(parentName);
    EDBUnit parent    = SNodes.get(parentName);
       
    if( newParent != null )
      return newParent;
   
    newParent = parents.createNext(parentName);
           
    if( parent != null ){
      EDBUnit children = parent.get("CHILDREN");
      children.createNext(SNode.getName());
 
      //parent.print("");
    }
   
    return newParent;
View Full Code Here

   *
   * @param SNodes the s nodes
   * @param UNode the u node
   */
  public void addParents(EDBUnit SNodes, Node UNode){
    EDBUnit SNode = SNodes.get( UNode.getName() );
    for( Node parent : UNode.getParents() ){
      createPARENT(SNodes, SNode, parent.getName());
    }   
  }
View Full Code Here

   * @param s the s
   * @param v the v
   * @return the eDB unit
   */
  public EDBUnit createSTATE(EDBUnit p, String s, String v){
    EDBUnit states   = p.get("STATES");
    EDBUnit st      = states.createNext(s);
    st.setData(v);
   
    //for the continuous states, we need to have mean number of the bin
    EDBUnit type   = p.get("INFO.TYPE");
    if( type.getData().equalsIgnoreCase("Continuous") ){
      EDBUnit statesMean   = p.get("STATES_MEAN");
      EDBUnit stMeanLast   = statesMean.getLastNext();
      EDBUnit stMean      = statesMean.createNext(s);
      stMean.setData(v);
     
      if( stMeanLast.getName().equalsIgnoreCase("NINF") ){
      //  dExtreamNINF = Double.valueOf(stMean.getName());
      }
     
      if( stMean.getName().equalsIgnoreCase("PINF") ){
      //  dExtreamPINF = Double.valueOf(stMeanLast.getName());
      }     
    }
   
    return st;
View Full Code Here

   *
   * @param SNodes the s nodes
   * @param UNode the u node
   */
  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();
     
View Full Code Here

TOP

Related Classes of edu.gmu.seor.prognos.unbbayesplugin.cps.datastructure.EDBUnit

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.