Commit 5f2d10ab authored by Jayant Khatkar's avatar Jayant Khatkar

decmcts for scheduler, major bug fix

parent e5aae54c
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment