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
99ef2d00
Commit
99ef2d00
authored
5 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
shortest path filtering for agent.handle
parent
0ace6d70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/envs/rail_env_shortest_paths.py
+9
-4
9 additions, 4 deletions
flatland/envs/rail_env_shortest_paths.py
with
9 additions
and
4 deletions
flatland/envs/rail_env_shortest_paths.py
+
9
−
4
View file @
99ef2d00
...
...
@@ -72,7 +72,7 @@ def get_valid_move_actions_(agent_direction: Grid4TransitionsEnum,
# N.B. get_shortest_paths is not part of distance_map since it refers to RailEnvActions (would lead to circularity!)
def
get_shortest_paths
(
distance_map
:
DistanceMap
,
max_depth
:
Optional
[
int
]
=
None
)
\
def
get_shortest_paths
(
distance_map
:
DistanceMap
,
max_depth
:
Optional
[
int
]
=
None
,
agent_handle
:
Optional
[
int
]
=
None
)
\
->
Dict
[
int
,
Optional
[
List
[
WalkingElement
]]]:
"""
Computes the shortest path for each agent to its target and the action to be taken to do so.
...
...
@@ -83,7 +83,9 @@ def get_shortest_paths(distance_map: DistanceMap, max_depth: Optional[int] = Non
Parameters
----------
distance_map
distance_map : reference to the distance_map
max_depth : max path length, if the shortest path is longer, it will be cutted
agent_handle : if set, the shortest for agent.handle will be returned , otherwise for all agents
Returns
-------
...
...
@@ -133,8 +135,11 @@ def get_shortest_paths(distance_map: DistanceMap, max_depth: Optional[int] = Non
WalkingElement
(
position
,
direction
,
RailEnvNextAction
(
RailEnvActions
.
STOP_MOVING
,
position
,
direction
)))
for
agent
in
distance_map
.
agents
:
_shortest_path_for_agent
(
agent
)
if
agent_handle
is
not
None
:
_shortest_path_for_agent
(
distance_map
.
agents
[
agent_handle
])
else
:
for
agent
in
distance_map
.
agents
:
_shortest_path_for_agent
(
agent
)
return
shortest_paths
...
...
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