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

New Facts in Environment Generation #19

Open
helloKep opened this issue Dec 18, 2024 · 2 comments
Open

New Facts in Environment Generation #19

helloKep opened this issue Dec 18, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@helloKep
Copy link
Collaborator

Following our discussion from this past Monday, it will be a good idea to include additional facts in the representation of the environment:

  • speed
  • global time horizon

As ASPired Train-Setters proposed for speed, I would like to implement the fact format speed(ID,Inv), which has the ID of the train as well as its inverse speed. For example, if Train 2 has a speed of 1/3, then its fact would be speed(2,3).

We have not discussed specifics for the global time horizon, but I would like to implement the fact format global(T), which has the maximum allowable number of time steps. For example, if an environment has a global time horizon of 120 steps, then its fact would be global(120).

Input here is always welcome, but I will get to work on pushing this as soon as possible.

@helloKep helloKep added the enhancement New feature or request label Dec 18, 2024
@helloKep helloKep self-assigned this Dec 18, 2024
@helloKep
Copy link
Collaborator Author

@JonathanDrathjer Maybe your group was already aware of this, but since this is my first time working with speed, this was new to me. You, apparently, don't explicitly define the speed of each train, but rather a probability of various speeds that could be assigned to the trains, regardless of how many trains there are.

Here's an example below:

speed_ratio_map= {
        1:   0.50,
        1/2: 0.00,  
        1/3: 0.00,
        1/4: 0.50
    }

In this case, there would be a 50% chance that a train is assigned a speed of 1 and a 50% chance that a train is assigned a speed of 1/4. You can change the probabilities, but they have to add up to 1. We can see an example in the Flatland code.

Furthermore, there's some helpful information on the Speed Profiles page. There is this concept of a speed counter:

All actions chosen by the agent during its travels within a cell are ignored. Except STOP_MOVING, if stop action is provided then the agent’s speed counter is not updated.

When I read this, it sounds like you need to "spend" X number of time steps (if X is the inverse of your speed) moving through a single cell before you can reach another one. For example, if you have an inverse speed of 4, and you spend one time step moving in a cell and then pass a wait, presumably you would still owe it 3 more move actions before you could reach another cell. This would be something good to verify.

@helloKep
Copy link
Collaborator Author

Global Time Horizon

  • The documentation of the horizon can be found on Line 709 of flatland-rl/docs/specifications /railway.md, which demonstrates how the maximum number of time steps is calculated
  • The implementation can be shown here in Line 45 of flatland-rl/flatland/envs /timetable_generators.py, which indicates that we can access this information from RailEnv._max_episode_steps

After initial testing, this is what the new fact output looks like:

% height: 40, width: 40, agents: 3

global(269).

train(0). start(0,(28,25),158,n). end(0,(13,12),219). speed(0,1).

train(1). start(1,(13,11),3,n). end(1,(28,26),240). speed(1,4).

train(2). start(2,(28,25),4,s). end(2,(13,12),231). speed(2,4).

cell((0,0), 0).
cell((0,1), 0).
cell((0,2), 0).
...

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

1 participant