firs of all I apologize if my approach is too dumb or simplistic, I am an economist trying very hard to get into programming, therefore I lack some specific skills. Anyways, I have the following code:
population = [[[0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1], [1], [0]],
[[0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1], [3], [1]],
[[0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0], [4], [2]],
[[1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0], [3], [3]]]
def ProbabilityList(population):
fitness = chromosome[2] for chromosome in population
manipulated_fitness = fitness + 1
total_weight=sum(manipulated_fitness)
relative_fitness= [chromosome[1]/total_weight for chromosome in population]
probabilities= [sum(relative_fitness) for i in range(len(relative_fitness))]
return (probabilities)
The logic of the population is [[[individual1],[fitness][counter]],[individual3],[fitness][counter]], and so on...
the counter is just a number so I can order the individuals.
So what I need in this case is to create a selection probability list based on the total fitness. I also need to add 1 to the basic fitness, since in the future the value might be zero and I cant use a deterministic selection method (that is, no individuals can have 0 probabilities)
Would anyone know a correct approach to deal with it like this?