private float execNode(TreeNode<PromoterNodeData> node, ArrayList molecules)
{
if (node != null)
{
if (node.getData().token == PromoterParser.eNodeType.OR)
return Math.Max(execNode(node.getLeftNode(), molecules), execNode(node.getRightNode(), molecules));
else if (node.getData().token == PromoterParser.eNodeType.AND)
return Math.Min(execNode(node.getLeftNode(), molecules), execNode(node.getRightNode(), molecules));
else if (node.getData().token == PromoterParser.eNodeType.NOT)
return 1f - execNode(node.getLeftNode(), molecules);
else if (node.getData().token == PromoterParser.eNodeType.CONSTANT)
return execConstant(node, molecules);
else if (node.getData().token == PromoterParser.eNodeType.BOOL)
return execBool(node);
else if (node.getData().token == PromoterParser.eNodeType.WORD)
{
Molecule mol = ReactionEngine.getMoleculeFromName(node.getData().value, molecules);
if (mol != null)
return mol.getConcentration();
}
else if (node.getData().token == PromoterParser.eNodeType.NUM)
return float.Parse(node.getData().value.Replace(",", "."));
}
return 1.0f;
}