コード例 #1
0
ファイル: ModelBuilder.cs プロジェクト: ancailliau/KAOSTools
        public KAOSModel Parse(string input, string filename)
        {
            KAOSModel model = new KAOSModel();
            Declarations = new Dictionary<KAOSMetaModelElement, IList<Declaration>> ();
            GoalModelParser _parser = new GoalModelParser ();

            Uri RelativePath = null;
            if (!string.IsNullOrEmpty (filename))
                RelativePath = new Uri(Path.GetFullPath (Path.GetDirectoryName(filename) + "/"));

            FirstStageBuilder FSB = new FirstStageBuilder (model, Declarations, RelativePath);
            FormulaBuilder FB = new FormulaBuilder (model, Declarations, FSB, RelativePath);
            SecondStageBuilder SSB = new SecondStageBuilder (model, Declarations, FSB, FB, RelativePath);
            ThirdStageBuilder TSB = new ThirdStageBuilder (model, Declarations, FSB, SSB, FB, RelativePath);

            var elements = _parser.Parse (input, filename) as ParsedElements;

            FSB.BuildElementWithKeys (elements);
            SSB.BuildElement (elements);
            TSB.BuildElement (elements);

            // Ensure that there is at least one alternative system
            if (model.AlternativeSystems().Count() == 0)
                model.Add (new AlternativeSystem (model) {
                    Name = "Default",
                    Definition = "Default alternative"
                });

            return model;
        }
コード例 #2
0
 public void Render(Goal g, KAOSModel model)
 {
     Render (g);
     foreach (var e in g.Provided ()) {
         Render (e.Obstacle ());
         Render (e);
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 public FormulaBuilder(KAOSModel model, 
                        IDictionary<KAOSMetaModelElement, 
                        IList<Declaration>> declarations, 
                        FirstStageBuilder fsb,
                        Uri relativePath)
 {
     this.model = model;
     this.Declarations = declarations;
     this.FSB = fsb;
     this.relativePath = relativePath;
 }
コード例 #5
0
        public void ComputeInAlternatives(KAOSModel model)
        {
            this.model = model;

            foreach (var goal in model.RootGoals()) {
                goal.InSystems = new HashSet<AlternativeSystem> (model.AlternativeSystems());
                DownPropagate (goal);
            }

            foreach (var g in model.RootGoals())
                Simplify (g);
        }
コード例 #6
0
ファイル: DotExport.cs プロジェクト: ancailliau/KAOSTools
        public DotExport(KAOSModel model, TextWriter writer, 
            float margin = 0.2f, float nodesep = 0.1f, float ranksep = 0.3f)
        {
            this.model = model;
            this.writer = writer;

            writer.WriteLine ("digraph model {\n");
            writer.WriteLine (string.Format ("graph[margin={0}, nodesep={1}, ranksep={2}];",
                              margin, nodesep, ranksep));
            writer.WriteLine ("edge[dir=back];");
            writer.WriteLine ();
        }
コード例 #7
0
        static HomeController()
        {
            Console.WriteLine ("Init");

            if (!System.IO.File.Exists(Path.Combine("Examples", file))) {
                throw new FileNotFoundException ();
            }

            code = System.IO.File.ReadAllText (Path.Combine("Examples", file));
            parser = new ModelBuilder ();

            model = parser.Parse (code, Path.Combine("Examples", file));
            model.IntegrateResolutions ();

            Console.WriteLine ("End of init");
        }
コード例 #8
0
        public void Render(KAOSModel model)
        {
            foreach (var g in model.GoalRefinements ().SelectMany (x => x.SubGoals ().Union (new [] { x.ParentGoal () })).Distinct ()) {
                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 r in model.GoalAgentAssignments ()) {
                Render (r, true);
            }
        }
コード例 #9
0
        public void Render(Goal g, KAOSModel model)
        {
            Render (g);

            // Exceptions
            foreach (var e in g.Exceptions ()) {
                if (!shapes.ContainsKey (e.ResolvingGoalIdentifier))
                    Render (e.ResolvingGoal());
                Render (e);
            }

            // Replacements
            foreach (var e in g.Replacements ()) {
                if (!shapes.ContainsKey (e.AnchorGoalIdentifier))
                    Render (e.AnchorGoal ());
                Render (e);
            }

            // Provided
            foreach (var e in g.Provided ()) {
                if (!shapes.ContainsKey (e.ResolvedObstacleIdentifier))
                    Render (e.Obstacle ());
                Render (e);
            }

            // Context refinements
            /*
            foreach (var r in g.ParentRefinements ().Union (g.Refinements ())) {
                if (!shapes.ContainsKey (r.ParentGoalIdentifier)) {
                    Render (r.ParentGoal ());
                }

                foreach (var sg in r.SubGoals ()) {
                    if (!shapes.ContainsKey (sg.Identifier)) {
                        Render (sg);
                    }
                }

                Render (r);
            }
            */
        }
コード例 #10
0
ファイル: KAOSToolCLI.cs プロジェクト: ancailliau/KAOSTools
        protected static void Init(string[] args)
        {
            bool show_help = false;
            options.Add ("h|help", "Show this message and exit", v => show_help = true);

            try {
                reminderArgs = options.Parse (args);

            } catch (OptionException e) {
                PrintError (e.Message);
                return;
            }

            if (show_help) {
                ShowHelp (options);
                return;
            }

            if (reminderArgs.Count == 0) {
                filename = ".";
                input = Console.In.ReadToEnd ();

            } else {
                if (!File.Exists (reminderArgs[0])) {
                    PrintError ("File `" + reminderArgs[0] + "` does not exists");
                    return;
                } else {
                    filename = reminderArgs[0];
                    input = File.ReadAllText (filename);
                }
            }

            model = BuildModel ();

            if (model != null) {
                var h = new AlternativeHelpers();
                h.ComputeInAlternatives (model);

                model.IntegrateResolutions ();
            }
        }
コード例 #11
0
        public void Render(Goal g, KAOSModel model)
        {
            Render (g);
            foreach (var e in g.Replacements ()) {
                Render (e.AnchorGoal ());
                Render (e);
            }

            foreach (var r in g.ParentRefinements ().Union (g.Refinements ())) {
                if (!shapes.ContainsKey (r.ParentGoalIdentifier)) {
                    Render (r.ParentGoal ());
                }

                foreach (var sg in r.SubGoals ()) {
                    if (!shapes.ContainsKey (sg.Identifier)) {
                        Render (sg);
                    }
                }

                Render (r);
            }
        }
コード例 #12
0
 public GoalRefinement(KAOSModel model, params Goal[] goals)
     : this(model)
 {
     foreach (var goal in goals)
         SubGoalIdentifiers.Add (goal.Identifier);
 }
コード例 #13
0
 public GoalRefinement(KAOSModel model, Goal goal)
     : this(model)
 {
     SubGoalIdentifiers.Add (goal.Identifier);
 }
コード例 #14
0
        public GoalRefinement(KAOSModel model)
            : base(model)
        {
            SubGoalIdentifiers = new List<string> ();
            DomainPropertyIdentifiers = new HashSet<string> ();
            DomainHypothesisIdentifiers = new HashSet<string> ();

            PositiveSoftGoalsIdentifiers = new HashSet<string> ();
            NegativeSoftGoalsIdentifiers = new HashSet<string> ();

            IsComplete = false;

            Parameters = new List<dynamic> ();
        }
コード例 #15
0
 public GoalException(KAOSModel model)
     : base(model)
 {
 }
コード例 #16
0
 public GoalAgentAssignment(KAOSModel model)
     : base(model)
 {
 }
コード例 #17
0
 public Resolution(KAOSModel model)
     : base(model)
 {
     ResolutionPattern = ResolutionPattern.None;
     Parameters = new List<dynamic> ();
 }
コード例 #18
0
 public AlternativeSystem(KAOSModel model)
     : base(model)
 {
     Alternatives = new HashSet<AlternativeSystem> ();
 }
コード例 #19
0
 public Agent(KAOSModel model)
     : base(model)
 {
     Type = AgentType.None;
 }
コード例 #20
0
 public DomainProperty(KAOSModel model)
     : base(model)
 {
 }
コード例 #21
0
 public DomainHypothesis(KAOSModel model)
     : base(model)
 {
 }
コード例 #22
0
 public Attribute(KAOSModel model)
     : base(model)
 {
     Derived = false;
 }
コード例 #23
0
 public AntiGoalRefinement(KAOSModel model)
     : base(model)
 {
     SubAntiGoalIdentifiers = new HashSet<string> ();
     ObstacleIdentifiers = new HashSet<string> ();
     DomainPropertyIdentifiers = new HashSet<string> ();
     DomainHypothesisIdentifiers = new HashSet<string> ();
 }
コード例 #24
0
 public ObstacleRefinement(KAOSModel model, params Obstacle[] obstacles)
     : this(model)
 {
     foreach (var obstacle in obstacles)
         SubobstacleIdentifiers.Add (obstacle.Identifier);
 }
コード例 #25
0
 public Predicate(KAOSModel model)
     : base(model)
 {
     Arguments = new List<PredicateArgument> ();
 }
コード例 #26
0
 public Relation(KAOSModel model)
     : base(model)
 {
     Links = new HashSet<Link> ();
 }
コード例 #27
0
 public GivenType(KAOSModel model)
     : base(model)
 {
 }
コード例 #28
0
 public Goal(KAOSModel model)
     : base(model)
 {
     InSystems = new HashSet<AlternativeSystem>();
 }
コード例 #29
0
 public Entity(KAOSModel model)
     : base(model)
 {
     ParentIdentifiers    = new HashSet<string> ();
 }
コード例 #30
0
 public Obstruction(KAOSModel model)
     : base(model)
 {
 }