/// <summary> /// /// </summary> /// <param name="first"></param> /// <param name="second"></param> /// <param name="p"></param> /// <param name="seed"></param> public RandomChoiceOfHeuristic(IHeuristicCalculator <State> first, IHeuristicCalculator <State> second, double p, int seed = 0) { this.first = first; this.second = second; this.p = p; this.rand = new Random(seed); }
public EPEA_Star(IHeuristicCalculator <WorldState> heuristic = null, bool mstar = false, bool mstarShuffle = false) : base(heuristic, mstar, mstarShuffle) { if (Constants.costFunction == Constants.CostFunction.MAKESPAN || Constants.costFunction == Constants.CostFunction.MAKESPAN_THEN_SUM_OF_COSTS ) { Trace.Assert(false, "Makespan support isn't implemented at the moment. Use A*+OD for now."); } }
public IterativeDeepeningCBS(ICbsSolver singleAgentSolver, ICbsSolver generalSolver, int maxThreshold = -1, int currentThreshold = -1, IHeuristicCalculator <CbsNode> heuristic = null) { this.mergeThreshold = currentThreshold; this.solver = generalSolver; this.singleAgentSolver = singleAgentSolver; this.maxThreshold = maxThreshold; this.heuristic = heuristic; if (currentThreshold < maxThreshold) { //this.solver = new MACBS_WholeTreeThreshold(solver, maxThreshold, currentThreshold + 1); } }
public PathfinderEngine(int width, int height, ICostCalculator costCalculator, IHeuristicCalculator heuristicCalculator, MovementMode explorationMode = MovementMode.FourDirection) { Debug.Assert(width > 0, "width <= 0"); Debug.Assert(height > 0, "height <= 0"); _width = width; _height = height; this.MovementMode = explorationMode; _solution = new PathfinderNode[width, height]; CostCalculator = costCalculator; HeuristicCalculator = heuristicCalculator; }
public AStar(IHeuristicCalculator heuristicCalculator) { _heuristicCalculator = heuristicCalculator; }
public PEA_Star(IHeuristicCalculator <WorldState> heuristic = null) : base(heuristic) { }
public A_Star_WithOD(IHeuristicCalculator <WorldState> heuristic = null, bool mStar = false, bool mStarShuffle = false) : base(heuristic, mStar, mStarShuffle) { }
public bool Search(Graph graph, IPathfindingNode source, IPathfindingNode target, IHeuristicCalculator hc) { pq.Add(source); while (pq.count > 0) { IPathfindingNode nextClosestNode = pq.PopFirst(); if (searchFrontier.ContainsKey(nextClosestNode)) { GraphEdge nearestEdge = searchFrontier[nextClosestNode]; if (shortestPahTree.ContainsKey(nextClosestNode)) { shortestPahTree[nextClosestNode] = nearestEdge; } else { shortestPahTree.Add(nextClosestNode, nearestEdge); } } if (nextClosestNode == target) { ConstructPath(source, target); return(true); } List <GraphEdge> frontier = graph.GetFrontier(nextClosestNode); for (int i = 0; i < frontier.Count; i++) { GraphEdge frontierEdge = frontier[i]; IPathfindingNode neighbour = frontierEdge.to; float realCost = nextClosestNode.RealNodeCost + frontierEdge.cost; float heuristicCost = hc.Calculate(neighbour, target); float totalCost = nextClosestNode.TotalNodeCost + frontierEdge.cost; if (searchFrontier.ContainsKey(neighbour) == false) { neighbour.TotalNodeCost = totalCost; neighbour.RealNodeCost = realCost; searchFrontier.Add(neighbour, frontierEdge); pq.Add(neighbour); } else if (realCost < neighbour.RealNodeCost) { neighbour.TotalNodeCost = totalCost; neighbour.RealNodeCost = realCost; pq.MarkToSort(); searchFrontier[neighbour] = frontierEdge; } } } return(false); }
public List <IPathfindingNode> FindPath(IPathfindingNode source, IPathfindingNode target, IHeuristicCalculator h) { var shortestPath = new List <IPathfindingNode>(); AStarGraphSearch graphSearch = new AStarGraphSearch(); bool success = graphSearch.Search(_graph, source, target, h); if (success) { shortestPath.Clear(); shortestPath.Add(source); shortestPath.AddRange(graphSearch.shortestPath); shortestPath.Add(target); } return(shortestPath); }