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
5550d87b
Commit
5550d87b
authored
5 years ago
by
u214892
Browse files
Options
Downloads
Patches
Plain Diff
#178 bugfix initial malfunction
parent
29cc5cda
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_flatland_malfunction.py
+1
-2
1 addition, 2 deletions
tests/test_flatland_malfunction.py
tests/test_multi_speed.py
+16
-6
16 additions, 6 deletions
tests/test_multi_speed.py
with
17 additions
and
8 deletions
tests/test_flatland_malfunction.py
+
1
−
2
View file @
5550d87b
...
@@ -153,7 +153,6 @@ def test_malfunction_process_statistically():
...
@@ -153,7 +153,6 @@ def test_malfunction_process_statistically():
assert
nb_malfunction
>
150
assert
nb_malfunction
>
150
# TODO test DO_NOTHING!
def
test_initial_malfunction
(
rendering
=
True
):
def
test_initial_malfunction
(
rendering
=
True
):
random
.
seed
(
0
)
random
.
seed
(
0
)
stochastic_data
=
{
'
prop_malfunction
'
:
1.
,
# Percentage of defective agents
stochastic_data
=
{
'
prop_malfunction
'
:
1.
,
# Percentage of defective agents
...
@@ -240,7 +239,7 @@ def test_initial_malfunction(rendering=True):
...
@@ -240,7 +239,7 @@ def test_initial_malfunction(rendering=True):
_assert
(
agent
.
direction
,
replay
.
direction
,
'
direction
'
)
_assert
(
agent
.
direction
,
replay
.
direction
,
'
direction
'
)
_assert
(
agent
.
malfunction_data
[
'
malfunction
'
],
replay
.
malfunction
,
'
malfunction
'
)
_assert
(
agent
.
malfunction_data
[
'
malfunction
'
],
replay
.
malfunction
,
'
malfunction
'
)
if
replay
.
action
:
if
replay
.
action
is
not
None
:
assert
info_dict
[
'
action_required
'
][
0
]
==
True
,
"
[{}] expecting action_required={}
"
.
format
(
i
,
True
)
assert
info_dict
[
'
action_required
'
][
0
]
==
True
,
"
[{}] expecting action_required={}
"
.
format
(
i
,
True
)
_
,
_
,
_
,
info_dict
=
env
.
step
({
0
:
replay
.
action
})
_
,
_
,
_
,
info_dict
=
env
.
step
({
0
:
replay
.
action
})
...
...
This diff is collapsed.
Click to expand it.
tests/test_multi_speed.py
+
16
−
6
View file @
5550d87b
import
time
import
numpy
as
np
import
numpy
as
np
from
flatland.core.grid.grid4
import
Grid4TransitionsEnum
from
flatland.core.grid.grid4
import
Grid4TransitionsEnum
...
@@ -97,6 +95,8 @@ def test_multi_speed_init():
...
@@ -97,6 +95,8 @@ def test_multi_speed_init():
old_pos
[
i_agent
]
=
env
.
agents
[
i_agent
].
position
old_pos
[
i_agent
]
=
env
.
agents
[
i_agent
].
position
# TODO test penalties!
# TODO test invalid actions!
def
test_multispeed_actions_no_malfunction_no_blocking
(
rendering
=
True
):
def
test_multispeed_actions_no_malfunction_no_blocking
(
rendering
=
True
):
"""
Test that actions are correctly performed on cell exit for a single agent.
"""
"""
Test that actions are correctly performed on cell exit for a single agent.
"""
rail
,
rail_map
=
make_simple_rail
()
rail
,
rail_map
=
make_simple_rail
()
...
@@ -191,7 +191,6 @@ def test_multispeed_actions_no_malfunction_no_blocking(rendering=True):
...
@@ -191,7 +191,6 @@ def test_multispeed_actions_no_malfunction_no_blocking(rendering=True):
speed
=
0.5
speed
=
0.5
)
)
# TODO test penalties!
agentStatic
:
EnvAgentStatic
=
env
.
agents_static
[
0
]
agentStatic
:
EnvAgentStatic
=
env
.
agents_static
[
0
]
info_dict
=
{
info_dict
=
{
'
action_required
'
:
[
True
]
'
action_required
'
:
[
True
]
...
@@ -216,7 +215,7 @@ def test_multispeed_actions_no_malfunction_no_blocking(rendering=True):
...
@@ -216,7 +215,7 @@ def test_multispeed_actions_no_malfunction_no_blocking(rendering=True):
_assert
(
agent
.
position
,
replay
.
position
,
'
position
'
)
_assert
(
agent
.
position
,
replay
.
position
,
'
position
'
)
_assert
(
agent
.
direction
,
replay
.
direction
,
'
direction
'
)
_assert
(
agent
.
direction
,
replay
.
direction
,
'
direction
'
)
if
replay
.
action
:
if
replay
.
action
is
not
None
:
assert
info_dict
[
'
action_required
'
][
0
]
==
True
,
"
[{}] expecting action_required={}
"
.
format
(
i
,
True
)
assert
info_dict
[
'
action_required
'
][
0
]
==
True
,
"
[{}] expecting action_required={}
"
.
format
(
i
,
True
)
_
,
_
,
_
,
info_dict
=
env
.
step
({
0
:
replay
.
action
})
_
,
_
,
_
,
info_dict
=
env
.
step
({
0
:
replay
.
action
})
...
@@ -424,7 +423,7 @@ def test_multispeed_actions_no_malfunction_blocking(rendering=True):
...
@@ -424,7 +423,7 @@ def test_multispeed_actions_no_malfunction_blocking(rendering=True):
_assert
(
a
,
agent
.
position
,
replay
.
position
,
'
position
'
)
_assert
(
a
,
agent
.
position
,
replay
.
position
,
'
position
'
)
_assert
(
a
,
agent
.
direction
,
replay
.
direction
,
'
direction
'
)
_assert
(
a
,
agent
.
direction
,
replay
.
direction
,
'
direction
'
)
if
replay
.
action
:
if
replay
.
action
is
not
None
:
assert
info_dict
[
'
action_required
'
][
a
]
==
True
,
"
[{}] agent {} expecting action_required={}
"
.
format
(
assert
info_dict
[
'
action_required
'
][
a
]
==
True
,
"
[{}] agent {} expecting action_required={}
"
.
format
(
step
,
a
,
True
)
step
,
a
,
True
)
action_dict
[
a
]
=
replay
.
action
action_dict
[
a
]
=
replay
.
action
...
@@ -534,9 +533,20 @@ def test_multispeed_actions_malfunction_no_blocking(rendering=True):
...
@@ -534,9 +533,20 @@ def test_multispeed_actions_malfunction_no_blocking(rendering=True):
direction
=
Grid4TransitionsEnum
.
SOUTH
,
direction
=
Grid4TransitionsEnum
.
SOUTH
,
action
=
None
action
=
None
),
),
# DO_NOTHING keeps moving!
Replay
(
position
=
(
5
,
6
),
direction
=
Grid4TransitionsEnum
.
SOUTH
,
action
=
RailEnvActions
.
DO_NOTHING
),
Replay
(
Replay
(
position
=
(
5
,
6
),
position
=
(
5
,
6
),
direction
=
Grid4TransitionsEnum
.
SOUTH
,
direction
=
Grid4TransitionsEnum
.
SOUTH
,
action
=
None
),
Replay
(
position
=
(
6
,
6
),
direction
=
Grid4TransitionsEnum
.
SOUTH
,
action
=
RailEnvActions
.
MOVE_FORWARD
action
=
RailEnvActions
.
MOVE_FORWARD
),
),
...
@@ -573,7 +583,7 @@ def test_multispeed_actions_malfunction_no_blocking(rendering=True):
...
@@ -573,7 +583,7 @@ def test_multispeed_actions_malfunction_no_blocking(rendering=True):
if
replay
.
malfunction
:
if
replay
.
malfunction
:
agent
.
malfunction_data
[
'
malfunction
'
]
=
2
agent
.
malfunction_data
[
'
malfunction
'
]
=
2
if
replay
.
action
:
if
replay
.
action
is
not
None
:
assert
info_dict
[
'
action_required
'
][
0
]
==
True
,
"
[{}] expecting action_required={}
"
.
format
(
i
,
True
)
assert
info_dict
[
'
action_required
'
][
0
]
==
True
,
"
[{}] expecting action_required={}
"
.
format
(
i
,
True
)
_
,
_
,
_
,
info_dict
=
env
.
step
({
0
:
replay
.
action
})
_
,
_
,
_
,
info_dict
=
env
.
step
({
0
:
replay
.
action
})
...
...
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