- Particle Swarm Optimization: https://www.mathworks.com/help/gads/particleswarm.html
- Output Functions: https://www.mathworks.com/help/gads/output-functions.html
A rather different stopping criteria for particle swarm
6 views (last 30 days)
Show older comments
Hello,
I am working on an optimization problem where the objective function is non-smooth and even worse, it is not
defined far from the optimal solution. To handle such a constraint I have used the 'death penalty' approach meaning
that once we are outside the feasible set (undefined objective) I assign +infinity (since my problem is minimization). I am
using particle swarm oprimization to solve this problem. Furthermore, I need to choose a very big MaxIterations so
that it never stops.
Because of the above-mentioned issues when I run my code either 1)"it finds a feasible solution (by chance) and from there it
correctly finds the global minimum' or 2)"it initially gets stucked with a undefined objective (also by chance) and from there sometimes
finds a feasible solution but sometimes it gets stucked there forever".
In order to fix this issue one can simply run the code for a short time and see whether 1 occurs or 2 occurs. If 1 happens it is great but
if 2 happens we can simply stop the code and re-run this again and again till 1 happens.
However, I would like to do this in my code not manually. So, now I ask my question in bellow:
Assume that MaxIterations=10^9. Is it possible to stop particle swarm from running if for the first
50 iterations (50 is an example only) the objective value is 'realmax' and re-run the code again and again untill
we see that we get an objective value within the first 50 iterations?
Thanks in advance!
Babak
0 Comments
Answers (1)
Kartik Saxena
on 24 Nov 2023
Hi,
I understand that you need to keep the iterations running after 50 only if we get an objective value within the first 50 iterations or else re-run the code.
Yes, you can achieve this behavior by using an output function with Particle Swarm Optimization (PSO) in MATLAB. An output function is called at the end of each iteration of the optimization process, and it can be used to halt the optimization based on custom criteria.
You can define an output function that checks if the best objective value is 'realmax' for the first 50 iterations, and if so, stops the optimization. You can then wrap your PSO call in a loop that retries until a feasible solution is found within the first 50 iterations.
For more information on using PSO in MATLAB and customizing it with output functions, you can refer to the following MathWorks documentation links:
I hope this resolves your issue.
0 Comments
See Also
Categories
Find more on Particle Swarm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!