public void TestCase2()
        {
            var input = @"
            declare goal
            id root
            refinedby child1, child2
            refinedby child3
            end

            declare goal
            id child1
            assignedto myagent
            end

            declare goal
            id child2
            assignedto myagent
            end

            declare goal
            id child3
            assignedto myagent
            end

            declare agent
            id myagent
            end
            ";
            var parser = new ModelBuilder ();
            var model = parser.Parse (input);

            var responsibilities = model.GetResponsibilities ();
            printresponsibilities2(responsibilities, 0);
        }
Esempio n. 2
0
        protected static KAOSModel BuildModel()
        {
            // try {
                var parser = new KAOSTools.Parsing.ModelBuilder ();
                var m = parser.Parse (input, filename);
                declarations = parser.Declarations;
                return m;

            // } catch (Exception e) {
            //    Console.WriteLine (e.Message);
            //    return null;
            // }
        }
Esempio n. 3
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");
        }
Esempio n. 4
0
        public void TestCompleteObstacleAssignments()
        {
            var input = @"
            declare obstacle
            id obstacle
            assignedto agent
            end";
            var parser = new ModelBuilder ();
            var model = parser.Parse (input);

            var view = new KAOSView (model);
            view.Add (model.ObstacleAgentAssignments().Single());

            view.CompleteObstacleAgentAssignments ();
            view.Elements.Count().ShallEqual (3);
        }
Esempio n. 5
0
        public void TestCompleteGoalRefinements()
        {
            var input = @"
            declare goal
            id goal
            refinedby child1, child2
            end";
            var parser = new ModelBuilder ();
            var model = parser.Parse (input);

            var view = new KAOSView (model);
            view.Add (model.GoalRefinements().Single());

            view.CompleteGoalRefinements ();
            view.Elements.Count().ShallEqual (4);
        }
Esempio n. 6
0
        public void TestCompleteAntiGoalAssignments()
        {
            var input = @"
            declare antigoal
            id goal
            assignedto agent
            end";
            var parser = new ModelBuilder ();
            var model = parser.Parse (input);

            var view = new KAOSView (model);
            view.Add (model.AntiGoalAgentAssignments().Single());

            view.CompleteAntiGoalAgentAssignments ();
            view.Elements.Count().ShallEqual (3);
        }
Esempio n. 7
0
        public void TestCase()
        {
            var input = @"
            declare entity
            id parent
            end

            declare entity
            id child_1
            is parent
            end

            declare entity
            id child_2
            is parent
            end
            ";
            var parser = new ModelBuilder ();
            var model = parser.Parse (input);
        }
Esempio n. 8
0
        public static void Main(string[] args)
        {
            var input = @"
            declare goal
            id root
            name ""Root""
            refinedby (case[0.5,0.5]) ""Maintain [Navigation Available]"", ""Bis""
            end

            declare goal
            name ""Bis""
            end

            declare goal
            name ""Maintain [Navigation Available]""
            obstructedby ""Navigation Not Available""
            end

            override obstacle
            name ""Navigation Not Available""
            refinedby ""Garmin Navigation Not Working"", ""iPhone Navigation Not Working""
            end

            override obstacle
            name ""Garmin Navigation Not Working""
            refinedby ""Garmin Device Broken""
            refinedby ""GPS Signal Blocked""
            end

            override obstacle
            name ""iPhone Navigation Not Working""
            refinedby ""iPhone Device Broken""
            refinedby ""GPS Signal Blocked""
            end

            override obstacle name ""Garmin Device Broken"" probability .3 end
            override obstacle name ""iPhone Device Broken"" probability .1 end
            override obstacle name ""GPS Signal Blocked"" probability .2 end";

            var parser = new ModelBuilder ();

            var filename = "/Users/acailliau/Dropbox/PhD/2013/Dependent obstacles/las.kaos";
            input = File.ReadAllText (filename);
            var model = parser.Parse (input, filename);

            Console.WriteLine ("--- [Non Satisfaction Formulas]");

            foreach (var g in model.Goals () ) {
                var node = g.GetNonSatisfactionFormula ();
                Console.WriteLine ("{0}={1}", g.FriendlyName, node.Simplify ());
            }
            Console.WriteLine ();
            foreach (var g in model.Obstacles ()) {
                Console.WriteLine ("{0}={1}", g.FriendlyName, g.GetNonSatisfactionFormula ());
            }

            Console.WriteLine ("---\n");

            Console.WriteLine ("--- [Probabilities]");

            foreach (var g in model.Goals ()) {
                Console.WriteLine ("P({0})={1}%", g.FriendlyName, Math.Round (g.ComputeProbability (), 4)*100);
            }

            Console.WriteLine ();

            foreach (var o in model.Obstacles ()) {
                Console.WriteLine ("P({0})={1}%", o.FriendlyName, Math.Round (o.ComputeProbability (), 4)*100);
            }

            Console.WriteLine ("---\n");
        }
Esempio n. 9
0
        public void TestObstruction()
        {
            var input = @"
            declare goal
            id goal
            obstructedby obstacle
            end";
            var parser = new ModelBuilder ();
            var model = parser.Parse (input);

            var view = new KAOSView (model);
            view.Add (model.Obstructions().Single());

            view.CompleteObstruction ();
            view.Elements.Count().ShallEqual (3);
        }
Esempio n. 10
0
        public void TestResolution()
        {
            var input = @"
            declare obstacle
            id obstacle
            resolvedby goal
            end";
            var parser = new ModelBuilder ();
            var model = parser.Parse (input);

            var view = new KAOSView (model);
            view.Add (model.Resolutions().Single());

            view.CompleteResolution ();
            view.Elements.Count().ShallEqual (3);
        }