AStarBidirection aStarBi = new AStarBidirection(g, opts.getWeighting(), opts.getTraversalMode()); aStarBi.setApproximation(getApproximation(ASTAR_BI, opts, g.getNodeAccess())); ra = aStarBi;
@Override protected void initCollections(int size) { super.initCollections(Math.min(size, 2000)); }
@Override public void updateBestPath(EdgeIteratorState edgeState, SPTEntry entry, int traversalId, boolean reverse) { if (g2 != null) { mg.plotNode(g2, traversalId, Color.YELLOW); } super.updateBestPath(edgeState, entry, traversalId, reverse); }
public AStarBidirection( Graph graph, FlagEncoder encoder, Weighting weighting, TraversalMode tMode ) { super(graph, encoder, weighting, tMode); int size = Math.min(Math.max(200, graph.getNodes() / 10), 2000); initCollections(size); BeelineWeightApproximator defaultApprox = new BeelineWeightApproximator(nodeAccess, weighting); defaultApprox.setDistanceCalc(new DistancePlaneProjection()); setApproximation(defaultApprox); }
public AStarBidirection(Graph graph, Weighting weighting, TraversalMode tMode) { super(graph, weighting, tMode); BeelineWeightApproximator defaultApprox = new BeelineWeightApproximator(nodeAccess, weighting); defaultApprox.setDistanceCalc(Helper.DIST_PLANE); setApproximation(defaultApprox); }
EdgeIterator iter = explorer.setBaseNode(currNode); while (iter.next()) { if (!accept(iter, currEdge.edge)) continue; updateBestPath(iter, ase, traversalId);
@Override public RoutingAlgorithm createAlgo(Graph g, AlgorithmOptions opts) { return new AStarBidirection(g, opts.getWeighting(), traversalMode); } };
@Override boolean fillEdgesFrom() { if (prioQueueOpenSetFrom.isEmpty()) return false; currFrom = prioQueueOpenSetFrom.poll(); bestWeightMapOther = bestWeightMapTo; fillEdges(currFrom, prioQueueOpenSetFrom, bestWeightMapFrom, outEdgeExplorer, false); visitedCountFrom++; return true; }
@Override protected Path extractPath() { if (finished()) return bestPath.extract(); return bestPath; }
public void updateBestPath(EdgeIteratorState edgeState, AStarEntry entryCurrent, int currLoc) { AStarEntry entryOther = bestWeightMapOther.get(currLoc); if (entryOther == null) return; boolean reverse = bestWeightMapFrom == bestWeightMapOther; // update μ double newWeight = entryCurrent.weightOfVisitedPath + entryOther.weightOfVisitedPath; if (traversalMode.isEdgeBased()) { if (entryOther.edge != entryCurrent.edge) throw new IllegalStateException("cannot happen for edge based execution of " + getName()); // see DijkstraBidirectionRef if (entryOther.adjNode != entryCurrent.adjNode) { entryCurrent = (AStar.AStarEntry) entryCurrent.parent; newWeight -= weighting.calcWeight(edgeState, reverse, EdgeIterator.NO_EDGE); } else if (!traversalMode.hasUTurnSupport()) // we detected a u-turn at meeting point, skip if not supported return; } if (newWeight < bestPath.getWeight()) { bestPath.setSwitchToFrom(reverse); bestPath.sptEntry = entryCurrent; bestPath.edgeTo = entryOther; bestPath.setWeight(newWeight); } }
astarbi.setApproximation(new LMApproximator(qGraph, this.graph.getNodes(), lms, activeLM, lms.getFactor(), false). setEpsilon(epsilon)); return algo;
while (iter.next()) if (!accept(iter, currEdge.edge)) continue; updateBestPath(iter, ase, traversalId);
new AStarBidirection(graph, weighting, tm), opts); path = biDirAlgoWithLandmarks.calcPath(41, 183); assertEquals(expectedPath.getWeight(), path.getWeight(), .1);
@Override boolean fillEdgesFrom() { if (prioQueueOpenSetFrom.isEmpty()) return false; currFrom = prioQueueOpenSetFrom.poll(); bestWeightMapOther = bestWeightMapTo; fillEdges(currFrom, prioQueueOpenSetFrom, bestWeightMapFrom, ignoreExplorationFrom, outEdgeExplorer, false); visitedCountFrom++; return true; }
@Override protected Path extractPath() { if (finished()) return bestPath.extract(); return bestPath; }
throw new IllegalStateException("cannot happen for edge based execution of " + getName());
AStarBidirection aStarBi = new AStarBidirection(g, opts.getWeighting(), opts.getTraversalMode()); aStarBi.setApproximation(getApproximation(ASTAR_BI, opts, g.getNodeAccess())); ra = aStarBi;
public AStarBidirection(Graph graph, Weighting weighting, TraversalMode tMode) { super(graph, weighting, tMode); BeelineWeightApproximator defaultApprox = new BeelineWeightApproximator(nodeAccess, weighting); defaultApprox.setDistanceCalc(Helper.DIST_PLANE); setApproximation(defaultApprox); }
@Override public void initTo(int to, double weight) { currTo = new AStarEntry(EdgeIterator.NO_EDGE, to, weight, weight); weightApprox.setTo(to); prioQueueOpenSetTo.add(currTo); if (currFrom != null) { currFrom.weight += weightApprox.approximate(currFrom.adjNode, false); currTo.weight += weightApprox.approximate(currTo.adjNode, true); } if (!traversalMode.isEdgeBased()) { bestWeightMapTo.put(to, currTo); if (currFrom != null) { bestWeightMapOther = bestWeightMapFrom; updateBestPath(GHUtility.getEdge(graph, currFrom.adjNode, to), currFrom, to); } } else if (currFrom != null && currFrom.adjNode == to) { // special case of identical start and end bestPath.sptEntry = currFrom; bestPath.edgeTo = currTo; finishedFrom = true; finishedTo = true; } }
@Override protected void initCollections( int nodes ) { // algorithm with CH does not need that much memory pre allocated super.initCollections(Math.min(initialCollectionSize, nodes)); }