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
b9092b25
Commit
b9092b25
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
fixed bug in generator related to random sampling
parent
f3471970
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/envs/schedule_generators.py
+9
-4
9 additions, 4 deletions
flatland/envs/schedule_generators.py
tests/test_random_seeding.py
+1
-1
1 addition, 1 deletion
tests/test_random_seeding.py
with
10 additions
and
5 deletions
flatland/envs/schedule_generators.py
+
9
−
4
View file @
b9092b25
...
...
@@ -87,13 +87,18 @@ def sparse_schedule_generator(speed_ratio_map: Mapping[float, float] = None, see
# Set target for agent
start_city
=
agent_start_targets_cities
[
agent_idx
][
0
]
target_city
=
agent_start_targets_cities
[
agent_idx
][
1
]
start
=
np
.
random
.
choice
(
train_stations
[
start_city
])
target
=
np
.
random
.
choice
(
train_stations
[
target_city
])
start_idx
=
np
.
random
.
choice
(
np
.
arange
(
len
(
train_stations
[
start_city
])))
target_idx
=
np
.
random
.
choice
(
np
.
arange
(
len
(
train_stations
[
target_city
])))
start
=
train_stations
[
start_city
][
start_idx
]
target
=
train_stations
[
target_city
][
target_idx
]
while
start
[
1
]
%
2
!=
0
:
start
=
np
.
random
.
choice
(
train_stations
[
start_city
])
start_idx
=
np
.
random
.
choice
(
np
.
arange
(
len
(
train_stations
[
start_city
])))
start
=
train_stations
[
start_city
][
start_idx
]
while
target
[
1
]
%
2
!=
1
:
target
=
np
.
random
.
choice
(
train_stations
[
target_city
])
target_idx
=
np
.
random
.
choice
(
np
.
arange
(
len
(
train_stations
[
target_city
])))
target
=
train_stations
[
target_city
][
target_idx
]
agent_orientation
=
(
agent_start_targets_cities
[
agent_idx
][
2
]
+
2
*
start
[
1
])
%
4
if
not
rail
.
check_path_exists
(
start
[
0
],
agent_orientation
,
target
[
0
]):
agent_orientation
=
(
agent_orientation
+
2
)
%
4
...
...
This diff is collapsed.
Click to expand it.
tests/test_random_seeding.py
+
1
−
1
View file @
b9092b25
...
...
@@ -20,7 +20,7 @@ def test_random_seeding():
# Test generation print
env
.
agents
[
0
].
target
=
(
0
,
0
)
for
step
in
range
(
10
0
):
for
step
in
range
(
10
):
actions
=
{}
actions
[
0
]
=
2
env
.
step
(
actions
)
...
...
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