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
We've introduced CostWrapper to be able to scale travel times on the fly based on vehicles speed_factor values. The current implementation is that we compute a scaling factor in the ctor:
Then when a duration value is requested, we scale the original matrix value (DIVISOR is 100 to keep a fair amount of precision since speed_factor is a double):
Duration c = duration_data[i * duration_matrix_size + j];
return (c * discrete_duration_factor) / DIVISOR;
}
The advantage of this approach is that even if speed_factor is a double, it keeps all our computations in the integer world (see #491). The current implementation have drawbacks though:
we're still doing an integer division for each call to duration or cost (heavily used!);
we still have rounding issues when getting back to seconds by dividing: depending on the speed_factor value, this can lead to different matrix durations being scaled to the same value.
I'd like to try to get rid of the division and simply use scaled values all over internally. This would amount to describing all durations as hundredth of second internally. We'd have to apply that change to all time-related values and round back to seconds upon solution formatting. This would add some code boilerplate but could improve precision while reducing computing time.
The text was updated successfully, but these errors were encountered:
A possible concern is that this would also lower by a factor of 100 the threshold for potential overflows which we check in Input::check_cost_bound. I'm not too worried by this at first glance.
We've introduced
CostWrapper
to be able to scale travel times on the fly based on vehiclesspeed_factor
values. The current implementation is that we compute a scaling factor in the ctor:vroom/src/structures/vroom/cost_wrapper.cpp
Line 17 in 4b898ec
Then when a duration value is requested, we scale the original matrix value (
DIVISOR
is 100 to keep a fair amount of precision sincespeed_factor
is a double):vroom/src/structures/vroom/cost_wrapper.h
Lines 36 to 39 in 4b898ec
The advantage of this approach is that even if
speed_factor
is a double, it keeps all our computations in the integer world (see #491). The current implementation have drawbacks though:duration
orcost
(heavily used!);speed_factor
value, this can lead to different matrix durations being scaled to the same value.I'd like to try to get rid of the division and simply use scaled values all over internally. This would amount to describing all durations as hundredth of second internally. We'd have to apply that change to all time-related values and round back to seconds upon solution formatting. This would add some code boilerplate but could improve precision while reducing computing time.
The text was updated successfully, but these errors were encountered: