I am working on a genetic algorithm implementation and I'm using DEAP toolbox. I've written a code that initializes chromosomes which their first gene is a float number in range of [0.01, 2048], their second gene is again float in range of [0.0001, 10] and their last three genes are boolean. This is my code:
toolbox.register("attr_flt1", random.uniform, 0.01, 2048)
toolbox.register("attr_flt2", random.uniform, 0.0001, 10)
toolbox.register("attr_bool", random.randint, 0, 1)
enter ctoolbox.register("individual", tools.initCycle, creator.Individual,
(toolbox.attr_flt1, toolbox.attr_flt2, toolbox.attr_bool, toolbox.attr_bool, toolbox.attr_bool),
n=1)
There is a sample of created population:
[1817.2852738610263, 6.184224906600851, 0, 0, 1], [1145.7253307024512, 8.618185266721435, 1, 0, 1], ...
Now, I want to do mutation and crossover on my chromosomes by considering differences in the genes types and ranges. Currently I have an error because a 0 value is produced for the first gene of a chromosome ,after applying crossover and mutation operators, which is wrong with my evaluation function. Can anyone help me code selection, mutation and crossover using DEAP toolbox that produce new population in ranges defined at first?