/* * * foreach (var subgoal in anchor.Refinements().SelectMany(x => x.SubGoals())) { * var assumption = new ObstacleNegativeAssumption { * Assumed = obstacle, * Implicit = true * }; * Propagate (assumption, subgoal); * } * */ static void DownPropagate(ObstacleAssumption assumption, Goal goal) { foreach (var children in goal.Refinements().SelectMany(x => x.SubGoals()).ToArray()) { //Console.WriteLine ("<pre> -- " + children.FriendlyName + " -- " + assumption.Obstacle().FriendlyName); //Console.WriteLine (string.Join ("\n", children.Obstacles ().Select (x => x.Identifier))); //Console.WriteLine ("</pre><hr />"); if (children.Obstacles().Select(x => x.Identifier).Contains(assumption.ResolvedObstacleIdentifier)) { var obstacleAssumption = (ObstacleAssumption)assumption.Copy(); obstacleAssumption.Identifier = Guid.NewGuid().ToString(); obstacleAssumption.SetAnchorGoal(children); children.model.Add(obstacleAssumption); DownPropagate(obstacleAssumption, children); } } /* * foreach (var obstacle in goal.Obstructions()) { * var obstacleAssumption = assumption.Copy (); * obstacleAssumption.SetAnchorGoal (children); * DownPropagate (obstacleAssumption, obstacle.Obstacle()); * } */ }
public static IEnumerable <Obstacle> Obstacles(this Goal goal) { return(goal.Refinements().SelectMany(x => x.SubGoals().SelectMany(y => y.Obstacles())) .Union(goal.Obstructions().SelectMany(x => x.Obstacles()))); }