Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yoogottamk
Flatland
Commits
f33ca157
Commit
f33ca157
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
limiting number of connections between cities not to be more then number of tracks internally
parent
4dc054cf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/flatland_2_0_example.py
+1
-1
1 addition, 1 deletion
examples/flatland_2_0_example.py
flatland/envs/rail_generators.py
+6
-4
6 additions, 4 deletions
flatland/envs/rail_generators.py
with
7 additions
and
5 deletions
examples/flatland_2_0_example.py
+
1
−
1
View file @
f33ca157
...
@@ -38,7 +38,7 @@ env = RailEnv(width=50,
...
@@ -38,7 +38,7 @@ env = RailEnv(width=50,
seed
=
0
,
# Random seed
seed
=
0
,
# Random seed
grid_mode
=
False
,
grid_mode
=
False
,
max_inter_city_rails
=
2
,
max_inter_city_rails
=
2
,
tracks_in_city
=
5
0
,
tracks_in_city
=
5
,
),
),
schedule_generator
=
sparse_schedule_generator
(),
schedule_generator
=
sparse_schedule_generator
(),
number_of_agents
=
50
,
number_of_agents
=
50
,
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/rail_generators.py
+
6
−
4
View file @
f33ca157
...
@@ -558,7 +558,9 @@ def sparse_rail_generator(num_cities=5, min_node_dist=20, node_radius=2,
...
@@ -558,7 +558,9 @@ def sparse_rail_generator(num_cities=5, min_node_dist=20, node_radius=2,
rail_array
=
grid_map
.
grid
rail_array
=
grid_map
.
grid
rail_array
.
fill
(
0
)
rail_array
.
fill
(
0
)
np
.
random
.
seed
(
seed
+
num_resets
)
np
.
random
.
seed
(
seed
+
num_resets
)
max_inter_city_rails_allowed
=
max_inter_city_rails
if
max_inter_city_rails_allowed
>
tracks_in_city
:
max_inter_city_rails_allowed
=
tracks_in_city
# Generate a set of nodes for the sparse network
# Generate a set of nodes for the sparse network
# Try to connect cities to nodes first
# Try to connect cities to nodes first
city_positions
=
[]
city_positions
=
[]
...
@@ -581,7 +583,7 @@ def sparse_rail_generator(num_cities=5, min_node_dist=20, node_radius=2,
...
@@ -581,7 +583,7 @@ def sparse_rail_generator(num_cities=5, min_node_dist=20, node_radius=2,
# Connect the cities through the connection points
# Connect the cities through the connection points
outer_connection_points
=
_connect_cities
(
node_positions
,
connection_points
,
connection_info
,
city_cells
,
outer_connection_points
=
_connect_cities
(
node_positions
,
connection_points
,
connection_info
,
city_cells
,
max_inter_city_rails
,
max_inter_city_rails
_allowed
,
rail_trans
,
grid_map
)
rail_trans
,
grid_map
)
# Build inner cities
# Build inner cities
...
@@ -705,7 +707,7 @@ def sparse_rail_generator(num_cities=5, min_node_dist=20, node_radius=2,
...
@@ -705,7 +707,7 @@ def sparse_rail_generator(num_cities=5, min_node_dist=20, node_radius=2,
connection_info
.
append
(
connections_per_direction
)
connection_info
.
append
(
connections_per_direction
)
return
connection_points
,
connection_info
return
connection_points
,
connection_info
def
_connect_cities
(
node_positions
,
connection_points
,
connection_info
,
city_cells
,
max_inter_city_rails
,
def
_connect_cities
(
node_positions
,
connection_points
,
connection_info
,
city_cells
,
max_inter_city_rails
_allowed
,
rail_trans
,
grid_map
):
rail_trans
,
grid_map
):
"""
"""
Function to connect the different cities through their connection points
Function to connect the different cities through their connection points
...
@@ -739,7 +741,7 @@ def sparse_rail_generator(num_cities=5, min_node_dist=20, node_radius=2,
...
@@ -739,7 +741,7 @@ def sparse_rail_generator(num_cities=5, min_node_dist=20, node_radius=2,
neighb_idx
=
neighbours
[
i
]
neighb_idx
=
neighbours
[
i
]
connected_to_city
.
append
(
neighb_idx
)
connected_to_city
.
append
(
neighb_idx
)
number_of_out_rails
=
np
.
random
.
randint
(
1
,
max_inter_city_rails
+
1
)
number_of_out_rails
=
np
.
random
.
randint
(
1
,
max_inter_city_rails
_allowed
+
1
)
for
tmp_out_connection_point
in
connection_points
[
current_node
][
direction
][:
number_of_out_rails
]:
for
tmp_out_connection_point
in
connection_points
[
current_node
][
direction
][:
number_of_out_rails
]:
# Find closest connection point
# Find closest connection point
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment