public void Visit(ActionDecision node) { PutLabel(node); output .AppendFormat("action({0})", node.Action) .AppendLine(); }
public virtual HistoryTreeNode getChild(ActionDecision childDecision) { foreach (HistoryTreeNode c in children) { if (c.Action.Equals(childDecision)) { return(c); } } return(null); }
private void PrintProgram(Decision nodes, Decision defaultDecision = null) { if (defaultDecision == null) { defaultDecision = new ActionDecision(-1); } StringBuilder output = new StringBuilder(); var writer = new DecisionProgramWriter(output); writer.Build(nodes, defaultDecision); Debug.WriteLine(output); }
void IDecisionVisitor.Visit(ActionDecision decision) { emit.Label(GetNodeLabel(decision).Def); this.action(emit, decision.Action); }
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; } }