Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final Best Position Logical Error #505

Open
r-karunathilake opened this issue Jan 18, 2023 · 0 comments
Open

Final Best Position Logical Error #505

r-karunathilake opened this issue Jan 18, 2023 · 0 comments

Comments

@r-karunathilake
Copy link

r-karunathilake commented Jan 18, 2023

PySwarms version:

Name: pyswarms 1.3.0
Python version: 3.11.0
Operating System: Windows 10

Description

After running global best and local best PSO I noticed that my best cost is NOT reproducible with the final position vector returned after the optimizer is done running.

I think there is a major issue with position return in 'optimize' method in global, local, binary and general optimizers.

final_best_cost = self.swarm.best_cost.copy()
final_best_pos = self.swarm.pbest_pos[self.swarm.pbest_cost.argmin()].copy()

From what I understand from reviewing the code, the 'final_best_pos' is only the best position vector of the last iteration of the swarm. This does NOT return the global best position found. I think it should simply be:

final_best_cost = self.swarm.best_cost.copy()
final_best_position = self.swarm.best_pos.copy()
Thoughts ?

@r-karunathilake r-karunathilake changed the title Final Best Position Return Error Final Best Position Logical Error Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant