final PreProcessLandmarks.LandmarksData fromData = getPreProcessData(fromNode); final PreProcessLandmarks.LandmarksData toData = getPreProcessData(toNode);
/** * Estimates the remaining travel cost from fromNode to toNode using the landmarks on the network. * * @param fromNode The first node. * @param toNode The second node. * @return The travel cost when traveling between the two given nodes. */ @Override protected double estimateRemainingTravelCost(final Node fromNode, final Node toNode) { PreProcessLandmarks.LandmarksData fromRole = getPreProcessData(fromNode); PreProcessLandmarks.LandmarksData toRole = getPreProcessData(toNode); double tmpTravCost; double travCost = 0; for (int i = 0, n = this.activeLandmarkIndexes.length; i < n; i++) { tmpTravCost = estimateRemainingTravelCost(fromRole, toRole, this.activeLandmarkIndexes[i]); if (tmpTravCost > travCost) { travCost = tmpTravCost; } } tmpTravCost = super.estimateRemainingTravelCost(fromNode, toNode); if (travCost > tmpTravCost) { return travCost; } /* else */ return tmpTravCost; }
/** * Checks whether there is a landmark in the set of the non-active landmarks that yields a better estimation than * the best active landmark. If there is, this landmark is added to the set of active landmark and its index is returned. * * @param fromNode The node for which we estimate the remaining travel time to the toNode. * @param toNode The target node. * @return The index of the landmark that has been added to the set of active landmarks, or -1 if no landmark was added. */ /*package*/ int checkToAddLandmark(final Node fromNode, final Node toNode) { double bestTravCostEst = estimateRemainingTravelCost(fromNode, toNode); PreProcessLandmarks.LandmarksData fromRole = getPreProcessData(fromNode); PreProcessLandmarks.LandmarksData toRole = getPreProcessData(toNode); int bestIndex = -1; for (int i = 0; i < this.landmarks.length; i++) { double tmpTravTime = estimateRemainingTravelCost(fromRole, toRole, i); if (tmpTravTime > bestTravCostEst) { bestIndex = i; bestTravCostEst = tmpTravTime; } } if (bestIndex != -1) { int[] newActiveLandmarks = new int[this.activeLandmarkIndexes.length + 1]; System.arraycopy(this.activeLandmarkIndexes, 0, newActiveLandmarks, 0, this.activeLandmarkIndexes.length); newActiveLandmarks[this.activeLandmarkIndexes.length] = bestIndex; this.activeLandmarkIndexes = newActiveLandmarks; } return bestIndex; }
PreProcessLandmarks.LandmarksData toRole = getPreProcessData(toNode); List<Double> newEstRemTravCosts = new ArrayList<>(); List<Node> nodesToBeUpdated = new ArrayList<>(); Node node = it.next(); AStarNodeData data = getData(node); PreProcessLandmarks.LandmarksData ppRole = getPreProcessData(node); double estRemTravCost = data.getExpectedRemainingCost(); double newEstRemTravCost = estimateRemainingTravelCost(ppRole, toRole, newLandmarkIndex);