-
Hello, I'm facing an issue with dynamically updating the speed of agents based on the number of agents within a specific polygon. The initial speed is set correctly, but it appears that the speed does not update as conditions change over time. if speed == 0: In this code, the speed is supposed to update to 1.2 if, after adding an agent, the polygon is empty. However, it seems that the agents only respond to the initial conditions and do not update their speed as the situation evolves. Problem Summary:
Any guidance or suggestions on how to resolve this issue would be greatly appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @K99-JDG I cannot see any updates to agent speed during the simulation in the code you attached. Let me explain: The actual simulations are executed later in the 7th cell, i.e.: while simulation.agent_count() > 0 and simulation.iteration_count() < 7000:
simulation.iterate() The code above is correct in the sense that it runs the simulation to completion or at most 70s. If you want to change agent parameters dynamically then you need to change them here. In the following example the agents speed is randomised every 250ms: while simulation.agent_count() > 0 and simulation.iteration_count() < 7000:
simulation.iterate(25) #Do 25 iterations, i.e. 25 * 10ms -> 250ms
for a in simulation.agents():
a.model.v0 = random.uniform(0.3,0.9) #Sets v0 (i.e. free flow speed, to a value in range [0.3, 0.9] |
Beta Was this translation helpful? Give feedback.
Hi @K99-JDG I cannot see any updates to agent speed during the simulation in the code you attached.
Let me explain:
In your 4th cell in the notebook you create multiple simulations and specify the initial conditions for your agents, some (in the hallway, I guess) are assigned the speed of 1.2 m/s while others (in the room to the right) are assigned 0 m/s, i.e. remain stationary.
All of what you do here is setting initial conditions.
The actual simulations are executed later in the 7th cell, i.e.:
The code above is correct in the sense that it runs the simulation to completion or at most 70…