def test_routing_functions(self): initial_config_ag = deepcopy(Config.ag) initial_turn_model = Config.UsedTurnModel initial_routing_type = Config.RotingType Config.ag.type = "Generic" Config.ag.topology = "2DMesh" Config.ag.x_size = 3 Config.ag.y_size = 3 Config.ag.z_size = 1 for turn_model in PackageFile.routing_alg_list_2d: Config.UsedTurnModel = deepcopy(turn_model) Config.TurnsHealth = deepcopy(Config.setup_turns_health()) ag_4_test = deepcopy(generate_ag(logging=None)) shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False) noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test, turn_model, False, False) self.assertEqual(check_deadlock_freeness(noc_rg), True) if turn_model in [PackageFile.XY_TurnModel, PackageFile.YX_TurnModel]: if turn_model == PackageFile.XY_TurnModel: self.assertEqual(return_turn_model_name(turn_model), '0') else: self.assertEqual(return_turn_model_name(turn_model), '13') self.assertEqual(degree_of_adaptiveness(ag_4_test, noc_rg, False)/72, 1) self.assertEqual(extended_degree_of_adaptiveness(ag_4_test, noc_rg, False)/72, 1) del ag_4_test del shmu_4_test Config.ag.type = "Generic" Config.ag.topology = "3DMesh" Config.ag.x_size = 3 Config.ag.y_size = 3 Config.ag.z_size = 3 Config.RotingType = "NonMinimalPath" for turn_model in PackageFile.routing_alg_list_3d: Config.UsedTurnModel = deepcopy(turn_model) Config.TurnsHealth = deepcopy(Config.setup_turns_health()) ag_4_test = deepcopy(generate_ag(logging=None)) shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False) noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test, turn_model, False, False) self.assertEqual(check_deadlock_freeness(noc_rg), True) if turn_model == PackageFile.XYZ_TurnModel: self.assertEqual(return_turn_model_name(turn_model), "3d_XYZ") self.assertEqual(degree_of_adaptiveness(ag_4_test, noc_rg, False)/702, 1) self.assertEqual(extended_degree_of_adaptiveness(ag_4_test, noc_rg, False)/702, 1) if turn_model == PackageFile.NegativeFirst3D_TurnModel: self.assertEqual(return_turn_model_name(turn_model), "3d_NegFirst") del ag_4_test del shmu_4_test del noc_rg Config.ag = deepcopy(initial_config_ag) Config.UsedTurnModel = initial_turn_model Config.TurnsHealth = deepcopy(Config.setup_turns_health()) Config.RotingType = initial_routing_type
def check_fault_tolerance_of_routing_algs(dimension, number_of_multi_threads, viz): """ runs appropriate functions for checking fault tolerance of the network according to the topology, on number_of_multi_threads parallel threads :param dimension: defines the topology of the network, either "2D" or "3D" :param number_of_multi_threads: number of threads for running the program :param viz: boolean, if True, generates visualization of convergence of the connectivity metirc :return: False if the Dimension is wrong, other wise True """ if dimension == '2D': Config.ag.topology = '2DMesh' Config.ag.z_size = 1 args = list(range(0, 25)) turn_model_list = all_2d_turn_model_package.all_2d_turn_models elif dimension == '3D': Config.ag.topology = '3DMesh' Config.ag.z_size = 3 args = list(range(0, 108, 4)) turn_model_list = PackageFile.routing_alg_list_3d else: print("Please choose a valid dimension!") return False for turn_model in turn_model_list: if dimension == '2D': p = Pool(number_of_multi_threads) function = partial(report_2d_turn_model_fault_tolerance, turn_model, viz) p.map(function, args) p.terminate() elif dimension == '3D': p = Pool(number_of_multi_threads) function = partial(report_3d_turn_model_fault_tolerance, turn_model, viz) p.map(function, args) p.terminate() if viz: for turn_model in turn_model_list: for arg in args: turn_model_name = return_turn_model_name(turn_model) file_name = None if dimension == '2D': file_name = str(turn_model_name) + "_eval_" + str(24 - arg) elif dimension == '3D': file_name = str(turn_model_name) + "_eval_" + str(108 - arg) viz_turn_model_evaluation(file_name) if dimension == '2D': viz_all_turn_models_against_each_other() return True
def check_fault_tolerance_of_routing_algs(dimension, number_of_multi_threads, viz): """ runs appropriate functions for checking fault tolerance of the network according to the topology, on number_of_multi_threads parallel threads :param dimension: defines the topology of the network, either "2D" or "3D" :param number_of_multi_threads: number of threads for running the program :param viz: boolean, if True, generates visualization of convergence of the connectivity metirc :return: False if the Dimension is wrong, other wise True """ if dimension == '2D': Config.ag.topology = '2DMesh' Config.ag.z_size = 1 args = list(range(0, 25)) turn_model_list = all_2d_turn_model_package.all_2d_turn_models elif dimension == '3D': Config.ag.topology = '3DMesh' Config.ag.z_size = 3 args = list(range(0, 108, 4)) turn_model_list = PackageFile.routing_alg_list_3d else: print "Please choose a valid dimension!" return False for turn_model in turn_model_list: if dimension == '2D': p = Pool(number_of_multi_threads) function = partial(report_2d_turn_model_fault_tolerance, turn_model, viz) p.map(function, args) p.terminate() elif dimension == '3D': p = Pool(number_of_multi_threads) function = partial(report_3d_turn_model_fault_tolerance, turn_model, viz) p.map(function, args) p.terminate() if viz: for turn_model in turn_model_list: for arg in args: turn_model_name = return_turn_model_name(turn_model) file_name = None if dimension == '2D': file_name = str(turn_model_name) + "_eval_" + str(24-arg) elif dimension == '3D': file_name = str(turn_model_name) + "_eval_" + str(108-arg) viz_turn_model_evaluation(file_name) if dimension == '2D': viz_all_turn_models_against_each_other() return True
def report_3d_turn_model_fault_tolerance(turn_model, viz, combination): """ generates 3D architecture graph with all combinations C(len(ag.nodes), combination) of links and writes the average connectivity metric in a file. :param turn_model: list of allowed turns for generating the routing graph :param combination: number of links to be present in the network :param viz: if true, generates the visualization files :return: None """ if combination == 108: raise ValueError( "breaking 108 edges out of 108 edges is not possible your connectivity is 0!" ) Config.UsedTurnModel = copy.deepcopy(turn_model) Config.TurnsHealth = copy.deepcopy(Config.setup_turns_health()) ag = copy.deepcopy(AG_Functions.generate_ag(report=False)) turn_model_name = return_turn_model_name(Config.UsedTurnModel) file_name = str(turn_model_name) + '_eval' turn_model_eval_file = open( 'Generated_Files/Turn_Model_Eval/' + file_name + '.txt', 'a+') if viz: file_name_viz = str(turn_model_name) + '_eval_' + str( len(ag.edges()) - combination) turn_model_eval_viz_file = open( 'Generated_Files/Internal/' + file_name_viz + '.txt', 'w') else: turn_model_eval_viz_file = None counter = 0 metric_sum = 0 list_of_avg = [] number_of_combinations = comb(108, combination) while True: sub_ag = sample(ag.edges(), combination) shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu.setup_noc_shm(ag, copy.deepcopy(Config.TurnsHealth), False) for link in list(sub_ag): shmu.break_link(link, False) noc_rg = copy.deepcopy( Routing.generate_noc_route_graph(ag, shmu, Config.UsedTurnModel, False, False)) connectivity_metric = reachability_metric(ag, noc_rg, False) counter += 1 metric_sum += connectivity_metric # std = None list_of_avg.append(float(metric_sum) / counter) if len(list_of_avg) > 5000: list_of_avg.pop(0) std = stdev(list_of_avg) if std < 0.009: # turn_model_eval_file.write("STD of the last 5000 average samples is bellow 0.009\n") # turn_model_eval_file.write("Terminating the search!\n") del shmu del noc_rg break if viz: turn_model_eval_viz_file.write( str(float(metric_sum) / counter) + "\n") if counter >= number_of_combinations: del shmu del noc_rg break # print("#:"+str(counter)+"\t\tC.M.:"+str(connectivity_metric)+"\t\t avg:", \ # float(metric_sum)/counter, "\t\tstd:", std) del shmu del noc_rg if counter > 0: avg_connectivity = float(metric_sum) / counter else: avg_connectivity = 0 turn_model_eval_file.write( str(len(ag.edges()) - combination) + "\t\t" + str(avg_connectivity) + "\n") turn_model_eval_file.close() if viz: turn_model_eval_viz_file.close() return None
def viz_2d_turn_model(turn_model_list): """ Reads all the 2D turn models and draw them in a file at GraphDrawings/Turn_Model.png :return: None """ print("===========================================") print("GENERATING TURN MODEL VISUALIZATIONS...") fig = plt.figure(figsize=(19, 12)) count = 1 for turn_model in turn_model_list: ax1 = plt.subplot(7, 8, count) if "E2S" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0, 0.5), xycoords='data', xytext=(0.2, 0.7), textcoords='data', size=20, arrowprops=dict( arrowstyle="->", color=color, connectionstyle="angle, angleA=0, angleB=90, rad=0")) if "S2W" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.2, 0.7), xycoords='data', xytext=(0.4, 0.5), textcoords='data', size=20, arrowprops=dict( arrowstyle="->", color=color, connectionstyle="angle, angleA=90, angleB=0, rad=0")) if "N2E" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.2, 0.3), xycoords='data', xytext=(0.0, 0.5), textcoords='data', size=20, arrowprops=dict( arrowstyle="->", color=color, connectionstyle="angle, angleA=90, angleB=0, rad=0")) if "W2N" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.4, 0.5), xycoords='data', xytext=(0.2, 0.3), textcoords='data', size=20, arrowprops=dict( arrowstyle="->", color=color, connectionstyle="angle, angleA=0, angleB=90, rad=0")) # ####################### if "S2E" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.75, 0.7), xycoords='data', xytext=(0.55, 0.5), textcoords='data', size=20, arrowprops=dict( arrowstyle="->", color=color, connectionstyle="angle, angleA=90, angleB=0, rad=0")) if "W2S" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.95, 0.5), xycoords='data', xytext=(0.75, 0.7), textcoords='data', size=20, arrowprops=dict( arrowstyle="->", color=color, connectionstyle="angle, angleA=0, angleB=90, rad=0")) if "E2N" in turn_model: color = 'black' else: color = 'red' ax1.annotate( "", xy=(0.55, 0.5), xycoords='data', xytext=(0.75, 0.3), textcoords='data', size=20, arrowprops=dict( arrowstyle="->", color=color, connectionstyle="angle, angleA=180, angleB=90, rad=0")) if "N2W" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.75, 0.3), xycoords='data', xytext=(0.95, 0.5), textcoords='data', size=20, arrowprops=dict( arrowstyle="->", color=color, connectionstyle="angle, angleA=90, angleB=0, rad=0")) ax1.text(0, 0.9, str(return_turn_model_name(turn_model)), fontsize=10) ax1.text(0, 0.8, str(turn_model), fontsize=5) count += 1 ax1.axis('off') plt.axis('off') plt.savefig("GraphDrawings/Turn_Model.png", dpi=300, bbox_inches='tight') plt.clf() plt.close(fig) # print("\033[35m* VIZ::\033[0m Turn Model viz " + # "TURN MODEL VIZ CREATED AT: GraphDrawings/Turn_Model_"+turn_model_name+".png") print("TURN MODEL VISUALIZATIONS READY...") return None
def viz_2d_turn_model(turn_model_list): """ Reads all the 2D turn models and draw them in a file at GraphDrawings/Turn_Model.png :return: None """ print ("===========================================") print ("GENERATING TURN MODEL VISUALIZATIONS...") fig = plt.figure(figsize=(19, 12)) count = 1 for turn_model in turn_model_list: ax1 = plt.subplot(7, 8, count) if "E2S" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0, 0.5), xycoords='data', xytext=(0.2, 0.7), textcoords='data', size=20, arrowprops=dict(arrowstyle="->", color=color, connectionstyle="angle, angleA=0, angleB=90, rad=0") ) if "S2W" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.2, 0.7), xycoords='data', xytext=(0.4, 0.5), textcoords='data', size=20, arrowprops=dict(arrowstyle="->", color=color, connectionstyle="angle, angleA=90, angleB=0, rad=0") ) if "N2E" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.2, 0.3), xycoords='data', xytext=(0.0, 0.5), textcoords='data', size=20, arrowprops=dict(arrowstyle="->", color=color, connectionstyle="angle, angleA=90, angleB=0, rad=0") ) if "W2N" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.4, 0.5), xycoords='data', xytext=(0.2, 0.3), textcoords='data', size=20, arrowprops=dict(arrowstyle="->", color=color, connectionstyle="angle, angleA=0, angleB=90, rad=0") ) # ####################### if "S2E" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.75, 0.7), xycoords='data', xytext=(0.55, 0.5), textcoords='data', size=20, arrowprops=dict(arrowstyle="->", color=color, connectionstyle="angle, angleA=90, angleB=0, rad=0") ) if "W2S" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.95, 0.5), xycoords='data', xytext=(0.75, 0.7), textcoords='data', size=20, arrowprops=dict(arrowstyle="->", color=color, connectionstyle="angle, angleA=0, angleB=90, rad=0") ) if "E2N" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.55, 0.5), xycoords='data', xytext=(0.75, 0.3), textcoords='data', size=20, arrowprops=dict(arrowstyle="->", color=color, connectionstyle="angle, angleA=180, angleB=90, rad=0") ) if "N2W" in turn_model: color = 'black' else: color = 'red' ax1.annotate("", xy=(0.75, 0.3), xycoords='data', xytext=(0.95, 0.5), textcoords='data', size=20, arrowprops=dict(arrowstyle="->", color=color, connectionstyle="angle, angleA=90, angleB=0, rad=0") ) ax1.text(0, 0.9, str(return_turn_model_name(turn_model)), fontsize=10) ax1.text(0, 0.8, str(turn_model), fontsize=5) count += 1 ax1.axis('off') plt.axis('off') plt.savefig("GraphDrawings/Turn_Model.png", dpi=300, bbox_inches='tight') plt.clf() plt.close(fig) # print ("\033[35m* VIZ::\033[0m Turn Model viz " + # "TURN MODEL VIZ CREATED AT: GraphDrawings/Turn_Model_"+turn_model_name+".png") print ("TURN MODEL VISUALIZATIONS READY...") return None
def test_routing_functions(self): initial_config_ag = deepcopy(Config.ag) initial_turn_model = Config.UsedTurnModel initial_routing_type = Config.RotingType Config.ag.type = "Generic" Config.ag.topology = "2DMesh" Config.ag.x_size = 3 Config.ag.y_size = 3 Config.ag.z_size = 1 for turn_model in PackageFile.routing_alg_list_2d: Config.UsedTurnModel = deepcopy(turn_model) Config.TurnsHealth = deepcopy(Config.setup_turns_health()) ag_4_test = deepcopy(generate_ag(logging=None)) shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit( ) shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False) noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test, turn_model, False, False) self.assertEqual(check_deadlock_freeness(noc_rg), True) if turn_model in [ PackageFile.XY_TurnModel, PackageFile.YX_TurnModel ]: if turn_model == PackageFile.XY_TurnModel: self.assertEqual(return_turn_model_name(turn_model), '0') else: self.assertEqual(return_turn_model_name(turn_model), '13') self.assertEqual( degree_of_adaptiveness(ag_4_test, noc_rg, False) / 72, 1) self.assertEqual( extended_degree_of_adaptiveness(ag_4_test, noc_rg, False) / 72, 1) del ag_4_test del shmu_4_test Config.ag.type = "Generic" Config.ag.topology = "3DMesh" Config.ag.x_size = 3 Config.ag.y_size = 3 Config.ag.z_size = 3 Config.RotingType = "NonMinimalPath" for turn_model in PackageFile.routing_alg_list_3d: Config.UsedTurnModel = deepcopy(turn_model) Config.TurnsHealth = deepcopy(Config.setup_turns_health()) ag_4_test = deepcopy(generate_ag(logging=None)) shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit( ) shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False) noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test, turn_model, False, False) self.assertEqual(check_deadlock_freeness(noc_rg), True) if turn_model == PackageFile.XYZ_TurnModel: self.assertEqual(return_turn_model_name(turn_model), "3d_XYZ") self.assertEqual( degree_of_adaptiveness(ag_4_test, noc_rg, False) / 702, 1) self.assertEqual( extended_degree_of_adaptiveness(ag_4_test, noc_rg, False) / 702, 1) if turn_model == PackageFile.NegativeFirst3D_TurnModel: self.assertEqual(return_turn_model_name(turn_model), "3d_NegFirst") del ag_4_test del shmu_4_test del noc_rg Config.ag = deepcopy(initial_config_ag) Config.UsedTurnModel = initial_turn_model Config.TurnsHealth = deepcopy(Config.setup_turns_health()) Config.RotingType = initial_routing_type
def test_routing_functions(self): # backing up the original config... initial_config_ag = deepcopy(Config.ag) initial_turn_model = Config.UsedTurnModel initial_routing_type = Config.RotingType # ----------------------------------------------------- Config.ag.type = "Generic" Config.ag.topology = "2DMesh" Config.RotingType = "MinimalPath" Config.ag.x_size = 3 Config.ag.y_size = 3 Config.ag.z_size = 1 for turn_model in PackageFile.routing_alg_list_2d: tmName = return_turn_model_name(turn_model) Config.UsedTurnModel = deepcopy(turn_model) Config.TurnsHealth = deepcopy(Config.setup_turns_health()) ag_4_test = deepcopy(generate_ag(logging=None)) shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit( ) shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False) noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test, turn_model, False, False) self.assertEqual(check_deadlock_freeness(noc_rg), True, msg=f"TM {tmName} Deadlock freeness failed") if turn_model in [ PackageFile.XY_TurnModel, PackageFile.YX_TurnModel ]: if turn_model == PackageFile.XY_TurnModel: self.assertEqual(tmName, '0', msg=f"TM name {tmName} is not 0") else: self.assertEqual(tmName, '13', msg=f"TM name {tmName} is not 13") self.assertEqual( degree_of_adaptiveness(ag_4_test, noc_rg, report=False) / 72.0, 1.0, msg=f"TM: {tmName} DOA failed") self.assertEqual(extended_degree_of_adaptiveness( ag_4_test, noc_rg, report=False) / 72.0, 1.0, msg=f"TM: {tmName} DOAex failed") del ag_4_test del shmu_4_test # ----------------------------------------------------- Config.ag.type = "Generic" Config.ag.topology = "3DMesh" Config.RotingType = "NonMinimalPath" Config.ag.x_size = 3 Config.ag.y_size = 3 Config.ag.z_size = 3 for turn_model in PackageFile.routing_alg_list_3d: Config.UsedTurnModel = deepcopy(turn_model) Config.TurnsHealth = deepcopy(Config.setup_turns_health()) ag_4_test = deepcopy(generate_ag(logging=None)) shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit( ) shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False) noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test, turn_model, False, False) self.assertEqual(check_deadlock_freeness(noc_rg), True, msg=f"TM: {turn_model} deadlock freeness Failed!") if turn_model == PackageFile.XYZ_TurnModel: self.assertEqual(return_turn_model_name(turn_model), "3d_XYZ", msg="Turn Model is not 3d_XYZ") self.assertEqual( degree_of_adaptiveness(ag_4_test, noc_rg, False) / 702, 1, msg="DoA test failed") self.assertEqual( extended_degree_of_adaptiveness(ag_4_test, noc_rg, False) / 702, 1, msg="ExDoA test failed") if turn_model == PackageFile.NegativeFirst3D_TurnModel: self.assertEqual(return_turn_model_name(turn_model), "3d_NegFirst", msg="TM name is not 3d_NegFirst") del ag_4_test del shmu_4_test del noc_rg # ----------------------------------------------------- # going back to original config Config.ag = deepcopy(initial_config_ag) Config.UsedTurnModel = initial_turn_model Config.TurnsHealth = deepcopy(Config.setup_turns_health()) Config.RotingType = initial_routing_type
def report_3d_turn_model_fault_tolerance(turn_model, viz, combination): """ generates 3D architecture graph with all combinations C(len(ag.nodes), combination) of links and writes the average connectivity metric in a file. :param turn_model: list of allowed turns for generating the routing graph :param combination: number of links to be present in the network :param viz: if true, generates the visualization files :return: None """ if combination == 108: raise ValueError("breaking 108 edges out of 108 edges is not possible your connectivity is 0!") Config.UsedTurnModel = copy.deepcopy(turn_model) Config.TurnsHealth = copy.deepcopy(Config.setup_turns_health()) ag = copy.deepcopy(AG_Functions.generate_ag(report=False)) turn_model_name = return_turn_model_name(Config.UsedTurnModel) file_name = str(turn_model_name)+'_eval' turn_model_eval_file = open('Generated_Files/Turn_Model_Eval/'+file_name+'.txt', 'a+') if viz: file_name_viz = str(turn_model_name)+'_eval_'+str(len(ag.edges())-combination) turn_model_eval_viz_file = open('Generated_Files/Internal/'+file_name_viz+'.txt', 'w') else: turn_model_eval_viz_file = None counter = 0 metric_sum = 0 list_of_avg = [] number_of_combinations = comb(108, combination) while True: sub_ag = sample(ag.edges(), combination) shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu.setup_noc_shm(ag, copy.deepcopy(Config.TurnsHealth), False) for link in list(sub_ag): shmu.break_link(link, False) noc_rg = copy.deepcopy(Routing.generate_noc_route_graph(ag, shmu, Config.UsedTurnModel, False, False)) connectivity_metric = reachability_metric(ag, noc_rg, False) counter += 1 metric_sum += connectivity_metric # std = None list_of_avg.append(float(metric_sum)/counter) if len(list_of_avg) > 5000: list_of_avg.pop(0) std = stdev(list_of_avg) if std < 0.009: # turn_model_eval_file.write("STD of the last 5000 average samples is bellow 0.009\n") # turn_model_eval_file.write("Terminating the search!\n") del shmu del noc_rg break if viz: turn_model_eval_viz_file.write(str(float(metric_sum)/counter)+"\n") if counter >= number_of_combinations: del shmu del noc_rg break # print "#:"+str(counter)+"\t\tC.M.:"+str(connectivity_metric)+"\t\t avg:", \ # float(metric_sum)/counter, "\t\tstd:", std del shmu del noc_rg if counter > 0: avg_connectivity = float(metric_sum)/counter else: avg_connectivity = 0 turn_model_eval_file.write(str(len(ag.edges())-combination)+"\t\t"+str(avg_connectivity)+"\n") turn_model_eval_file.close() if viz: turn_model_eval_viz_file.close() return None