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
de4b7206
Commit
de4b7206
authored
5 years ago
by
u229589
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring: prediction_builder knows its environment and can access the distance map directly
parent
5f4773a1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/custom_observation_example.py
+1
-1
1 addition, 1 deletion
examples/custom_observation_example.py
flatland/core/env_prediction_builder.py
+1
-1
1 addition, 1 deletion
flatland/core/env_prediction_builder.py
flatland/envs/predictions.py
+3
-8
3 additions, 8 deletions
flatland/envs/predictions.py
with
5 additions
and
10 deletions
examples/custom_observation_example.py
+
1
−
1
View file @
de4b7206
...
...
@@ -141,7 +141,7 @@ class ObservePredictions(TreeObsForRailEnv):
:return:
'''
self
.
predictions
=
self
.
predictor
.
get
(
custom_args
=
{
'
distance_map
'
:
self
.
env
.
distance_map
}
)
self
.
predictions
=
self
.
predictor
.
get
()
self
.
predicted_pos
=
{}
for
t
in
range
(
len
(
self
.
predictions
[
0
])):
...
...
This diff is collapsed.
Click to expand it.
flatland/core/env_prediction_builder.py
+
1
−
1
View file @
de4b7206
...
...
@@ -28,7 +28,7 @@ class PredictionBuilder:
"""
pass
def
get
(
self
,
custom_args
=
None
,
handle
=
0
):
def
get
(
self
,
handle
=
0
):
"""
Called whenever get_many in the observation build is called.
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/predictions.py
+
3
−
8
View file @
de4b7206
...
...
@@ -17,14 +17,12 @@ class DummyPredictorForRailEnv(PredictionBuilder):
The prediction acts as if no other agent is in the environment and always takes the forward action.
"""
def
get
(
self
,
custom_args
=
None
,
handle
=
None
):
def
get
(
self
,
handle
=
None
):
"""
Called whenever get_many in the observation build is called.
Parameters
-------
custom_args: dict
Not used in this dummy implementation.
handle : int (optional)
Handle of the agent for which to compute the observation vector.
...
...
@@ -90,15 +88,13 @@ class ShortestPathPredictorForRailEnv(PredictionBuilder):
# Initialize with depth 20
self
.
max_depth
=
max_depth
def
get
(
self
,
custom_args
=
None
,
handle
=
None
):
def
get
(
self
,
handle
=
None
):
"""
Called whenever get_many in the observation build is called.
Requires distance_map to extract the shortest path.
Parameters
-------
custom_args: dict
- distance_map : dict
handle : int (optional)
Handle of the agent for which to compute the observation vector.
...
...
@@ -116,8 +112,7 @@ class ShortestPathPredictorForRailEnv(PredictionBuilder):
agents
=
self
.
env
.
agents
if
handle
:
agents
=
[
self
.
env
.
agents
[
handle
]]
assert
custom_args
is
not
None
distance_map
=
custom_args
.
get
(
'
distance_map
'
)
distance_map
=
self
.
env
.
distance_map
assert
distance_map
is
not
None
prediction_dict
=
{}
...
...
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