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
b4a27625
"README.md" did not exist on "8d88ac276aa4258667a01df07c87229c5e68c7f1"
Commit
b4a27625
authored
5 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
readability
parent
04bede79
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/envs/rail_generators_city_generator.py
+17
-21
17 additions, 21 deletions
flatland/envs/rail_generators_city_generator.py
with
17 additions
and
21 deletions
flatland/envs/rail_generators_city_generator.py
+
17
−
21
View file @
b4a27625
...
@@ -84,7 +84,7 @@ def city_generator(num_cities: int = 5,
...
@@ -84,7 +84,7 @@ def city_generator(num_cities: int = 5,
# noinspection PyTypeChecker
# noinspection PyTypeChecker
def
create_stations_from_city_locations
(
rail_trans
:
RailEnvTransitions
,
def
create_stations_from_city_locations
(
rail_trans
:
RailEnvTransitions
,
grid_map
:
GridTransitionMap
,
grid_map
:
GridTransitionMap
,
generate_city_locations
:
IntVector2DArray
,
generate_city_locations
:
IntVector2DArray
Array
,
intern_max_number_of_station_tracks
:
int
)
->
(
IntVector2DArray
,
intern_max_number_of_station_tracks
:
int
)
->
(
IntVector2DArray
,
IntVector2DArray
,
IntVector2DArray
,
IntVector2DArray
,
IntVector2DArray
,
...
@@ -144,7 +144,7 @@ def city_generator(num_cities: int = 5,
...
@@ -144,7 +144,7 @@ def city_generator(num_cities: int = 5,
# noinspection PyTypeChecker
# noinspection PyTypeChecker
def
create_switches_at_stations
(
rail_trans
:
RailEnvTransitions
,
def
create_switches_at_stations
(
rail_trans
:
RailEnvTransitions
,
grid_map
:
GridTransitionMap
,
grid_map
:
GridTransitionMap
,
station_tracks
:
IntVector2DArray
,
station_tracks
:
IntVector2DArray
Array
,
nodes_added
:
IntVector2DArray
,
nodes_added
:
IntVector2DArray
,
intern_nbr_of_switches_per_station_track
:
int
)
->
IntVector2DArray
:
intern_nbr_of_switches_per_station_track
:
int
)
->
IntVector2DArray
:
...
@@ -429,44 +429,40 @@ def city_generator(num_cities: int = 5,
...
@@ -429,44 +429,40 @@ def city_generator(num_cities: int = 5,
# ----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------
# generate city topology
# generate city topology
nodes_added
,
train_stations
,
s_nodes
,
e_nodes
,
station_tracks
=
\
nodes_added
,
train_stations
_slots
,
s_nodes
,
e_nodes
,
station_tracks
=
\
create_stations_from_city_locations
(
rail_trans
,
grid_map
,
create_stations_from_city_locations
(
rail_trans
,
grid_map
,
generate_city_locations
,
generate_city_locations
,
intern_max_number_of_station_tracks
)
intern_max_number_of_station_tracks
)
# build switches
# build switches
# TODO remove true/false block
create_switches_at_stations
(
rail_trans
,
grid_map
,
station_tracks
,
nodes_added
,
if
True
:
intern_nbr_of_switches_per_station_track
)
create_switches_at_stations
(
rail_trans
,
grid_map
,
station_tracks
,
nodes_added
,
intern_nbr_of_switches_per_station_track
)
# ----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------
# connect stations
# connect stations
# TODO remove true/false block
if
do_random_connect_stations
:
if
True
:
connect_random_stations
(
rail_trans
,
grid_map
,
s_nodes
,
e_nodes
,
nodes_added
,
if
do_random_connect_stations
:
intern_connect_max_nbr_of_shortes_city
)
connect_random_stations
(
rail_trans
,
grid_map
,
s_nodes
,
e_nodes
,
nodes_added
,
else
:
intern_connect_max_nbr_of_shortes_city
)
connect_stations
(
rail_trans
,
grid_map
,
s_nodes
,
e_nodes
,
nodes_added
,
else
:
intern_connect_max_nbr_of_shortes_city
)
connect_stations
(
rail_trans
,
grid_map
,
s_nodes
,
e_nodes
,
nodes_added
,
intern_connect_max_nbr_of_shortes_city
)
# ----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------
# fix all transition at starting / ending points (mostly add a dead end, if missing)
# fix all transition at starting / ending points (mostly add a dead end, if missing)
# TODO
i would lik
e to remove the fixing stuff
.
# TODO
we might hav
e to remove the fixing stuff
in the future
for
i
in
range
(
len
(
nodes_added
)):
for
i
in
range
(
len
(
nodes_added
)):
grid_map
.
fix_transitions
(
nodes_added
[
i
])
grid_map
.
fix_transitions
(
nodes_added
[
i
])
# ----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------
# remove stations where rail is a switch
# remove stations where
underlaying
rail is a switch
remove_switch_stations
(
rail_trans
,
grid_map
,
train_stations
)
remove_switch_stations
(
rail_trans
,
grid_map
,
train_stations
_slots
)
# ----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------
# Slot availability in node
# Slot availability in node
node_available_start
=
[]
node_available_start
=
[]
node_available_target
=
[]
node_available_target
=
[]
for
node_idx
in
range
(
max_num_cities
):
for
node_idx
in
range
(
max_num_cities
):
node_available_start
.
append
(
len
(
train_stations
[
node_idx
]))
node_available_start
.
append
(
len
(
train_stations
_slots
[
node_idx
]))
node_available_target
.
append
(
len
(
train_stations
[
node_idx
]))
node_available_target
.
append
(
len
(
train_stations
_slots
[
node_idx
]))
# Assign agents to slots
# Assign agents to slots
for
agent_idx
in
range
(
num_agents
):
for
agent_idx
in
range
(
num_agents
):
...
@@ -499,7 +495,7 @@ def city_generator(num_cities: int = 5,
...
@@ -499,7 +495,7 @@ def city_generator(num_cities: int = 5,
return
grid_map
,
{
'
agents_hints
'
:
{
return
grid_map
,
{
'
agents_hints
'
:
{
'
num_agents
'
:
num_agents
,
'
num_agents
'
:
num_agents
,
'
agent_start_targets_nodes
'
:
agent_start_targets_nodes
,
'
agent_start_targets_nodes
'
:
agent_start_targets_nodes
,
'
train_stations
'
:
train_stations
'
train_stations
'
:
train_stations
_slots
}}
}}
return
generator
return
generator
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