Пример #1
0
        public void TestGetGoalsTiming()
        {
            string main_path       = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName + @"\PlanningProblems\BoxPushing\B3\";
            string filePathProblem = main_path + "p.pddl";
            string filePathDomain  = main_path + "d.pddl";

            Domain  d = Parser.ParseDomain(filePathDomain, "agent");
            Problem p = Parser.ParseProblem(filePathProblem, d);


            IterativeMAPlanner ma_planner = new IterativeMAPlanner(d, p, SDRPlanner.Planners.FF);
            var ma_result = ma_planner.Plan();

            Assert.IsNotNull(ma_result);

            Constant                    a1     = d.GetAgents()[0];
            PlanResult                  pr     = ma_result[a1];
            List <Predicate>            goals  = p.GetGoals();
            Dictionary <Predicate, int> timing = new Dictionary <Predicate, int>();

            pr.Plan.GetGoalsTiming(goals, null, ref timing);

            string plan = PlanTreePrinter.Print(pr.Plan);

            File.WriteAllText(main_path + "plan_" + a1.Name + ".txt", plan);
            Assert.AreEqual(timing.Count, p.GetGoals().Count - 1);
        }
Пример #2
0
        public PlanResult Plan(Constant activeAgent, List <Predicate> activeGoals,
                               List <KeyValuePair <Predicate, int> > goalsCompletionTime,
                               List <Action> reqActions)
        {
            m_AgentDomain  = Parser.ParseDomain(m_GeneralDomain.FilePath, m_GeneralDomain.AgentCallsign);
            m_AgentProblem = Parser.ParseProblem(m_GeneralProblem.FilePath, m_AgentDomain);

            m_ActiveAgent = activeAgent;
            m_ActiveGoals = m_AgentProblem.GetGoals();

            m_GoalsCompletionTime = goalsCompletionTime;
            m_ReqCollabActions    = reqActions;

            DateTime start = DateTime.Now;

            AddNoopAction();
            AddTimeConstraints();
            List <Action> extractedActions;

            AddCollabActionReq(out extractedActions);
            ConvertToSingleAgentProblem();
            AddPrevCompletionOfGoals();
            SetGoals();
            //Reasoning not working for button pushing domain
            AddReasoningActions();
            //AddCosts();

            SDRPlanner sdrPlanner        = new SDRPlanner(m_AgentDomain, m_AgentProblem, m_planner);
            string     s1                = m_AgentDomain.ToString();
            string     s2                = m_AgentProblem.ToString();
            ConditionalPlanTreeNode Plan = sdrPlanner.OfflinePlanning();
            string s     = m_AgentDomain.ToString();
            bool   Valid = sdrPlanner.Valid;

            // Return extracted actions to domain
            foreach (var action in extractedActions)
            {
                m_AgentDomain.Actions.Add(action);
            }

            TimeSpan PlanningTime = DateTime.Now - start;

            PlanResult result = new PlanResult(activeAgent, Plan, PlanningTime, Valid,
                                               goalsCompletionTime, reqActions,
                                               m_AgentDomain, m_AgentProblem,
                                               m_GeneralDomain, m_GeneralProblem);
            // Write plan to file
            string path = Path.GetDirectoryName(m_AgentDomain.FilePath) + "\\plan_" + m_ActiveAgent.Name + ".txt";

            File.WriteAllText(path, PlanTreePrinter.Print(result.Plan));
            return(result);
        }
        private void AddResult(Constant agent, ConditionalPlanTreeNode plan, PlanDetails pd, TimeSpan planningTime, Boolean valid)
        {
            string           planAsText = PlanTreePrinter.Print(plan);
            ucExecuteResults er         = new ucExecuteResults(agent, planAsText, pd, planningTime, valid);

            er.SelectedGoalAchievementTime += Er_SelectedGoalAchievementTime;
            er.CloseTab   += Er_CloseTab;
            er.AddtoFinal += Er_AddtoFinal;
            TabPage tp = new TabPage();

            tp.Text = "agent " + agent.ToString();
            tp.Controls.Add(er);
            tcResults.TabPages.Add(tp);
        }
Пример #4
0
        public ucExecuteResults(PlanDetails pd) : this()
        {
            PlanDetails = pd;

            rtxtPlan.Text        = PlanTreePrinter.Print(pd.Plan);;
            lblAvgDepth.Text     = pd.LeafsDepth.Average().ToString();
            lblMakespan.Text     = pd.MakeSpan.ToString();
            lblValid.Text        = pd.Valid.ToString();
            lblPlanningTime.Text = (pd.PlanningTime.TotalMilliseconds / (double)1000).ToString(".##") + "s";


            UpdateCollabActions(pd.JointActionsTimes);
            UpdateGoalAchievementsTime(pd.GoalsTiming);
        }
Пример #5
0
        public void SingleAgentSDRPlanner_TestConvertToSingleAgentProblemButtonsTwoJoint()
        {
            string  filePathProblem = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName + @"\PlanningProblems\ButtonPushing\B2\p.pddl";
            string  filePathDomain  = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName + @"\PlanningProblems\ButtonPushing\B2\d.pddl";
            Domain  d = Parser.ParseDomain(filePathDomain, "agent");
            Problem p = Parser.ParseProblem(filePathProblem, d);

            // parameters
            Constant currentAgent = new Constant("agent", "a1");

            SingleAgentSDRPlanner saSDR  = new SingleAgentSDRPlanner(d, p, SDRPlanner.Planners.FF);
            PlanResult            result = saSDR.Plan(currentAgent, null, null, null);
            string s = PlanTreePrinter.Print(result.Plan);

            Assert.IsNotNull(result.Plan);
        }
Пример #6
0
        public void RunPP_ButtonPushing_TestB2()
        {
            string             main_path       = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName + @"\PlanningProblems\ButtonPushing\B2\";
            string             filePathProblem = main_path + "p.pddl";
            string             filePathDomain  = main_path + "d.pddl";
            Domain             d          = Parser.ParseDomain(filePathDomain, "agent");
            Problem            p          = Parser.ParseProblem(filePathProblem, d);
            IterativeMAPlanner ma_planner = new IterativeMAPlanner(d, p, SDRPlanner.Planners.FF);
            var result = ma_planner.Plan();

            foreach (var res in result)
            {
                string plan = PlanTreePrinter.Print(res.Value.Plan);
                File.WriteAllText(main_path + "plan_" + res.Key.Name + ".txt", plan);
            }
            Console.WriteLine("Done");
        }
Пример #7
0
        internal static bool RunProblem(string mainPath)
        {
            string             filePathProblem = mainPath + "p.pddl";
            string             filePathDomain  = mainPath + "d.pddl";
            Domain             d          = Parser.ParseDomain(filePathDomain, "agent");
            Problem            p          = Parser.ParseProblem(filePathProblem, d);
            IterativeMAPlanner ma_planner = new IterativeMAPlanner(d, p, SDRPlanner.Planners.FF);
            var result = ma_planner.Plan();

            foreach (var res in result)
            {
                string plan = PlanTreePrinter.Print(res.Value.Plan);
                File.WriteAllText(mainPath + "plan_" + res.Key.Name + ".txt", plan);
            }
            bool isValid = CheckMAPlan.IsValid2(d, p, result);

            return(isValid);
        }
Пример #8
0
        private void RunTest(string ProblemPath)
        {
            string             main_path       = ProblemPath;
            string             filePathProblem = main_path + "p.pddl";
            string             filePathDomain  = main_path + "d.pddl";
            Domain             d          = Parser.ParseDomain(filePathDomain, "rover");
            Problem            p          = Parser.ParseProblem(filePathProblem, d);
            IterativeMAPlanner ma_planner = new IterativeMAPlanner(d, p, SDRPlanner.Planners.FF);
            var result = ma_planner.Plan();

            foreach (var res in result)
            {
                string plan = PlanTreePrinter.Print(res.Value.Plan);
                File.WriteAllText(main_path + "plan_" + res.Key.Name + ".txt", plan);
            }
            bool isValid = CheckMAPlan.IsValid(result);

            Console.WriteLine("Is valid? " + isValid);
            Console.WriteLine("Done");
        }
Пример #9
0
        public void RunPP_RescueOperation_TestRO1()
        {
            string             main_path       = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName + @"\PlanningProblems\RescueOperation\RO1\";
            string             filePathProblem = main_path + "p.pddl";
            string             filePathDomain  = main_path + "d.pddl";
            Domain             d          = Parser.ParseDomain(filePathDomain, "agent");
            Problem            p          = Parser.ParseProblem(filePathProblem, d);
            IterativeMAPlanner ma_planner = new IterativeMAPlanner(d, p, SDRPlanner.Planners.FF);
            var result = ma_planner.Plan();

            foreach (var res in result)
            {
                string plan = PlanTreePrinter.Print(res.Value.Plan);
                File.WriteAllText(main_path + "plan_" + res.Key.Name + ".txt", plan);
            }
            bool isValid = CheckMAPlan.IsValid(result);

            Console.WriteLine("Is valid? " + isValid);
            Console.WriteLine("Done");
        }
Пример #10
0
        public void TestPrint2()
        {
            ConditionalPlanTreeNode cptn1 = new ConditionalPlanTreeNode();

            Assert.AreEqual(PlanTreePrinter.Print(cptn1), "");
        }