Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
结
结合Transformer与多智能体强化学习的多无人机编码缓存传输方法
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
牛辰龙
结合Transformer与多智能体强化学习的多无人机编码缓存传输方法
Commits
4bc6d041
Commit
4bc6d041
authored
Jan 07, 2023
by
hzq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev] update
parent
76427e68
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
18 deletions
+18
-18
README.md
README.md
+1
-0
envs/env_discrete.py
envs/env_discrete.py
+1
-1
runner/separated/env_runner.py
runner/separated/env_runner.py
+3
-1
runner/shared/env_runner.py
runner/shared/env_runner.py
+3
-10
train/train.py
train/train.py
+10
-6
No files found.
README.md
View file @
4bc6d041
...
...
@@ -66,6 +66,7 @@ class EnvCore(object):
只需要编写这一部分的代码,就可以无缝衔接MAPPO。在env_core.py之后,单独提出来了两个文件env_discrete.py和env_continuous.py这两个文件用于封装处理动作空间和离散动作空间。在algorithms/utils/act.py中elif self.continuous_action:这个判断逻辑也是用来处理连续动作空间的。和runner/shared/env_runner.py部分的# TODO 这里改造成自己环境需要的形式即可都是用来处理连续动作空间的。
在train.py文件里面,选择注释连续环境,或者离散环境进行demo环境的切换。
## Related Efforts
...
...
envs/env_discrete.py
View file @
4bc6d041
...
...
@@ -82,7 +82,7 @@ class DiscreteActionEnv(object):
def
seed
(
self
,
seed
):
pass
class
MultiDiscrete
(
gym
.
Space
):
class
MultiDiscrete
():
"""
- The multi-discrete action space consists of a series of discrete action spaces with different parameters
- It can be adapted to both a Discrete action space or a continuous (Box) action space
...
...
runner/separated/env_runner.py
View file @
4bc6d041
...
...
@@ -133,7 +133,9 @@ class EnvRunner(Runner):
elif
self
.
envs
.
action_space
[
agent_id
].
__class__
.
__name__
==
'Discrete'
:
action_env
=
np
.
squeeze
(
np
.
eye
(
self
.
envs
.
action_space
[
agent_id
].
n
)[
action
],
1
)
else
:
raise
NotImplementedError
# TODO 这里改造成自己环境需要的形式即可
action_env
=
actions
# raise NotImplementedError
actions
.
append
(
action
)
temp_actions_env
.
append
(
action_env
)
...
...
runner/shared/env_runner.py
View file @
4bc6d041
...
...
@@ -5,18 +5,11 @@
# @File : env_runner.py
"""
"""
# @Time : 2021/7/1 7:04 下午
# @Author : hezhiqiang01
# @Email : hezhiqiang01@baidu.com
# @File : huaru_runner.py
"""
import
time
import
numpy
as
np
import
torch
from
runner.shared.base_runner
import
Runner
import
imageio
#
import imageio
def
_t2n
(
x
):
...
...
@@ -269,5 +262,5 @@ class EnvRunner(Runner):
print
(
"average episode rewards is: "
+
str
(
np
.
mean
(
np
.
sum
(
np
.
array
(
episode_rewards
),
axis
=
0
))))
if
self
.
all_args
.
save_gifs
:
imageio
.
mimsave
(
str
(
self
.
gif_dir
)
+
'/render.gif'
,
all_frames
,
duration
=
self
.
all_args
.
ifi
)
#
if self.all_args.save_gifs:
#
imageio.mimsave(str(self.gif_dir) + '/render.gif', all_frames, duration=self.all_args.ifi)
train/train.py
View file @
4bc6d041
...
...
@@ -22,10 +22,11 @@ from envs.env_wrappers import SubprocVecEnv, DummyVecEnv
def
make_train_env
(
all_args
):
def
get_env_fn
(
rank
):
def
init_env
():
# from envs.env_continuous import ContinuousActionEnv
# env = ContinuousActionEnv()
from
envs.env_discrete
import
DiscreteActionEnv
env
=
DiscreteActionEnv
()
# TODO 注意注意,这里选择连续还是离散可以选择注释上面两行,或者下面两行。
from
envs.env_continuous
import
ContinuousActionEnv
env
=
ContinuousActionEnv
()
# from envs.env_discrete import DiscreteActionEnv
# env = DiscreteActionEnv()
env
.
seed
(
all_args
.
seed
+
rank
*
1000
)
return
env
return
init_env
...
...
@@ -35,8 +36,11 @@ def make_train_env(all_args):
def
make_eval_env
(
all_args
):
def
get_env_fn
(
rank
):
def
init_env
():
from
envs.env_discrete
import
DiscreteActionEnv
env
=
DiscreteActionEnv
()
# TODO 注意注意,这里选择连续还是离散可以选择注释上面两行,或者下面两行。
from
envs.env_continuous
import
ContinuousActionEnv
env
=
ContinuousActionEnv
()
# from envs.env_discrete import DiscreteActionEnv
# env = DiscreteActionEnv()
env
.
seed
(
all_args
.
seed
+
rank
*
1000
)
return
env
return
init_env
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment