-
Notifications
You must be signed in to change notification settings - Fork 46
Add optimizers from PySwarms #639
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
@janosg could you review this? A few points:
|
If I see correctly, you only use the rng for inital positions. Is this the only stochastic part of the algorithm or are ther other stochastic parts that make the optimization non-deterministic even if a seed is set?
You can deviate from this default if there are good reasons. Especially for a global optimizer I don't think it is problematic to set this to 0 because global optimizers are usually expected to run until |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have time to completely finish the review but this should give you some pointers to continue working on the PR.
Stochastic parts in PySwarms:
If we set convergence_ftol_rel to 0, it disables early convergence and forces the algorithm to run for STOPPING_MAXITER iterations by default if stopping_maxiter is not set. However, running optimization for STOPPING_MAXITER times i.e (1_000_000) takes a long time. |
Then we need a very big warning that the seed does not make the algorithm deterministic. Would setting a global numpy seed help? i.e.
As I said, you can deviate from defaults where necessary. Of course, we would not leave maxiter at a million if this is a bad default. Maybe 1000 would be a good idea? We just can't have a variable called "STOPPING_MAXITER_GLOBAL" (analogous to "STOPPING_MAXFUN_GLOBAL") in the algo options because what an iteration is changes between optimizers. |
The failing test should be fixed after you update the branch. |
…into pyswarms-optimizer
I meant that there are stochastic parts to it, but setting the global seed does make it deterministic. Yes setting global seed work. I will add a warning if seed is set.
Yes, 1000 is a reasonable number for PySwarms, so I had introduced STOPPING_MAXITER_GLOBAL earlier, but I will remove it and just default to 1000 iterations. |
This PR introduces the following optimizers from PySwarms:
pyswarms_global_best
pyswarms_local_best
pyswarms_general