/*
         *
         *      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 Obstacle Obstacle(this ObstacleAssumption exception)
 {
     return(exception.model.Obstacles().SingleOrDefault(y => y.Identifier == exception.ResolvedObstacleIdentifier));
 }
 public static Goal Anchor(this ObstacleAssumption exception)
 {
     return(exception.model.Goals().SingleOrDefault(y => y.Identifier == exception.AnchorGoalIdentifier));
 }
Beispiel #4
0
 public void Add(ObstacleAssumption v)
 {
     this.obstacleRepository.Add(v);
 }