Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
bigprint
pyDecMCTS
Commits
5f2d10ab
Commit
5f2d10ab
authored
Jan 08, 2020
by
Jayant Khatkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decmcts for scheduler, major bug fix
parent
e5aae54c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
DecMCTS.py
DecMCTS.py
+13
-8
No files found.
DecMCTS.py
View file @
5f2d10ab
...
...
@@ -105,16 +105,17 @@ class Tree:
self
.
comms
=
{}
# Plan with no robots initially
self
.
comm_n
=
comm_n
# number of action dists to communicate
# Set Action sequence as nothing for now
self
.
my_act_dist
=
ActionDistribution
([
0
],[
1
])
# Graph add root node of tree
self
.
graph
.
add_node
(
1
,
mu
=
0
,
N
=
0
,
state
=
self
.
state_store
(
self
.
data
,
None
,
None
)
state
=
self
.
state_store
(
self
.
data
,
None
,
None
,
self
.
id
)
)
# Set Action sequence as nothing for now
self
.
my_act_dist
=
ActionDistribution
([
self
.
graph
.
node
[
1
][
"state"
]],[
1
])
self
.
_expansion
(
1
)
...
...
@@ -158,6 +159,7 @@ class Tree:
# For now, just using q = mu**2
temp
=
nx
.
get_node_attributes
(
self
.
graph
,
"mu"
)
temp
.
pop
(
1
,
None
)
top_n_nodes
=
sorted
(
temp
,
key
=
temp
.
get
,
reverse
=
True
)[:
self
.
comm_n
]
X
=
[
self
.
graph
.
node
[
n
][
"state"
]
for
n
in
top_n_nodes
]
...
...
@@ -200,13 +202,16 @@ class Tree:
self
.
id
)
if
len
(
options
)
==
0
:
return
False
# create empty nodes underneath the node being expanded
for
o
in
options
:
self
.
graph
.
add_node
(
len
(
self
.
graph
)
+
1
,
mu
=
0
,
N
=
0
,
state
=
self
.
state_store
(
self
.
data
,
self
.
graph
.
node
[
start_node
][
"state"
],
o
)
state
=
self
.
state_store
(
self
.
data
,
self
.
graph
.
node
[
start_node
][
"state"
],
o
,
self
.
id
)
)
self
.
graph
.
add_edge
(
start_node
,
len
(
self
.
graph
))
...
...
@@ -259,7 +264,7 @@ class Tree:
# sim_action = self.sim_selection_func(self.data, options, state)
#
# # add that to the actions of the current robot
# temp_state = self.state_store(self.data, temp_state, sim_action)
# temp_state = self.state_store(self.data, temp_state, sim_action
, self.id
)
#
# # calculate the reward at the end of simulation
# rew = self.reward(self.data, temp_state) \
...
...
@@ -282,8 +287,8 @@ class Tree:
start_node
=
self
.
_parent
(
start_node
)
self
.
graph
.
node
[
start_node
][
"mu"
]
=
\
(
gamma
*
self
.
graph
.
node
[
start_node
][
"mu"
]
+
avg_reward
)
\
/
(
gamma
*
self
.
graph
.
node
[
start_node
][
"N"
]
+
1
)
(
gamma
*
self
.
graph
.
node
[
start_node
][
"mu"
]
*
self
.
graph
.
node
[
start_node
][
"N"
]
+
avg_reward
)
\
/
(
self
.
graph
.
node
[
start_node
][
"N"
]
+
1
)
self
.
graph
.
node
[
start_node
][
"N"
]
=
\
gamma
*
self
.
graph
.
node
[
start_node
][
"N"
]
+
1
...
...
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