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
5a867edf
Commit
5a867edf
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
added safety breaks in loops to prevent infinite loops.
parent
6bb57805
No related branches found
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
+9
-8
9 additions, 8 deletions
examples/flatland_2_0_example.py
tests/test_flatland_env_sparse_rail_generator.py
+2
-1
2 additions, 1 deletion
tests/test_flatland_env_sparse_rail_generator.py
with
11 additions
and
9 deletions
examples/flatland_2_0_example.py
+
9
−
8
View file @
5a867edf
...
@@ -19,15 +19,16 @@ stochastic_data = {'prop_malfunction': 0.5, # Percentage of defective agents
...
@@ -19,15 +19,16 @@ stochastic_data = {'prop_malfunction': 0.5, # Percentage of defective agents
}
}
TreeObservation
=
TreeObsForRailEnv
(
max_depth
=
2
,
predictor
=
ShortestPathPredictorForRailEnv
())
TreeObservation
=
TreeObsForRailEnv
(
max_depth
=
2
,
predictor
=
ShortestPathPredictorForRailEnv
())
env
=
RailEnv
(
width
=
1
0
,
env
=
RailEnv
(
width
=
2
0
,
height
=
1
0
,
height
=
2
0
,
rail_generator
=
sparse_rail_generator
(
num_cities
=
3
,
# Number of cities in map (where train stations are)
rail_generator
=
sparse_rail_generator
(
num_cities
=
5
,
# Number of cities in map (where train stations are)
num_intersections
=
1
,
# Number of interesections (no start / target)
num_intersections
=
4
,
# Number of interesections (no start / target)
num_trainstations
=
8
,
# Number of possible start/targets on map
num_trainstations
=
15
,
# Number of possible start/targets on map
min_node_dist
=
3
,
# Minimal distance of nodes
min_node_dist
=
3
,
# Minimal distance of nodes
node_radius
=
2
,
# Proximity of stations to city center
node_radius
=
3
,
# Proximity of stations to city center
num_neighb
=
2
,
# Number of connections to other cities/intersections
num_neighb
=
3
,
# Number of connections to other cities/intersections
seed
=
15
,
# Random seed
seed
=
15
,
# Random seed
realistic_mode
=
True
),
),
number_of_agents
=
5
,
number_of_agents
=
5
,
stochastic_data
=
stochastic_data
,
# Malfunction generator data
stochastic_data
=
stochastic_data
,
# Malfunction generator data
...
@@ -86,7 +87,7 @@ for trials in range(1, n_trials + 1):
...
@@ -86,7 +87,7 @@ for trials in range(1, n_trials + 1):
obs
=
env
.
reset
()
obs
=
env
.
reset
()
for
idx
in
range
(
env
.
get_num_agents
()):
for
idx
in
range
(
env
.
get_num_agents
()):
tmp_agent
=
env
.
agents
[
idx
]
tmp_agent
=
env
.
agents
[
idx
]
speed
=
(
idx
%
4
)
+
1
speed
=
(
idx
%
5
)
+
1
tmp_agent
.
speed_data
[
"
speed
"
]
=
1
/
speed
tmp_agent
.
speed_data
[
"
speed
"
]
=
1
/
speed
env_renderer
.
reset
()
env_renderer
.
reset
()
# Here you can also further enhance the provided observation by means of normalization
# Here you can also further enhance the provided observation by means of normalization
...
...
This diff is collapsed.
Click to expand it.
tests/test_flatland_env_sparse_rail_generator.py
+
2
−
1
View file @
5a867edf
...
@@ -42,10 +42,11 @@ def test_sparse_rail_generator():
...
@@ -42,10 +42,11 @@ def test_sparse_rail_generator():
node_radius
=
3
,
# Proximity of stations to city center
node_radius
=
3
,
# Proximity of stations to city center
num_neighb
=
3
,
# Number of connections to other cities
num_neighb
=
3
,
# Number of connections to other cities
seed
=
5
,
# Random seed
seed
=
5
,
# Random seed
realistic_mode
=
Tru
e
# Ordered distribution of nodes
realistic_mode
=
Fals
e
# Ordered distribution of nodes
),
),
number_of_agents
=
10
,
number_of_agents
=
10
,
obs_builder_object
=
GlobalObsForRailEnv
())
obs_builder_object
=
GlobalObsForRailEnv
())
# reset to initialize agents_static
# reset to initialize agents_static
env_renderer
=
RenderTool
(
env
,
gl
=
"
PILSVG
"
,
)
env_renderer
=
RenderTool
(
env
,
gl
=
"
PILSVG
"
,
)
env_renderer
.
render_env
(
show
=
True
,
show_observations
=
True
,
show_predictions
=
False
)
env_renderer
.
render_env
(
show
=
True
,
show_observations
=
True
,
show_predictions
=
False
)
env_renderer
.
gl
.
save_image
(
"
./sparse_generator_false.png
"
)
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