def get_results(self): for f in self.parent.upper_frame.right_frame.list_files: structure = read_file(join("Data/all", f), f in listFiles) if self.parent.upper_frame.left_frame.algo.get() == 0: preferences = structure["preferences"] if self.parent.upper_frame.left_frame.filtered.get(): preferences, nb_voters, nb_unique = remove_last_ballots( preferences) candidates = structure["candidates"] ensemble, best = bnb(len(preferences), preferences, candidates) axes, card = find_axes2(best[0][0], candidates) axes = filter_symmetric_axes(axes) for axis in axes: self.results.append((f, axis)) else: if self.parent.upper_frame.left_frame.dissimilarity.get() == 0: dissimilarity_function = dissimilarity_and_n elif self.parent.upper_frame.left_frame.dissimilarity.get( ) == 1: dissimilarity_function = dissimilarity_and_or else: dissimilarity_function = dissimilarity_over_over if f in listFiles: t, permutations = find_axis_from_structure( structure, dissimilarity_function, self.parent.upper_frame.left_frame.weighted.get()) else: t, permutations = find_axis_from_structure( structure, dissimilarity_function, self.parent.upper_frame.left_frame.weighted.get(), unwanted_candidates=[2, 3, 7, 11]) permutations = filter_symmetric_axes(permutations[1]) for permutation in permutations: self.results.append((f, permutation))
def calculate_bnb(self, file, vrow, filtered): structure = read_file("Data/all/" + str(file), file in listFiles) if not filtered: preferences = structure["preferences"] candidates = structure["candidates"] Label(self, text=str(structure["nb_voters"])).grid(row=vrow, column=3) Label(self, text=str(structure["nb_unique_orders"])).grid(row=vrow, column=5) else: preferences_bis = structure["preferences"] preferences, nb_voters, nb_unique = remove_last_ballots( preferences_bis) candidates = structure["candidates"] Label(self, text=str(nb_voters)).grid(row=vrow, column=3) Label(self, text=str(nb_unique)).grid(row=vrow, column=5) t1 = time() ensemble, best = bnb(len(preferences), preferences, candidates) t2 = time() Label(self, text=str(best[1])).grid(row=vrow, column=7) Label(self, text=str(len(best[0][0]))).grid(row=vrow, column=9) if not filtered: Label(self, text=str(best[1] * 100.0 / structure["nb_voters"])).grid( row=vrow, column=11) else: Label(self, text=str(best[1] * 100.0 / nb_voters)).grid(row=vrow, column=11) axes, card = find_axes2(best[0][0], candidates) Label(self, text=str(len(axes))).grid(row=vrow, column=13) Label(self, text=str(t2 - t1)).grid(row=vrow, column=15)
def get_results(self): for f in self.parent.upper_frame.right_frame.list_files: structure = read_file(join("Data/all", f), f in listFiles) if self.parent.upper_frame.left_frame.algo.get() == 0: preferences = structure["preferences"] if self.parent.upper_frame.left_frame.filtered.get(): preferences, nb_voters, nb_unique = remove_last_ballots(preferences) candidates = structure["candidates"] ensemble, best = bnb(len(preferences), preferences, candidates) axes, card = find_axes2(best[0][0], candidates) axes = filter_symmetric_axes(axes) for axis in axes: self.results.append((f, axis)) else: if self.parent.upper_frame.left_frame.dissimilarity.get() == 0: dissimilarity_function = dissimilarity_and_n elif self.parent.upper_frame.left_frame.dissimilarity.get() == 1: dissimilarity_function = dissimilarity_and_or else: dissimilarity_function = dissimilarity_over_over if f in listFiles: t, permutations = find_axis_from_structure(structure, dissimilarity_function, self.parent.upper_frame.left_frame.weighted.get()) else: t, permutations = find_axis_from_structure(structure, dissimilarity_function, self.parent.upper_frame.left_frame.weighted.get(), unwanted_candidates=[2, 3, 7, 11]) permutations = filter_symmetric_axes(permutations[1]) for permutation in permutations: self.results.append((f, permutation))
def calculate_bnb(self, file, vrow, filtered): structure = read_file("Data/all/" + str(file), file in listFiles) if not filtered: preferences = structure["preferences"] candidates = structure["candidates"] Label(self, text=str(structure["nb_voters"])).grid(row=vrow, column=3) Label(self, text=str(structure["nb_unique_orders"])).grid(row=vrow, column=5) else: preferences_bis = structure["preferences"] preferences, nb_voters, nb_unique = remove_last_ballots(preferences_bis) candidates = structure["candidates"] Label(self, text=str(nb_voters)).grid(row=vrow, column=3) Label(self, text=str(nb_unique)).grid(row=vrow, column=5) t1 = time() ensemble, best = bnb(len(preferences), preferences, candidates) t2 = time() Label(self, text=str(best[1])).grid(row=vrow, column=7) Label(self, text=str(len(best[0][0]))).grid(row=vrow, column=9) if not filtered: Label(self, text=str(best[1] * 100.0 / structure["nb_voters"])).grid(row=vrow, column=11) else: Label(self, text=str(best[1] * 100.0 / nb_voters)).grid(row=vrow, column=11) axes, card = find_axes2(best[0][0], candidates) Label(self, text=str(len(axes))).grid(row=vrow, column=13) Label(self, text=str(t2 - t1)).grid(row=vrow, column=15)