Archived
0

try refill at start before search

This commit is contained in:
iMoHax
2015-07-15 11:21:27 +03:00
parent 98684ecd69
commit 86330d52cc

View File

@@ -31,8 +31,15 @@ public class TransitPath {
cEdge.setFuelCost(fuelCost);
entries.add(cEdge);
if (fuel < 0 || fuel < edge.getMinFuel()){
refillCount++;
if (refillCount == 0){
fuel = refill(edges, 0);
if (fuel < 0){
fuel = refill(edges, entries.size()-1);
}
} else {
fuel = refill(edges, entries.size()-1);
}
refillCount++;
} else {
fuel -= fuelCost;
}
@@ -68,7 +75,7 @@ public class TransitPath {
max = e.getMaxFuel();
}
}
throw new IllegalStateException("Is not exists path");
return -1;
}
private double updateFuelCost(List<ConnectibleGraph<Vendor>.BuildEdge> edges, int startIndex, int endIndex, double fuel){