* @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;