variable length individuals size range

29 views
Skip to first unread message

leena nasir

unread,
May 28, 2022, 6:45:21 AM5/28/22
to deap-users
Hello, I am very new to Deap and has just started learning the basic cuilding blocks, currently I am facing a problem, I am trying to create individuals of variables sizes using the following code which I have found somewhere in your users group:

def gen_individual(icls, min, max):

    return icls([random.random() for _ in range(random.randint(min, max, 2))])

toolbox.register("individual", gen_individual, creator.Individual, min=20, max=200)

Things seemed to work fine until I have noticed that the individuals sizes can go below the defined range 20-200, and can create individuals of size 10 and less and these sizes causes problems in my model. Any ideas for: why is this happening having that the range is defined, any suggestions for how to set the range between 20 and 200 restrictively ?

Reply all
Reply to author
Forward
0 new messages