Exemple #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);
        }
 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;
 }
        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);
        }
Exemple #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 ();
        }
        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");
        }
        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);
            }
            */
        }
Exemple #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);
            }
        }
 public GoalRefinement(KAOSModel model, params Goal[] goals)
     : this(model)
 {
     foreach (var goal in goals)
         SubGoalIdentifiers.Add (goal.Identifier);
 }
 public GoalRefinement(KAOSModel model, Goal goal)
     : this(model)
 {
     SubGoalIdentifiers.Add (goal.Identifier);
 }
        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> ();
        }
 public GoalException(KAOSModel model)
     : base(model)
 {
 }
 public GoalAgentAssignment(KAOSModel model)
     : base(model)
 {
 }
 public Resolution(KAOSModel model)
     : base(model)
 {
     ResolutionPattern = ResolutionPattern.None;
     Parameters = new List<dynamic> ();
 }
 public AlternativeSystem(KAOSModel model)
     : base(model)
 {
     Alternatives = new HashSet<AlternativeSystem> ();
 }
 public Agent(KAOSModel model)
     : base(model)
 {
     Type = AgentType.None;
 }
 public DomainProperty(KAOSModel model)
     : base(model)
 {
 }
 public DomainHypothesis(KAOSModel model)
     : base(model)
 {
 }
 public Attribute(KAOSModel model)
     : base(model)
 {
     Derived = false;
 }
 public AntiGoalRefinement(KAOSModel model)
     : base(model)
 {
     SubAntiGoalIdentifiers = new HashSet<string> ();
     ObstacleIdentifiers = new HashSet<string> ();
     DomainPropertyIdentifiers = new HashSet<string> ();
     DomainHypothesisIdentifiers = new HashSet<string> ();
 }
 public ObstacleRefinement(KAOSModel model, params Obstacle[] obstacles)
     : this(model)
 {
     foreach (var obstacle in obstacles)
         SubobstacleIdentifiers.Add (obstacle.Identifier);
 }
 public Predicate(KAOSModel model)
     : base(model)
 {
     Arguments = new List<PredicateArgument> ();
 }
 public Relation(KAOSModel model)
     : base(model)
 {
     Links = new HashSet<Link> ();
 }
 public GivenType(KAOSModel model)
     : base(model)
 {
 }
 public Goal(KAOSModel model)
     : base(model)
 {
     InSystems = new HashSet<AlternativeSystem>();
 }
 public Entity(KAOSModel model)
     : base(model)
 {
     ParentIdentifiers    = new HashSet<string> ();
 }
 public Obstruction(KAOSModel model)
     : base(model)
 {
 }