* Creates the cpt by deterministic equation.
*
* @param name the name
*/
public void createCPTbyDeterministicEquation( String name ){
EDBUnit type = EDB.This().get("ROOT.NODES."+name+".INFO.TYPE");
EDBUnit eqList = EDB.This().get("ROOT.NODES."+name+".EQUATION");
EDBUnit cpt = EDB.This().get("ROOT.NODES."+name+".CPT");
EDBUnit states = EDB.This().get("ROOT.NODES."+name+".STATES");
if( eqList == null )
return;
Map<EDBUnit, Object> mapResultsByEq = new HashMap<EDBUnit, Object>();
ArrayList<DiscreteNodesCombination> listDiscreteNodeCombination = new ArrayList<DiscreteNodesCombination>();
get_DiscreteNode_combination(cpt, listDiscreteNodeCombination, eqList );
EDBUnit eq = null;
if( !listDiscreteNodeCombination.isEmpty() ){
for( DiscreteNodesCombination dc: listDiscreteNodeCombination){
eq = dc.getEquation();
ArrayList<EDBUnit> ifEUnit = new ArrayList<EDBUnit>();
findEUnitOnCondition(cpt, dc.mapValuesForAssingnment, ifEUnit );
for( EDBUnit cptOne : ifEUnit ){
//eq.print("");
if( !eq.hasChildren() )
eq = eqList;
createCPTbyManyDeterministicEquation(eq, cptOne, type, mapResultsByEq, dc.mapValuesForAssingnment);
}
}
}else{
createCPTbyOneDeterministicEquation(eqList, cpt, type, mapResultsByEq);
}
//create new state space based on deterministic calculation.
ArrayList<Double> arrayNewStates = new ArrayList<Double>();
for(EDBUnit e: mapResultsByEq.keySet()){
Object d = mapResultsByEq.get(e);
if( !arrayNewStates.contains(d) ){
arrayNewStates.add((Double)d);
}
}
Collections.sort(arrayNewStates);
states.removeAllChildren();
for(Double d: arrayNewStates){
states.createNext(d.toString());
}
for(EDBUnit e: mapResultsByEq.keySet()){
Object finded = mapResultsByEq.get(e);
// e.print("");
e.removeAllNEXTChildren();
// e.print("");
EDBUnit t = e;
for(Double d: arrayNewStates){
t = t.createNext(d.toString());
if( finded.equals(d) ){
t.setData("1");
}else{
t.setData("0");
}
}
//e.print("");
}
}