def CommAccuracy(chain, generation): dynamic_set = basics.load(3, chain, generation, "d") static_set = basics.load(3, chain, generation, "s") accuracy = 0 for item in dynamic_set + static_set: target_triangle = item[1] + ";" + item[2] + ";" + item[3] selected_triangle = item[5] + ";" + item[6] + ";" + item[7] if target_triangle == selected_triangle: accuracy += 1 return accuracy
def generation_pairs(chain, generation): dynamic_set = basics.load(3, chain, generation, "d") static_set = basics.load(3, chain, generation, "s") triangle_pairs = [] for item in dynamic_set + static_set: target_triangle = item[1] + ";" + item[2] + ";" + item[3] selected_triangle = item[5] + ";" + item[6] + ";" + item[7] if target_triangle != selected_triangle: triangle_pairs.append([target_triangle, selected_triangle]) return triangle_pairs
def CommError(chain, generation, distances=None): if distances == None: distances = reliable_distances dynamic_set = basics.load(3, chain, generation, "d") static_set = basics.load(3, chain, generation, "s") triangle_pairs = [] for item in dynamic_set + static_set: target_triangle = item[1] + ";" + item[2] + ";" + item[3] selected_triangle = item[5] + ";" + item[6] + ";" + item[7] if target_triangle != selected_triangle: triangle_pairs.append(target_triangle + "~" + selected_triangle) error = 0.0 for pair in triangle_pairs: error += distances[pair] return error