if (decision instanceof SingleDecision) {
throw new GuideException("A branched decision model expect more than one decisions. ");
}
boolean success = false;
final SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex);
if (decisionIndex+1 < decision.numberOfDecisions()) {
if (singleDecision.continueWithNextDecision()) {
if (children == null) {
children = new HashMap<Integer,DecisionModel>();
}
DecisionModel child = children.get(singleDecision.getDecisionCode());
if (child != null) {
success = child.predictFromKBestList(decision);
}
}
}
if (!success) {
success = singleDecision.updateFromKBestList();
if (decisionIndex+1 < decision.numberOfDecisions()) {
if (singleDecision.continueWithNextDecision()) {
if (children == null) {
children = new HashMap<Integer,DecisionModel>();
}
DecisionModel child = children.get(singleDecision.getDecisionCode());
if (child == null) {
child = initChildDecisionModel(((MultipleDecision)decision).getSingleDecision(decisionIndex+1),
branchedDecisionSymbols+(branchedDecisionSymbols.length() == 0?"":"_")+singleDecision.getDecisionSymbol());
children.put(singleDecision.getDecisionCode(), child);
}
child.predict(decision);
}
}
}