public static void TestBenchmarks() { var domainNames = new List <string>() { "arth", "batman" }; foreach (var dn in domainNames) { var testDomainDirectory = Parser.GetTopDirectory() + @"Benchmarks\" + dn + @"\domain.pddl"; var testDomain = Parser.GetDomain(Parser.GetTopDirectory() + @"Benchmarks\" + dn + @"\domain.pddl", PlanType.PlanSpace); var testProblem = Parser.GetProblem(Parser.GetTopDirectory() + @"Benchmarks\" + dn + @"\prob01.pddl"); ProblemFreezer PF = new ProblemFreezer(dn, testDomainDirectory, testDomain, testProblem); PF.Serialize(); var directory = @"D:\Documents\Frostbow\Benchmarks\Results\"; var cutoff = 6000f; var k = 1; var initPlan = PlanSpacePlanner.CreateInitialPlan(PF); RunPlanner(initPlan.Clone() as IPlan, new ADstar(), new E0(new AddReuseHeuristic()), k, cutoff, directory, 0); RunPlanner(initPlan.Clone() as IPlan, new ADstar(), new E1(new AddReuseHeuristic()), k, cutoff, directory, 0); RunPlanner(initPlan.Clone() as IPlan, new ADstar(), new E2(new AddReuseHeuristic()), k, cutoff, directory, 0); RunPlanner(initPlan.Clone() as IPlan, new ADstar(), new E3(new AddReuseHeuristic()), k, cutoff, directory, 0); //RunPlanner(initPlan.Clone() as IPlan, new DFS(), new Nada(new ZeroHeuristic()), k, cutoff, directory, 0); RunPlanner(initPlan.Clone() as IPlan, new BFS(), new Nada(new ZeroHeuristic()), k, cutoff, directory, 0); } }
public static void RunProblem(string directory, string domainName, string domainDirectory, Domain domain, Problem problem, float cutoff, int HTN_level, Dictionary <Composite, List <Decomposition> > CompositeMethods) { // Reset Cached Items GroundActionFactory.Reset(); CacheMaps.Reset(); var PF = new ProblemFreezer(domainName, domainDirectory, domain, problem); PF.Serialize(); Console.WriteLine("Detecting Statics"); GroundActionFactory.DetectStatics(); var initPlan = PlanSpacePlanner.CreateInitialPlan(PF); // Removing irrelevant actions Console.WriteLine("Removing Irrelevant Actions"); var staticInitial = initPlan.Initial.Predicates.Where(state => GroundActionFactory.Statics.Contains(state)); // Every action that has No preconditions which are both static and not in staticInitial var possibleActions = GroundActionFactory.GroundActions.Where(action => !action.Preconditions.Any(pre => GroundActionFactory.Statics.Contains(pre) && !staticInitial.Contains(pre))); GroundActionFactory.GroundActions = possibleActions.ToList(); GroundActionFactory.GroundLibrary = possibleActions.ToDictionary(item => item.ID, item => item); // Composing HTNs Console.WriteLine("Composing HTNs"); Composite.ComposeHTNs(HTN_level, CompositeMethods); // Caching Causal Maps Console.WriteLine("Caching Causal Maps"); CacheMaps.Reset(); CacheMaps.CacheLinks(GroundActionFactory.GroundActions); CacheMaps.CacheGoalLinks(GroundActionFactory.GroundActions, initPlan.Goal.Predicates); // Cache Heuristic Costs (dynamic programming) Console.WriteLine("Caching Heuristic Costs"); CacheMaps.CacheAddReuseHeuristic(initPlan.Initial); // Redo to gaurantee accuracy (needs refactoring) initPlan = PlanSpacePlanner.CreateInitialPlan(PF); var probNum = Int32.Parse(problem.Name); Console.WriteLine(String.Format("Running Problem {0}", probNum)); RunPlanner(initPlan.Clone() as IPlan, new ADstar(false), new E0(new AddReuseHeuristic(), true), cutoff, directory, probNum); //RunPlanner(initPlan.Clone() as IPlan, new ADstar(true), new E0(new AddReuseHeuristic()), cutoff, directory, probNum); //RunPlanner(initPlan.Clone() as IPlan, new ADstar(true), new E1(new AddReuseHeuristic()), cutoff, directory, probNum); //RunPlanner(initPlan.Clone() as IPlan, new ADstar(true), new E2(new AddReuseHeuristic()), cutoff, directory, probNum); //RunPlanner(initPlan.Clone() as IPlan, new ADstar(true), new E3(new AddReuseHeuristic()), cutoff, directory, probNum); //RunPlanner(initPlan.Clone() as IPlan, new BFS(false), new Nada(new ZeroHeuristic()), cutoff, directory, probNum); // RunPlanner(initPlan.Clone() as IPlan, new BFS(true), new Nada(new ZeroHeuristic()), cutoff, directory, probNum); }
public static ProblemFreezer ReadDomainAndProblem(bool serializeIt, int whichProblem) { var domainName = "blocks"; var domainDirectory = Parser.GetTopDirectory() + @"Benchmarks\" + domainName + @"\domain.pddl"; var domain = Parser.GetDomain(Parser.GetTopDirectory() + @"Benchmarks\" + domainName + @"\domain.pddl", PlanType.PlanSpace); var problem = Parser.GetProblem(Parser.GetTopDirectory() + @"Benchmarks\" + domainName + @"\prob0" + whichProblem.ToString() + @".pddl"); var PF = new ProblemFreezer(domainName, domainDirectory, domain, problem); if (serializeIt) { PF.Serialize(); } else { PF.Deserialize(); } return(PF); }