public void Render(Obstacle o, KAOSModel model)
        {
            Render (o);
            foreach (var obstruction in o.model.Obstructions ().Where (x => x.ObstacleIdentifier == o.Identifier)) {
                Render (obstruction.ObstructedGoal ());
                Render (obstruction);
            }

            RenderRefinement (o);
        }
        void RenderRefinement(Obstacle o)
        {
            foreach (var refinement in o.Refinements()) {
                foreach (var child in refinement.SubObstacles ()) {
                    Render (child);
                    RenderRefinement (child);

                    foreach (var resolution in child.Resolutions ()) {
                        Render (resolution.ResolvingGoal ());
                        Render (resolution);
                    }
                }
                Render (refinement);
            }
        }
예제 #3
0
 private static void AddElementsFor(this IList<string> alphabet, Obstacle obstacle)
 {
     alphabet.AddElementsFor (obstacle.FormalSpec);
 }
        static void Integrate(Goal obstructedGoal, Obstacle obstacle, Resolution resolution)
        {
            var anchor = obstructedGoal;
            if (resolution.Parameters.Count > 0) {
                anchor = resolution.Parameters[0];
            }
            anchor = FinalAnchor (anchor);

            if (resolution.ResolutionPattern == ResolutionPattern.GoalSubstitution
                | resolution.ResolutionPattern == ResolutionPattern.GoalWeakening) {

                var goalReplacement = new GoalReplacement (obstructedGoal.model) {
                    Implicit = true
                };
                goalReplacement.SetObstacle (obstacle);
                goalReplacement.SetResolvingGoal (resolution.ResolvingGoal ());
                goalReplacement.SetAnchorGoal (anchor);

                obstructedGoal.model.Add (goalReplacement);

                // Replace in refinements
                var resolving_goal = resolution.ResolvingGoal ();
                foreach (var r in anchor.ParentRefinements ().ToArray ()) {
                    r.Remove (anchor);
                    r.Add (resolving_goal);
                }

                // Replace children refinements
                foreach (var r in anchor.Refinements ().ToArray ()) {
                    anchor.model.Remove (r);
                    var r2 = (GoalRefinement) r.Copy ();
                    r2.Identifier = Guid.NewGuid ().ToString ();
                    r2.SetParentGoal (resolving_goal);
                    resolution.model.Add (r2);
                }

                // Replace in exceptions
                foreach (var r in anchor.Exceptions ().ToArray ()) {
                    r.SetAnchorGoal (resolving_goal);
                }

                // Replace in provided
                foreach (var r in anchor.Provided ().ToArray ()) {
                    r.SetAnchorGoal (resolving_goal);
                }

                // Replace in agent assignements
                foreach (var r in anchor.AgentAssignments ().ToArray ()) {
                    r.GoalIdentifier = resolving_goal.Identifier;
                }

            } else {

                var goalException = new GoalException (obstructedGoal.model) {
                    Implicit = true
                };
                goalException.SetObstacle (obstacle);
                goalException.SetResolvingGoal (resolution.ResolvingGoal ());
                goalException.SetAnchorGoal (anchor);

                obstructedGoal.model.Add (goalException);

                /*
                var obstacleAssumption = new ObstacleAssumption (resolution.model);
                obstacleAssumption.SetAnchorGoal (anchor);
                obstacleAssumption.SetObstacle (obstacle);

                if (anchor.Identifier != obstructedGoal.Identifier) {
                Console.WriteLine ("DownPropagate " + obstacle.FriendlyName + " ("+obstructedGoal.FriendlyName +") on " + anchor.FriendlyName );
                }
                */

                // DownPropagate (obstacleAssumption, anchor);
            }
        }
        static void RecursiveIntegration(Goal obstructedGoal, Obstacle obstacle)
        {
            foreach (var resolution in obstacle.Resolutions().ToArray ()) {
                Integrate (obstructedGoal, obstacle, resolution);
            }

            foreach (var subobstacle in obstacle.Refinements().SelectMany (x => x.SubObstacles()).ToArray ()) {
                RecursiveIntegration (obstructedGoal, subobstacle);
            }
        }
예제 #6
0
        void DownPropagate(Goal parent, Obstacle obstacle)
        {
            var alternatives_to_add = new List<AlternativeSystem> (parent.InSystems);

            if (obstacle.InSystems == null)
                obstacle.InSystems = new HashSet<AlternativeSystem> ();

            foreach (var a in alternatives_to_add) {
                obstacle.InSystems.Add (a);
            }

            DownPropagate (obstacle);
        }
예제 #7
0
 public void ExportResolution(Obstacle o, Resolution g)
 {
     writer.WriteLine (@"""{0}"" -> ""{1}"" [arrowtail=onormaltee];",
                       o.Identifier,
                       g.ResolvingGoal().Identifier);
 }
예제 #8
0
        public void ExportRefinement(Obstacle parent, ObstacleRefinement refinement)
        {
            var tempGUID = Guid.NewGuid().ToString();
            writer.WriteLine (@"""{0}""[shape=circle,width=.1,fixedsize=true,label=""""];", tempGUID);
            writer.WriteLine (@"""{0}"" -> ""{1}"" [arrowtail=onormal];", parent.Identifier, tempGUID);

            foreach (var child in refinement.SubObstacles()) {
                writer.WriteLine (@"""{0}"" -> ""{1}"" [arrowtail=none];", tempGUID, child.Identifier);
            }

            foreach (var child in refinement.DomainHypotheses()) {
                writer.WriteLine (@"""{0}"" -> ""{1}"" [arrowtail=none];", tempGUID, child.Identifier);
            }

            foreach (var child in refinement.DomainProperties()) {
                writer.WriteLine (@"""{0}"" -> ""{1}"" [arrowtail=none];", tempGUID, child.Identifier);
            }
        }
예제 #9
0
 public void SetParentObstacle(Obstacle element)
 {
     this.ParentObstacleIdentifier = element.Identifier;
 }
예제 #10
0
 public ObstacleRefinement(KAOSModel model, Obstacle obstacle)
     : this(model)
 {
     SubobstacleIdentifiers.Add (obstacle.Identifier);
 }
예제 #11
0
 public void Add(Obstacle obstacle)
 {
     Obstacles.Add (obstacle);
 }
예제 #12
0
        public static IEncodedString GetPartialObstacleDiagram(Obstacle o)
        {
            var view = new PartialModelView ();
            view.Add (o);

            foreach (var r in o.ParentRefinements ()) {
                view.Add (r);
                view.Add (r.ParentObstacle ());
            }

            foreach (var r in o.Refinements()) {
                view.Add (r);
                foreach (var gg in r.SubObstacles ()) {
                    view.Add (gg);
                }
                foreach (var gg in r.DomainProperties ()) {
                    view.Add (gg);
                }
                foreach (var gg in r.DomainHypotheses ()) {
                    view.Add (gg);
                }
            }

            foreach (var r in o.Obstructions ()) {
                view.Add (r);
                view.Add (r.ObstructedGoal ());
            }

            foreach (var r in o.Resolutions ()) {
                view.Add (r);
                view.Add (r.ResolvingGoal ());
            }

            var stream1 = new MemoryStream();
            var ser = new DataContractJsonSerializer(typeof(PartialModelView));
            ser.WriteObject(stream1, view);
            stream1.Position = 0;
            StreamReader sr = new StreamReader(stream1);
            return new RawString (sr.ReadToEnd());
        }
예제 #13
0
        void DownPropagate(Obstacle parent, ObstacleRefinement refinement)
        {
            var alternatives_to_add = new List<AlternativeSystem> (parent.InSystems);

            if (refinement.InSystems == null)
                refinement.InSystems = new HashSet<AlternativeSystem> ();

            foreach (var a in alternatives_to_add) {
                refinement.InSystems.Add (a);
            }

            foreach (var child in refinement.SubObstacles()) {
                if (child.InSystems == null)
                    child.InSystems = new HashSet<AlternativeSystem> ();

                foreach (var a in alternatives_to_add) {
                    child.InSystems.Add (a);
                }

                DownPropagate (child);
            }
        }
예제 #14
0
        void DownPropagate(Obstacle obstacle)
        {
            foreach (var childRefinement in obstacle.Refinements()) {
                DownPropagate (obstacle, childRefinement);
            }

            foreach (var resolution in obstacle.Resolutions()) {
                DownPropagate (obstacle, resolution.ResolvingGoal());
            }
        }
예제 #15
0
        void DownPropagate(Obstacle parent, Goal resolution)
        {
            var alternatives_to_add = new List<AlternativeSystem> (parent.InSystems);

            if (resolution.InSystems == null)
                resolution.InSystems = new HashSet<AlternativeSystem> ();

            foreach (var a in alternatives_to_add) {
                resolution.InSystems.Add (a);
            }

            DownPropagate (resolution);
        }
예제 #16
0
 public void SetObstacle(Obstacle obstacle)
 {
     this.ObstacleIdentifier = obstacle.Identifier;
 }
예제 #17
0
 public void ExportObstacle(Obstacle o)
 {
     var name = new StringBuilder (o.Name);
     if (name.Length > 30) {
         var midspace = o.Name.IndexOf (' ', (o.Name.Length / 2) - 1);
         name.Replace (" ", @"\n", midspace, 1);
     }
     writer.WriteLine (@"""{0}"" [shape=polygon,skew=-.1,label=""{1}"",style=filled,fillcolor=""#ffa9ad"",penwidth={2},fontname=""HelveticaNeue"",fontsize=9,margin=""-.2,0""];",
                       o.Identifier, name, o.Refinements().Count() == 0 ? 2 : 1);
 }
예제 #18
0
 public void Add(Obstacle obstacle)
 {
     this.ObstacleIdentifiers.Add (obstacle.Identifier);
 }
예제 #19
0
        public void ExportRefinementRecursively(Obstacle o, bool exportObstacle = false)
        {
            if (o.Refinements().Count() > 0) {
                writer.WriteLine ();
                writer.WriteLine ("# Refinement for obstacle '{0}'", o.Name);
                writer.WriteLine ();
            }

            if (exportObstacle)
                ExportObstacle (o);
            foreach (var r in o.Refinements()) {
                ExportRefinement (o, r);

                foreach (var child in r.SubObstacles()) {
                    ExportRefinementRecursively (child, exportObstacle);
                }
            }
        }
예제 #20
0
 public void SetObstacle(Obstacle obstacle)
 {
     ResolvedObstacleIdentifier = obstacle.Identifier;
 }
예제 #21
0
 public static MvcHtmlString GetLink(this HtmlHelper helper, Obstacle obstacle)
 {
     return helper.ActionLink (obstacle.FriendlyName, "GoalModel");
 }
        protected void Render(Obstacle obstacle)
        {
            int lineWidth = 1;
            if (obstacle.AgentAssignments().Count() > 0)
                lineWidth = 2;

            AddInvertParallelogram (obstacle.Identifier, obstacle.FriendlyName,
                lineWidth, 1, 0.590278, 0.611992);
        }