-
Notifications
You must be signed in to change notification settings - Fork 697
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
added use_lit costing option for pedestrian #3957
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good to me! Just a tiny nit.
Next PR(s) can deal with
- adding additional penalties if the edge is a tunnel and unlit
- adding
use_lit
to bicycle costing, what do you think @dnesbitt61 ?
I personally don't think RAD testing is very necessary, though it'll be called on most edges which are ped accessible. Also its impact is fairly well imaginable IMO.
src/sif/dynamiccost.cc
Outdated
@@ -354,6 +358,11 @@ void DynamicCost::set_use_living_streets(float use_living_streets) { | |||
2.f * (1.f - use_living_streets) * (1.f - kMinLivingStreetFactor)); | |||
} | |||
|
|||
void DynamicCost::set_use_lit(float use_lit) { | |||
unlit_factor_ = | |||
use_lit < 0.5f ? 1 + (kMinLitFactor + 2.f * use_lit) : ((kMinLitFactor - 5) + 12.f * use_lit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use float everywhere to avoid implicit conversions
repeated AvoidEdge exclude_edges = 78; | ||
oneof has_elevator_penalty { | ||
float elevator_penalty = 79; | ||
} | ||
uint32 fixed_speed = 80; | ||
uint32 axle_count = 81; | ||
float use_lit = 82; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we have to do it a oneof
here to satisfy the JSON_PBF_RANGED_DEFAULT
macro @chrstnbwnkl , even though it wouldn't actually be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha, funny, reverting actually pulls up my initial comment again..
proto/options.proto
Outdated
oneof has_use_lit { | ||
float use_lit = 82; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the default is 0.f then you dont need to use oneof
because both not being set and the default are one and the same value. i know that all the other ones, even the ones that default to 0 are using oneof
but thats only because i didnt get a chance to go back and do these, you could be the guy to start the wave :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
went the way of a new macro and no oneof
src/sif/pedestriancost.cc
Outdated
if (!edge->lit()) { | ||
factor *= unlit_factor_; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may be a preoptimization however, it is possible to do this without a branch (if
), you can cast the bool to float and multiply with it instead which may help performance somewhat, it certainly wont be slower than the branch statement.
if (!edge->lit()) { | |
factor *= unlit_factor_; | |
} | |
factor *= (!edge->lit()) * unlit_factor_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is bullcrap sorry, didnt think about hard enough, when it is lit we need the factor to still be 1, so we need some slightly more complicated math to avoid the if
i'll respond later, you can ignore this for now haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok this is my actual suggestion to remove the branch:
factor *= edge->lit() + (!edge->lit() * unlit_factor_);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe just forget about it haha)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrstnbwnkl actually implemented your suggestion:)
The completely unrelated |
is it possible we changed costing in the default case? that would make the bss path different for the pedestrian part potentially. i would have expected the code we added would simply be |
That's what I figured too, but I just can't see it happening in the code changes.. Still can't really debug, but hopefully on the weekend I'll have more time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done now. I also renamed the astar_bss.cc
test file to astar_bikeshare.cc
as that caused problems with VS Code's gdb implementation.
@@ -354,6 +358,11 @@ void DynamicCost::set_use_living_streets(float use_living_streets) { | |||
2.f * (1.f - use_living_streets) * (1.f - kMinLivingStreetFactor)); | |||
} | |||
|
|||
void DynamicCost::set_use_lit(float use_lit) { | |||
unlit_factor_ = | |||
use_lit < 0.5f ? kMinLitFactor + 2.f * use_lit : ((kMinLitFactor - 5.f) + 12.f * use_lit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I just can't see it happening in the code changes.
OK, I'm just blind (again).. There was a tiny bug there @chrstnbwnkl which caused the default to be a unlit_factor_
of 2 (as it must've been, not sure why I didn't see it..).
@@ -92,6 +95,7 @@ constexpr float kDefaultUseFerry = 0.5f; // Default preference of using | |||
constexpr float kDefaultUseRailFerry = 0.4f; // Default preference of using a rail ferry 0-1 | |||
constexpr float kDefaultUseTracks = 0.5f; // Default preference of using tracks 0-1 | |||
constexpr float kDefaultUseLivingStreets = 0.1f; // Default preference of using living streets 0-1 | |||
constexpr float kDefaultUseLit = 0.f; // Default preference of using lit ways 0-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrstnbwnkl why a default of 0.f vs 0.5f? Meaning no preference by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concept with lit
is to avoid unlit edges and not do any modulation of lit edges. Then 0 has no influence at all, so it's fully opt-in for clients.
@@ -89,6 +89,8 @@ const std::string kDefaultPedestrianType = "foot"; | |||
// hills) to 1 (take hills when they offer a more direct, less time, path). | |||
constexpr float kDefaultUseHills = 0.5f; | |||
|
|||
constexpr float kDefaultUseLit = 0.f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrstnbwnkl same comment as above. Why not 0.5f for the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrstnbwnkl The reason I am asking about this is that I am wondering what the differences are between master and this branch when running pedestrian routes from here https://github.com/valhalla/valhalla/tree/master/test_requests I am wondering if there could be a negative impact. May need to add new tests with areas that have lit tag prevalent and areas where it is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're not changing the use_lit
request option there shouldn't be any differences at all compared to master. Only when you start with use_lit > 0
in costing options, there'll be differences. We thought we could avoid doing a RAD testing tbh 😇 since the impact is very well imaginable IMO, see the graph in @chrstnbwnkl 's OP. Do let us know if you're somewhat concerned, maybe we can talk about it tmrw in the 8:30 review session if you have the time @gknisely ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also there's tests for BSS handling which were failing when we had the tiny bug where the default use_lit
wasn't zero, but 0.1 or so. That's requesting against a tileset in Paris and it ends up taking different paths, even with low use_lit
values.
Issue
Adds a
use_lit
costing option to pedestrian costing, see discussion in #3848.The
use_lit
value is converted into anavoid_unlit
factor using the following formula:Which maps the range
[0, 1]
to the factor range[1, 8]
, so thatuse_lit=0
has no effect on the route,0 < use_lit < 0.5
has some effect on the route and0.5 ≤ use_lit ≤ 1
has a comparatively stronger effect on the route.use_lit
is defined indynamiccost
so it could be used as well by e.g. bicycle costing, the exact implementation for which would need to be discussed (as an avid cyclist myself I could see a necessity for this, as the degree to which a cyclist can be seen by other road users greatly determines safety at night).Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?