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
33634863
Commit
33634863
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
connection updated for disjunct nodes
parent
37a2a213
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+28
-5
28 additions, 5 deletions
flatland/envs/rail_generators.py
with
29 additions
and
6 deletions
examples/flatland_2_0_example.py
+
1
−
1
View file @
33634863
...
...
@@ -34,7 +34,7 @@ env = RailEnv(width=50,
height
=
50
,
rail_generator
=
sparse_rail_generator
(
num_cities
=
9
,
# Number of cities in map (where train stations are)
num_intersections
=
0
,
# Number of intersections (no start / target)
num_trainstations
=
5
0
,
# Number of possible start/targets on map
num_trainstations
=
1
0
,
# Number of possible start/targets on map
min_node_dist
=
3
,
# Minimal distance of nodes
node_radius
=
4
,
# Proximity of stations to city center
num_neighb
=
4
,
# Number of connections to other cities/intersections
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/rail_generators.py
+
28
−
5
View file @
33634863
...
...
@@ -667,8 +667,8 @@ def sparse_rail_generator(num_cities=5, num_intersections=4, num_trainstations=2
if
distance_on_rail
(
tmp_out_connection_point
,
neighb_connection_point
)
<
center_distance
:
i
+=
1
connect_nodes
(
rail_trans
,
grid_map
,
tmp_out_connection_point
,
neighb_connection_point
)
boarder_connections
.
add
(
tmp_out_connection_point
)
boarder_connections
.
add
(
neighb_connection_point
)
boarder_connections
.
add
(
(
tmp_out_connection_point
,
current_node
)
)
boarder_connections
.
add
(
(
neighb_connection_point
,
neighb
)
)
node_stack
.
pop
(
0
)
...
...
@@ -722,10 +722,11 @@ def sparse_rail_generator(num_cities=5, num_intersections=4, num_trainstations=2
connection_points
[
trainstation_node
][
corner_node_idx
],
(
station_x
,
station_y
))
if
len
(
connection
)
!=
0
:
if
connection_points
[
trainstation_node
][
corner_node_idx
]
in
boarder_connections
:
boarder_connections
.
remove
(
connection_points
[
trainstation_node
][
corner_node_idx
])
if
(
connection_points
[
trainstation_node
][
corner_node_idx
],
trainstation_node
)
in
boarder_connections
:
boarder_connections
.
remove
(
(
connection_points
[
trainstation_node
][
corner_node_idx
],
trainstation_node
))
grid_map
.
fix_transitions
((
station_x
,
station_y
))
# Check if connection was made
if
len
(
connection
)
==
0
:
if
len
(
train_stations
[
trainstation_node
])
>
0
:
...
...
@@ -737,8 +738,30 @@ def sparse_rail_generator(num_cities=5, num_intersections=4, num_trainstations=2
num_agents
=
built_num_trainstation
warnings
.
warn
(
"
sparse_rail_generator: num_agents > nr_start_goal, changing num_agents
"
)
# Connect all disjunct parts of the network
if
len
(
boarder_connections
)
>
0
:
to_be_deleted
=
[]
for
disjunct_node
in
boarder_connections
:
print
(
disjunct_node
)
conn
=
connect_nodes
(
rail_trans
,
grid_map
,
disjunct_node
[
0
],
train_stations
[
disjunct_node
[
1
]][
0
])
if
len
(
conn
)
>
0
:
to_be_deleted
.
append
(
disjunct_node
)
for
tbd
in
to_be_deleted
:
boarder_connections
.
remove
(
tbd
)
print
(
boarder_connections
)
# Fix all nodes with illegal transition maps
flat_trainstation_list
=
[
item
for
sublist
in
train_stations
for
item
in
sublist
]
for
cell_to_fix
in
flat_trainstation_list
:
grid_map
.
fix_transitions
(
cell_to_fix
)
grid_map
.
fix_transitions
((
station_x
,
station_y
))
flat_list
=
[
item
for
sublist
in
connection_points
for
item
in
sublist
]
for
cell_to_fix
in
flat_list
:
grid_map
.
fix_transitions
(
cell_to_fix
)
...
...
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