From e8331864ab4449bc9bc1b5909a6e3658af60beab Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Fri, 22 May 2020 14:53:37 +0200 Subject: [PATCH] Improved A* time estimation --- .../algorithm/shortestpath/AStarAlgorithm.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java index 329cc0f..ab9078f 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java @@ -1,10 +1,6 @@ package org.insa.graphs.algorithm.shortestpath; -import org.insa.graphs.algorithm.AbstractInputData; import org.insa.graphs.model.Graph; -import org.insa.graphs.model.Node; -import org.insa.graphs.model.Point; -import org.insa.graphs.model.RoadInformation; public class AStarAlgorithm extends DijkstraAlgorithm { @@ -23,11 +19,11 @@ public class AStarAlgorithm extends DijkstraAlgorithm { final double distance = graph.getNodes().get(i).getPoint().distanceTo( data.getDestination().getPoint() ); - final double maxSpeed = data.getMaximumSpeed(); - double estimatedCost = distance; - if (data.getMode() == ShortestPathData.Mode.TIME) - estimatedCost /= maxSpeed; - labels[i].setEstimatedCost(estimatedCost); + final double maxSpeed = graph.getGraphInformation().getMaximumSpeed(); + double estimatedCost = distance; + if (data.getMode() == ShortestPathData.Mode.TIME) + estimatedCost /= maxSpeed; + labels[i].setEstimatedCost(estimatedCost); } return this.doDijkstra(labels, data, graph); }