You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The decision to do it this way pre-dates my participation in the project, but if I had to guess, I'd say it was a performance choice - historically, integer math was faster than floating point math on most CPUs (although the reality of that on modern hardware is complicated).
I don't know that any deep justification for this choice has ever been given. It would certainly be possible to use a float type instead, but it would likely come with a myriad of subtle changes to behaviour, due to floating point precision behaviour. I cannot say whether the changes would be significant or not. 🤷♂️
Thanks @danpat for the quick reply. It makes sense due to historically chosen. Agree with no need to change to float by now.
For the multiply 10 part, especially for duration * 10, I think it'll be better to use macro/simple function instead. There're too many hardcodes in repo by now. I'll try to create PR when I have time.
When I read code, I found that the unit of
weight/duration
seems100ms
instead ofseconds
.I found below comments from code:
osrm-backend/include/util/typedefs.hpp
Line 81 in e86d937
using TurnPenalty = std::int16_t; // turn penalty in 100ms units
Also, I found a lot of hardcoded codes multiply
weight/duration
by10
, e.g.osrm-backend/src/extractor/graph_compressor.cpp
Line 253 in e86d937
node_duration_penalty = extraction_turn.duration * 10; node_weight_penalty = extraction_turn.weight * weight_multiplier;
osrm-backend/src/extractor/extraction_containers.cpp
Line 397 in a1e5061
I think use the
100ms
unit is a little strange. Why did this?Moreover, I wrote down a document How OSRM Calculate Weight and Duration when I reading codes. FYI. Please let me know if anything not correct, thanks!
The text was updated successfully, but these errors were encountered: