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

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


  public EDBUnit createParentStateOnCPT(EDBUnit CPT, EDBUnit nextNode){
    if( nextNode == null )
      return null;
   
    String str = nextNode.getName();
    EDBUnit parentState = EDB.This().get("ROOT.NODES."+str+".STATES");
    EDBUnit parentType = EDB.This().get("ROOT.NODES."+str+".INFO.TYPE");
    createSTATEonCPT(CPT, parentState.getNext(), str, parentType.getData());
   
    return createParentStateOnCPT(CPT, nextNode.getNext());
  }
View Full Code Here


    if( strParentType.equalsIgnoreCase("Continuous") && nextNode.getNext() == null ){
      return null;
    }
   
    EDBUnit newLast = lastCPT.create(nextNode.getName());   
    //add parent name on state of child
    newLast.setData(strData);
   
    return FindNextParentState(lastCPT, nextNode.getNext(), strData, strParentType);
  }
View Full Code Here

   * @param strParentName the str parent name
   * @param strParentType the str parent type
   */
  public void createSTATEonCPT(EDBUnit lastCPT, EDBUnit pStates, String strParentName, String strParentType){ 
    //finding last row of CPT                EX) ROOT.NODES.Child.CPT.5
    EDBUnit lastCPTISA = lastCPT.getRel("ISA");
    if(lastCPTISA != null && lastCPTISA.map.size() != 0 ){
      for( String str : lastCPTISA.map.keySet() ){
        EDBUnit t = lastCPTISA.map.get(str);
        createSTATEonCPT(t, pStates, strParentName, strParentType);
      }
    }
    else{//this is the last row
      FindNextParentState(lastCPT, pStates, strParentName, strParentType);
View Full Code Here

   * @param UNode the u node
   * @param coord the coord
   */
  public void createCurrentStatesOnLastOfCPT(EDBUnit lastCPT, EDBUnit curNode, Node UNode, int coord[]){ 
    //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);
       
        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() );
       
        createCurrentStatesOnLastOfCPT(t, curNode, UNode, coord);
      }
    }
    else
    {   
      EDBUnit states = curNode.get("STATES");
      CreateNextState(lastCPT, states.getNext(), UNode, coord);
     
     
   
  }
View Full Code Here

  public EDBUnit CreateNextState(EDBUnit lastCPT, EDBUnit nextNode, Node UNode, int coord[]){
    if( nextNode == null )
      return null;

    //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());
   
    return CreateNextState(lastCPT, nextNode.getNext(), UNode, coord);
  }
View Full Code Here

   */
  public EDBUnit CreateNextStateForContinuous(EDBUnit lastCPT, EDBUnit nextNode, String strData){
    if( nextNode == null || nextNode.getNext() == null )
      return null;
    EDBUnit newLast = lastCPT.createNext(nextNode.getName());   
    //add parent name on state of child
    newLast.setData(strData);
   
    return CreateNextStateForContinuous(lastCPT, nextNode.getNext(), strData);
  }
View Full Code Here

   * @param curNode the cur node
   * @param UNode the u node
   * @return the eDB unit
   */
  public EDBUnit createCPT(EDBUnit curNode, Node UNode){
    EDBUnit parents = curNode.get("PARENTS");
    EDBUnit CPT = curNode.get("CPT");
   
    //1. create parent states    //EX) p1s1.p2s1
    createParentStateOnCPT( CPT, parents.getNext() );
     
    //2. create current states    //EX) p1s1.p2s1.[next:s1].[next:s2]
View Full Code Here

   * @param pn the pn
   * @return the eDB unit
   */
  public EDBUnit convert( ProbabilisticNetwork pn ) {
    //1. get default nodes
    EDBUnit SNodes = EDB.This().get("ROOT.NODES");
   
    ArrayList<String> list = new ArrayList<String>();
    //1.1 get an organized order of UNodes
    searchUNodesOrder( pn, list );
   
    //2. create each node
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNode(list.get(i));
      createSNode( SNodes, UNode );
    }
   
    //3. create relation
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNode(list.get(i));
      addParents( SNodes, UNode );
    }
   
    //4. create states
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNode(list.get(i));
      createStates( SNodes, UNode );
    }
   
    //5. create CPT
    EDBUnit ISA1 = SNodes.getRel("ISA");
    for( String str : ISA1.getMap().keySet() ){
      EDBUnit node = ISA1.map.get(str);
      Node UNode = pn.getNode(str);
     
      if( UNode instanceof GmmNodePluginStub ){
      }else
      if( UNode instanceof ProbabilisticNode ){
        createCPT(node, UNode);
      }
    }
   
    //SNodes.print("");
   
    //6. compile script
    EDBUnit ISA = SNodes.getRel("ISA");
    for( String str : ISA.getMap().keySet() ){
      EDBUnit node = ISA.map.get(str);
      EDBUnit script = node.get("SCRIPT");
      if( script.getData() != null && script.getData().length() > 1 ){
        CPSCompilerMain.This().setCurrentNode(str);
        CPSCompilerMain.This().compile(script.getData());
      }
    }
   
    //
    return SNodes;
View Full Code Here

   *
   * @param pn the new evidences
   */
  public void setEvidences( SingleEntityNetwork pn ) {
    //1. create default nodes
    EDBUnit SNodes = EDB.This().get("ROOT.NODES");
      
    //4. create states
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNodeAt(i);
      TreeVariable tv = (TreeVariable)UNode;
      EDBUnit SNode = SNodes.get(UNode.getName());
     
      if(tv.hasEvidence()) {
        EDBUnit evidence = SNode.create("EVIDENCE")
        String ev = UNode.getStateAt(tv.getEvidence());
        evidence.setData(ev);
      }
    }
     
  }
View Full Code Here

   * Sets the locations.
   *
   * @param pn the new locations
   */
  public void setLocations( SingleEntityNetwork pn ) {
    EDBUnit SNodes = EDB.This().get("ROOT.NODES");
   
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNodeAt(i);
      EDBUnit SNode = SNodes.get(UNode.getName());
      EDBUnit info   = SNode.get("INFO");
      EDBUnit X = info.get("X");
      EDBUnit Y = info.get("Y");
             
      Point2D position = UNode.getPosition();
      Double dx = new Double(position.getX());
      Double dy = new Double(position.getY());
      X.setData(dx.toString());
      Y.setData(dy.toString());
    }
  }
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.