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
Flatland
Flatland
Commits
979b637c
Commit
979b637c
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
minor bugfixes
parent
543a88d9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!154
147 new level generator
Pipeline
#1751
failed
5 years ago
Stage: tests
Stage: integration_testing
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/flatland_2_0_example.py
+13
-12
13 additions, 12 deletions
examples/flatland_2_0_example.py
flatland/envs/generators.py
+2
-3
2 additions, 3 deletions
flatland/envs/generators.py
with
15 additions
and
15 deletions
examples/flatland_2_0_example.py
+
13
−
12
View file @
979b637c
...
...
@@ -12,24 +12,25 @@ np.random.seed(1)
# Training on simple small tasks is the best way to get familiar with the environment
# Use a the malfunction generator to break agents from time to time
stochastic_data
=
{
'
prop_malfunction
'
:
0.5
,
'
malfunction_rate
'
:
30
,
'
min_duration
'
:
3
,
'
max_duration
'
:
10
}
stochastic_data
=
{
'
prop_malfunction
'
:
0.5
,
# Percentage of defective agents
'
malfunction_rate
'
:
30
,
# Rate of malfunction occurence
'
min_duration
'
:
3
,
# Minimal duration of malfunction
'
max_duration
'
:
10
# Max duration of malfunction
}
TreeObservation
=
TreeObsForRailEnv
(
max_depth
=
2
,
predictor
=
ShortestPathPredictorForRailEnv
())
env
=
RailEnv
(
width
=
5
0
,
height
=
5
0
,
rail_generator
=
sparse_rail_generator
(
num_cities
=
10
,
# Number of cities in map
num_intersections
=
3
,
# Number of interesections in map
num_trainstations
=
40
,
# Number of possible start/targets on map
min_node_dist
=
10
,
# Minimal distance of nodes
env
=
RailEnv
(
width
=
1
0
,
height
=
1
0
,
rail_generator
=
sparse_rail_generator
(
num_cities
=
3
,
# Number of cities in map
num_intersections
=
1
,
# Number of interesections in map
num_trainstations
=
8
,
# 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
=
4
,
# Number of connections to other cities
num_neighb
=
2
,
# Number of connections to other cities
seed
=
15
,
# Random seed
),
number_of_agents
=
10
,
number_of_agents
=
5
,
stochastic_data
=
stochastic_data
,
# Malfunction generator data
obs_builder_object
=
TreeObservation
)
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/generators.py
+
2
−
3
View file @
979b637c
...
...
@@ -875,7 +875,7 @@ def sparse_rail_generator(num_cities=100, num_intersections=10, num_trainstation
# Set number of neighboring nodes
if
len
(
available_nodes
)
>=
num_neighb
:
connected_neighb_idx
=
available_nodes
[
0
:
2
]
# np.random.choice(available_nodes, num_neighb, replace=False)
0
:
num_neighb
]
# np.random.choice(available_nodes, num_neighb, replace=False)
else
:
connected_neighb_idx
=
available_nodes
...
...
@@ -885,10 +885,8 @@ def sparse_rail_generator(num_cities=100, num_intersections=10, num_trainstation
node_stack
.
append
(
neighb
)
connect_nodes
(
rail_trans
,
rail_array
,
node_positions
[
current_node
],
node_positions
[
neighb
])
node_stack
.
pop
(
0
)
# Place train stations close to the node
# We currently place them uniformly distirbuted among all cities
train_stations
=
[[]
for
i
in
range
(
num_cities
)]
for
station
in
range
(
num_trainstations
):
...
...
@@ -940,6 +938,7 @@ def sparse_rail_generator(num_cities=100, num_intersections=10, num_trainstation
tries
+=
1
# Test again with new start node if no pair is found (This code needs to be improved)
if
tries
>
10
:
break
start_node
=
np
.
random
.
choice
(
avail_start_nodes
)
node_available_start
[
start_node
]
-=
1
...
...
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