Skip to content

Instantly share code, notes, and snippets.

@cmd-ntrf
Created November 21, 2013 14:54
Show Gist options
  • Save cmd-ntrf/7582971 to your computer and use it in GitHub Desktop.
Save cmd-ntrf/7582971 to your computer and use it in GitHub Desktop.
[deap-users] Set up a simulation fit
import random
import numpy
from deap import base
from deap import creator
from deap import tools
creator.create("Fitness", base.Fitness, weights=(1.0,))
creator.create("Individual", numpy.ndarray, fitness=creator.Fitness)
toolbox = base.Toolbox()
toolbox.register("attr_lay1_thickness", random.randint, 50, 600)
toolbox.register("attr_lay2_thickness", random.randint, 100, 300)
toolbox.register("attr_lay3_thickness", random.randint, 150, 500)
cycle = (toolbox.attr_lay1_thickness, toolbox.attr_lay2_thickness, toolbox.attr_lay3_thickness)
toolbox.register("individual", tools.initCycle, creator.Individual, cycle, n=1)
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
MU = 50
pop = toolbox.population(MU)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment