'''
Created on 09-04-2012

@author: pita
'''
from deap import creator, tools, base, benchmarks, algorithms
import logging
import numpy
import random
import sys

logging.basicConfig(level=logging.CRITICAL, stream=sys.stdout)

creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", numpy.ndarray, fitness=creator.FitnessMin) #@UndefinedVariable

toolbox = base.Toolbox()
toolbox.register("attr", lambda :numpy.random.random() * 10 - 5)

toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr, n=20) #@UndefinedVariable
toolbox.register("population", tools.initRepeat, list, toolbox.individual) 

toolbox.register("evaluate", benchmarks.rastrigin)
toolbox.register("mate", tools.cxUniform, indpb=0.4)
#toolbox.register("mate", tools.cxTwoPoints)
toolbox.register("mutate", tools.mutGaussian, mu=0, sigma=1, indpb=0.02)
toolbox.register("select", tools.selTournament, tournsize=5)

def compute():
    random.seed(47)
    pop = toolbox.population(n=180)
    hof = tools.HallOfFame(1)
    stats = tools.Statistics(lambda ind: ind.fitness.values)
    stats.register("Avg", tools.mean)
    stats.register("Std", tools.std)
    stats.register("Min", min)
    stats.register("Max", max)
    
    algorithms.eaSimple(toolbox, pop, 0.4, 0.3, 410, halloffame=hof)
    #algorithms.eaMuPlusLambda(toolbox, pop, 500, 100, 0.8 , 0.1, 500, hof)
    return sorted(list(hof[-1]))
    
    #return pop, stats, hof

def main():
    best_in=compute()
    logging.critical("Best individual is %s, %s", (lambda x: sorted(list(x)))(best_in)) 
    



if __name__ == '__main__':
    main()

fbac63bf33f7188881fc222c1511ba2e7e02d019
<mask token>


def compute():
    random.seed(47)
    pop = toolbox.population(n=180)
    hof = tools.HallOfFame(1)
    stats = tools.Statistics(lambda ind: ind.fitness.values)
    stats.register('Avg', tools.mean)
    stats.register('Std', tools.std)
    stats.register('Min', min)
    stats.register('Max', max)
    algorithms.eaSimple(toolbox, pop, 0.4, 0.3, 410, halloffame=hof)
    return sorted(list(hof[-1]))


def main():
    best_in = compute()
    logging.critical('Best individual is %s, %s', (lambda x: sorted(list(x)
        ))(best_in))


<mask token>

<mask token>
logging.basicConfig(level=logging.CRITICAL, stream=sys.stdout)
creator.create('FitnessMin', base.Fitness, weights=(-1.0,))
creator.create('Individual', numpy.ndarray, fitness=creator.FitnessMin)
<mask token>
toolbox.register('attr', lambda : numpy.random.random() * 10 - 5)
toolbox.register('individual', tools.initRepeat, creator.Individual,
    toolbox.attr, n=20)
toolbox.register('population', tools.initRepeat, list, toolbox.individual)
toolbox.register('evaluate', benchmarks.rastrigin)
toolbox.register('mate', tools.cxUniform, indpb=0.4)
toolbox.register('mutate', tools.mutGaussian, mu=0, sigma=1, indpb=0.02)
toolbox.register('select', tools.selTournament, tournsize=5)


def compute():
    random.seed(47)
    pop = toolbox.population(n=180)
    hof = tools.HallOfFame(1)
    stats = tools.Statistics(lambda ind: ind.fitness.values)
    stats.register('Avg', tools.mean)
    stats.register('Std', tools.std)
    stats.register('Min', min)
    stats.register('Max', max)
    algorithms.eaSimple(toolbox, pop, 0.4, 0.3, 410, halloffame=hof)
    return sorted(list(hof[-1]))


def main():
    best_in = compute()
    logging.critical('Best individual is %s, %s', (lambda x: sorted(list(x)
        ))(best_in))


if __name__ == '__main__':
    main()

<mask token>
logging.basicConfig(level=logging.CRITICAL, stream=sys.stdout)
creator.create('FitnessMin', base.Fitness, weights=(-1.0,))
creator.create('Individual', numpy.ndarray, fitness=creator.FitnessMin)
toolbox = base.Toolbox()
toolbox.register('attr', lambda : numpy.random.random() * 10 - 5)
toolbox.register('individual', tools.initRepeat, creator.Individual,
    toolbox.attr, n=20)
toolbox.register('population', tools.initRepeat, list, toolbox.individual)
toolbox.register('evaluate', benchmarks.rastrigin)
toolbox.register('mate', tools.cxUniform, indpb=0.4)
toolbox.register('mutate', tools.mutGaussian, mu=0, sigma=1, indpb=0.02)
toolbox.register('select', tools.selTournament, tournsize=5)


def compute():
    random.seed(47)
    pop = toolbox.population(n=180)
    hof = tools.HallOfFame(1)
    stats = tools.Statistics(lambda ind: ind.fitness.values)
    stats.register('Avg', tools.mean)
    stats.register('Std', tools.std)
    stats.register('Min', min)
    stats.register('Max', max)
    algorithms.eaSimple(toolbox, pop, 0.4, 0.3, 410, halloffame=hof)
    return sorted(list(hof[-1]))


def main():
    best_in = compute()
    logging.critical('Best individual is %s, %s', (lambda x: sorted(list(x)
        ))(best_in))


if __name__ == '__main__':
    main()

<mask token>
from deap import creator, tools, base, benchmarks, algorithms
import logging
import numpy
import random
import sys
logging.basicConfig(level=logging.CRITICAL, stream=sys.stdout)
creator.create('FitnessMin', base.Fitness, weights=(-1.0,))
creator.create('Individual', numpy.ndarray, fitness=creator.FitnessMin)
toolbox = base.Toolbox()
toolbox.register('attr', lambda : numpy.random.random() * 10 - 5)
toolbox.register('individual', tools.initRepeat, creator.Individual,
    toolbox.attr, n=20)
toolbox.register('population', tools.initRepeat, list, toolbox.individual)
toolbox.register('evaluate', benchmarks.rastrigin)
toolbox.register('mate', tools.cxUniform, indpb=0.4)
toolbox.register('mutate', tools.mutGaussian, mu=0, sigma=1, indpb=0.02)
toolbox.register('select', tools.selTournament, tournsize=5)


def compute():
    random.seed(47)
    pop = toolbox.population(n=180)
    hof = tools.HallOfFame(1)
    stats = tools.Statistics(lambda ind: ind.fitness.values)
    stats.register('Avg', tools.mean)
    stats.register('Std', tools.std)
    stats.register('Min', min)
    stats.register('Max', max)
    algorithms.eaSimple(toolbox, pop, 0.4, 0.3, 410, halloffame=hof)
    return sorted(list(hof[-1]))


def main():
    best_in = compute()
    logging.critical('Best individual is %s, %s', (lambda x: sorted(list(x)
        ))(best_in))


if __name__ == '__main__':
    main()

'''
Created on 09-04-2012

@author: pita
'''
from deap import creator, tools, base, benchmarks, algorithms
import logging
import numpy
import random
import sys

logging.basicConfig(level=logging.CRITICAL, stream=sys.stdout)

creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", numpy.ndarray, fitness=creator.FitnessMin) #@UndefinedVariable

toolbox = base.Toolbox()
toolbox.register("attr", lambda :numpy.random.random() * 10 - 5)

toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr, n=20) #@UndefinedVariable
toolbox.register("population", tools.initRepeat, list, toolbox.individual) 

toolbox.register("evaluate", benchmarks.rastrigin)
toolbox.register("mate", tools.cxUniform, indpb=0.4)
#toolbox.register("mate", tools.cxTwoPoints)
toolbox.register("mutate", tools.mutGaussian, mu=0, sigma=1, indpb=0.02)
toolbox.register("select", tools.selTournament, tournsize=5)

def compute():
    random.seed(47)
    pop = toolbox.population(n=180)
    hof = tools.HallOfFame(1)
    stats = tools.Statistics(lambda ind: ind.fitness.values)
    stats.register("Avg", tools.mean)
    stats.register("Std", tools.std)
    stats.register("Min", min)
    stats.register("Max", max)
    
    algorithms.eaSimple(toolbox, pop, 0.4, 0.3, 410, halloffame=hof)
    #algorithms.eaMuPlusLambda(toolbox, pop, 500, 100, 0.8 , 0.1, 500, hof)
    return sorted(list(hof[-1]))
    
    #return pop, stats, hof

def main():
    best_in=compute()
    logging.critical("Best individual is %s, %s", (lambda x: sorted(list(x)))(best_in)) 
    



if __name__ == '__main__':
    main()
