public void setStatesOfUDB(ProbabilisticNetwork rede, EDBUnit sNode){
EDBUnit states = sNode.get("STATES");
EDBUnit cpt = sNode.get("CPT");
EDBUnit eq = sNode.get("EQUATION");
String type = sNode.get("INFO.TYPE").getData();
Node uNode = rede.getNode(sNode.getName());
if( type.equalsIgnoreCase("Discrete") ){
/////////////////////////////////////////////////////////////////////////////////////
//1. add UnBBayes node information from MathNode information
// remove all states of the current node
((ProbabilisticNode)uNode).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();
// set fist state info of unBBayes
uNode.setStateAt(stateFirst.getName(), 0);
// store index map of states
stateIndexMap.put( stateFirst.getName(), c++);
// add second and next states
AddNewStatesToBNNode( uNode, stateIndexMap, c, stateFirst.getNext() );
/////////////////////////////////////////////////////////////////////////////////////
//3. fill zero on table
PotentialTable auxTab = (PotentialTable) ((IRandomVariable) uNode).getProbabilityFunction();
int curStateSize = uNode.getStatesSize();
for( INode parent : uNode.getParentNodes() )
curStateSize *= parent.getStatesSize();
for( int i = 0; i < curStateSize; i++ )
auxTab.addValueAt(i, 0);
auxTab.setTableSize(curStateSize);
/////////////////////////////////////////////////////////////////////////////////////
//4. add new values in the states of BN
// EX]
// CPT[Isa]parent1.state1{parent1.Name}[Isa]parent2.state1{parent2.Name}[Next]cur.state1[Next]cur.state2
// ...
int coord[] = new int[uNode.getParentNodes().size()+1];
AddNewStatesValueToBNNode( cpt, coord, stateIndexMap, auxTab );
((TreeVariable)uNode).initMarginalList();
//5. add new scripts of BN