DEAP / deap

Distributed Evolutionary Algorithms in Python
http://deap.readthedocs.org/
GNU Lesser General Public License v3.0
5.69k stars 1.11k forks source link

error: float object is not iterable #574

Open sharonvzach opened 3 years ago

sharonvzach commented 3 years ago

I have been working on a problem which uses ANSYS to perform the evaluation function and thus find the fitness values. I have used DEAP's NSGA-II framework [https://github.com/DEAP/deap/blob/master/examples/ga/nsga2.py] used for the benchmark test as something to built on making suitable changes where ever necessary to fit my needs. The problem arises while executing lines 80-83 in the link provided above, it shows an error message "float object is not iterable". This is in spite of the fact that the individual is registered in the DEAP toolbox as a list which is an iterable in line. I have replaced line 32 ### creator.create("Individual", array.array, typecode='d', fitness=creator.FitnessMin) with ### creator.create("Individual", list, fitness=creator.FitnessMulti) . It is line #82 in the code provided that flashes the error `message.```

fmder commented 2 years ago

There is probably a problem on how you return you fitness in the evaluation function. Remember even if returning a single value it should be a tuple of 1.