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

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


    //output complete percentage   
//    double count = ((double)countTree/(double)sizeTree)*100;
//    CPSDialog.This().insertTextOut("[Node."+ cNode.getName() + "] Completed: " + (int)count + "%", 1);   
//    ++countTree;
   
    EDBUnit node = EDB.This().get("ROOT.NODES."+cNode.getName());
    EDBUnit states = node.get("STATES");
    EDBUnit cpt = node.get("CPT");
//    EDBUnit eq = node.get("SCRIPT");
    String type = node.get("INFO.TYPE").getData();
    node.print("");   
    /////////////////////////////////////////////////////////////////////////////////////
    //1. add UnBBayes node information from MathNode information
    // remove all states of the current node
    ((ProbabilisticNode)cNode).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();
    EDBUnit stateSecond = stateFirst.getNext();
    String strFirstStateName = stateFirst.getName();
 
    if( type.equals("Continuous") || type.equals("Discretized") ){
      strFirstStateName = "[" + stateFirst.getName() +", "+ stateSecond.getName() + "]";
    }
   
    if( cNode.getStatesSize() <= 0 )
      cNode.appendState(strFirstStateName);
   
View Full Code Here


   */
  public void piMessagesSending(EDBUnit type, EDBUnit msg, EDBUnit node, EDBUnit cpt, EDBUnit pi, EDBUnit lambda, EDBUnit lambda_from_children, EDBUnit childNext){
    if( childNext == null )
      return;
   
    EDBUnit cNode = EDB.This().get("ROOT.ENGINES.DMP.NODES."+childNext.getName());
    EDBUnit pi_from_parent_in_child = cNode.get("MSG.PI_FROM_PARENTS." + node.getName());
    EDBUnit lam = new EDBUnit(lambda);
    
  //  long time2 = System.nanoTime(); 
    prod_lambda(lam, type, msg, lambda, lambda_from_children, childNext);
  //  System.out.println("4.1. prod_lambda  " + (System.nanoTime()- time2) );
  //  long time1 = System.nanoTime();
View Full Code Here

   * Show results.
   */
  public void showResults(){
    //showing result
     int iText = 0;
    EDBUnit nodes = EDB.This().get("ROOT.ENGINES."+getEngineName() +".NODES");
    EDBUnit ISA = nodes.getRel("ISA")
    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 bel = node.get("BEL");
      
      System.out.println(" " + str + ":");
       // CPSDialog.This().insertTextOut(" " + str + ":", iText++);
     
      if( evidence != null ){
        evidence.print("         ");
        // CPSDialog.This().insertTextOut(evidence.printOnAString("         "), iText++);
      }else
      if( bel != null ){
        bel.print("         ");
         //CPSDialog.This().insertTextOut(bel.printOnAString("         "), iText++);
      }
    }
  }
View Full Code Here

                     "defineEvidence(isJettisoningCargo_ship1, True);"+
                     "run(DMP);")
    time_dmp = (System.nanoTime()- time);
    System.out.println("Total DMP Time:  " + time_dmp + "  nano sec");
   
    EDBUnit node = EDB.This().get("ROOT.ENGINES.DMP.NODES.isShipOfInterest_ship1");
    EDBUnit bel = node.get("BEL");
    bel.print("isShipOfInterest_ship1");
   
    System.out.println(" ");
  }
View Full Code Here

       
    CPSCompilerMain.This().compile( ev + "run(DMP);")
    time_dmp = (System.nanoTime()- time);
    System.out.println("Total DMP Time:  " + time_dmp + "  nano sec");
   
    EDBUnit node = EDB.This().get("ROOT.ENGINES.DMP.NODES.isShipOfInterest_ship1");
    EDBUnit bel = node.get("BEL");
    bel.print("isShipOfInterest_ship1");
   
    System.out.println(" ");
  }
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
   * @return the eDB unit
   */
  public EDBUnit createCPT(EDBUnit curNode){
    EDBUnit parents = curNode.get("PARENTS");
    EDBUnit CPT = curNode.get("CPT");
    CPT.removeAllChildren();
   
    //1. create parent states    //EX) mid.one.sour
    createParentStateOnCPT( CPT, parents.getNext() );
    //curNode.print("");
    //2. create current states    //EX) mid.one.sour.green
View Full Code Here

    for( EDBUnit t : ifEUnit ){
      //if(t.getName().equalsIgnoreCase("CPT"))
      {
        for( String strState: map.keySet()){
          String strVaule = map.get(strState);
          EDBUnit state = t.getNext().getNext(strState);
          if( state == null )
            return;
          state.setData(strVaule);
        }
      }
    }
  }
View Full Code Here

   *
   * @param cur the current e unit
   * @return the eDB unit
   */
  public EDBUnit SetExperimentNumber(EDBUnit cur){
    EDBUnit n = cur.getNext();
   
    if( n == null ) return null;
   
    EDBUnit s =  EDB.This().get("ROOT.NODES."+strCurrentNode+".STATES");
   
    EDBUnit r = FindNextState(s, n.getName());
 
    if( r.getData2().equals("null"))
      return null;
   
    Double d1 = Double.parseDouble(n.getData());
    Double d2 = Double.parseDouble(r.getData2());
    d1 += d2;
    n.setData(d1.toString());
     
    return SetExperimentNumber(n);
  }
View Full Code Here

   * @param cTree the c tree
   * @param skip the skip
   * @param hasMinus the has minus
   */
  public void convertCommonTreeToEUnit( EDBUnit eq, CommonTree cTree, boolean skip, boolean hasMinus ){
    EDBUnit echild = eq;
   
    //if cTree is "-", then check its child.
    //if its child is a character such as "X", then put "*" and put "-1" and "X" as child.
    //if its child is a number such as "3, then change it as "-3"
    //EX] 1-X  => 1 + -1 * X
    //if it has child1 and child2, put +, set MinusOne command. And then next iteration of child2
    //use the command
    //EX] -X  => -1 * X
    //if it has just one child1, do MinusOne command
    //EX] -0.5*X => -0.5 * X
    //
     if( cTree.toString().equalsIgnoreCase("-") ){
      //iteration
      CommonTree child1 = (CommonTree) cTree.getChild(0);  
      CommonTree child2 = (CommonTree) cTree.getChild(1);
 
      if( child1 != null && child2 == null && CPSMath.isNum(child1.toString())){
        if( CPSMath.isNum(child1.toString()) ){
          echild = eq.createDummy( "-" + child1.toString() );
          convertCommonTreeToEUnit( echild, child1, true, false )
          return;
        }
         
      }
      if( child1 != null && child2 != null && CPSMath.isNum(child2.toString())){
        EDBUnit eNew = eq.createDummy( "+" );
        echild = eNew.createDummy( "-" + child2.toString() );
     
        convertCommonTreeToEUnit( eNew, child1, false, false );
        convertCommonTreeToEUnit( echild, child2, true, false );
        return;
      }
     
      if( child1 != null && child2 != null && isOperater(child2.toString())){
        EDBUnit eNew = eq.createDummy( "+" );
        convertCommonTreeToEUnit( eNew, child1, false, false );
        convertCommonTreeToEUnit( eNew, child2, false, true );
        return;
      }
    }

    if( hasMinus ){
      EDBUnit eNew = eq.createDummy(cTree.toString());
      CommonTree child1 = (CommonTree) cTree.getChild(0);  
      CommonTree child2 = (CommonTree) cTree.getChild(1);
     
      if( CPSMath.isNum(child1.toString())){
        echild = eNew.createDummy( "-" + child1.toString() );
        convertCommonTreeToEUnit( echild, child1, true, false );
        convertCommonTreeToEUnit( eNew, child2, false, false );
        return;
     
    }
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.