public void Visit(ActionDecision node) { PutLabel(node); output .AppendFormat("action({0})", node.Action) .AppendLine(); }
private ActionDecision GetActionDecision(int id) { ActionDecision result; if (!actionIdToDecision.TryGetValue(id, out result)) { result = new ActionDecision(id); actionIdToDecision[id] = result; } return(result); }
private Decision Build( int first, int last, KeyValuePair <int, int>[] upperBounds) { int size = last - first; if (size > platform.MaxLinearCount) { // binary search nodes int middle = first + (size - 1) / 2; var branch = new RelationalBranchDecision( RelationalOperator.LessOrEqual, upperBounds[middle].Key); // positive branch branch.Left = Build(first, middle + 1, upperBounds); // negative branch branch.Right = Build(middle + 1, last, upperBounds); return(branch); } else { Decision result = null; RelationalBranchDecision lastBranch = null; // linear search nodes for (; first != last; ++first) { int key = upperBounds[first].Key; RelationalBranchDecision branch; if (first > 0 && (key - upperBounds[first - 1].Key) == 1) { branch = new RelationalBranchDecision(RelationalOperator.Equal, key); } else { branch = new RelationalBranchDecision(RelationalOperator.LessOrEqual, key); } branch.Left = new ActionDecision(upperBounds[first].Value); branch.Right = null; if (lastBranch != null) { lastBranch.Right = branch; } else { result = branch; } lastBranch = branch; } if (lastBranch != null) { lastBranch.Right = new ActionDecision(defaultAction); } else { result = new ActionDecision(defaultAction); } return(result); } }