Portfolio-Optimization-using-Genetic-Algorithm icon indicating copy to clipboard operation
Portfolio-Optimization-using-Genetic-Algorithm copied to clipboard

Issue of Int object is not iterable

Open sureshgautam opened this issue 4 years ago • 2 comments

First of all, wonderful contribrituion to solve portfolio optimization using GA!

During implementation, found issue with 'int object is not iterable' while executing next_generation in Task#10. Saw issue duteto sum(chk), where chk is an integer variable in the scope and used in sum function, which except list, tuple, dict, or arrey as its input. I applied the fix by removing sum (Original: if sum(chk)>0 Change: if chk>0:) in the next_generation function, however, please verify and fix your code base, or reject if I missed anything in which context fix is not required.

PS: ipython notebook was executed in the google colab environment. After applying the changes, solution works fine as per requirements.

sureshgautam avatar May 23 '21 03:05 sureshgautam

I have a same problem with @sureshgautam I change the sum(chk)>0 to chk>0 just like him, but it made an error in the Arithmatic-crossover at the end of the code. the iteration of the arithmetic-crossover did not end. Can you check it?

justinkim95 avatar May 25 '21 16:05 justinkim95

i have made same change but assigning negative weights if portfolio returns are negative

Skr1996 avatar Oct 23 '22 03:10 Skr1996