for(MFrag mfrag: mebn.getMFragList()){
// we are creating one continuous SSBN node per each possible combination of arguments in a continuous resident node
for (Node node : mfrag.getNodes()) {
if (node instanceof ContinuousResidentNode) {
ContinuousResidentNode continuousResidentNode = (ContinuousResidentNode) node;
if (continuousResidentNode.getOrdinaryVariableList() == null
|| continuousResidentNode.getOrdinaryVariableList().isEmpty()) {
continue; // go to next node
}
// prepare all possible combinations of arguments. The ovs are synchronized by index
boolean hasAtLeastOneCombination = true; // true if all Lists in combinator were filled
List<List<LiteralEntityInstance>> combinator = new ArrayList<List<LiteralEntityInstance>>();
for (OrdinaryVariable ov : continuousResidentNode.getOrdinaryVariableList()) {
List<LiteralEntityInstance> contentOfCombinator = new ArrayList<LiteralEntityInstance>();
// get all values for ov
List<String> ovValues = knowledgeBase.getEntityByType(ov.getValueType().getName());
if (ovValues.isEmpty()) {
// this iterator cannot be filled, because ov has no possible values
hasAtLeastOneCombination = false;
break;
}
// add all possible values for ov
for (String ovValue : ovValues) {
contentOfCombinator.add(LiteralEntityInstance.getInstance(ovValue, ov.getValueType()));
}
combinator.add(contentOfCombinator);
}
// do not add node if there is some ov with no possible value (that means, no combination can be created)
if (!hasAtLeastOneCombination) {
continue; // go to next continuous node
}
// list of indexes of combinator
List<Integer> indexes = new ArrayList<Integer>(combinator.size());
for (int i = 0; i < combinator.size(); i++) {
// Note that at this point, each list in combinator has at least 1 element, because hasAtLeastOneCombination == true (so, 0 is a valid index)
indexes.add(0);
}
/*
* iterate on combinator using indexes.
* E.g.: combinator = {{a,b},{1,2}};
* then indexes must iterate like:
* {0,0} (means (a,1));
* {1,0} (means (b,1));
* {0,1} (means (a,2));
* {1,1} (means (b,2));
*
*/
while (hasAtLeastOneCombination) {
// create a continuous ssbn node for each possible combination of combinator
SimpleSSBNNode ssbnNode = SimpleSSBNNode.getInstance(continuousResidentNode);
ssbnNode.setFinished(false);
// fill arguments of ssbnNode
for (int i = 0; i < continuousResidentNode.getOrdinaryVariableList().size(); i++) {
ssbnNode.setEntityForOv(
continuousResidentNode.getOrdinaryVariableList().get(i),
combinator.get(i).get(indexes.get(i))
);
}
if (logManager != null) {