From 2d7e08dd3abe97ee4245e9b3c643b2b2bd73578b Mon Sep 17 00:00:00 2001 From: Erik Nygren <erik.nygren@sbb.ch> Date: Sun, 1 Sep 2019 07:37:48 -0400 Subject: [PATCH] renaming --- docs/flatland_2.0.md | 12 ++++++------ examples/flatland_2_0_example.py | 6 +++--- flatland/envs/rail_generators.py | 8 ++++---- tests/test_flatland_envs_sparse_rail_generator.py | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/flatland_2.0.md b/docs/flatland_2.0.md index 0ed2f1bd..03c1ff39 100644 --- a/docs/flatland_2.0.md +++ b/docs/flatland_2.0.md @@ -43,7 +43,7 @@ RailGenerator = sparse_rail_generator(num_cities=10, # Nu node_radius=3, # Proximity of stations to city center num_neighb=3, # Number of connections to other cities seed=5, # Random seed - realistic_mode=True # Ordered distribution of nodes + grid_mode=True # Ordered distribution of nodes ) # Build the environment @@ -57,22 +57,22 @@ env = RailEnv(width=50, You can tune the following parameters: -- `num_citeis` is the number of cities on a map. Cities are the only nodes that can host start and end points for agent tasks (Train stations). Here you have to be carefull that the number is not too high as all the cities have to fit on the map. When `realistic_mode=False` you have to be carefull when chosing `min_node_dist` because leves will fails if not all cities (and intersections) can be placed with at least `min_node_dist` between them. +- `num_citeis` is the number of cities on a map. Cities are the only nodes that can host start and end points for agent tasks (Train stations). Here you have to be carefull that the number is not too high as all the cities have to fit on the map. When `grid_mode=False` you have to be carefull when chosing `min_node_dist` because leves will fails if not all cities (and intersections) can be placed with at least `min_node_dist` between them. - `num_intersections` is the number of nodes that don't hold any trainstations. They are also the first priority that a city connects to. We use these to allow for sparse connections between cities. - `num_trainstations`defines the *Total* number of trainstations in the network. This also sets the max number of allowed agents in the environment. This is also a delicate parameter as there is only a limitid amount of space available around nodes and thus if the number is too high the level generation will fail. *Important*: Only the number of agents provided to the environment will actually produce active train stations. The others will just be present as dead-ends (See figures below). -- `min_node_dist`is only used if `realistic_mode=False` and represents the minimal distance between two nodes. +- `min_node_dist`is only used if `grid_mode=False` and represents the minimal distance between two nodes. - `node_radius` defines the extent of a city. Each trainstation is placed at a distance to the closes city node that is smaller or equal to this number. - `num_neighb`defines the number of neighbouring nodes that connect to each other. Thus this changes the connectivity and thus the amount of alternative routes in the network. - `seed` is used to initialize the random generator -- `realistic_mode` currently only changes how the nodes are distirbuted. If it is set to `True` the nodes are evenly spreas out and cities and intersecitons are set between each other. +- `grid_mode` currently only changes how the nodes are distirbuted. If it is set to `True` the nodes are evenly spreas out and cities and intersecitons are set between each other. If you run into any bugs with sets of parameters please let us know. -Here is a network with `realistic_mode=False` and the parameters from above. +Here is a network with `grid_mode=False` and the parameters from above.  -and here with `realistic_mode=True` +and here with `grid_mode=True`  diff --git a/examples/flatland_2_0_example.py b/examples/flatland_2_0_example.py index 1a18cb40..f8a61377 100644 --- a/examples/flatland_2_0_example.py +++ b/examples/flatland_2_0_example.py @@ -34,16 +34,16 @@ env = RailEnv(width=50, height=50, rail_generator=sparse_rail_generator(num_cities=25, # Number of cities in map (where train stations are) num_intersections=0, # Number of intersections (no start / target) - num_trainstations=0, # Number of possible start/targets on map + num_trainstations=50, # Number of possible start/targets on map min_node_dist=3, # Minimal distance of nodes node_radius=2, # Proximity of stations to city center num_neighb=3, # Number of connections to other cities/intersections seed=15, # Random seed - realistic_mode=True, + grid_mode=True, enhance_intersection=False ), schedule_generator=sparse_schedule_generator(speed_ration_map), - number_of_agents=0, + number_of_agents=20, stochastic_data=stochastic_data, # Malfunction data generator obs_builder_object=TreeObservation) diff --git a/flatland/envs/rail_generators.py b/flatland/envs/rail_generators.py index 93e7ce55..39796515 100644 --- a/flatland/envs/rail_generators.py +++ b/flatland/envs/rail_generators.py @@ -527,7 +527,7 @@ def random_rail_generator(cell_type_relative_proportion=[1.0] * 11) -> RailGener def sparse_rail_generator(num_cities=5, num_intersections=4, num_trainstations=2, min_node_dist=20, node_radius=2, - num_neighb=3, realistic_mode=False, enhance_intersection=False, seed=0): + num_neighb=3, grid_mode=False, enhance_intersection=False, seed=0): """ This is a level generator which generates complex sparse rail configurations @@ -537,7 +537,7 @@ def sparse_rail_generator(num_cities=5, num_intersections=4, num_trainstations=2 :param min_node_dist: Minimal distance between nodes :param node_radius: Proximity of trainstations to center of city node :param num_neighb: Number of neighbouring nodes each node connects to - :param realistic_mode: True -> NOdes evenly distirbuted in env, False-> Random distribution of nodes + :param grid_mode: True -> NOdes evenly distirbuted in env, False-> Random distribution of nodes :param enhance_intersection: True -> Extra rail elements added at intersections :param seed: Random Seed :return: @@ -565,7 +565,7 @@ def sparse_rail_generator(num_cities=5, num_intersections=4, num_trainstations=2 intersection_positions = [] # Evenly distribute cities and intersections - if realistic_mode: + if grid_mode: tot_num_node = num_intersections + num_cities nodes_ratio = height / width nodes_per_row = int(np.ceil(np.sqrt(tot_num_node * nodes_ratio))) @@ -581,7 +581,7 @@ def sparse_rail_generator(num_cities=5, num_intersections=4, num_trainstations=2 to_close = True tries = 0 - if not realistic_mode: + if not grid_mode: while to_close: x_tmp = node_radius + np.random.randint(height - node_radius) y_tmp = node_radius + np.random.randint(width - node_radius) diff --git a/tests/test_flatland_envs_sparse_rail_generator.py b/tests/test_flatland_envs_sparse_rail_generator.py index db7cac61..c60d5062 100644 --- a/tests/test_flatland_envs_sparse_rail_generator.py +++ b/tests/test_flatland_envs_sparse_rail_generator.py @@ -15,7 +15,7 @@ def test_sparse_rail_generator(): node_radius=3, # Proximity of stations to city center num_neighb=3, # Number of connections to other cities seed=5, # Random seed - realistic_mode=False # Ordered distribution of nodes + grid_mode=False # Ordered distribution of nodes ), schedule_generator=sparse_schedule_generator(), number_of_agents=10, -- GitLab