flatland-rl
flatland-rl copied to clipboard
Add option to deactivate departure and arrival windows
a momentary fix works by:
def deactivate_windows(env): for agent in env.agents: agent.earliest_departure = 0 agent.latest_arrival = np.inf agent.status = TrainState.READY_TO_DEPART
usage: env = .... env.reset() deactivate_windows(env)
A cleaner solution would involve sth. like a parameter: env = RailEnv(...., include_windows=False)
and some internal logic which does not involve the arrival and departure times, and starts the agent's states in TrainState.READY_TO_DEPART
I just found out that this is not enough to reinstate the previous behaviour of flatlatland (version 2).
reason: there is a check if agent.state == TrainState.DONE and agent.arrival_time is None: ....
in the handle_done_state() method of RailEnv, where agents are removed from the environment. It seems that on the original creation of an environment and first reset, the agent.arrival_time is always None. Once the environment was run and agent reached target, agent.arrival_time is set to some integer value. Upon another reset, it maintains this value... Let's think about how to handle this.
I found out that this is not so much an issue of the reset() but of "broken references". E.g. if we do env = RailEnv(...) env.reset(...) agent = env.agents[0] now agent.arrival_time is None.
(bring agent to his target) now agent.arrival_time has some value, say 3.
if we do: env.reset(...) we now still have agent.arrival_time = 3
but env.agents[0].arrival_time is None.
So the issue lies in that our reference "agent" does not refer to env.agents[0] anymore.
My conclusion is that this is not really a bug. It might still be a possible pitfall for users.
The issue can be closed, right?
mmarti-tsch @.***> schrieb am Mi., 12. Juli 2023, 16:26:
I found out that this is not so much an issue of the reset() but of "broken references". E.g. if we do env = RailEnv(...) env.reset(...) agent = env.agents[0] now agent.arrival_time is None.
(bring agent to his target) now agent.arrival_time has some value, say 3.
if we do: env.reset(...) we now still have agent.arrival_time = 3
but env.agents[0].arrival_time is None.
So the issue lies in that our reference "agent" does not refer to env.agents[0] anymore.
My conclusion is that this is not really a bug. It might still be a possible pitfall for users.
— Reply to this email directly, view it on GitHub https://github.com/flatland-association/flatland-rl/issues/10#issuecomment-1632629794, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPQ2XS3LJJPNLSYLMLOM43XP2XX3ANCNFSM6AAAAAAXXFEAKM . You are receiving this because you are subscribed to this thread.Message ID: @.***>