Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible mistake in path.cost() #161

Open
GeoWonk opened this issue Aug 16, 2022 · 0 comments
Open

Possible mistake in path.cost() #161

GeoWonk opened this issue Aug 16, 2022 · 0 comments

Comments

@GeoWonk
Copy link

GeoWonk commented Aug 16, 2022

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;
}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant