I have this code for Particle Swarm Optimization (PSO) and the matlab shows this error :
First of all, I dont have equality constraints. Second there's an error shows: "Unrecognized function or variable 'PSO_non_linear_constraint'."
clc %clears the command window
clear all % clears the previous work space
close all % closes the privous graphical objects(figures)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% constrained function with equality and inequality contraints
fun=@(x)1.1*x(1) + 1.2*x(2) + 2*x(3) + 1.3*x(4) + 3*x(5);
%%
constraints=@(x)[-8*x(1) - 2*x(2) - 15*x(3) - 4*x(4) - 30*x(5) + 60;
-9*x(1) - 3*x(2) - 3*x(3) - 1*x(4) - 9*x(5) + 100;
-35*x(1) - 3*x(2) - 17*x(3) - 1*x(4) - 16*x(5) + 120;
-100*x(1) - 90*x(2) - 350*x(3) - 200*x(4) - 410*x(5) + 2100;
-10*x(1) - 20*x(2) - 40*x(3) - 25*x(4) - 40*x(5) + 400;];
constraints_eq=@(x)[];
nvars=5; % number of variables to be optimized
LB=[0;0;0;0;0];
UB=[Inf;Inf;Inf;Inf;Inf];
Npop=200;
max_iter=5000;
[Xmin,Fmin]=PSO_non_linear_constraint(fun,constraints,constraints_eq,LB,UB,nvars,Npop,max_iter);