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
sfwatergit
Flatland
Commits
6d7fbf29
Commit
6d7fbf29
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
Minor updaes in handling the predictor.
parent
91ff7d01
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/envs/env_utils.py
+1
-1
1 addition, 1 deletion
flatland/envs/env_utils.py
flatland/envs/observations.py
+14
-4
14 additions, 4 deletions
flatland/envs/observations.py
with
15 additions
and
5 deletions
flatland/envs/env_utils.py
+
1
−
1
View file @
6d7fbf29
...
@@ -92,7 +92,7 @@ def coordinate_to_position(width, coords):
...
@@ -92,7 +92,7 @@ def coordinate_to_position(width, coords):
position
=
[]
position
=
[]
for
t
in
coords
:
for
t
in
coords
:
position
.
append
((
t
[
1
]
*
width
+
t
[
0
]))
position
.
append
((
t
[
1
]
*
width
+
t
[
0
]))
return
np
.
array
(
position
)
return
np
.
as
array
(
position
)
.
flatten
()
class
AStarNode
():
class
AStarNode
():
"""
A node class for A* Pathfinding
"""
"""
A node class for A* Pathfinding
"""
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/observations.py
+
14
−
4
View file @
6d7fbf29
...
@@ -6,6 +6,7 @@ from collections import deque
...
@@ -6,6 +6,7 @@ from collections import deque
import
numpy
as
np
import
numpy
as
np
from
flatland.core.env_observation_builder
import
ObservationBuilder
from
flatland.core.env_observation_builder
import
ObservationBuilder
from
flatland.envs.env_utils
import
coordinate_to_position
class
TreeObsForRailEnv
(
ObservationBuilder
):
class
TreeObsForRailEnv
(
ObservationBuilder
):
...
@@ -175,11 +176,17 @@ class TreeObsForRailEnv(ObservationBuilder):
...
@@ -175,11 +176,17 @@ class TreeObsForRailEnv(ObservationBuilder):
if
self
.
predictor
:
if
self
.
predictor
:
self
.
predicted_pos
=
{}
self
.
predicted_dir
=
{}
self
.
predictions
=
self
.
predictor
.
get
()
self
.
predictions
=
self
.
predictor
.
get
()
pred_pos
=
np
.
concatenate
([[
x
[:,
1
:
3
]]
for
x
in
list
(
self
.
predictions
.
values
())],
axis
=
0
)
for
t
in
range
(
len
(
self
.
predictions
[
0
])):
pred_pos
=
list
(
map
(
list
,
zip
(
*
pred_pos
)))
pos_list
=
[]
pred_dir
=
[
x
[:,
2
]
for
x
in
list
(
self
.
predictions
.
values
())]
dir_list
=
[]
for
a
in
handles
:
pos_list
.
append
(
self
.
predictions
[
a
][
t
][
1
:
3
])
dir_list
.
append
(
self
.
predictions
[
a
][
t
][
3
])
self
.
predicted_pos
.
update
({
t
:
coordinate_to_position
(
self
.
env
.
width
,
pos_list
)})
self
.
predicted_dir
.
update
({
t
:
dir_list
})
observations
=
{}
observations
=
{}
for
h
in
handles
:
for
h
in
handles
:
observations
[
h
]
=
self
.
get
(
h
)
observations
[
h
]
=
self
.
get
(
h
)
...
@@ -317,6 +324,9 @@ class TreeObsForRailEnv(ObservationBuilder):
...
@@ -317,6 +324,9 @@ class TreeObsForRailEnv(ObservationBuilder):
# Cummulate the number of agents on branch with other direction
# Cummulate the number of agents on branch with other direction
other_agent_opposite_direction
+=
1
other_agent_opposite_direction
+=
1
if
self
.
predictor
:
# Register possible conflict
if
position
in
self
.
location_has_target
:
if
position
in
self
.
location_has_target
:
if
num_steps
<
other_target_encountered
:
if
num_steps
<
other_target_encountered
:
other_target_encountered
=
num_steps
other_target_encountered
=
num_steps
...
...
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