BnB(i, N, Pi) else: Cmax = service.loss_function(Pi, m) if Cmax < UB[0]: UB[0] = Cmax Pi_star[0] = Pi Pi = [] for j in N: BnB(j, N, Pi) return UB, Pi_star if __name__ == '__main__': _, m, data = service.read_data( 'D:\Programming\python\SPD\\fsp\data\\data002.txt') Lb_functions = [ BranchAndBounds.bound_1, BranchAndBounds.bound_2, BranchAndBounds.bound_3, BranchAndBounds.bound_4 ] Ub_functions = [BranchAndBounds.ub_1, BranchAndBounds.ub_2] for lb in Lb_functions: for Ub_functions in Ub_functions: """ Kombinacja funkcji [Cmax], [perm] = BranchAndBounds.find_c_max(data, m, ub, lb) print(Cmax) """ pass
class BruteForce: @staticmethod def find_c_max(data, m): def recursive(S, C_max, leaf, best, m): if len(S) > 0: for i in S: s = copy.copy(S) s.remove(i) l = copy.copy(leaf) l.append(i) recursive(s, C_max, l, best, m) else: C_tmp = FSPService.loss_function(leaf, m) if C_max[0] > C_tmp: C_max[0] = C_tmp best[0] = leaf tmp = [math.inf] leafs = [] perm = [[]] recursive(data, tmp, leafs, perm, m) return tmp[0], perm[0] _, m, data = FSPService.read_data( 'D:\Programming\python\SPD\\fsp\data\data003.txt') Cmax, perm = BruteForce.find_c_max(data, m) print(Cmax) print(perm)