How does particle swarm deal with objective function evaluations to NaN?

4 views (last 30 days)
Hi everyone, Simple question, though I haven't been able to find a definite answer: How does the Particle Swarm optimization routine deal with points that return a value of the objective function of NaN? I know that if FunValCheck can force it to stop in this event, but what is the default behavior?
Thanks!

Accepted Answer

Walter Roberson
Walter Roberson on 31 Aug 2015
The default value is to let the NaN "pollute" whatever calculation it is involved in. For example,
(nan+2+5)/3
is nan. Any arithmetic operation involving NaN and floating point numbers will result in NaN (if the integer classes are involved the answer is weirder.) Logically any comparison involving nan is false except for ~= which is defined as true even if both values are nan. This can have unexpected effects in the calculations that depend on exactly how the calculation is code.
A min() involving nan will only result in nan if all of the values are nan, so a particle with nan will not be detected as the best value. On the other hand its updated position could become nan, potentially the positions of other particles could become nan if some kind of consensus were being used, and so on. Depending on the coding, it might get replaced by a better result and have no further effect, or it might just be unproductive, or it might poison the calculations and mess up other particles.
  3 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!