Fixed costs source

This commit is contained in:
Arnaud Vergnet 2020-03-30 16:05:47 +02:00
parent b2aa8243cc
commit daec1d198f

View file

@ -49,13 +49,12 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
notifyNodeReached(arc.getDestination());
if (current.isNotMarked() && data.isAllowed(arc)) {
this.updateCost(arc, parent, current, heap);
this.updateCost(arc, parent, current, heap, data);
}
}
}
System.out.println("Nb itérations: " + iterationCounter);
ShortestPathSolution solution = null;
// Destination has no predecessor, the solution is infeasible...
if (labels[destination].getFatherArc() == null) {
solution = new ShortestPathSolution(data, AbstractSolution.Status.INFEASIBLE);
@ -81,8 +80,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
return solution;
}
private void updateCost(Arc arc, Label parent, Label current, BinaryHeap<Label> heap) {
double newCost = parent.getCost() + arc.getLength();
private void updateCost(Arc arc, Label parent, Label current, BinaryHeap<Label> heap, ShortestPathData data) {
double newCost = parent.getCost() + data.getCost(arc);
if (newCost < current.getCost()) {
try {
heap.remove(current);