def run_ga(fast): """Initialize and run the genetic algorithms.""" alleles = GAllele.GAlleles() # create list of all alleles alleles.add(GAllele.GAlleleRange(1, 1000)) # range for the number of days alleles.add(GAllele.GAlleleRange(1, 20)) # range for hidden nodes alleles.add(GAllele.GAlleleRange(1, 10)) # number of epochs alleles.add(GAllele.GAlleleList([True, False])) # bias alleles.add( GAllele.GAlleleList([float(x * Decimal("0.1")) for x in range(0, 10)])) # momentum alleles.add(GAllele.GAlleleList([TanhLayer, SigmoidLayer])) # tanh/sigmoid genome = G1DList.G1DList(len(alleles)) genome.setParams(allele=alleles, fast=fast) genome.evaluator.set(eval_func) genome.mutator.set(Mutators.G1DListMutatorAllele) genome.initializator.set(Initializators.G1DListInitializatorAllele) gen_alg = GSimpleGA.GSimpleGA(genome) gen_alg.setMultiProcessing(not fast) gen_alg.selector.set(Selectors.GRouletteWheel) gen_alg.setGenerations(20) gen_alg.evolve(freq_stats=0) return gen_alg.bestIndividual()
def new_genome(results_path, **kwargs): ''' *new_genome : takes a set of alleles [function_alleles, leaves_alleles] and options that define initializator, mutator, crossover, evaluator and returns a genome with those options possible initializator : "grow" : "grow" algorithm of network = recursive and possibly incomplete possible mutator : "simple" : change genomic alleles with possible alleles with probability pmut possible crossover : possible evaluator : "degree_distribution", "2distributions" possible network-type : "directed_weighted", "directed_unweighted", "undirected_weighted", "undirected_unweighted" possible tree_type : "with_constants" ''' evaluation_method = kwargs.get("evaluation_method") network_type = kwargs.get("network_type") data_path = kwargs.get("data_path") name = kwargs.get("name") dynamic = kwargs.get("dynamic") extension = kwargs.get("extension") choices = emo.get_alleles(evaluation_method, network_type) genome = py.GTree.GTree() #genome.setParams(nb_nodes=ne.get_number_of_nodes(results_path)) #genome.setParams(nb_edges=ne.get_number_of_edges(results_path)) genome.setParams(data_path=data_path) genome.setParams(results_path=results_path) genome.setParams(name=name) genome.setParams(extension=extension) #defines alleles : one array containing possible leaves and one containing possible functions alleles = gall.GAlleles() lst = gall.GAlleleList(choices) alleles.add(lst) genome.setParams(allele=alleles) #defines the way to construct a random tree genome.setParams(max_depth=int(kwargs.get("max_depth", "3"))) genome.setParams(max_siblings=int(kwargs.get("max_siblings", "2"))) genome.setParams(tree_type=kwargs.get("tree_type", "default")) genome.initializator.set(tree_init) #defines the how to evaluate a genome genome.setParams(evaluation_method=evaluation_method) if dynamic: genome.evaluator.set(eval_func_dynamic) else: genome.evaluator.set(eval_func) #defines the crossover function - default now #defines the function that mutates trees genome.mutator.set(mutate_tree) #defines the network_type genome.setParams(network_type=network_type) #tree_init(genome) return genome
def solve(): setOfAlleles = GAllele.GAlleles(homogeneous=True) lst = [i for i in xrange(len(points))] a = GAllele.GAlleleList(lst) setOfAlleles.add(a) genome = G1DList.G1DList(len(points)) genome.setParams(allele=setOfAlleles) genome.evaluator.set(eval_func) genome.mutator.set(Mutators.G1DListMutatorSwap) genome.crossover.set(Crossovers.G1DListCrossoverOX) genome.initializator.set(tsp_initializator) ga = GSimpleGA.GSimpleGA(genome) ga.setGenerations(1000) ga.setMinimax(Consts.minimaxType["minimize"]) ga.setCrossoverRate(1.0) ga.setMutationRate(0.03) ga.setPopulationSize(80) ga.evolve(freq_stats=100) best = ga.bestIndividual() best.append(best[0]) for i in range(len(best) - 1): canvas.create_line(points[best[i]].x, points[best[i]].y, points[best[i + 1]].x, points[best[i + 1]].y)
def main_run(): global cm, coords # load the tsp data file filehandle = open("instancias.txt", "r+") coords = read_file(filehandle) cm = cartesian_matrix(coords) # set the alleles to the cities numbers setOfAlleles = GAllele.GAlleles(homogeneous=True) lst = [i for i in xrange(len(coords))] a = GAllele.GAlleleList(lst) setOfAlleles.add(a) genome = G1DList.G1DList(len(coords)) genome.setParams(allele=setOfAlleles) genome.evaluator.set(eval_func) genome.mutator.set(Mutators.G1DListMutatorSwap) genome.crossover.set(Crossovers.G1DListCrossoverOX) genome.initializator.set(G1DListTSPInitializator) ga = GSimpleGA.GSimpleGA(genome) ga.setGenerations(1000) ga.setMinimax(Consts.minimaxType["minimize"]) ga.setCrossoverRate(1.0) ga.setMutationRate(0.03) ga.setPopulationSize(80) ga.evolve(freq_stats=100) best = ga.bestIndividual() write_tour_to_img(coords, best, "tsp_result.png")
def run_main(): # Genome instance setOfAlleles = GAllele.GAlleles() for i in xrange(1000): # You can even add objects instead of strings or # primitive values a = GAllele.GAlleleList(['UP', 'DOWN', 'LEFT', 'RIGHT']) setOfAlleles.add(a) # Genome instance genome = G1DList.G1DList(300) #genome.setParams(rangemin=0, rangemax=10) genome.setParams(allele=setOfAlleles) # The evaluator function (objective function) genome.evaluator.set(eval_func) # This mutator and initializator will take care of # initializing valid individuals based on the allele set # that we have defined before genome.mutator.set(Mutators.G1DListMutatorAllele) genome.initializator.set(Initializators.G1DListInitializatorAllele) # Genetic Algorithm Instance ga = GSimpleGA.GSimpleGA(genome) ga.selector.set(Selectors.GRouletteWheel) ga.setGenerations(800) ga.stepCallback.set(evolve_callback) # Do the evolution ga.evolve() # Best individual print ga.bestIndividual()
def _make_alleles(self): """ Returns a GAllelle.Galleles instance with alleles corresponding to the parameters specified by the user""" alleles = GAllele.GAlleles() count = 0 for param in self.get_parameters().values(): allele = None count += 1 val = param.evaluate() #now grab the value low = param.low high = param.high metadata = param.get_metadata()[0][1] #then it's a float or an int, or a member of an array if ('low' in metadata or 'high' in metadata) or array_test.search(param.targets[0]): if isinstance(val, real_types): #some kind of float allele = GAllele.GAlleleRange(begin=low, end=high, real=True) #some kind of int if isinstance(val, int_types): allele = GAllele.GAlleleRange(begin=low, end=high, real=False) elif "values" in metadata and isinstance(metadata['values'], iterable_types): allele = GAllele.GAlleleList(metadata['values']) if allele: alleles.add(allele) else: self.raise_exception("%s is not a float, int, or enumerated \ datatype. Only these 3 types are allowed"%(param.targets[0]),ValueError) self.count = count return alleles
def run_main(): print "Starting main()!" #sys.stdout.flush() global NUM_GENS, NUM_POP, NUM_ELITE, GLOB_COUNT, NO_OF_PARAMS setOfAlleles = GAllele.GAlleles() sf = GAllele.GAlleleList(strp_fac) su = GAllele.GAlleleList(strp_unt) cn = GAllele.GAlleleList(cb_nds) # cs = GAllele.GAlleleList(cb_buf_size) al = GAllele.GAlleleList(alignment) sb = GAllele.GAlleleList(siv_buf_size) setOfAlleles.add(sf) setOfAlleles.add(su) setOfAlleles.add(cn) # setOfAlleles.add(cs) setOfAlleles.add(al) setOfAlleles.add(sb) genome = G1DList.G1DList(NO_OF_PARAMS) genome.setParams(allele=setOfAlleles) genome.evaluator.set(eval_func) genome.mutator.set(Mutators.G1DListMutatorAllele) genome.initializator.set(Initializators.G1DListInitializatorAllele) ga = GSimpleGA.GSimpleGA(genome) ga.selector.set(Selectors.GRouletteWheel) ga.setMutationRate(0.15); ga.setGenerations(NUM_GENS) #ga.terminationCriteria.set(ConvergenceCriteria) ga.setPopulationSize(NUM_POP) ga.setMinimax(Consts.minimaxType["minimize"]) ga.setElitism(True) ga.setElitismReplacement(NUM_ELITE) print 'ga.evolve' ga.evolve(freq_stats=1) print 'closing result' result_output.close() print 'Best solution' print ga.bestIndividual()
def main_run(path): global cm, coords # write_random(filename, number of the cities, max width, max height) #write_random("tsp_coords.txt", 50, 400, 400) # load the tsp data file filehandle = open("tsp_coords.txt", "r") coords = path cm = cartesian_matrix(coords) # set the alleles to the cities numbers setOfAlleles = GAllele.GAlleles(homogeneous=True) lst = [ i for i in xrange(len(coords)) ] a = GAllele.GAlleleList(lst) setOfAlleles.add(a) genome = G1DList.G1DList(len(coords)) genome.setParams(allele=setOfAlleles) genome.evaluator.set(eval_func) genome.mutator.set(Mutators.G1DListMutatorSwap) genome.crossover.set(Crossovers.G1DListCrossoverOX) genome.initializator.set(G1DListTSPInitializator) ga = GSimpleGA.GSimpleGA(genome) ga.setGenerations(300) ga.setMinimax(Consts.minimaxType["minimize"]) ga.setCrossoverRate(1.0) ga.setMutationRate(0.03) ga.setPopulationSize(80) #sqlite_adapter = DBAdapters.DBSQLite(identify="tsp", commit_freq=1000, frequency=500) #ga.setDBAdapter(sqlite_adapter) # This is to make a video # ga.stepCallback.set(evolve_callback) ga.evolve(freq_stats=100) best = ga.bestIndividual() best.fitness_list = fitness_list if PIL_SUPPORT: write_tour_to_img(coords,cm, best, "tsp_result_%d.png") else: print "No PIL detected, cannot plot the graph !" return [best.getRawScore(), fitness_list]
def main_run(distancesFileName, fragmentFileName, crossover_rate=1.0, mutation_rate=0.03, population_size=80): """ @param distancesFileName String The file containing the pairwise distances of all fragments """ global cm, coords, fragments # Load the fragments fragmentFile = open(fragmentFileName, "r") fragments = readFragmentFile(fragmentFile) # load the tsp data file filehandle = open(distancesFileName, "r") coords = read_coords(filehandle) cm = coords # set the alleles to the cities numbers setOfAlleles = GAllele.GAlleles(homogeneous=True) lst = [i for i in xrange(len(coords))] a = GAllele.GAlleleList(lst) setOfAlleles.add(a) genome = G1DList.G1DList(len(coords)) genome.setParams(allele=setOfAlleles) genome.evaluator.set(eval_func) genome.mutator.set(Mutators.G1DListMutatorSwap) genome.crossover.set(Crossovers.G1DListCrossoverOX) genome.initializator.set(G1DListTSPInitializator) ga = GSimpleGA.GSimpleGA(genome) ga.setGenerations(5000) # 10000 is a good "real" value ga.setMinimax(Consts.minimaxType["minimize"]) ga.setCrossoverRate(crossover_rate) ga.setMutationRate(mutation_rate) ga.setPopulationSize(population_size) ga.evolve(freq_stats=100) best = ga.bestIndividual() return eval_func(best), best.getInternalList()
def run_main(): # Genome instance setOfAlleles = GAllele.GAlleles() # From 0 to 10 we can have only some # defined ranges of integers for i in xrange(11): a = GAllele.GAlleleRange(0, i) setOfAlleles.add(a) # From 11 to 19 we can have a set # of elements for i in xrange(11, 20): # You can even add objects instead of strings or # primitive values a = GAllele.GAlleleList(['a', 'b', 'xxx', 666, 0]) setOfAlleles.add(a) print setOfAlleles genome = G1DList.G1DList(20) genome.setParams(allele=setOfAlleles) # The evaluator function (objective function) genome.evaluator.set(eval_func) # This mutator and initializator will take care of # initializing valid individuals based on the allele set # that we have defined before genome.mutator.set(Mutators.G1DListMutatorAllele) genome.initializator.set(Initializators.G1DListInitializatorAllele) # Genetic Algorithm Instance ga = GSimpleGA.GSimpleGA(genome) ga.setGenerations(40) # Do the evolution, with stats dump # frequency of 10 generations ga.evolve(freq_stats=5) # Best individual print ga.bestIndividual()
def __init__(self, generations, population, crossover, mutation, elite, experiment, genCallBack, evalFunc, drivers): self.experiment = experiment self.population = population self.crossoverProb = crossover self.elite = elite self.mutationProb = mutation self.generations = generations self.genCallBack = genCallBack self.evalFunc = evalFunc self.drivers = drivers # sets pyevolve # create alleles to make a GA model. each driver is represented as an allele # each driver can take k different routes which is modelled by the different # values each allele can take driversAlleles = GAllele.GAlleles() for dr in drivers: lst = GAllele.GAlleleList(range(dr.od.numPaths)) driversAlleles.add(lst) # define a genome with length = length of drivers genome = G1DList.G1DList(len(drivers)) genome.setParams(allele=driversAlleles) genome.evaluator.set(self.evalFuncCallback) genome.initializator.set(self.initGenome) # Genetic Algorithm Instance self.ga = GSimpleGA.GSimpleGA(genome) self.ga.setMinimax(Consts.minimaxType["minimize"]) self.ga.selector.set(Selectors.GRankSelector) self.ga.setGenerations(self.generations) self.ga.stepCallback.set(self.genCallBack) self.ga.setMutationRate(self.mutationProb) self.ga.setCrossoverRate(self.crossoverProb) self.ga.setPopulationSize(self.population) self.ga.terminationCriteria.set(GSimpleGA.RawStatsCriteria) self.ga.setElitism(True) self.ga.setElitismReplacement(self.elite) self.ga.setSortType(Consts.sortType["raw"])
def run(self): # Allele define valid chromosome value alleles = GAllele.GAlleles() # Define gene with 2 chromosomes # MA type alleles.add(GAllele.GAlleleList([0, 1, 2, 3, 4])) # MA range alleles.add(GAllele.GAlleleRange(1, 99)) # Genome instance, 1D List genome = G1DList.G1DList(len(alleles)) # Sets the range max and min of the 1D List genome.setParams(allele=alleles) # The evaluator function (evaluation function) genome.evaluator.set(self.fitness) # This mutator and initializator will take care of # initializing valid individuals based on the allele set # that we have defined before genome.mutator.set(Mutators.G1DListMutatorAllele) genome.initializator.set(Initializators.G1DListInitializatorAllele) # Genetic Algorithm Instance ga = GSimpleGA.GSimpleGA(genome) # Set the Roulette Wheel selector method, the number of generations and # the termination criteria ga.selector.set(Selectors.GRouletteWheel) ga.setGenerations(self.gen) ga.setPopulationSize(self.pop) ga.terminationCriteria.set(GSimpleGA.ConvergenceCriteria) pop = ga.getPopulation() pop.scaleMethod.set(Scaling.SigmaTruncScaling) ga.evolve(freq_stats=10) # Best individual self.best = ga.bestIndividual()
def test_createAlleleList_default(self): _allelelist = GAllele.GAlleleList() self.assertEqual(_allelelist.options, []) _allelelist = GAllele.GAlleleList(options=[1, 2, 3]) self.assertEqual(_allelelist.options, [1, 2, 3])
# In[ ]: Start = dt.datetime.now() S = dt.datetime.now() genome = G1DList.G1DList(len(gd_req)) setOfAlleles = GAllele.GAlleles() for i in np.array(gd_req["skill_requirement"]): # You can even add an object to the list try: b = skill_matrix.loc[i].unique() except: b = [0] a = GAllele.GAlleleList(b) setOfAlleles.add(a) genome.setParams(allele=setOfAlleles) genome.mutator.set(mutator_allel_final) #genome.initializator.set(Initializators.G1DListInitializatorAllele) genome.initializator.set(initializator_final_temp) genome.crossover.set(crossover_uniform_final_all) # The evaluator function (objective function) genome.evaluator.set(obj_test_all) #ga.setElitism(True) # Genetic Algorithm Instance ga = GSimpleGA.GSimpleGA(genome) ga.selector.set(Selectors.GRankSelector) ga.stepCallback.set(callback_agent_count)
def generateDecision(self): setOfAlleles = GAllele.GAlleles(homogeneous=True) #raw_input("Press ENTER to exit") # prepare indices #print "Preparing indices..." indicesContainer = IndicesContainer(self.training_low_prices, self.training_high_prices, self.training_close_prices, self.training_volumes) indicesContainer.computeIndices() indicesList = indicesContainer.getIndicesList() # prepare sell trend and buy trend vectors #print "Preparing sell trend and buy trend vectors..." #normalizedIndicesList = indices.indicesNormalizer().normalize(indicesContainer.getIndicesList()) tradingGA.sellTrendBeginning, tradingGA.buyTrendBeginning = simpleTrendBeginningsFinder( self.training_close_prices, indicesList).findTrendBeginnings() # prepare individual #print "Preparing first individual..." a = GAllele.GAlleleList(indicesList) setOfAlleles.add(a) genome = G1DList.G1DList() genome.setParams(allele=setOfAlleles) genome.evaluator.set(eval_func) genome.mutator.set(G1DListStockMutator) genome.crossover.set(G1DListStockCrossoverOperator) genome.initializator.set(G1DListStockInitializator) # prepare engine #print "Preparing Genetic Algorithm engine..." ga = GSimpleGA.GSimpleGA(genome) ga.setGenerations(self.generations) ga.setMinimax(Consts.minimaxType["maximize"]) ga.setCrossoverRate(1.0) ga.setMutationRate(0.1) ga.setElitismReplacement(3) ga.selector.set(Selectors.GUniformSelector) ga.setPopulationSize(self.population_size) #print "Executing indices subset search..." ga.evolve(freq_stats=0) best = ga.bestIndividual() #print "Generating trading signal..." #print "Preparing prediction set indices..." predictionIndicesContainer = IndicesContainer( self.prediction_low_prices, self.prediction_high_prices, self.prediction_close_prices, self.prediction_volumes) predictionIndicesContainer.computeIndices() predictionIndicesList = predictionIndicesContainer.getIndicesList() # prepare sell trend and buy trend vectors #print "Preparing prediction set sell trend and buy trend vectors..." sell = computeClusterCentre(best.getInternalList(), tradingGA.sellTrendBeginning) buy = computeClusterCentre(best.getInternalList(), tradingGA.buyTrendBeginning) predictionIndicesList = pickIndices(predictionIndicesList, best.getInternalList()) prediction = computeClusterCentre( predictionIndicesList, len(predictionIndicesList[0].getResult( ))) #trend beginning to ostatni element listy z danymi d1 = numpy.linalg.norm(numpy.asarray(buy) - numpy.asarray(prediction)) d2 = numpy.linalg.norm(numpy.asarray(sell) - numpy.asarray(prediction)) if d1 < d2: #print "Time for Buyin'" return 1 elif d1 > d2: #print "Time for Sellin'" return -1 return 0
def test_AlleleList_iter(self): _allelelist = GAllele.GAlleleList(options=[1, 2, 3]) self.assertIsInstance(iter(_allelelist), Iterable)
def test_AlleleList_slicing(self): _allelelist = GAllele.GAlleleList(options=[1, 2, 3]) self.assertEqual(_allelelist[0:2], [1, 2]) self.assertEqual(_allelelist[1], 2) _allelelist[1] = 4 self.assertEqual(_allelelist[1], 4)
def test_AlleleList_getRandomAllele(self): _allelelist = GAllele.GAlleleList(options=[1, 2, 3]) random_allele = _allelelist.getRandomAllele() self.assertIn(random_allele, _allelelist.options)
def test_AlleleList_add(self): _allelelist = GAllele.GAlleleList(options=[1, 2, 3]) _allelelist.add(4) self.assertEqual(_allelelist.options, [1, 2, 3, 4])
#pueden usarse numeros especificos, letras, listas, tuplas, diccionarios, objetos personalizados, otros, y combinaciones #de todos los anteriores; el limite lo pone quien programa. #Un ejemplo de definicion de uso de alelos en pyevolve, podria ser: #setOfAlleles = GAllele.GAlleles() #En este caso se usaran 20 genes #for x in xrange(20): #Iteracion para agregar el alfabeto a cada gen # a = GAllele.GAlleleList(['a', 24.2685, [1,2,3,4], Objeto()]) #Se define el alfabeto (puede ser cambiante) # setOfAlleles.add(a) #Se agrega al set de alelos, para el gen en cuestion # #genome = G1DList.G1DList(20) #se crea el tipo de genoma, en este caso de 20 genes #genome.setParams(allele=setOfAlleles) #se usa el set de alelos para este genoma # Se definen los alelos (alfabeto) a utilizar, y se asigna a cada gen (se puede asignar alfabetos distintos para cada gen) setOfAlleles = GAllele.GAlleles() for x in xrange(): a = GAllele.GAlleleList() #Defina el alfabeto setOfAlleles.add(a) genome = G1DList.G1DList() # Se agrega la lista de alelos como parametro del genoma genome.setParams(allele=setOfAlleles) # Defina que funcion evaluadora, initializator, mutator y crossover utilizara. Busque los ultimos 3 en el Anexo genome.evaluator.set() genome.initializator.set() genome.mutator.set() genome.crossover.set() ga = GSimpleGA.GSimpleGA(genome)
def run_ga(): global ga #___________________Genome instance # setOfAlleles = GAllele.GAlleleList() pars_min = velocity_min + depth_min + vpvs_min pars_max = velocity_max + depth_max + vpvs_max num_pars = len(pars_min) for (vmin, vmax) in zip(pars_min, pars_max): tmp = GAllele.GAlleleRange(vmin, vmax, real=True) setOfAlleles.add(tmp) genome = G1DList.G1DList(num_pars) genome.setParams(allele=setOfAlleles) genome.initializator.set(Initializators.G1DListInitializatorAllele) genome.mutator.set(Mutators.G1DListMutatorAllele) genome.crossover.set(Crossovers.G1DListCrossoverUniform) #___________________The evaluator function (objective function) # genome.evaluator.set(eval_func) #___________________Genetic Algorithm Instance # ga = GSimpleGA.GSimpleGA(genome, seed=int(seed)) if num_cpu: ga.setMultiProcessing(True, True, int(num_cpu)) if ga_selector == 'T': ga.selector.set(Selectors.GTournamentSelector) if ga_selector == 'R': ga.selector.set(Selectors.GRouletteWheel) if ga_selector == 'N': ga.selector.set(Selectors.GRankSelector) if ga_selector == 'M': ga.selector.setRandomApply(True) ga.selector.set(Selectors.GTournamentSelector, 0.75) ga.selector.add(Selectors.GRouletteWheel, 0.20) ga.selector.add(Selectors.GRankSelector) ga.setMinimax(Consts.minimaxType["minimize"]) ga.setGenerations(int(generationSize)) ga.setPopulationSize(int(populationSize)) ga.setCrossoverRate(pCrossover) ga.setMutationRate(pMutation) ga.setElitism(True) ga.setElitismReplacement(int(num_etlsm)) #___________________Sets the DB Adapter # sqlite_adapter = DBAdapters.DBSQLite(identify=dbase_name, resetDB=eval(resetDB)) ga.setDBAdapter(sqlite_adapter) #___________________Do the evolution # ga.evolve(freq_stats=5) #___________________Print Best individual # best = ga.bestIndividual() best_rs = best.getRawScore() best_v = best.genomeList[:len(velocity_min)] best_d = best.genomeList[len(velocity_min):2 * len(velocity_min)] best_r = best.genomeList[2 * len(velocity_min):] print '' print '+++ Best Raw Score =', best_rs print '+++ FinalModel :' print ' +++ Velocity :', rnd(best_v, 2) print ' +++ Depth :', rnd(best_d, 2) print ' +++ VpVs :', rnd(best_r, 2) return best, best_rs, best_v, best_d, best_r
def test_AlleleList_repr(self): _allelelist = GAllele.GAlleleList(options=[1, 2, 3]) self.assertIsInstance(repr(_allelelist), str)
def test_AlleleList_remove(self): _allelelist = GAllele.GAlleleList(options=[1, 2, 3]) _allelelist.remove(2) self.assertEqual(_allelelist.options, [1, 3])
def test_AlleleList_len(self): _allelelist = GAllele.GAlleleList(options=[1, 2, 3]) self.assertEqual(len(_allelelist), 3)
def test_AlleleList_clear(self): _allelelist = GAllele.GAlleleList(options=[1, 2, 3]) _allelelist.clear() self.assertEqual(_allelelist.options, [])
rmsd = calc_fitted_2graphs(chromosome[0], chromosome[1], chromosome[2], chromosome[6] * chromosome[3], chromosome[4], chromosome[5]) if chromosome[1] == chromosome[4] and chromosome[2] == chromosome[ 5] and chromosome[6] == 1: rmsd = rmsd * 2 score = 1 / rmsd return score #initialize alleles setOfAlleles = GAllele.GAlleles() #first variable pkidvf = npy.arange(0.1, 30.1, 0.1) setOfAlleles.add(GAllele.GAlleleList(pkidvf)) #second variable pn = npy.arange(1, 8.1, 1) setOfAlleles.add(GAllele.GAlleleList(pn)) #third variable phase = npy.arange(0, 360.1, 10) setOfAlleles.add(GAllele.GAlleleList(phase)) #repeat assignment of variables for second curve setOfAlleles.add(GAllele.GAlleleList(pkidvf)) setOfAlleles.add(GAllele.GAlleleList(pn)) setOfAlleles.add(GAllele.GAlleleList(phase)) #binary value for using 1 or 2 functions func1or2 = [0, 1] setOfAlleles.add(GAllele.GAlleleList(func1or2))