currentNode = newNode;
}
}
private void visitDecisionNode() {
DecisionNode decisionNode = (DecisionNode) currentNode.getActivityNode();
double normalizationFactor = decisionNode.getOutgoings().size();
//TODO write code to compute the normalization factor
// remove decision node from execution branch
ExecutionNode parentNode = currentNode.getParent();
parentNode.removeChild(currentNode);
currentNode = parentNode;
// check if we have already decided
DecisionContainer container = null;
for (int i = 0; i < decisionContainers.size(); i++) {
DecisionContainer temp = decisionContainers.get(i);
if (temp.getDecisionNode().equals(decisionNode)) { // we have already taken a decision
// reset subsequent decisions
for (int j = i + 1; j < decisionContainers.size(); j++) {
decisionContainers.remove(i+1);
}
container = temp;
}
}
if (container == null) { // create a decision container if not present
container = new DecisionContainer(decisionNode);
for (ActivityEdge edge : decisionNode.getOutgoings()) {
container.addDecision(new Decision(edge, 1d / normalizationFactor));
}
decisionContainers.add(container);
}
boolean flag = true;
for (ActivityEdge edge : decisionNode.getOutgoings()) {
ActivityNode target = edge.getTarget();
Decision decision = container.findDecision(edge);
if (decision.doTakeDecision()) { // we are taking this edge
double newChance = parentNode.getChance() * 1d / normalizationFactor;