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
6baaf842
Commit
6baaf842
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
agent targets and agent start positions are always on seperate tracks
parent
39a249ac
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
examples/flatland_2_0_example.py
+3
-3
3 additions, 3 deletions
examples/flatland_2_0_example.py
flatland/envs/schedule_generators.py
+7
-4
7 additions, 4 deletions
flatland/envs/schedule_generators.py
with
10 additions
and
7 deletions
examples/flatland_2_0_example.py
+
3
−
3
View file @
6baaf842
...
@@ -28,9 +28,9 @@ speed_ration_map = {1.: 1., # Fast passenger train
...
@@ -28,9 +28,9 @@ speed_ration_map = {1.: 1., # Fast passenger train
1.
/
3.
:
0.
,
# Slow commuter train
1.
/
3.
:
0.
,
# Slow commuter train
1.
/
4.
:
0.
}
# Slow freight train
1.
/
4.
:
0.
}
# Slow freight train
env
=
RailEnv
(
width
=
10
0
,
env
=
RailEnv
(
width
=
5
0
,
height
=
10
0
,
height
=
5
0
,
rail_generator
=
sparse_rail_generator
(
num_cities
=
2
0
,
# Number of cities in map (where train stations are)
rail_generator
=
sparse_rail_generator
(
num_cities
=
1
0
,
# Number of cities in map (where train stations are)
seed
=
10
,
# Random seed
seed
=
10
,
# Random seed
grid_mode
=
False
,
grid_mode
=
False
,
max_inter_city_rails
=
2
,
max_inter_city_rails
=
2
,
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/schedule_generators.py
+
7
−
4
View file @
6baaf842
"""
Schedule generators (railway undertaking,
"
EVU
"
).
"""
"""
Schedule generators (railway undertaking,
"
EVU
"
).
"""
import
random
import
warnings
import
warnings
from
typing
import
Tuple
,
List
,
Callable
,
Mapping
,
Optional
,
Any
from
typing
import
Tuple
,
List
,
Callable
,
Mapping
,
Optional
,
Any
...
@@ -74,11 +75,13 @@ def sparse_schedule_generator(speed_ratio_map: Mapping[float, float] = None) ->
...
@@ -74,11 +75,13 @@ def sparse_schedule_generator(speed_ratio_map: Mapping[float, float] = None) ->
# Set target for agent
# Set target for agent
start_city
=
agent_start_targets_nodes
[
agent_idx
][
0
]
start_city
=
agent_start_targets_nodes
[
agent_idx
][
0
]
target_city
=
agent_start_targets_nodes
[
agent_idx
][
1
]
target_city
=
agent_start_targets_nodes
[
agent_idx
][
1
]
start
=
random
.
choice
(
train_stations
[
start_city
])
target
=
random
.
choice
(
train_stations
[
target_city
])
while
start
[
1
]
%
2
!=
0
:
start
=
random
.
choice
(
train_stations
[
start_city
])
while
target
[
1
]
%
2
!=
1
:
target
=
random
.
choice
(
train_stations
[
start_city
])
start_city_idx
=
np
.
random
.
randint
(
len
(
train_stations
[
start_city
]))
start
=
train_stations
[
start_city
][
start_city_idx
]
target_station_idx
=
np
.
random
.
randint
(
len
(
train_stations
[
target_city
]))
target
=
train_stations
[
target_city
][
target_station_idx
]
agent_orientation
=
(
agent_start_targets_nodes
[
agent_idx
][
2
]
+
2
*
start
[
1
])
%
4
agent_orientation
=
(
agent_start_targets_nodes
[
agent_idx
][
2
]
+
2
*
start
[
1
])
%
4
if
not
rail
.
check_path_exists
(
start
[
0
],
agent_orientation
,
target
[
0
]):
if
not
rail
.
check_path_exists
(
start
[
0
],
agent_orientation
,
target
[
0
]):
agent_orientation
=
(
agent_orientation
+
2
)
%
4
agent_orientation
=
(
agent_orientation
+
2
)
%
4
...
...
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