public static SearchResults runPlanner(string problem, Heuristic h, bool useTwoQueues = false, int maxTimeMinutes = 10) { Problem p = new Problem(problem, false); p.DomainName = Path.GetFileName(Path.GetDirectoryName(problem)); if (useTwoQueues) { MultiHeuristicAStarSearch engine = new MultiHeuristicAStarSearch(p, new List <IHeuristic>() { h, new FFHeuristic(p) }); engine.TimeLimitOfSearch = TimeSpan.FromMinutes(maxTimeMinutes); engine.Start(); return(engine.GetSearchResults(false)); } else { AStarSearch engine = new AStarSearch(p, h); engine.TimeLimitOfSearch = TimeSpan.FromMinutes(maxTimeMinutes); engine.Start(); return(engine.GetSearchResults(false)); } }
public void TC_MultiHeuristicAStarSearch() { var sasProblem = new Planner.SAS.Problem(new SASInputData(GetFilePath("TC_Gripper.sas"))); var sasSearch = new MultiHeuristicAStarSearch(sasProblem, new BlindHeuristic()); sasSearch.Start(); var sasSolution = sasSearch.GetSearchResults(); Assert.AreEqual("Multi-Heuristic A* Search", sasSolution.Algorithm); Assert.AreEqual("TC_Gripper", sasSolution.ProblemName); Assert.AreEqual("Blind Heuristic", sasSolution.Heuristic); Assert.AreEqual(ResultStatus.SolutionFound, sasSolution.ResultStatus); Assert.IsTrue(sasSolution.SearchTime.TotalMilliseconds > 0); Assert.AreEqual(11, sasSolution.SolutionCost); Assert.IsNotNull(sasSolution.SolutionPlan); Assert.AreEqual(11, sasSolution.SolutionPlan.GetCost()); var sasSearch2 = new MultiHeuristicAStarSearch(sasProblem, new BlindHeuristic()); sasSearch2.Start(SearchType.BackwardWithConditions); var sasSolution2 = sasSearch2.GetSearchResults(); Assert.AreEqual("Multi-Heuristic A* Search (Backward)", sasSolution2.Algorithm); Assert.AreEqual("TC_Gripper", sasSolution2.ProblemName); Assert.AreEqual("Blind Heuristic", sasSolution2.Heuristic); Assert.AreEqual(ResultStatus.SolutionFound, sasSolution2.ResultStatus); Assert.IsTrue(sasSolution2.SearchTime.TotalMilliseconds > 0); Assert.AreEqual(11, sasSolution2.SolutionCost); Assert.IsNotNull(sasSolution2.SolutionPlan); Assert.AreEqual(11, sasSolution2.SolutionPlan.GetCost()); var sasSearch3 = new MultiHeuristicAStarSearch(sasProblem, new BlindHeuristic()); sasSearch3.Start(SearchType.BackwardWithStates); var sasSolution3 = sasSearch3.GetSearchResults(); Assert.AreEqual("Multi-Heuristic A* Search (Backward)", sasSolution3.Algorithm); Assert.AreEqual("TC_Gripper", sasSolution3.ProblemName); Assert.AreEqual("Blind Heuristic", sasSolution3.Heuristic); Assert.AreEqual(ResultStatus.SolutionFound, sasSolution3.ResultStatus); Assert.IsTrue(sasSolution3.SearchTime.TotalMilliseconds > 0); Assert.AreEqual(11, sasSolution3.SolutionCost); Assert.IsNotNull(sasSolution3.SolutionPlan); Assert.AreEqual(11, sasSolution3.SolutionPlan.GetCost()); var pddlProblem = new Planner.PDDL.Problem(new PDDLInputData(GetFilePath("TC_Gripper_D.pddl"), GetFilePath("TC_Gripper_P.pddl"))); var pddlSearch = new MultiHeuristicAStarSearch(pddlProblem, new BlindHeuristic()); pddlSearch.Start(); var pddlSolution = pddlSearch.GetSearchResults(); Assert.AreEqual("Multi-Heuristic A* Search", pddlSolution.Algorithm); Assert.AreEqual("gripper", pddlSolution.DomainName); Assert.AreEqual("problem-1", pddlSolution.ProblemName); Assert.AreEqual("Blind Heuristic", pddlSolution.Heuristic); Assert.AreEqual(ResultStatus.SolutionFound, pddlSolution.ResultStatus); Assert.IsTrue(pddlSolution.SearchTime.TotalMilliseconds > 0); Assert.AreEqual(5, pddlSolution.SolutionCost); Assert.IsNotNull(pddlSolution.SolutionPlan); Assert.AreEqual(5, pddlSolution.SolutionPlan.GetCost()); var pddlSearch2 = new MultiHeuristicAStarSearch(pddlProblem, new BlindHeuristic()); pddlSearch2.Start(SearchType.BackwardWithConditions); var pddlSolution2 = pddlSearch2.GetSearchResults(); Assert.AreEqual("Multi-Heuristic A* Search (Backward)", pddlSolution2.Algorithm); Assert.AreEqual("gripper", pddlSolution2.DomainName); Assert.AreEqual("problem-1", pddlSolution2.ProblemName); Assert.AreEqual("Blind Heuristic", pddlSolution2.Heuristic); Assert.AreEqual(ResultStatus.SolutionFound, pddlSolution2.ResultStatus); Assert.IsTrue(pddlSolution2.SearchTime.TotalMilliseconds > 0); Assert.AreEqual(5, pddlSolution2.SolutionCost); Assert.IsNotNull(pddlSolution2.SolutionPlan); Assert.AreEqual(5, pddlSolution2.SolutionPlan.GetCost()); var pddlSearch3 = new MultiHeuristicAStarSearch(pddlProblem, new BlindHeuristic()); pddlSearch3.Start(SearchType.BackwardWithStates); var pddlSolution3 = pddlSearch3.GetSearchResults(); Assert.AreEqual("Multi-Heuristic A* Search (Backward)", pddlSolution3.Algorithm); Assert.AreEqual("gripper", pddlSolution3.DomainName); Assert.AreEqual("problem-1", pddlSolution3.ProblemName); Assert.AreEqual("Blind Heuristic", pddlSolution3.Heuristic); Assert.AreEqual(ResultStatus.SolutionFound, pddlSolution3.ResultStatus); Assert.IsTrue(pddlSolution3.SearchTime.TotalMilliseconds > 0); Assert.AreEqual(5, pddlSolution3.SolutionCost); Assert.IsNotNull(pddlSolution3.SolutionPlan); Assert.AreEqual(5, pddlSolution3.SolutionPlan.GetCost()); }