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
Fix inappropriate approximation of Math.exp #502
Conversation
Good catch! Can you also plot the graph for the new implementation of this commit? I am wondering how more expensive it is to use Math.exp instead of these approximations. |
Good pointer. I found a variante of this
A little bit closer to the Math.exp, brings back a correct 0.0 on exp(Double.NEGATIVE_INFINITY) and should not lose too much time. |
The goal of
I highly doubt that any of the new variants of FastMath.exp will return 0 if you input negative infinity.
After giving it some more thought, I would say we should remove FastMath altogether. This is pretty much a classic example of "premature optimization" and will likely cause problems again without any significant benefit to us. |
Right, my fail. I check also
All right, agreed. |
Don't worry, this stuff can be tricky.
I think FastMath is only called a lot in a hot loop when the car routing models are used. And the old code made less than 2 % difference even in the worst scenario where this function is called millions of times per ~ 300 km. |
If you want to remove FastMath entirely, feel free to just close this pull request. I sadly won't have time to contribute much to BRouter in the next couple of weeks or months. |
@afischerdev, @abrensch, I think we should address this issue as part of the next update. My preferred solution would be to just drop FastMath altogether. What do you think? |
I would agree that and could do the job the next days |
FastMath.exp was neither continuous nor strictly monotonically increasing for x < -1 and therefore inappropriate for the intended purpose.
@afischerdev, I have changed my pull request accordingly. |
FastMath.exp
was discontinuous for x < -1 and thus completely ruined the output of Tobler's hiking function:It also messed up the
decayFactor
calculation when the distance between two consecutive nodes was greater than 100m.