Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
REST
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
REST
Commits
3dc620ab
Commit
3dc620ab
authored
Sep 01, 2022
by
lvzhengyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add env framework
parent
708dde03
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
0 deletions
+60
-0
agent.py
+7
-0
env/__init__.py
+0
-0
env/env.py
+53
-0
No files found.
agent.py
View file @
3dc620ab
"""
@brief: agent for RL
@author: Zhengyang Lyu
@date: 2022.9.1
"""
from
model
import
Encoder
,
Decoder
,
D
import
torch
import
torch.nn
as
nn
# TODO: finish the mask
# leave the mask provided by the environment
# TODO: make the vectorized version
class
Actor
(
nn
.
Module
):
def
__init__
(
self
,
dim_e
=
D
,
dim_q
=
360
)
->
None
:
...
...
env/__init__.py
0 → 100644
View file @
3dc620ab
env/env.py
0 → 100644
View file @
3dc620ab
"""
@brief: environment for RL
@author: Zhengyang Lyu
@date: 2022.9.1
"""
import
gym
from
gym
import
spaces
class
RSMTEnv
(
gym
.
Env
):
def
__init__
(
self
,
num_nodes
,
pos_l
,
pos_h
,
render_mode
=
None
)
->
None
:
"""
@param pos_l/pos_h: min/max of the positions
"""
super
()
.
__init__
()
self
.
render_mode
=
render_mode
self
.
num_nodes
=
num_nodes
self
.
pos_l
=
pos_l
self
.
pos_h
=
pos_h
self
.
observation_space
=
spaces
.
Dict
({
"positions"
:
spaces
.
Box
(
pos_l
,
pos_h
,
shape
=
(
num_nodes
,
2
),
dtype
=
float
),
"mask_unvisited"
:
spaces
.
MultiBinary
(
num_nodes
),
"mask_visited"
:
spaces
.
MultiBinary
(
num_nodes
),
})
self
.
action_space
=
spaces
.
Dict
({
"u"
:
spaces
.
Discrete
(
num_nodes
),
"w"
:
spaces
.
Discrete
(
num_nodes
),
"s"
:
spaces
.
Discrete
(
2
),
})
self
.
mask_unvisited
=
None
self
.
mask_visited
=
None
def
_get_obs
(
self
):
pass
def
_get_info
(
self
):
pass
def
reset
(
self
,
seed
=
None
):
super
()
.
reset
(
seed
=
seed
)
pass
def
step
(
self
,
action
):
obs
=
self
.
_get_obs
()
info
=
self
.
_get_info
()
# return obs, reward, done, info
def
close
(
self
):
pass
\ No newline at end of file
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