Fixed costs source
This commit is contained in:
父節點
b2aa8243cc
當前提交
daec1d198f
共有 1 個文件被更改,包括 3 次插入 和 4 次删除
|
@ -49,13 +49,12 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
notifyNodeReached(arc.getDestination());
|
notifyNodeReached(arc.getDestination());
|
||||||
|
|
||||||
if (current.isNotMarked() && data.isAllowed(arc)) {
|
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);
|
System.out.println("Nb itérations: " + iterationCounter);
|
||||||
ShortestPathSolution solution = null;
|
ShortestPathSolution solution = null;
|
||||||
|
|
||||||
// Destination has no predecessor, the solution is infeasible...
|
// Destination has no predecessor, the solution is infeasible...
|
||||||
if (labels[destination].getFatherArc() == null) {
|
if (labels[destination].getFatherArc() == null) {
|
||||||
solution = new ShortestPathSolution(data, AbstractSolution.Status.INFEASIBLE);
|
solution = new ShortestPathSolution(data, AbstractSolution.Status.INFEASIBLE);
|
||||||
|
@ -81,8 +80,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
return solution;
|
return solution;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCost(Arc arc, Label parent, Label current, BinaryHeap<Label> heap) {
|
private void updateCost(Arc arc, Label parent, Label current, BinaryHeap<Label> heap, ShortestPathData data) {
|
||||||
double newCost = parent.getCost() + arc.getLength();
|
double newCost = parent.getCost() + data.getCost(arc);
|
||||||
if (newCost < current.getCost()) {
|
if (newCost < current.getCost()) {
|
||||||
try {
|
try {
|
||||||
heap.remove(current);
|
heap.remove(current);
|
||||||
|
|
載入中…
Reference in a new issue