I have a DEAP toolbox setup
import random
from deap import base, tools, creator, algorithms
toolbox = base.Toolbox()
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
toolbox.register("individual", tools.initRepeat, creator.Individual, random.random, n=2)
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
I want to force the value of certain individuals in the population. For this, I would like to create individuals that have a given genome and add them to the population
pop = toolbox.population(n=10)
new_individual = ?
pop.append(new_individual)
How do I define the new individual? Doing new_individual = toolbox.individual([.1, .2])
doesn't work. Nor does new_individual = toolbox.individual(); new_individual.values = [.1, .2]
. If I do new_individual = [.1, .2]
, then it no longer has the right type (list
rather than deap.creator.Individual
.