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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
elrichgro
Flatland
Commits
a42db14d
Commit
a42db14d
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
detecting fractional speed of agents traveling the same direction
parent
2d7e08dd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/envs/observations.py
+20
-2
20 additions, 2 deletions
flatland/envs/observations.py
with
20 additions
and
2 deletions
flatland/envs/observations.py
+
20
−
2
View file @
a42db14d
...
@@ -219,7 +219,7 @@ class TreeObsForRailEnv(ObservationBuilder):
...
@@ -219,7 +219,7 @@ class TreeObsForRailEnv(ObservationBuilder):
#1: if own target lies on the explored branch the current distance from the agent in number of cells is stored.
#1: if own target lies on the explored branch the current distance from the agent in number of cells is stored.
#2: if another agents target is detected the distance in number of cells from the agents current loca
i
ton
#2: if another agents target is detected the distance in number of cells from the agents current locat
i
on
is stored
is stored
#3: if another agent is detected the distance in number of cells from current agent position is stored.
#3: if another agent is detected the distance in number of cells from current agent position is stored.
...
@@ -246,6 +246,15 @@ class TreeObsForRailEnv(ObservationBuilder):
...
@@ -246,6 +246,15 @@ class TreeObsForRailEnv(ObservationBuilder):
(possible future use: number of other agents in other direction in this branch, ie. number of conflicts)
(possible future use: number of other agents in other direction in this branch, ie. number of conflicts)
0 = no agent present other direction than myself
0 = no agent present other direction than myself
#10: malfunctioning/blokcing agents
n = number of time steps the oberved agent remains blocked
#11: slowest observed speed of an agent in same direction
1 if no agent is observed
min_fractional speed otherwise
...
@@ -260,6 +269,10 @@ class TreeObsForRailEnv(ObservationBuilder):
...
@@ -260,6 +269,10 @@ class TreeObsForRailEnv(ObservationBuilder):
# Update local lookup table for all agents' positions
# Update local lookup table for all agents' positions
self
.
location_has_agent
=
{
tuple
(
agent
.
position
):
1
for
agent
in
self
.
env
.
agents
}
self
.
location_has_agent
=
{
tuple
(
agent
.
position
):
1
for
agent
in
self
.
env
.
agents
}
self
.
location_has_agent_direction
=
{
tuple
(
agent
.
position
):
agent
.
direction
for
agent
in
self
.
env
.
agents
}
self
.
location_has_agent_direction
=
{
tuple
(
agent
.
position
):
agent
.
direction
for
agent
in
self
.
env
.
agents
}
self
.
location_has_agent_speed
=
{
tuple
(
agent
.
position
):
agent
.
speed_data
[
'
speed
'
]
for
agent
in
self
.
env
.
agents
}
self
.
location_has_agent_malfunction
=
{
tuple
(
agent
.
position
):
agent
.
malfunction_data
[
'
malfunction
'
]
for
agent
in
self
.
env
.
agents
}
if
handle
>
len
(
self
.
env
.
agents
):
if
handle
>
len
(
self
.
env
.
agents
):
print
(
"
ERROR: obs _get - handle
"
,
handle
,
"
len(agents)
"
,
len
(
self
.
env
.
agents
))
print
(
"
ERROR: obs _get - handle
"
,
handle
,
"
len(agents)
"
,
len
(
self
.
env
.
agents
))
agent
=
self
.
env
.
agents
[
handle
]
# TODO: handle being treated as index
agent
=
self
.
env
.
agents
[
handle
]
# TODO: handle being treated as index
...
@@ -332,7 +345,8 @@ class TreeObsForRailEnv(ObservationBuilder):
...
@@ -332,7 +345,8 @@ class TreeObsForRailEnv(ObservationBuilder):
unusable_switch
=
np
.
inf
unusable_switch
=
np
.
inf
other_agent_same_direction
=
0
other_agent_same_direction
=
0
other_agent_opposite_direction
=
0
other_agent_opposite_direction
=
0
malfunctioning_agent
=
0
min_fractional_speed
=
1.
num_steps
=
1
num_steps
=
1
while
exploring
:
while
exploring
:
# #############################
# #############################
...
@@ -347,6 +361,10 @@ class TreeObsForRailEnv(ObservationBuilder):
...
@@ -347,6 +361,10 @@ class TreeObsForRailEnv(ObservationBuilder):
# Cummulate the number of agents on branch with same direction
# Cummulate the number of agents on branch with same direction
other_agent_same_direction
+=
1
other_agent_same_direction
+=
1
# Check fractional speed of agents
current_fractional_speed
=
self
.
location_has_agent_speed
[
position
]
if
current_fractional_speed
<
min_fractional_speed
:
min_fractional_speed
=
current_fractional_speed
if
self
.
location_has_agent_direction
[
position
]
!=
direction
:
if
self
.
location_has_agent_direction
[
position
]
!=
direction
:
# 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
...
...
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