def main(): np.random.seed(7890) # recebendo instâncias r = ReadingDatas("dat/p01") r.readFile() # adicionando clientes Customers.addCustomers(r) # for cst in Customers.get_customersList().values(): # print(cst) # adicionando depósitos Depots.addDepots(r) # print("\n\n\n\") # for dpt in Depots.get_depotsList().values(): # print(dpt) # cálculo das distâncias Distances.euclidianDistanceAll(Customers.get_customersList(), Depots.get_depotsList()) # for cst in Customers.get_customersList(): # print(cst) # print(Customers.get_customersList()[cst].get_depotsDistances()) # print("\n\n\n") # for cst in Customers.get_customersList(): # print(cst) # print(Customers.get_customersList()[cst].get_neighborsDistances()) ga = GA() ga.GA()
def main(SEED, POP, DESC, PROB_MUT, PROB_LS_POP, PROB_LS, PROB_LSB, PROB_LSBP, GEN_ILS, GEN_ILSA, DATFILE, INSTANCE): # redefinindo variáveis conforme Package Irace # config.FRAC_MAX_DISTRIBUTION = FRAC config.SIZE_POP = POP config.SIZE_DESC = DESC config.PROB_MUTATION = PROB_MUT config.PROB_LS_POP = PROB_LS_POP config.PROB_LS = PROB_LS config.PROB_LS_BEST = PROB_LSB config.PROB_LS_BEST_P = PROB_LSBP config.GEN_ILS = GEN_ILS config.GEN_ILSA = GEN_ILSA seed = SEED timeIni = time.time() # exit(0) # recebendo instâncias r = ReadingDatas(INSTANCE) r.readFile() # adicionando clientes Customers.addCustomers(r) # adicionando depósitos Depots.addDepots(r) # cálculo das distâncias Distances.euclidianDistanceAll(Customers.get_customersList(), Depots.get_depotsList()) ga = GA() best = ga.GA(seed) cost = best.get_cost() timeEnd = (time.time() - timeIni) / 60.0 logging.debug("Melhor indivíduo: %s" % best) logging.debug("tempo total: " + str(timeEnd) + " minutos.") logging.debug("------------fim algoritmo genético-----------") with open(DATFILE, 'w') as f: f.write(str(cost))