Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
def choose_priority(G, G1, K, balance_info):
#parameters
delta = .8
max_len = 7
weights = set([balance_info[i][j] for j in balance_info[i] for i in balance_info])
weights.remove(0.)
weights.remove(0)
print(weights)
unbalanced = max(weights) > (1+sigma)*min(weights) # this is our first check
if not unbalanced:
return None
# now we look for all constraining edges
base_flow = R2_regular_all(G,deep_copy(balance_info), make_empty_err_dict(balance_info))[0]
perturb_val = max(weights) - min(weights)
edges_max_flow = [] # alist of edges with (u,v,path_len, new_max_flow)
for edge in G.get_edges():
key_copy = deep_copy(balance_info)
key_copy[edge[0]][edge[1]] += perturb_val
new_flow = R2_regular_all(G,key_copy, make_empty_err_dict(key_copy))[0]
# this is where we decide which edges are reasonable and which aren't
# this could be more in depth later, now it is just length and assumes no noise/successes
# see overleaf document
if new_flow/perturb_val >= delta and G._paths[edge[0]][edge[1]] < max_len:
edges_max_flow.append((edge[0],edge[1],G._paths[edge[0]][edge[1]], new_flow))
#sort these edges according to constraining edges
"""
TODO: would like some way of making this localized for local version
so that we don't end up trying to balance raandomly on other side of the network
"""
edges_max_flow.sort(key=lambda x: x[path_len])
return edges_max_flow
def make_empty_err_dict(key_pools):
return {{"": for j in key_pools[i]} for i in key_pools}