-
Notifications
You must be signed in to change notification settings - Fork 378
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
Example of how to reroute all vehicles [DO NOT MERGE] #759
base: master
Are you sure you want to change the base?
Conversation
The checking of the final edge is not valid for certain OSM maps (e.g. this). For most vehicles the route is a single element list. |
You are correct. You can use self.k.vehicle.get_position(veh_id) to figure out the vehicle position and self.k.network.edge_length(edge) to get the edge length and figure out when you are near the end of the edge. Adding that check for single edge routes should solve this issue. I can push that fix after the weekend (I don't use electronics on Saturdays) or you can implement it if you need it before then. |
Something like this?
|
Moreover I get this weird situation in which the previous if statement |
Yes that's the idea! One possible issue could be your value of eta is too small; if one of your edges is not too long and your speed is high you could travel off the edge before this condition catches it. Could you check if this is what's hapening? A trick we used to use for this situation (that you could try) is to add long fake edges to every edge in the network that way there's zero chance of this happening. This is why there are weirdly long edges at the end of the grid example. |
Using Since this method seems a little forced in my opinion, I was wondering if there is a way to extract routes from an OSM map programmatically. |
Cool! There isn't one that I know of, at least because it's an ill-posed problem. Technically any route is valid but you wouldn't take some routes (very long ones, routes that contain cycles). We have some work in progress to add this feature but it's not ready yet. If you wind up developing that feature and want to contribute it it would be very appreciated! |
I would love to contribute, but my project is due to next Sunday and I don't think I have the time. |
Np. Hope it helps and let me know if anything comes up. Feel free to open a PR with any of these additions, I'm sure other people will find use for them and its a good way to give your work more visibility. |
I found out that using the add method, you do not reintroduce the agent in the rl_ids. This causes the samples to have inconsistent length, thus leading to the error. I tried using a custom add funtion:
But for some reason is not working as expected. Is there a way to reintroduce an RL vehicle immediately after the rerouting so that the next update will consider its observations? |
There will be occasions where it’s not possible to reinsert the vehicle immediately. I’d just track the IDs and output a zero vector for that vehicle for the timestep it is missing. That shouldn’t be a problem as long as the amount of time it’s missing is small. |
Which are such occasions? Why wouldn't it be possible to reroute the agent immediately? |
Where you want to insert them is blocked for example. |
Adds an optional param that lets you reroute every vehicle if it is on its final edge.