for (int i = 0; i < input.size(); i++) {
this.variables.setVariable(i, input.getData(i));
}
final ExpressionValue v = this.rootNode.evaluate();
final VariableMapping resultMapping = getResultType();
final MLData result = new BasicMLData(1);
boolean success = false;
switch (resultMapping.getVariableType()) {
case floatingType:
if (v.isNumeric()) {
result.setData(0, v.toFloatValue());
success = true;
}
break;
case stringType:
result.setData(0, v.toFloatValue());
success = true;
break;
case booleanType:
if (v.isBoolean()) {
result.setData(0, v.toBooleanValue() ? 1.0 : 0.0);
success = true;
}
break;
case intType:
if (v.isNumeric()) {
result.setData(0, v.toIntValue());
success = true;
}
break;
case enumType:
if (v.isEnum()) {
result.setData(0, v.toIntValue());
success = true;
}
break;
}
if (!success) {
throw new EARuntimeError("EncogProgram produced "
+ v.getExpressionType().toString() + " but "
+ resultMapping.getVariableType().toString()
+ " was expected.");
}
return result;