VerifFastest
This commit is contained in:
parent
7624518c7e
commit
51b28efa2d
6 changed files with 28 additions and 15 deletions
|
@ -17,12 +17,22 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ShortestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes , ShortestPathData data)
|
public void shortestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes , ShortestPathData data)
|
||||||
{
|
{
|
||||||
Path p = Path.createShortestPathFromNodes(data.getGraph(), solutionNodes);
|
Path p = Path.createShortestPathFromNodes(data.getGraph(), solutionNodes);
|
||||||
System.out.println("shortest path : " + p.getLength());
|
System.out.println("shortest path : " + p.getLength());
|
||||||
if (p.getLength()-solution.getPath().getLength() < 1.00){
|
if (p.getLength()-solution.getPath().getLength() < 1.00){
|
||||||
System.out.println("le chemin Astar est le shortest");
|
System.out.println("le chemin Astar bien est le shortest");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fastestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes,ShortestPathData data){
|
||||||
|
Path p= Path.createFastestPathFromNodes(data.getGraph(), solutionNodes);
|
||||||
|
System.out.println("fastest path : " + p.getMinimumTravelTime());
|
||||||
|
if (p.getMinimumTravelTime()-solution.getPath().getMinimumTravelTime() < 1.00){
|
||||||
|
System.out.println("le chemin Astar est bien le fastest");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,18 +97,30 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
solutionNodes.add(a.getOrigin());
|
solutionNodes.add(a.getOrigin());
|
||||||
}
|
}
|
||||||
solutionNodes.add(data.getDestination());
|
solutionNodes.add(data.getDestination());
|
||||||
ShortestVerif(solution, solutionNodes, data);
|
shortestVerif(solution, solutionNodes, data);
|
||||||
|
fastestVerif(solution, solutionNodes, data);
|
||||||
|
|
||||||
return solution;
|
return solution;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShortestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes , ShortestPathData data)
|
|
||||||
|
public void shortestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes , ShortestPathData data)
|
||||||
{
|
{
|
||||||
Path p = Path.createShortestPathFromNodes(data.getGraph(), solutionNodes);
|
Path p = Path.createShortestPathFromNodes(data.getGraph(), solutionNodes);
|
||||||
System.out.println("shortest path : " + p.getLength());
|
System.out.println("shortest path : " + p.getLength());
|
||||||
if (p.getLength()-solution.getPath().getLength() < 1.00){
|
if (p.getLength()-solution.getPath().getLength() < 1.00){
|
||||||
System.out.println("le chemin Dijkstra est le shortest");
|
System.out.println("le chemin Dijkstra est bien le shortest");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void fastestVerif(ShortestPathSolution solution,ArrayList<Node> solutionNodes,ShortestPathData data){
|
||||||
|
Path p= Path.createFastestPathFromNodes(data.getGraph(), solutionNodes);
|
||||||
|
System.out.println("fastest path : " + p.getMinimumTravelTime());
|
||||||
|
if (p.getMinimumTravelTime()-solution.getPath().getMinimumTravelTime() < 1.00){
|
||||||
|
System.out.println("le chemin Dijkstra est bien le fastest");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -266,7 +266,6 @@ public class Path {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public float getLength() {
|
public float getLength() {
|
||||||
// TODO:
|
|
||||||
float length=0;
|
float length=0;
|
||||||
for (Arc arc : arcs) {
|
for (Arc arc : arcs) {
|
||||||
length += arc.getLength();
|
length += arc.getLength();
|
||||||
|
@ -282,14 +281,6 @@ public class Path {
|
||||||
* @return Time (in seconds) required to travel this path at the given speed (in
|
* @return Time (in seconds) required to travel this path at the given speed (in
|
||||||
* kilometers-per-hour).
|
* kilometers-per-hour).
|
||||||
*
|
*
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
=======
|
|
||||||
<<<<<<< HEAD
|
|
||||||
*/
|
*/
|
||||||
public double getTravelTime(double speed) {
|
public double getTravelTime(double speed) {
|
||||||
double TotalTime = 0;
|
double TotalTime = 0;
|
||||||
|
@ -305,7 +296,7 @@ public class Path {
|
||||||
*
|
*
|
||||||
* @return Minimum travel time to travel this path (in seconds).
|
* @return Minimum travel time to travel this path (in seconds).
|
||||||
*
|
*
|
||||||
* @deprecated Need to be implemented.
|
*
|
||||||
*/
|
*/
|
||||||
public double getMinimumTravelTime() {
|
public double getMinimumTravelTime() {
|
||||||
double minTime = 0;
|
double minTime = 0;
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue