Ejemplo n.º 1
0
        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;
        }
 public void Render(Goal g, KAOSModel model)
 {
     Render (g);
     foreach (var e in g.Provided ()) {
         Render (e.Obstacle ());
         Render (e);
     }
 }
        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);
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
        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 ();
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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);
            }
        }
        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);
            }
            */
        }
Ejemplo n.º 10
0
        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 ();
            }
        }
        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);
            }
        }
Ejemplo n.º 12
0
 public GoalRefinement(KAOSModel model, params Goal[] goals)
     : this(model)
 {
     foreach (var goal in goals)
         SubGoalIdentifiers.Add (goal.Identifier);
 }
Ejemplo n.º 13
0
 public GoalRefinement(KAOSModel model, Goal goal)
     : this(model)
 {
     SubGoalIdentifiers.Add (goal.Identifier);
 }
Ejemplo n.º 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> ();
        }
Ejemplo n.º 15
0
 public GoalException(KAOSModel model)
     : base(model)
 {
 }
Ejemplo n.º 16
0
 public GoalAgentAssignment(KAOSModel model)
     : base(model)
 {
 }
Ejemplo n.º 17
0
 public Resolution(KAOSModel model)
     : base(model)
 {
     ResolutionPattern = ResolutionPattern.None;
     Parameters = new List<dynamic> ();
 }
Ejemplo n.º 18
0
 public AlternativeSystem(KAOSModel model)
     : base(model)
 {
     Alternatives = new HashSet<AlternativeSystem> ();
 }
Ejemplo n.º 19
0
 public Agent(KAOSModel model)
     : base(model)
 {
     Type = AgentType.None;
 }
Ejemplo n.º 20
0
 public DomainProperty(KAOSModel model)
     : base(model)
 {
 }
Ejemplo n.º 21
0
 public DomainHypothesis(KAOSModel model)
     : base(model)
 {
 }
Ejemplo n.º 22
0
 public Attribute(KAOSModel model)
     : base(model)
 {
     Derived = false;
 }
Ejemplo n.º 23
0
 public AntiGoalRefinement(KAOSModel model)
     : base(model)
 {
     SubAntiGoalIdentifiers = new HashSet<string> ();
     ObstacleIdentifiers = new HashSet<string> ();
     DomainPropertyIdentifiers = new HashSet<string> ();
     DomainHypothesisIdentifiers = new HashSet<string> ();
 }
Ejemplo n.º 24
0
 public ObstacleRefinement(KAOSModel model, params Obstacle[] obstacles)
     : this(model)
 {
     foreach (var obstacle in obstacles)
         SubobstacleIdentifiers.Add (obstacle.Identifier);
 }
Ejemplo n.º 25
0
 public Predicate(KAOSModel model)
     : base(model)
 {
     Arguments = new List<PredicateArgument> ();
 }
Ejemplo n.º 26
0
 public Relation(KAOSModel model)
     : base(model)
 {
     Links = new HashSet<Link> ();
 }
Ejemplo n.º 27
0
 public GivenType(KAOSModel model)
     : base(model)
 {
 }
Ejemplo n.º 28
0
 public Goal(KAOSModel model)
     : base(model)
 {
     InSystems = new HashSet<AlternativeSystem>();
 }
Ejemplo n.º 29
0
 public Entity(KAOSModel model)
     : base(model)
 {
     ParentIdentifiers    = new HashSet<string> ();
 }
Ejemplo n.º 30
0
 public Obstruction(KAOSModel model)
     : base(model)
 {
 }