def resumeSession(runNumber): #raise Exception("Not properly integrated with new graphics! Exiting...") population, params = loadSession(runNumber) path = "./Data/Run " + str(runNumber) #Get the iteration number try: os.remove(path + "/.DS_Store") #Try and get rid of .DS_Store except: pass iterNumber = int(sorted(os.listdir(path)[1:], key=lambda x: int(x.split(" ")[-1]))[-1].split(" ")[-1]) + 1 """ #What that (^) line does - Gets a list of all files in the directory ./Data/Run # and get rid of evolution_parameters.pkl os.listdir(path)[1] - Sorts the list based on the number after 'Iteration ' sorted(os.listdir(path), key=lambda x: int(x.split(" ")[-1]) - Gets the last element and extracts its number [-1].split(" ")[-1]) - Increments that number by 1 + 1 """ #Startup the graphics window window = graphics.StatusWindow(params.iterations, params.popSize, params.trainingTimeout, params.trainingTarget) #Restart evolution GA.continuousEvolution(population, params, run_number = runNumber, start_iteration_number = iterNumber, graphicsWindow = window)
def createSession(popSize = 45, iterations = 10, mutate=0.2, extraParents=0.1, originalParents=0.2, hiddenLayers = 3, maxLayerSize = 15, trainingTimeout = 10, trainingTarget = 1.0): global window population = GA.networkLib.createPopulation(popSize, hiddenLayers, maxLayerSize) #Startup the graphics window window = graphics.StatusWindow(iterations, popSize, trainingTimeout, trainingTarget) window.update() #raise Exception("Program stopped!") #Set up an object to store evolutionary parameters params = GA.EvolutionObject() params.popSize = popSize params.iterations = iterations params.mutate = mutate params.extraParents = extraParents params.originalParents = originalParents params.trainingTimeout = trainingTimeout params.trainingTarget = trainingTarget #Start the program GA.continuousEvolution(population, params, graphicsWindow = window)