createEdgeOfUDB( rede, node, nextParent.getNext() );
}
public void run(String strArg){
ProbabilisticNetwork rede = new ProbabilisticNetwork("Network Name");
/* ArrayList<String> tempList = new ArrayList<String>();
tempList.add("C");
tempList.add("B");
tempList.add("A");
tempList.add("Z");
tempList.add("W");
tempList.add("Y");
tempList.add("X");
tempList.add("U");
EDBUnit nodes = EDB.This().get("ROOT.NODES");
EDBUnit ISA = nodes.getRel("ISA");
for( String str : tempList ){
EDBUnit node = ISA.map.get(str);
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());
}
}
}
try {
rede.compile();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}