# Load the random state load_state(random_path) # ----------------------------------------------------------------- # Load the parameters table parameters = tables.from_file(parameters_path, format="ascii.ecsv") # Load the chi squared table chi_squared = tables.from_file(chi_squared_path, format="ascii.ecsv") # ----------------------------------------------------------------- # Load the GA ga = GAEngine.from_file(path) # Check whether the chi-squared and parameter tables match for i in range(len(parameters)): assert parameters["Unique name"][i] == chi_squared["Unique name"][i] # Get the scores scores = chi_squared["Chi-squared"] check = parameters # Set the scores ga.set_scores(scores, check) # ----------------------------------------------------------------- new_generation = last_generation + 1 if last_generation is not None else 0
# Load the random state load_state(random_path) # ----------------------------------------------------------------- # Load the parameters table parameters = tables.from_file(parameters_path, format="ascii.ecsv") # Load the chi squared table chi_squared = tables.from_file(chi_squared_path, format="ascii.ecsv") # ----------------------------------------------------------------- # Load the GA ga = GAEngine.from_file(path) # Check whether the chi-squared and parameter tables match for i in range(len(parameters)): assert parameters["Unique name"][i] == chi_squared["Unique name"][i] # Get the scores scores = chi_squared["Chi-squared"] check = parameters # Set the scores ga.set_scores(scores, check) # ----------------------------------------------------------------- new_generation = last_generation + 1 if last_generation is not None else 0
# Inform the user log.info("Creating the GA engine ...") # Genome instance genome = G1DList(2) genome.setParams(rangemin=0., rangemax=50., bestrawscore=0.00, rounddecimal=2) genome.initializator.set(initializators.G1DListInitializatorReal) genome.mutator.set(mutators.G1DListMutatorRealGaussian) #genome.evaluator.set(chi_squared_function) # Inform the user log.info("Creating the GA engine ...") # Genetic algorithm instance ga = GAEngine(genome) ga.terminationCriteria.set(RawScoreCriteria) ga.setMinimax(constants.minimaxType["minimize"]) ga.setGenerations(5) ga.setCrossoverRate(0.5) ga.setPopulationSize(100) ga.setMutationRate(0.5) # Initialize the genetic algorithm ga.initialize() name_column = [] par_a_column = [] par_b_column = []
seed = config.seed prng = setup_prng(seed) # ----------------------------------------------------------------- # Genome instance genome = G1DList(2) genome.setParams(rangemin=0., rangemax=50., bestrawscore=0.00, rounddecimal=2) genome.initializator.set(initializators.G1DListInitializatorReal) genome.mutator.set(mutators.G1DListMutatorRealGaussian) # Set the evaluator function genome.evaluator.set(chi_squared_function) # Genetic algorithm instance ga = GAEngine(genome) ga.terminationCriteria.set(RawScoreCriteria) ga.setMinimax(constants.minimaxType["minimize"]) ga.setGenerations(5) ga.setCrossoverRate(0.5) ga.setPopulationSize(100) ga.setMutationRate(0.5) # Evolve #ga.evolve(freq_stats=False) ga.evolve() print("Final generation:", ga.currentGeneration) # -----------------------------------------------------------------
# Inform the user log.info("Creating the GA engine ...") # Genome instance genome = G1DList(2) genome.setParams(rangemin=0., rangemax=50., bestrawscore=0.00, rounddecimal=2) genome.initializator.set(initializators.G1DListInitializatorReal) genome.mutator.set(mutators.G1DListMutatorRealGaussian) #genome.evaluator.set(chi_squared_function) # Inform the user log.info("Creating the GA engine ...") # Genetic algorithm instance ga = GAEngine(genome) ga.terminationCriteria.set(RawScoreCriteria) ga.setMinimax(constants.minimaxType["minimize"]) ga.setGenerations(5) ga.setCrossoverRate(0.5) ga.setPopulationSize(100) ga.setMutationRate(0.5) # Initialize the genetic algorithm ga.initialize() name_column = [] par_a_column = [] par_b_column = [] pop = ga.internalPop
seed = config.seed prng = setup_prng(seed) # ----------------------------------------------------------------- # Genome instance genome = G1DList(2) genome.setParams(rangemin=0., rangemax=50., bestrawscore=0.00, rounddecimal=2) genome.initializator.set(initializators.G1DListInitializatorReal) genome.mutator.set(mutators.G1DListMutatorRealGaussian) # Set the evaluator function genome.evaluator.set(chi_squared_function) # Genetic algorithm instance ga = GAEngine(genome) ga.terminationCriteria.set(RawScoreCriteria) ga.setMinimax(constants.minimaxType["minimize"]) ga.setGenerations(5) ga.setCrossoverRate(0.5) ga.setPopulationSize(100) ga.setMutationRate(0.5) # Evolve #ga.evolve(freq_stats=False) ga.evolve() print("Final generation:", ga.currentGeneration) # -----------------------------------------------------------------