def get_data(self): self.tokenID = read() epoch_time = time.time() self.ts = str(datetime.datetime.fromtimestamp(epoch_time)) pass
return pos2 def oneGeneration(self): # generational newPop = [] for _ in range(self.__param['popSize']): p1 = self.__population[self.selection()] p2 = self.__population[self.selection()] off = p1.crossover(p2) off.mutation() newPop.append(off) self.__population = newPop self.evaluation() net = read('data/50p_easy_01_tsp.txt') MIN = 1 noDim = net["noNodes"] # initialise de GA parameters gaParam = {'popSize': 100, 'noGen': 1000, 'pc': 0.8, 'pm': 0.1} # problem parameters problParam = { 'min': MIN, 'max': noDim, 'function': modularity, 'noDim': noDim, 'noBits': 8, 'noNodes': net['noNodes'] } # store the best/average solution of each iteration (for a final plot used to anlyse the GA's convergence)
from ACO import ACO from Graph import Graph from Read import read, readTSP from random import seed from random import randint net = read('data/easy.txt') graph = Graph(net['mat'], net['noNodes']) aco = ACO(100, 150, 1, 1, 0.5, 5) bestSolution, bestDistance = aco.solve(graph) print(str(bestDistance) + ": ") for i in range(len(bestSolution)): print(str(bestSolution[i]) + " ")
f.write(x) else: f.write(x) elif s1 in x: break elif s2 in x: f.write(x) f.close() break else: f.write(x) file.close() arr=np.zeros(30,dtype=int) m=1 while m<c+1: read(m,arr) m=m+1 while True: speak.Speak("Would you like to know which questions remain unsolved or revise your answers? Answering no will end the paper") answer=stt() if answer=="no": break else: speak.Speak("Choose Option: 1. Revise answers\n2. Unsolved Questions\n") ans=stt() if int(ans)==2: unsolved(arr,c) elif int(ans)==1: revise(arr,c) else: