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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
elrichgro
Flatland
Commits
014f2d74
Commit
014f2d74
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
priority to connect to intersection instead of other city.
minor bug fixes in node connecting algorithm
parent
d3657c20
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
flatland/envs/generators.py
+6
-0
6 additions, 0 deletions
flatland/envs/generators.py
tests/test_flatland_env_sparse_rail_generator.py
+3
-3
3 additions, 3 deletions
tests/test_flatland_env_sparse_rail_generator.py
with
9 additions
and
3 deletions
flatland/envs/generators.py
+
6
−
0
View file @
014f2d74
...
...
@@ -874,11 +874,16 @@ def sparse_rail_generator(num_cities=100, num_intersections=10, num_trainstation
current_node
=
node_stack
[
0
]
delete_idx
=
np
.
where
(
available_nodes_full
==
current_node
)
available_nodes_full
=
np
.
delete
(
available_nodes_full
,
delete_idx
,
0
)
if
current_node
<
num_cities
and
len
(
available_intersections
)
>
0
:
available_nodes
=
available_intersections
delete_idx
=
np
.
where
(
available_cities
==
current_node
)
available_cities
=
np
.
delete
(
available_cities
,
delete_idx
,
0
)
elif
len
(
available_intersections
)
>
0
:
available_nodes
=
available_cities
delete_idx
=
np
.
where
(
available_intersections
==
current_node
)
available_intersections
=
np
.
delete
(
available_intersections
,
delete_idx
,
0
)
else
:
available_nodes
=
available_nodes_full
...
...
@@ -892,6 +897,7 @@ def sparse_rail_generator(num_cities=100, num_intersections=10, num_trainstation
if
len
(
available_nodes
)
>=
num_neighb
:
connected_neighb_idx
=
available_nodes
[
0
:
num_neighb
]
# np.random.choice(available_nodes, num_neighb, replace=False)
print
(
current_node
,
"
-->
"
,
connected_neighb_idx
)
else
:
connected_neighb_idx
=
available_nodes
...
...
This diff is collapsed.
Click to expand it.
tests/test_flatland_env_sparse_rail_generator.py
+
3
−
3
View file @
014f2d74
...
...
@@ -30,12 +30,12 @@ def test_sparse_rail_generator():
num_trainstations
=
10
,
# Number of possible start/targets on map
min_node_dist
=
10
,
# Minimal distance of nodes
node_radius
=
2
,
# Proximity of stations to city center
num_neighb
=
2
,
# Number of connections to other cities
seed
=
1
5
,
# Random seed
num_neighb
=
1
,
# Number of connections to other cities
seed
=
5
,
# Random seed
),
number_of_agents
=
0
,
obs_builder_object
=
GlobalObsForRailEnv
())
# reset to initialize agents_static
env_renderer
=
RenderTool
(
env
,
gl
=
"
PILSVG
"
,
)
env_renderer
.
render_env
(
show
=
True
,
show_observations
=
True
,
show_predictions
=
False
)
time
.
sleep
(
5
)
time
.
sleep
(
19
)
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