Skip to content
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

Add option to deactivate departure and arrival windows #10

Open
mmarti-tsch opened this issue May 5, 2023 · 5 comments
Open

Add option to deactivate departure and arrival windows #10

mmarti-tsch opened this issue May 5, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@mmarti-tsch
Copy link
Contributor

mmarti-tsch commented May 5, 2023

No description provided.

@mmarti-tsch mmarti-tsch added the enhancement New feature or request label May 5, 2023
@mmarti-tsch
Copy link
Contributor Author

mmarti-tsch commented May 5, 2023

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)

@mmarti-tsch
Copy link
Contributor Author

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

@mmarti-tsch
Copy link
Contributor Author

mmarti-tsch commented Jun 15, 2023

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.

@mmarti-tsch
Copy link
Contributor Author

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.

@aiAdrian
Copy link
Contributor

aiAdrian commented Jul 12, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants