node.setMFragInstance(mFragInstance);
//--- 1) Evaluate if the node is a finding.
IResidentNode resident = node.getResidentNode();
List<OVInstance> argumentList = new ArrayList<OVInstance>();
for(int i = 0; i < node.getOvArray().length; i++){
argumentList.add(OVInstance.getInstance(node.getOvArray()[i], node.getEntityArray()[i]));
}
StateLink exactValue = kb.searchFinding(
node.getResidentNode(), argumentList);
/*
* Nota: como o algoritmo apenas sobe, é necessário continuar a avaliação
* acima mesmo quando o nó for setado como um finding, pois acima dele pode
* ter uma query ou nó que influência a query. (Caso fosse feita a avaliação
* acima e abaixo, não seria necessária esta subida, mas o algoritmo seria
* mais complexo). Isto gerará um monte de nós candidados a serem excluidos
* no próximo passo.
*/
if(exactValue!= null){
//The node is a finding...
node.setState(exactValue.getState());
ssbn.addFindingToTheFindingList(node);
if (logManager != null) {
logManager.printText(level4, false, " -> Node " + node +
" set as a finding. Exact Value = " + exactValue);
}
}
//---- 2) Create the parents of node from the resident nodes
//If the context node of the MFrag don't are evaluated, the creation of
//the parents isn't possible
if(mFragInstance.isUseDefaultDistribution()){
if (logManager != null) {
logManager.printText(level4, false, " -> Node can't be evaluated: mfrag using default distribution");
}
return;
}
OrdinaryVariable[] ovFilledArray = node.getOvArray();
LiteralEntityInstance[] entityFilledArray = node.getEntityArray();
if (logManager != null) {
logManager.printText(level4, false, " 1) Evaluate the resident node parents");
}
for(ResidentNode residentNodeParent: resident.getResidentNodeFatherList()){
List<SimpleSSBNNode> createdNodesList = createParents(node,
ovFilledArray, entityFilledArray, residentNodeParent);
if (logManager != null) {
logManager.printText(level4, false, "Resident parents generates from the resident node " +
residentNodeParent);
}
int count = 0;
for(SimpleSSBNNode newNode: createdNodesList){
if (logManager != null) {
logManager.printText(level4, false, "Evaluate " + count + " - "+ newNode);
}
count= count + 1 ;
evaluateNodeInMFragInstance(mFragInstance, newNode);
}
}
//---- 3) Create the parents of node from the input nodes
if (logManager != null) {
logManager.printText(level4, false, " 2) Evaluate the input node parents");
}
for(InputNode inputNodeParent: resident.getParentInputNodesList()){
if(inputNodeParent.getResidentNodePointer().getResidentNode().equals(resident)){
//Special case: the recursivity.
if (logManager != null) {
logManager.printText(level4, false, " Recursivity treatment: " + resident);