1

I want the vehicles in the inflow to drive constant speed but I want this constant speed to change between episodes (let's make this speed uniformly sampled between 10 m/s and 25 m/s). E.g. in episode #5 all vehicles drive in 12.3 m/s and in episode #6 all vehicles drive in 19.7 m/s.

How can I do that?

Can I do it with only one inflow or do I need an infinite number of inflows, one per speed and change dynamically between them? (which I'm not sure how, anyway)

Gabizon
  • 339
  • 4
  • 15

1 Answers1

2

Yes! It's a little tricky but you can make it work. If you look at the reset method on line 988 of the following file (https://github.com/flow-project/flow/blob/master/flow/envs/bottleneck.py) you can see that what we do is create a new set of inflows and then restart the simulation so that the new set of inflows is active. You should be able to add a similar bit of code to your environment to make it work.

  • Thanks, I can't use the same implementation as I have flow version 0.4.0_dev. Instead I've implemented a method inside my implementation of Env that overrides self.scenario wherever the reset() method is called. This method creates an InFlows() object with a random velocity , then creates a NetParams() object that holds this Inflows, and then using this NetParams() creates a new Scenario which now replaces the old one. It doesn't seem to actually affect the other vehicles velocities. Any idea? Do I have to use restart_simulation()? It will really slow my code. – Gabizon Oct 23 '19 at 12:45
  • Well, you could just create a custom vehicle class that takes a fixed speed and drives at that speed. Then at reset you can pick a new speed for that vehicle. – Eugene Vinitsky Oct 23 '19 at 19:24
  • I can do that, but then how should I define the inflow? It has a depart_speed and goes by it right? – Gabizon Oct 24 '19 at 07:22
  • Ah yes, if you want to use inflows you will have to restart the simulation everytime. Fortunately, it's actually really not a huge speed loss (and not restarting your simulation actually causes SUMO to slow down if you run it for too long). – Eugene Vinitsky Oct 26 '19 at 20:53
  • Actually in my case it is a huge speed loss. I've just finished benchmarking and it seems like the difference is about x4 slower when using restart_instance() – Gabizon Nov 04 '19 at 11:58
  • Hi Gabizon, we are shifting away from stackoverflow to Slack ot improve our response times. Please join us at https://join.slack.com/t/flow-users/shared_invite/enQtNzk5NzE1OTkyNTE0LTU0YmE5ZTVkZmJmNDg1Nzg2YThjOThmY2ZlYWE2ZjQ0NTE1NjE3Y2YwMTljY2U5M2Y3MDhmMWUzZDM3YWViNmE – Eugene Vinitsky Nov 08 '19 at 19:53