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
1cb2c042
Commit
1cb2c042
authored
5 years ago
by
gmollard
Browse files
Options
Downloads
Patches
Plain Diff
change in wrapper should solve bug
parent
1c1e6dc8
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
RailEnvRLLibWrapper.py
+8
-8
8 additions, 8 deletions
RailEnvRLLibWrapper.py
train.py
+7
-7
7 additions, 7 deletions
train.py
with
15 additions
and
15 deletions
RailEnvRLLibWrapper.py
+
8
−
8
View file @
1cb2c042
...
...
@@ -6,15 +6,15 @@ from flatland.envs.generators import random_rail_generator
class
RailEnvRLLibWrapper
(
RailEnv
,
MultiAgentEnv
):
def
__init__
(
self
,
width
,
height
,
rail_generator
=
random_rail_generator
(),
number_of_agents
=
1
,
obs_builder_object
=
TreeObsForRailEnv
(
max_depth
=
2
)):
def
__init__
(
self
,
config
):
#
width,
#
height,
#
rail_generator=random_rail_generator(),
#
number_of_agents=1,
#
obs_builder_object=TreeObsForRailEnv(max_depth=2)):
super
(
RailEnvRLLibWrapper
,
self
).
__init__
(
width
=
width
,
height
=
height
,
rail_generator
=
rail_generator
,
number_of_agents
=
number_of_agents
,
obs_builder_object
=
obs_builder_object
)
super
(
RailEnvRLLibWrapper
,
self
).
__init__
(
width
=
config
[
"
width
"
]
,
height
=
config
[
"
height
"
]
,
rail_generator
=
config
[
"
rail_generator
"
]
,
number_of_agents
=
config
[
"
number_of_agents
"
]
)
def
reset
(
self
,
regen_rail
=
True
,
replace_agents
=
True
):
self
.
agents_done
=
[]
...
...
This diff is collapsed.
Click to expand it.
train.py
+
7
−
7
View file @
1cb2c042
...
...
@@ -11,7 +11,7 @@ from flatland.envs.generators import complex_rail_generator
import
ray.rllib.agents.ppo.ppo
as
ppo
import
ray.rllib.agents.dqn.dqn
as
dqn
from
ray.rllib.agents.ppo.ppo
import
PPO
Agent
from
ray.rllib.agents.ppo.ppo
import
PPO
Trainer
from
ray.rllib.agents.dqn.dqn
import
DQNAgent
from
ray.rllib.agents.ppo.ppo_policy_graph
import
PPOPolicyGraph
from
ray.rllib.agents.dqn.dqn_policy_graph
import
DQNPolicyGraph
...
...
@@ -64,10 +64,10 @@ def train(config):
rail_generator=random_rail_generator(cell_type_relative_proportion=transition_probability),
number_of_agents=1)
"""
env
=
RailEnvRLLibWrapper
(
width
=
20
,
height
=
20
,
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
5
,
min_dist
=
5
,
max_dist
=
99999
,
seed
=
0
),
number_of_agents
=
5
)
env
_config
=
{
"
width
"
:
20
,
"
height
"
:
20
,
"
rail_generator
"
:
complex_rail_generator
(
nr_start_goal
=
5
,
min_dist
=
5
,
max_dist
=
99999
,
seed
=
0
),
"
number_of_agents
"
:
5
}
"""
env = RailEnv(width=20,
height=20,
...
...
@@ -77,7 +77,6 @@ def train(config):
"""
register_env
(
"
railenv
"
,
lambda
_
:
env
)
# if config['render']:
# env_renderer = RenderTool(env, gl="QT")
# plt.figure(figsize=(5,5))
...
...
@@ -105,9 +104,10 @@ def train(config):
# agent_config["num_gpus_per_worker"] = 2.0
agent_config
[
"
num_cpus_for_driver
"
]
=
5
agent_config
[
"
num_envs_per_worker
"
]
=
15
agent_config
[
"
env_config
"
]
=
env_config
#agent_config["batch_mode"] = "complete_episodes"
ppo_trainer
=
PPO
Agent
(
env
=
f
"
railenv
"
,
config
=
agent_config
)
ppo_trainer
=
PPO
Trainer
(
env
=
f
"
railenv
"
,
config
=
agent_config
)
for
i
in
range
(
100000
+
2
):
print
(
"
== Iteration
"
,
i
,
"
==
"
)
...
...
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