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
pranjal_dhole
Flatland
Commits
50d67dce
Commit
50d67dce
authored
4 years ago
by
hagrid67
Browse files
Options
Downloads
Patches
Plain Diff
cleaned up agent_close_following notebook, added an assert on frozen agent states
parent
ff1a2416
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
flatland/envs/agent_chains.py
+8
-2
8 additions, 2 deletions
flatland/envs/agent_chains.py
flatland/utils/jupyter_utils.py
+16
-7
16 additions, 7 deletions
flatland/utils/jupyter_utils.py
notebooks/Agent-Close-Following.ipynb
+2940
-35
2940 additions, 35 deletions
notebooks/Agent-Close-Following.ipynb
with
2964 additions
and
44 deletions
flatland/envs/agent_chains.py
+
8
−
2
View file @
50d67dce
...
@@ -4,6 +4,7 @@ import numpy as np
...
@@ -4,6 +4,7 @@ import numpy as np
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
from
typing
import
List
,
Tuple
from
typing
import
List
,
Tuple
import
graphviz
as
gv
class
MotionCheck
(
object
):
class
MotionCheck
(
object
):
"""
Class to find chains of agents which are
"
colliding
"
with a stopped agent.
"""
Class to find chains of agents which are
"
colliding
"
with a stopped agent.
...
@@ -180,10 +181,15 @@ class MotionCheck(object):
...
@@ -180,10 +181,15 @@ class MotionCheck(object):
def
render
(
omc
:
MotionCheck
):
def
render
(
omc
:
MotionCheck
,
horizontal
=
True
):
oAG
=
nx
.
drawing
.
nx_agraph
.
to_agraph
(
omc
.
G
)
oAG
=
nx
.
drawing
.
nx_agraph
.
to_agraph
(
omc
.
G
)
oAG
.
layout
(
"
dot
"
)
oAG
.
layout
(
"
dot
"
)
return
oAG
.
draw
(
format
=
"
png
"
)
sDot
=
oAG
.
to_string
()
if
horizontal
:
sDot
=
sDot
.
replace
(
'
{
'
,
'
{ rankdir=
"
LR
"
'
)
#return oAG.draw(format="png")
# This returns a graphviz object which implements __repr_svg
return
gv
.
Source
(
sDot
)
class
ChainTestEnv
(
object
):
class
ChainTestEnv
(
object
):
"""
Just for testing agent chains
"""
Just for testing agent chains
...
...
This diff is collapsed.
Click to expand it.
flatland/utils/jupyter_utils.py
+
16
−
7
View file @
50d67dce
...
@@ -19,30 +19,39 @@ from flatland.utils import env_edit_utils as eeu
...
@@ -19,30 +19,39 @@ from flatland.utils import env_edit_utils as eeu
class
Behaviour
():
class
Behaviour
():
def
__init__
(
self
,
env
):
def
__init__
(
self
,
env
):
self
.
env
=
env
self
.
env
=
env
self
.
nAg
=
len
(
env
.
agents
)
def
getActions
(
self
):
def
getActions
(
self
):
return
{}
return
{}
class
AlwaysForward
(
Behaviour
):
class
AlwaysForward
(
):
def
getActions
(
self
):
pass
return
{
i
:
RailEnvActions
.
MOVE_FORWARD
for
i
in
range
(
self
.
nAg
)
}
class
EnvCanvas
():
class
EnvCanvas
():
def
__init__
(
self
,
env
):
def
__init__
(
self
,
env
,
behaviour
:
Behaviour
=
None
):
self
.
env
=
env
self
.
env
=
env
self
.
iStep
=
0
if
behaviour
is
None
:
behaviour
=
AlwaysForward
(
env
)
self
.
behaviour
=
behaviour
self
.
oRT
=
RenderTool
(
env
,
show_debug
=
True
)
self
.
oRT
=
RenderTool
(
env
,
show_debug
=
True
)
self
.
render
()
self
.
oCan
=
canvas
.
Canvas
(
size
=
(
600
,
300
))
self
.
oCan
=
canvas
.
Canvas
(
size
=
(
600
,
300
))
self
.
oCan
.
put_image_data
(
self
.
oRT
.
get_image
()
)
self
.
render
()
def
render
(
self
):
def
render
(
self
):
self
.
oRT
.
render_env
(
show_rowcols
=
True
,
show_inactive_agents
=
True
,
show_observations
=
False
)
self
.
oRT
.
render_env
(
show_rowcols
=
True
,
show_inactive_agents
=
True
,
show_observations
=
False
)
self
.
oCan
.
put_image_data
(
self
.
oRT
.
get_image
())
def
step
(
self
):
dAction
=
self
.
behaviour
.
getActions
()
self
.
env
.
step
(
dAction
)
def
show
(
self
):
def
show
(
self
):
self
.
render
()
self
.
render
()
self
.
oCan
.
put_image_data
(
self
.
oRT
.
get_image
())
display
.
display
(
self
.
oCan
)
display
.
display
(
self
.
oCan
)
This diff is collapsed.
Click to expand it.
notebooks/Agent-Close-Following.ipynb
+
2940
−
35
View file @
50d67dce
source diff could not be displayed: it is too large. Options to address this:
view the blob
.
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