Thanks for posting this solid particle swarm optimization code. I believe this already helped others a lot. But could you please have a look of line 44 of your code where you have:
self.pos_best_i=self.position_i
Here you would like to copy the content of position_i list to pos_best_i. However, the assignment just copies the reference to the list. Then, whenever the position_i gets modified in the future, post_best_i always gets modified as well because of this reference. Should we change it to the typical list.copy() or copy.copy() or whatever:)
Hello Mr. Rooy,
Thanks for posting this solid particle swarm optimization code. I believe this already helped others a lot. But could you please have a look of line 44 of your code where you have:
self.pos_best_i=self.position_i
Here you would like to copy the content of position_i list to pos_best_i. However, the assignment just copies the reference to the list. Then, whenever the position_i gets modified in the future, post_best_i always gets modified as well because of this reference. Should we change it to the typical list.copy() or copy.copy() or whatever:)