Skip to content
Snippets Groups Projects
Commit 14bdcc10 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

ActionDistribution object fixed

parent 62365825
Branches
Tags
No related merge requests found
......@@ -15,30 +15,22 @@ class ActionDistribution:
Action Distribution
Working with action sequences and their respective probability
An Action Sequence here refers to the node_id of the relevant
node in the Tree. The actual action sequence to get to that
node is stored inside the node.
To initialise, Inputs:
- X: list of node_ids (ints)
- n: number of action sequences for comms
- X: list of action sequences
- q: probability of each action sequence (normalised in intialisation)
"""
def __init__(self, X, n, beta=0.5):
def __init__(self, X, q):
# Starting distribution is uniform
self.q = [1/n] * n
# Action sequence as provided
assert(len(X)==n)
self.X = X
# Beta value set to initial value
self.beta = beta
self.n = n
# Normalise
self.q = (np.array(q)/sum(q)).tolist()
def best_action(self):
"""
Most likely action sequence
......@@ -53,21 +45,6 @@ class ActionDistribution:
return np.random.choice(self.X, p=self.q)
def update(self, Xnew):
"""
Update Distribution
"""
# If new Action sequences to consider, reset
if set(Xnew) != set(self.X):
self.X = Xnew
self.q = [1/self.n] * self.n
else:
Eqn = "TODO"
class Tree:
"""
DecMCTS tree
......@@ -97,7 +74,7 @@ class Tree:
reward/available actions in coordination with others
"""
def __init__(self, data, reward_func, avail_actions_func, c_p=1):
def __init__(self, data, reward_func, avail_actions_func, comm_n, c_p=1):
self.data = data
self.graph = nx.DiGraph()
......@@ -105,10 +82,12 @@ class Tree:
self.available_actions = avail_actions_func
self.c_p = c_p
self.comms = {} # Plan with no robots initially
# TODO CHANGE FOLLOWING LINE
self.my_action_distribution = ActionDistribution(X,n)
self.comm_n = comm_n # number of action dists to communicate
# Set Action sequence as nothing for now
self.my_act_dist = ActionDistribution([[]],[1])
# Graph
# Graph add root node of tree
self.graph.add_node(1,
mu=0,
N=0,
......
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