-
Notifications
You must be signed in to change notification settings - Fork 333
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
Scaling logic of speed_factor
is flawed for high values
#591
Comments
@krashish8 thanks for summing up the situation! The The I think we should simply enforce (and document) reasonable values of I can't really think of use-cases with the need of higher values, but if need be they could (should?) be treated differently: either by adjusting the routing layer, or by scaling the matrix manually prior to solving the problem. |
Yes, I understand that Normally, the
In such cases, These cases can be easily tackled by scaling the matrix manually or using some other units of measurement (such as meter and m/sec, since 50m/sec is sufficiently large). It is good to have this documented, just to make the users aware of it. |
I think because of similar reasons, for the values of This is fine, considering nothing is "exact" in the real world, the service time or speed are all approximate. Still, can you think of some way of tackling this issue? I think the only best way would be to do some manual preprocessing i.e. scaling the matrix cost such that all the speed_factors become closer to 1. Anyone using a custom matrix and relying "only" on the speed_factor for scaling would think of this as an error. |
That's technically true but the introduction in the API docs states that "all timings are in seconds" and "all distances are in meters" (in order to be consistent with calls to routing engines). So users tweaking expected values/units should not really complain when getting inconsistent results. ;-) The need for higher
The rounding effect you point out is bigger (and less and less acceptable) as the |
Thanks, @jcoupey, got it! :) I agree that reducing the speed factor to the range Anyway, the speed factor is a double value, so it can accommodate any such range of speeds by custom scaling. |
So all in all it boils down to:
I'd like to have this straightened up in the next release, @krashish8 would you consider submitting a PR for this by any chance? ;-) |
Thanks, I'd love to submit a PR! :) |
Problem
The
speed_factor
in the vehicle does not scale vehicle travel times properly for higher values.Specifically, the output produced is same for the same values of
std::round(100/speed_factor)
. So,speed_factor > 200
, all durations are0
and random routes are computed100 <= speed_factor <= 200
, i.e., the result is same for any speed factor in this range.0 < speed_factor <= 100
, but the time values in the output may not be exact. e.g.speed_factor = 70
andspeed_factor = 100
produce the same result, because100/70 ~ 100/100 ~ 1
.For small values of
speed_factor
, everything is fine.Also,
speed_factor = 0
sounds like an undefined behaviour.speed_factor < 0
is also possible, leading to random outputs.To Reproduce
Change the
speed_factor
values in the input json and compare the result.Expectation
Only positive values of
speed_factor
must be allowed, and the vehicle travel times shall scale properly for any values of thespeed_factor
.The text was updated successfully, but these errors were encountered: