Exemplo n.º 1
0
        public static ISet <Goal> LeafGoals(this KAOSModel model)
        {
            var goals = new HashSet <Goal> (model.Goals());

            foreach (var refinement in model.GoalRefinements())
            {
                goals.Remove(refinement.ParentGoal());
            }

            return(goals);
        }
Exemplo n.º 2
0
        static IEnumerable <string> GetAncestors(KAOSModel _model, IEnumerable <string> goals)
        {
            var fixpoint          = new HashSet <string> (goals);
            var goalsToProcessSet = new HashSet <string> (goals);
            var goalsToProcess    = new Queue <string>(goals);

            while (goalsToProcess.Count > 0)
            {
                var current = goalsToProcess.Dequeue();
                goalsToProcessSet.Remove(current);
                var refinements = _model.GoalRefinements(x => x.SubGoalIdentifiers.Any(y => y.Identifier == current));
                foreach (var r in refinements)
                {
                    fixpoint.Add(r.ParentGoalIdentifier);
                    if (!goalsToProcessSet.Contains(r.ParentGoalIdentifier))
                    {
                        goalsToProcessSet.Add(r.ParentGoalIdentifier);
                        goalsToProcess.Enqueue(r.ParentGoalIdentifier);
                    }
                }
            }

            return(fixpoint);
        }