Map<String, String> mapSample = new HashMap<String, String>();
sampleList.add(mapSample);
Double lw = 1.0;
//showing result
EDBUnit nodes = EDB.This().get("ROOT.ENGINES.LW.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 eq = node.getCopied("EQUATION");
//System.out.println(" " + str + ":");
//node.print("node ");
//if this node is an evidence node
if( evidence != null ){
if( type.getData().equalsIgnoreCase("Discrete") ){
EDBUnit state = cpt.getNext(evidence.getData());
lw *= state.getDataByDouble();
mapSample.put( str, evidence.getData() );
}else
if( type.getData().equalsIgnoreCase("Continuous") ){
mapSample.put( str, evidence.getData() );
lw *= getProbFromEquation( cpt, eq, mapSample, evidence.getDataByDouble() );
}
}
else //if this node is not an evidence node
if( type.getData().equalsIgnoreCase("Discrete") ){
EDBUnit isa = cpt.getRel("ISA");
//this node doesn't have parents
if( isa == null ){
String strState = sampling(cpt);
mapSample.put(str, strState);
}else //this node has parents
{
String strState = samplingFromCPT(cpt, mapSample);
mapSample.put(str, strState);
}
}else
if( type.getData().equalsIgnoreCase("Continuous") ){
EDBUnit isa = cpt.getRel("ISA");
//this node doesn't have parents
if( isa == null ){
Double d = sampling( 0, eq, mapSample );
mapSample.put(str, d.toString());
}else //this node has parents