private static void RecPrint(ConditionalPlanTreeNode node, int depth, string path, ref StringBuilder sb) { if (node == null) { return; } if (node.Action != null) { sb.AppendLine(path + node.Action.Name.ToString()); } if (node.SingleChild != null) { string tPath = path + "\t"; RecPrint(node.SingleChild, depth + 1, tPath, ref sb); } if (node.FalseObservationChild != null) { string tPath = path + "\t(f)"; RecPrint(node.FalseObservationChild, depth + 1, tPath, ref sb); } if (node.TrueObservationChild != null) { string tPath = path + "\t(t)"; RecPrint(node.TrueObservationChild, depth + 1, tPath, ref sb); } }
public static string Print(ConditionalPlanTreeNode root) { StringBuilder sb = new StringBuilder(); RecPrint(root, 0, "", ref sb); return(sb.ToString()); }
// public static bool IsValid(Dictionary <Constant, PlanResult> plans) { List <PreconditionsAndEffectsAtTime> peatCollection = new List <PreconditionsAndEffectsAtTime>(); int latestTimeOperationObserved = 0; // Collect all the preconditions and effects from all the agent's plans at each timestamp foreach (var plan in plans) { Constant agent = plan.Key; ConditionalPlanTreeNode cptn = plan.Value.Plan; // get all actions List <Action> actionsUsed = new List <Action>(); cptn.GetActionUsed(ref actionsUsed); foreach (var a in actionsUsed) { int actionTime = a.GetTime(); Formula effects = a.Effects; Formula preconditions = a.Preconditions; PreconditionsAndEffectsAtTime peat = new PreconditionsAndEffectsAtTime(); peat.agent = agent; peat.Time = actionTime; peat.Effects = effects; peat.Preconditions = preconditions; peatCollection.Add(peat); //Update latest operation time latestTimeOperationObserved = Math.Max(latestTimeOperationObserved, actionTime); } } // Create aggregated collection of effects over time Dictionary <int, Formula> effectsCollection = new Dictionary <int, Formula>(); Dictionary <int, Formula> preconditionsCollection = new Dictionary <int, Formula>(); for (int i = 0; i <= latestTimeOperationObserved; i++) { // Get all effects at time i CompoundFormula combinedEffects = new CompoundFormula("and"); foreach (var effFormula in peatCollection.FindAll(x => x.Time == i).Select(x => x.Effects).ToList()) { combinedEffects.AddOperand(effFormula); } effectsCollection.Add(i, combinedEffects); // Get all the preconditions at time i CompoundFormula combinedPreconditions = new CompoundFormula("and"); foreach (var effFormula in peatCollection.FindAll(x => x.Time == i).Select(x => x.Preconditions).ToList()) { combinedPreconditions.AddOperand(effFormula); } preconditionsCollection.Add(i, combinedPreconditions); } return(true); }
public ConditionalPlanTreeNode EnforceSpecificActionTimes(Dictionary <Action, int> jointActionsTimes) { ConditionalPlanTreeNode currentNode = null; if (Action != null) { Action newAction = Action.RemoveTime(); string sActionName = newAction.Name; } return(currentNode); }
private static List <Action> GenerateJointActionsListForSingleInitialState(PartiallySpecifiedState initialState, Dictionary <Constant, PlanResult> plans) { foreach (var agentPlan in plans) { Constant agent = agentPlan.Key; PlanResult planResult = agentPlan.Value; ConditionalPlanTreeNode cptn = planResult.Plan; List <Action> actions = new List <Action>(); cptn.GetActionUsed(ref actions); return(actions); } return(null); }
public PlanDetails(ConditionalPlanTreeNode conditionalPlanTreeNode) { Plan = conditionalPlanTreeNode; }