Compare commits
2 commits
d68a7e5ca9
...
ac18c2d522
| Author | SHA1 | Date | |
|---|---|---|---|
| ac18c2d522 | |||
| e8331864ab |
2 changed files with 22 additions and 27 deletions
|
|
@ -1,10 +1,6 @@
|
||||||
package org.insa.graphs.algorithm.shortestpath;
|
package org.insa.graphs.algorithm.shortestpath;
|
||||||
|
|
||||||
import org.insa.graphs.algorithm.AbstractInputData;
|
|
||||||
import org.insa.graphs.model.Graph;
|
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 {
|
public class AStarAlgorithm extends DijkstraAlgorithm {
|
||||||
|
|
||||||
|
|
@ -23,11 +19,11 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
||||||
final double distance = graph.getNodes().get(i).getPoint().distanceTo(
|
final double distance = graph.getNodes().get(i).getPoint().distanceTo(
|
||||||
data.getDestination().getPoint()
|
data.getDestination().getPoint()
|
||||||
);
|
);
|
||||||
final double maxSpeed = data.getMaximumSpeed();
|
final double maxSpeed = graph.getGraphInformation().getMaximumSpeed();
|
||||||
double estimatedCost = distance;
|
double estimatedCost = distance;
|
||||||
if (data.getMode() == ShortestPathData.Mode.TIME)
|
if (data.getMode() == ShortestPathData.Mode.TIME)
|
||||||
estimatedCost /= maxSpeed;
|
estimatedCost /= maxSpeed;
|
||||||
labels[i].setEstimatedCost(estimatedCost);
|
labels[i].setEstimatedCost(estimatedCost);
|
||||||
}
|
}
|
||||||
return this.doDijkstra(labels, data, graph);
|
return this.doDijkstra(labels, data, graph);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public abstract class AlgoTest {
|
||||||
protected ArrayList<PathDataset> invalidTestData;
|
protected ArrayList<PathDataset> invalidTestData;
|
||||||
|
|
||||||
// Graphs to use
|
// Graphs to use
|
||||||
private Graph graphInsa, graphSquare, graphBretagne;
|
private Graph graphInsa, graphSquare, graphBretagne, graphGuadeloupe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to store all data related to a path and its computed solutions
|
* Class used to store all data related to a path and its computed solutions
|
||||||
|
|
@ -129,6 +129,7 @@ public abstract class AlgoTest {
|
||||||
graphInsa = readGraph("../Maps/insa.mapgr");
|
graphInsa = readGraph("../Maps/insa.mapgr");
|
||||||
graphSquare = readGraph("../Maps/carre.mapgr");
|
graphSquare = readGraph("../Maps/carre.mapgr");
|
||||||
graphBretagne = readGraph("../Maps/bretagne.mapgr");
|
graphBretagne = readGraph("../Maps/bretagne.mapgr");
|
||||||
|
graphGuadeloupe = readGraph("../Maps/guadeloupe.mapgr");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -139,20 +140,23 @@ public abstract class AlgoTest {
|
||||||
filterTime = ArcInspectorFactory.getAllFilters().get(2);
|
filterTime = ArcInspectorFactory.getAllFilters().get(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PathDataset getNewPathDataset(Graph graph, int originID, int destinationID) {
|
||||||
|
return new PathDataset(
|
||||||
|
graph,
|
||||||
|
graph.getNodes().get(originID),
|
||||||
|
graph.getNodes().get(destinationID)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates valid data sets
|
* Creates valid data sets
|
||||||
*/
|
*/
|
||||||
private void initValidPathList() {
|
private void initValidPathList() {
|
||||||
validTestData = new ArrayList<>();
|
validTestData = new ArrayList<>();
|
||||||
|
|
||||||
validTestData.add(new PathDataset(
|
validTestData.add(getNewPathDataset(graphInsa, 512, 526));
|
||||||
graphInsa,
|
validTestData.add(getNewPathDataset(graphGuadeloupe, 12822, 13687));
|
||||||
graphInsa.getNodes().get(512),
|
validTestData.add(getNewPathDataset(graphSquare, 21, 17));
|
||||||
graphInsa.getNodes().get(526)));
|
|
||||||
validTestData.add(new PathDataset(
|
|
||||||
graphSquare,
|
|
||||||
graphSquare.getNodes().get(21),
|
|
||||||
graphSquare.getNodes().get(17)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -161,15 +165,10 @@ public abstract class AlgoTest {
|
||||||
private void initInvalidPathList() {
|
private void initInvalidPathList() {
|
||||||
invalidTestData = new ArrayList<>();
|
invalidTestData = new ArrayList<>();
|
||||||
|
|
||||||
invalidTestData.add(new PathDataset(
|
invalidTestData.add(getNewPathDataset(graphBretagne, 29270, 545599));
|
||||||
graphBretagne,
|
invalidTestData.add(getNewPathDataset(graphGuadeloupe, 26963, 4307));
|
||||||
graphBretagne.getNodes().get(29270),
|
invalidTestData.add(getNewPathDataset(graphGuadeloupe, 8185, 8185));
|
||||||
graphBretagne.getNodes().get(545599)));
|
invalidTestData.add(getNewPathDataset(graphSquare, 10, 10));
|
||||||
|
|
||||||
invalidTestData.add(new PathDataset(
|
|
||||||
graphSquare,
|
|
||||||
graphSquare.getNodes().get(10),
|
|
||||||
graphSquare.getNodes().get(10)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue