Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
baselines
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
xzhaoma
baselines
Commits
c4df1ca0
"README.md" did not exist on "8a9ba90d245a9d90f72738ff7b996bfef58dcad8"
Commit
c4df1ca0
authored
5 years ago
by
gmollard
Browse files
Options
Downloads
Patches
Plain Diff
up to date environment initialization
parent
31396ec1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
grid_search_configs/n_agents_grid_search/config.gin
+3
-3
3 additions, 3 deletions
grid_search_configs/n_agents_grid_search/config.gin
grid_search_train.py
+34
-13
34 additions, 13 deletions
grid_search_train.py
train.py
+28
-14
28 additions, 14 deletions
train.py
with
65 additions
and
30 deletions
grid_search_configs/n_agents_grid_search/config.gin
+
3
−
3
View file @
c4df1ca0
...
...
@@ -3,9 +3,9 @@ run_grid_search.num_iterations = 1002
run_grid_search.save_every = 200
run_grid_search.hidden_sizes = [32, 32]
run_grid_search.map_width =
1
5
run_grid_search.map_height =
1
5
run_grid_search.n_agents = {"grid_search": [
1
,
2
,
3, 4
]}
run_grid_search.map_width = 5
0
run_grid_search.map_height = 5
0
run_grid_search.n_agents = {"grid_search": [
2
,
5
,
10, 20
]}
run_grid_search.horizon = 50
...
...
This diff is collapsed.
Click to expand it.
grid_search_train.py
+
34
−
13
View file @
c4df1ca0
...
...
@@ -40,23 +40,44 @@ def train(config, reporter):
env_name
=
f
"
rail_env_
{
config
[
'
n_agents
'
]
}
"
# To modify if different environments configs are explored.
# Example generate a rail given a manual specification,
# a map of tuples (cell_type, rotation)
transition_probability
=
[
0.5
,
# empty cell - Case 0
1.0
,
# Case 1 - straight
1.0
,
# Case 2 - simple switch
0.3
,
# Case 3 - diamond drossing
0.5
,
# Case 4 - single slip
0.5
,
# Case 5 - double slip
0.2
,
# Case 6 - symmetrical
0.0
]
# Case 7 - dead end
transition_probability
=
[
15
,
# empty cell - Case 0
5
,
# Case 1 - straight
5
,
# Case 2 - simple switch
1
,
# Case 3 - diamond crossing
1
,
# Case 4 - single slip
1
,
# Case 5 - double slip
1
,
# Case 6 - symmetrical
0
,
# Case 7 - dead end
1
,
# Case 1b (8) - simple turn right
1
,
# Case 1c (9) - simple turn left
1
]
# Case 2b (10) - simple switch mirrored
# Example generate a random rail
"""
env = RailEnv(width=10,
height=10,
rail_generator=random_rail_generator(cell_type_relative_proportion=transition_probability),
number_of_agents=1)
"""
env
=
RailEnv
(
width
=
config
[
'
map_width
'
],
height
=
config
[
'
map_height
'
],
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
50
,
min_dist
=
5
,
max_dist
=
99999
,
seed
=
0
),
number_of_agents
=
config
[
'
n_agents
'
])
"""
env = RailEnv(width=20,
height=20,
rail_generator=rail_from_list_of_saved_GridTransitionMap_generator(
[
'
../notebooks/temp.npy
'
]),
number_of_agents=3)
"""
# Example generate a random rail
env
=
RailEnvRLLibWrapper
(
width
=
config
[
'
map_width
'
],
height
=
config
[
'
map_height
'
],
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
config
[
"
n_agents
"
],
nr_extra
=
20
,
min_dist
=
12
),
number_of_agents
=
config
[
"
n_agents
"
])
#
env = RailEnvRLLibWrapper(width=config['map_width'], height=config['map_height'],
#
rail_generator=complex_rail_generator(nr_start_goal=config["n_agents"], nr_extra=20, min_dist=12),
#
number_of_agents=config["n_agents"])
register_env
(
env_name
,
lambda
_
:
env
)
...
...
This diff is collapsed.
Click to expand it.
train.py
+
28
−
14
View file @
c4df1ca0
...
...
@@ -45,23 +45,37 @@ def train(config):
random
.
seed
(
1
)
np
.
random
.
seed
(
1
)
# Example generate a rail given a manual specification,
# a map of tuples (cell_type, rotation)
transition_probability
=
[
0.5
,
# empty cell - Case 0
1.0
,
# Case 1 - straight
1.0
,
# Case 2 - simple switch
0.3
,
# Case 3 - diamond drossing
0.5
,
# Case 4 - single slip
0.5
,
# Case 5 - double slip
0.2
,
# Case 6 - symmetrical
0.0
]
# Case 7 - dead end
transition_probability
=
[
15
,
# empty cell - Case 0
5
,
# Case 1 - straight
5
,
# Case 2 - simple switch
1
,
# Case 3 - diamond crossing
1
,
# Case 4 - single slip
1
,
# Case 5 - double slip
1
,
# Case 6 - symmetrical
0
,
# Case 7 - dead end
1
,
# Case 1b (8) - simple turn right
1
,
# Case 1c (9) - simple turn left
1
]
# Case 2b (10) - simple switch mirrored
# Example generate a random rail
env
=
RailEnvRLLibWrapper
(
width
=
15
,
height
=
15
,
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
1
,
nr_extra
=
20
,
min_dist
=
12
),
"""
env = RailEnv(width=10,
height=10,
rail_generator=random_rail_generator(cell_type_relative_proportion=transition_probability),
number_of_agents=1)
"""
env
=
RailEnv
(
width
=
50
,
height
=
50
,
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
50
,
min_dist
=
5
,
max_dist
=
99999
,
seed
=
0
),
number_of_agents
=
5
)
"""
env = RailEnv(width=20,
height=20,
rail_generator=rail_from_list_of_saved_GridTransitionMap_generator(
[
'
../notebooks/temp.npy
'
]),
number_of_agents=3)
"""
register_env
(
"
railenv
"
,
lambda
_
:
env
)
# if config['render']:
...
...
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