Avoiding zero-valued gene using pygad

114 Views Asked by At

I am optimizing a function with 3 parameters according to experimental data. I defined a value space for the genes:

gene_space=[np.linspace(0.6,0.8,100), np.linspace(0.1,0.2,100),np.linspace(34,35,1000)]

and this is my general configuration:

    ga_instance = pygad.GA(num_generations=num_generations,
                       num_parents_mating=num_parents_mating, 
                       fitness_func=fitness_function,
                       sol_per_pop=sol_per_pop, 
                       num_genes=num_genes,
                       on_generation=callback_generation,
                       crossover_type=crossover_func,
                       parent_selection_type=parent_selection_func,
                       gene_space=gene_space, 
                       mutation_type="adaptive",
                       mutation_probability = [0.5, 0.1])

I get a fairly accurate final value with respect to the experimental value in the iterative process I am using. However, sometimes some of the parameters become zero and the range of values I imposed for the genes is not respected.

Is there any way to force the genes to take a non-zero value?

Thank you very much for any help!

0

There are 0 best solutions below