def update_all_links_attributes(plr, load): for u, v, d in WSN_Links.edges_iter(data=True): WSN_Links[u][v]['plr'] = plr WSN_Links[u][v]['load'] = load link_weight = LinkCost(WSN_Links[u][v]['plr'], WSN_Links[u][v]['load']) WSN_Links[u][v]['weight'] = link_weight.get_weight(link_weight) links[(u, v)] = link_weight.get_weight(link_weight) # print(link_weight.get_weight(link_weight)) print("")
def update_link_attributes(u, v, plr, load): if plr is -1: WSN_Links[u][v]['plr'] = WSN_Links[u][v]['plr'] else: WSN_Links[u][v]['plr'] += plr if load is -1: WSN_Links[u][v]['load'] = WSN_Links[u][v]['load'] else: WSN_Links[u][v]['load'] += load link_weight = LinkCost(WSN_Links[u][v]['plr'], WSN_Links[u][v]['load']) WSN_Links[u][v]['weight'] = link_weight.get_weight(link_weight) links[(u, v)] = link_weight.get_weight(link_weight)
def update_link_attribs(wsn, u, v, plr, load): config.total_operations += 1 current_link_weight = LinkCost(wsn[u][v]['plr'], wsn[u][v]['load']) if plr is -1: wsn[u][v]['plr'] = wsn[u][v]['plr'] else: wsn[u][v]['plr'] += plr if load is -1: wsn[u][v]['load'] = wsn[u][v]['load'] else: wsn[u][v]['load'] += load link_weight = LinkCost(wsn[u][v]['plr'], wsn[u][v]['load']) wsn[u][v]['weight'] = link_weight.get_weight(link_weight) return current_link_weight.get_weight(current_link_weight)
def update_link_attributes(u, v, plr, load): if plr is -1: config.wsn_for_this_perm[u][v]['plr'] = config.wsn_for_this_perm[u][v][ 'plr'] else: config.wsn_for_this_perm[u][v]['plr'] += plr if load is -1: config.wsn_for_this_perm[u][v]['load'] = config.wsn_for_this_perm[u][ v]['load'] else: config.wsn_for_this_perm[u][v]['load'] += load link_weight = LinkCost(config.wsn_for_this_perm[u][v]['plr'], config.wsn_for_this_perm[u][v]['load']) config.wsn_for_this_perm[u][v]['weight'] = link_weight.get_weight( link_weight) config.link_weights_for_this_perm[( u, v)] = link_weight.get_weight(link_weight)
def update_all_links_attributes(wsn, plr, load): for u, v, d in wsn.edges_iter(data=True): wsn[u][v]['plr'] = plr wsn[u][v]['load'] = load link_weight = LinkCost(wsn[u][v]['plr'], wsn[u][v]['load']) wsn[u][v]['weight'] = link_weight.get_weight(link_weight) #link_weights[(u, v)] = link_weight.get_weight(link_weight) # # print(link_weight.get_weight(link_weight)) print(wsn.edges(data=True)) print("")
def parse_init_adj_list(self, init_adj_list): # init_adj_list is a tuple consisting of a list of coordinates for each nodes as well as the adjacencies adj_list = {} link_quality = {} #print "init_adj_list", init_adj_list for node in init_adj_list: if node % 2 == 0: services = ["tmp", "hum", "lgt"] else: services = ["tmp", "co2"] # print(node) # self.__WSN_Substrate.add_node(node, {'rank': 1, 'load': 1}) self.__WSN_Substrate.add_node(node, { 'rank': 1, 'load': 1, 'zone': 1, 'services': services }) neighbor_list = [] for neighbor in init_adj_list.get(node): substrate_link = LinkCost(neighbor[1], 1) #print "neigh",neighbor link_weight = substrate_link.get_weight(substrate_link) self.__inital_weight += link_weight self.__WSN_Substrate.add_edge(node, neighbor[0], { 'plr': neighbor[1], 'load': 0, 'weight': link_weight }) link_quality.update({(node, neighbor[0]): neighbor[1]}) #self.__link_weights[(n, neighbor)] = 1 neighbor_list.append(neighbor[0]) #print(neighbor_list) adj_list.update({node: neighbor_list}) self.__link_quality = sorted(link_quality.items(), key=lambda x: x[1]) # print("adj_list",adj_list) return adj_list
def update_all_links_attributes(wsn, plr, load): for u, v, d in config.wsn.edges_iter(data=True): wsn[u][v]['plr'] = plr wsn[u][v]['load'] = load link_weight = LinkCost(wsn[u][v]['plr'], wsn[u][v]['load']) wsn[u][v]['weight'] = link_weight.get_weight(link_weight)