bikehopper / graphhopper

Open source routing engine for OpenStreetMap. Use it as Java library or standalone web server.
https://www.graphhopper.com/open-source/
Apache License 2.0
3 stars 0 forks source link

[WIP] Convert penalty values to whole numbers #143

Closed rsarathy closed 1 day ago

rsarathy commented 3 months ago

Fractional penalty values are rounded to the nearest whole number because of the limited number of bits available (four) for decimal encoding, and the specified factor (1).

penaltyEnc = new DecimalEncodedValueImpl(getKey(name, "penalty"), 4, PenaltyCode.getFactor(1), penaltyTwoDirections);

Therefore, the only possible values for penalties are the whole numbers 0-15. For example, 9.5 will be rounded to 10.0.

If we want to respect half-point penalty values, then the above code should be changed to

penaltyEnc = new DecimalEncodedValueImpl(getKey(name, "penalty"), 5, 0.5, penaltyTwoDirections);

increasing the number of bits from 4 to 5, and the factor from 1.0 to 0.5.

However, since I don't know what the performance implications are wrt increasing the number of bits, this change will maintain the same router behavior while making our code more readable.