question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Early stropping (ftol) if cost isn't reduced

See original GitHub issue

Describe the bug When the ftol is used and the best cost is equal in two consecutive iteration, the search is stopped even if the cost is high.

To Reproduce options = {'c1': 0.5, 'c2': 0.3, 'w':0.9} optimizer = ps.single.GlobalBestPSO(n_particles=100, dimensions=2, options=options, ftol=1e-10) cost, pos = optimizer.optimize(fx.sphere, iters=1000, n_processes=None, verbose=True)

Output is something like this. Position: [0.06410654 0.02934344], Cost: 0.0049706854704889645

As can be seen, x1 and x2 are far from zero, the cost is relatively high, and it’s much higher than 1e-10. The reason is that the algorithm couldn’t find lower cost so the swarm.best_cost is equal to best_cost_yet_found. So the search is stopped even if the cost remains high.

Environment (please complete the following information):

  • PySwarms Version 1.1.0

How to fix In optimizer code, an additional check should be performed to ignore if swarm.best_cost == best_cost_yet_found. After applying the fix, the output will be:

Position: [-8.05105641e-06 -6.63608458e-07], Cost: 6.525988549305629e-11

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:36 (29 by maintainers)

github_iconTop GitHub Comments

2reactions
hakan-gecilicommented, May 9, 2020

Hi @nishnash54 I was busy with my thesis, I just finished reading the PR #401 . You guys were having so much fun 😃

Yes, You can use my code, actually I have should I posted my previous comment in that PR.

2reactions
hakan-gecilicommented, May 4, 2020

I will comment only on ftol_iter part. ftol_iter causes early stopping and can be stuck at a local optimum and that is what we intended to do by using ftol_iter. This option is for users who are only interested in finding a good feasible solution, but not an exact global solution because they have a big problem. In my case, each iteration takes 3 minutes, and I usually run more than 500 iterations. In my case, a fast good feasible solution is a lot better than a late exact solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why in general is early stopping a good regularisation ...
Early stopping is very similar to regularisation like Lasso or Ridge. It is similarly reducing the size of the parameters.
Read more >
Fetal scalp blood sampling - Acutecaretesting.org
The rationale for this monitoring is based on the fact that reduced oxygen delivery to the fetus affects heart rate, which is normally...
Read more >
Stropping: What It Is And How It's Accomplished
First, use a knife of known sharpness. Cut a bit from the leather. Note the force needed to peel off a few pieces...
Read more >
How do you strop a knife? - Knivesandtools
Polishing the edge of your knife is called stropping. It is the final step in the sharpening process. You can only use a...
Read more >
Knife Sharpening and Stropping: Tips, Links, and References
Sharp tools require less effort to use and can help protect your hands from ... If the knife is still not sharp, then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found