DEAP / deap

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

convert fit type from int into tuple #729

Closed amghazanfari closed 1 year ago

amghazanfari commented 1 year ago

when i use deap with python3.11 i get this error

Traceback (most recent call last):
  File "/home/amir/Templates/deap/main2.py", line 101, in <module>
    main()
  File "/home/amir/Templates/deap/main2.py", line 42, in main
    population, logbook = algorithms.eaSimple(population, toolbox,
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/amir/Templates/deap/venv/lib/python3.11/site-packages/deap/algorithms.py", line 152, in eaSimple
    ind.fitness.values = fit
    ^^^^^^^^^^^^^^^^^^
  File "/home/amir/Templates/deap/venv/lib/python3.11/site-packages/deap/base.py", line 188, in setValues
    assert len(values) == len(self.weights), "Assigned values have not the same length than fitness weights"
           ^^^^^^^^^^^
TypeError: object of type 'int' has no len()

this is because fit must be inside a tuple