Exemple #1
0
def main():
	configuration = Configuration()

	configuration.setPopulationSize(50)

	crossoverOp = CrossoverMutateOperator()
	configuration.addGeneticOperator(crossoverOp)		

	chromosoneSel = BestChromosonesSelector()
	configuration.addNaturalSelector(chromosoneSel)	

	geno	= Genotype(configuration)

	for i in range(0,2*geno.getPopulation().getPopulationSize()):
		tspChromosone = TSPChromosone(distanceMap)
		tspChromosone.setRandomValue()
		geno.getPopulation().addChromosone(tspChromosone)

	
	for i in range(0,10):
		geno.evolve()
		geno.getPopulation().getChromosones().sort()
		print geno.getPopulation().getChromosones()[0]
Exemple #2
0
def main():

    configuration = Configuration()
    configuration.setPopulationSize(50)

    crossoverOp = CrossoverMutateOperator()
    configuration.addGeneticOperator(crossoverOp)

    chromosoneSel = BestChromosonesSelector()
    configuration.addNaturalSelector(chromosoneSel)

    geno = Genotype(configuration)

    for i in range(0, 2 * geno.getPopulation().getPopulationSize()):
        cubicSolverChromosone = CubicSolverChromosone(a, b, c, d)
        cubicSolverChromosone.setGeneBounds(-10.0, 10.0)
        cubicSolverChromosone.setRandomValue()
        geno.getPopulation().addChromosone(cubicSolverChromosone)

    for i in range(0, 1000):
        geno.evolve()
        geno.getPopulation().getChromosones().sort()
        print geno.getPopulation().getChromosones()[0]
Exemple #3
0
def main():
	
	configuration = Configuration()
	configuration.setPopulationSize(50)

	crossoverOp = CrossoverMutateOperator()
	configuration.addGeneticOperator(crossoverOp)		

	chromosoneSel = BestChromosonesSelector()
	configuration.addNaturalSelector(chromosoneSel)	

	geno	= Genotype(configuration)

	for i in range(0,2*geno.getPopulation().getPopulationSize()):
		cubicSolverChromosone = CubicSolverChromosone(a,b,c,d)
		cubicSolverChromosone.setGeneBounds(-10.0,10.0)
		cubicSolverChromosone.setRandomValue()
		geno.getPopulation().addChromosone(cubicSolverChromosone)

	
	for i in range(0,1000):
		geno.evolve()
		geno.getPopulation().getChromosones().sort()
		print geno.getPopulation().getChromosones()[0]