Skip to content

Possible mistake in path.cost() #161

@GeoWonk

Description

@GeoWonk

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 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;
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions