I am using DEAP package in Python to write a program for optimization with evolutionary algorithm specifically with Genetic.
I need to create chromosomes by using list type in python. This chromosome should have five float genes (alleles) in different ranges.
My main problem is to create such a chromosome. However, it would be better if I could use tools.initRepeat function of deap package for this.
For the cases in which all the genes are in the same range we could use the following code:
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
IND_SIZE=10
toolbox = base.Toolbox()
toolbox.register("attr_float", random.random)
toolbox.register("individual", tools.initRepeat, creator.Individual,
toolbox.attr_float, n=IND_SIZE)
That I got from here.