Commit 975bd2f0 authored by Jayant Khatkar's avatar Jayant Khatkar

expansion complete, working on simulation

parent d869b1b2
......@@ -74,12 +74,13 @@ class Tree:
reward/available actions in coordination with others
"""
def __init__(self, data, reward_func, avail_actions_func, comm_n, c_p=1):
def __init__(self, data, reward_func, avail_actions_func, comm_n, c_p=1, time_func=None):
self.data = data
self.graph = nx.DiGraph()
self.reward = reward_func
self.available_actions = avail_actions_func
self.time_func = time_func
self.c_p = c_p
self.comms = {} # Plan with no robots initially
self.comm_n = comm_n # number of action dists to communicate
......@@ -92,7 +93,7 @@ class Tree:
mu=0,
N=0,
action_seq=[],
cost=0
time=0
)
......@@ -163,7 +164,7 @@ class Tree:
"""
Grow Tree by one node
"""
### SELECTION
start_node = 1
while len(self._childNodes(start_node))>0:
......@@ -173,6 +174,30 @@ class Tree:
state = self._get_state(start_node)
options = self.available_actions(self.data, state)
# create empty nodes underneath the node being expanded
for o in options:
self.graph.add_node(len(self.graph)
mu = 0,
N = 0,
action_seq=self.graph.nodes[start_node]["action_seq"] + [o],
time=0
)
self.graph.add_edge(start_node, len(self.graph))
if self.time_func != None:
# TODO Do the time calculations
pass
### SIMULATION
avg_reward = 0
best_reward = float("-Inf")
for i in range(nsims):
# TODO
pass
def send_comms(self):
return self.my_act_dist
......
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