barefoot icon indicating copy to clipboard operation
barefoot copied to clipboard

Possible mistake in path.cost()

Open GeoWonk opened this issue 1 year ago • 0 comments

in Path.java I note the following method which sums the length of edges in the route including partial lengths of the source and target edges. In both cases this proportion is calculated as 1 - edge.fraction(). If I understand what is going on this should only be true for source whereas the proportion for the target edge should just be target.fraction(). The proportion of the source is the length of the edge less how far the vehicle is already along it, whereas the proportion of the target is how far the vehicle is along it. `/** * Gets cost value of the path for an arbitrary {@link Cost} function. * * @param cost {@link Cost} function to be used. * @return Cost value of the path. */ public double cost(Cost<E> cost) { double value = cost.cost(source.edge(), 1 - source.fraction());

    for (int i = 1; i < edges.size(); ++i) {
        value += cost.cost(edges.get(i));
    }

    value -= cost.cost(target.edge(), 1 - target.fraction());

    return value;
}`

GeoWonk avatar Aug 16 '22 03:08 GeoWonk