Beispiel #1
0
        public void ForbiddenDaysIsWeekInForbiddenDays()
        {
            var startDate    = new DateTime(2018, 10, 03);  // Monday
            var weekdaySlots = new DailySlot[][]
            {
                new DailySlot[]        // Sunday
                {
                    new DailySlot {
                        StartTime = new DateTime(1, 1, 1, 10, 00, 00), EndTime = new DateTime(1, 1, 1, 11, 00, 00)
                    },
                    new DailySlot {
                        StartTime = new DateTime(1, 1, 1, 16, 00, 00), EndTime = new DateTime(1, 1, 1, 17, 00, 00)
                    }
                },
                new DailySlot[] { },        // Monday
                new DailySlot[] { },        // Tuesday
                new DailySlot[] { },        // Wednesday
                new DailySlot[]             // Thursday
                {
                    new DailySlot {
                        StartTime = new DateTime(1, 1, 1, 10, 00, 00), EndTime = new DateTime(1, 1, 1, 11, 00, 00)
                    },
                    new DailySlot {
                        StartTime = new DateTime(1, 1, 1, 16, 00, 00), EndTime = new DateTime(1, 1, 1, 17, 00, 00)
                    }
                },
                new DailySlot[] { },        // Friday
                new DailySlot[] { }         // Saturday
            };

            Assert.IsTrue(PlannerScheduler.IsWeekInForbiddenDays(startDate, weekdaySlots, new DateTime[] { new DateTime(2018, 10, 4) }));
            Assert.IsTrue(PlannerScheduler.IsWeekInForbiddenDays(startDate, weekdaySlots, new DateTime[] { new DateTime(2018, 10, 9) }));
        }
        public void Initialize(ProblemDefinition problemDefinition, string planningSimulationWorldName)
        {
            var world        = new World(planningSimulationWorldName);
            var stateManager = world.GetOrCreateSystem <StateManager>();

            world.GetOrCreateSystem <SimulationSystemGroup>().AddSystemToUpdateList(stateManager);
            var playerLoop = UnityEngine.LowLevel.PlayerLoop.GetCurrentPlayerLoop();

            ScriptBehaviourUpdateOrder.AddWorldToPlayerLoop(world, ref playerLoop);

            m_StateConverter = new PlannerStateConverter <TraitBasedObject, StateEntityKey, StateData, StateDataContext, StateManager>(problemDefinition, stateManager);

            m_Scheduler = new PlannerScheduler <StateEntityKey, ActionKey, StateManager, StateData, StateDataContext, ActionScheduler, DefaultCumulativeRewardEstimator, TerminationEvaluator, DestroyStatesJobScheduler>();
            m_Scheduler.Initialize(stateManager, new DefaultCumulativeRewardEstimator(), new TerminationEvaluator(), problemDefinition.DiscountFactor);

            m_Executor = new Match3PlanExecutor(stateManager, m_StateConverter);

            // Ensure planning jobs are not running when destroying the state manager
            stateManager.Destroying += () => m_Scheduler.CurrentJobHandle.Complete();
        }
Beispiel #3
0
        public IPlan Run(IPlan initPlan, ISearch SearchMethod, ISelection SelectMethod, int pnum, float cutoff)
        {
            var directory = Parser.GetTopDirectory() + "/Results/";

            System.IO.Directory.CreateDirectory(directory);
            var POP = new PlannerScheduler(initPlan.Clone() as IPlan, SelectMethod, SearchMethod)
            {
                directory     = directory,
                problemNumber = pnum
            };
            //Debug.Log("Running plan-search");
            var Solutions = POP.Solve(1, cutoff);

            if (Solutions != null)
            {
                CachePlan(Solutions[0] as PlanSchedule);
                return(Solutions[0]);
            }
            //Debug.Log(string.Format("explored: {0}, expanded: {1}", POP.Open, POP.Expanded));
            return(null);
        }
Beispiel #4
0
        public List <string> RunTest(float cutoffTime, int probNum, string problemDirectory, bool run_all)
        {
            Parser.path = @"D:\documents\frostbow\";
            DeCacheWithProblemSpec(problemDirectory);

            var initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
            var PlanSteps   = new List <string>();

            initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
            Run(initialPlan, new ADstar(false), new E3Star(new AddReuseHeuristic(), 6), probNum, cutoffTime);

            if (run_all)
            {
                // E0
                initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
                Run(initialPlan, new ADstar(false), new E0(new AddReuseHeuristic()), probNum, cutoffTime);
                initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
                Run(initialPlan, new ADstar(false), new E0(new NumOpenConditionsHeuristic()), probNum, cutoffTime);
                initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
                Run(initialPlan, new ADstar(false), new E0(new ZeroHeuristic()), probNum, cutoffTime);

                // E3
                initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
                Run(initialPlan, new ADstar(false), new E3(new AddReuseHeuristic()), probNum, cutoffTime);
                initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
                Run(initialPlan, new ADstar(false), new E3(new NumOpenConditionsHeuristic()), probNum, cutoffTime);


                initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
                Run(initialPlan, new ADstar(false), new E3(new ZeroHeuristic()), probNum, cutoffTime);

                var karray = new List <int>()
                {
                    1, 2, 4, 6, 8, 16
                };
                foreach (var k in karray)
                {
                    initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
                    Run(initialPlan, new ADstar(false), new E3Star(new AddReuseHeuristic(), k), probNum, cutoffTime);
                    initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
                    Run(initialPlan, new ADstar(false), new E3Star(new NumOpenConditionsHeuristic(), k), probNum, cutoffTime);
                    initialPlan = PlannerScheduler.CreateInitialPlan(initial, goal);
                    Run(initialPlan, new ADstar(false), new E3Star(new ZeroHeuristic(), k), probNum, cutoffTime);
                }
            }
            // END OF ESPERIMENT

            //var solution = Run(initialPlan, new ADstar(false), new E3Star(new AddReuseHeuristic()), cutoffTime);
            //var solution = Run(initialPlan, new ADstar(false), new E3Star(new NumOpenConditionsHeuristic()), cutoffTime);
            //var solution = Run(initialPlan, new ADstar(false), new E3(new AddReuseHeuristic()), cutoffTime);


            //var solution = Run(initialPlan, new ADstar(false), new E3(new AddReuseHeuristic()), cutoffTime);
            //var solution = Run(initPlan, new BFS(), new Nada(new ZeroHeuristic()), 20000);

            //if (solution != null)
            //{
            //    //Debug.Log(solution.ToStringOrdered());

            //    foreach (var step in solution.Orderings.TopoSort(solution.InitialStep))
            //    {
            //        Console.WriteLine(step);
            //        PlanSteps.Add(step.ToString());
            //    }
            //}
            //else
            //{

            //    Console.WriteLine("No good");
            //}
            return(PlanSteps);
        }