MATLAB: What is the correction of error: Failure in initial user-supplied objective function evaluation. PARTICLESWARM cannot continue

initial user-supplied objective functionparticleswarm

I'm trying to solve an optimization problem using PARTICLESWARM function in MATLAB2014b. with aid of Open Source ECG Toolbox, version 1.0, November 2006 Released under the GNU General Public License.
The main objective of the code is to find the optimal parameters of the ECG model to achieve the minimum model error.
I have used PSO as optimizer to find these optimal parameters.
ends up with error:
Failure in initial user-supplied objective function evaluation. PARTICLESWARM cannot continue

Best Answer

Without reading your code, I can tell you that your initial swarm contained at least one point that led to a NaN or Inf or complex objective function value. To avoid this error,
  • Ensure that your objective function always returns finite real values, by carefully debugging it, OR
  • Pass an initial swarm where every point returns a real finite value. See the InitialSwarmMatrix option in particleswarm options.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation