public void Render(KAOSModel model)
        {
            //var goalsInRefinements = model.GoalRefinements ().SelectMany (x => x.SubGoals ().Union (new[] {
            //    x.ParentGoal ()
            //})).Distinct ();

            foreach (var g in model.Goals())
            {
                Render(g);
            }

            foreach (var d in model.GoalRefinements().SelectMany(x => x.DomainProperties()).Distinct())
            {
                Render(d);
            }

            foreach (var r in model.GoalRefinements())
            {
                Render(r);
            }

            foreach (var o in model.Obstacles())
            {
                Render(o);
            }

            foreach (var o in model.ObstacleRefinements())
            {
                Render(o);
            }

            foreach (var o in model.Obstructions())
            {
                Render(o);
            }

            foreach (var o in model.Resolutions())
            {
                Render(o);
            }

            foreach (var r in model.GoalAgentAssignments())
            {
                Render(r, true);
            }

            foreach (var o in model.Resolutions())
            {
                RenderAnchorArrow(o);
            }
        }
예제 #2
0
        public static Document ExportModel(KAOSModel _model)
        {
            mapping = new Dictionary <Omnigraffle.Sheet, Dictionary <string, Omnigraffle.ShapedGraphic> >();

            var document = new Omnigraffle.Document();

            var canvas = new Omnigraffle.Sheet(1, string.Format("Model"));
            var shapes = new Dictionary <string, IList <Graphic> >();

            var u = new GoalModelGenerator(canvas, shapes);

            u.Render(_model);
            document.Canvas.Add(canvas);

            var s2 = new Omnigraffle.Sheet(1, "Goal and Obstacle Model");
            var u2 = new GoalAndObstacleModelGenerator(s2, new Dictionary <string, IList <Graphic> >());

            u2.Render(_model);

            document.Canvas.Add(s2);


            int i = 0;

            foreach (var o in _model.Obstructions().Select(x => x.Obstacle()))
            {
                i++;
                var s  = new Omnigraffle.Sheet(1, string.Format($"Obstacle diagram for '{o.FriendlyName}'"));
                var u3 = new ObstacleDiagramGenerator(s, new Dictionary <string, IList <Graphic> >());
                u3.Render(o, _model);
                document.Canvas.Add(s);
            }

            i = 0;
            foreach (var goalWithException in _model.Exceptions().Select(x => x.AnchorGoal())
                     .Union(_model.Replacements().Select(x => x.ResolvingGoal()))
                     .Union(_model.ObstacleAssumptions().Select(x => x.Anchor()))
                     .Distinct())
            {
                i++;
                var s  = new Omnigraffle.Sheet(1, string.Format($"Exception diagram for '{goalWithException.FriendlyName}'"));
                var u3 = new ExceptionDiagramGenerator(s, new Dictionary <string, IList <Graphic> >());
                u3.Render(goalWithException, _model);
                document.Canvas.Add(s);
            }

            return(document);
        }
예제 #3
0
        public ISatisfactionRate GetESR(Goal g)
        {
            if (goalCache.ContainsKey(g))
            {
                return(goalCache[g]);
            }

            ISatisfactionRate cps = null;
            var refinements       = _model.GoalRefinements(r => r.ParentGoalIdentifier == g.Identifier);

            if (refinements.Count() > 1)
            {
                throw new PropagationException(PropagationException.MULTIPLE_REFINEMENTS);
            }

            if (refinements.Count() == 1)
            {
                cps = GetESR(refinements.Single());
            }

            if (refinements.Count() == 0)
            {
                var obstructions = _model.Obstructions(r => r.ObstructedGoalIdentifier == g.Identifier);
                if (obstructions.Count() == 0)
                {
                    cps = DoubleSatisfactionRate.ONE;
                }
                else
                {
                    cps = obstructions.Select(x => GetESR(x).OneMinus()).Aggregate(DoubleSatisfactionRate.ONE, (x, y) => (DoubleSatisfactionRate)x.Product(y));
                }
            }

            _model.satisfactionRateRepository.AddGoalSatisfactionRate(g.Identifier, cps);
            goalCache.Add(g, cps);
            return(cps);
        }