function [gbest,gbestval,fitcount]= CPSO_func(fhd,Max_FES,Particle_Number,Dimension,VRmin,VRmax,varargin)
% CPSO - Function
% Version : 1.02
% Originally Designed by J. J. Liang
% Revised by C. Chen in Apr 3, 2013
% Last Update : Apr 27, 2013
ps = Particle_Number;% Particle Number
D = Dimension; % Dimension of the Target Problem
fi = [1.49 1.49]; % Acceleration Constants
groupnum = D; % Number of Groups
me = ceil(Max_FES / ps / 6); % MAX Generation
iwt = 0.9 - (1:me) .* (0.5 ./ me);% Inertia Weight
e1 = zeros(ps,1);
e = zeros(ps,1);
vel = zeros(ps,D);
vel1 = zeros(ps,D);
aa = zeros(ps,D);
aa1 = zeros(ps,D);
%% Boundaries
if length(VRmin) == 1
VRmin = repmat(VRmin,1,D);
VRmax = repmat(VRmax,1,D);
end
mv = (VRmax - VRmin);
mv1 = mv;
VRmin = repmat(VRmin,ps,1);
VRmax = repmat(VRmax,ps,1);
% Vmin = repmat(-mv,ps,1);
% Vmax = -Vmin;
%% Initialize Every Particle
pos = round( VRmin + (VRmax - VRmin) .* rand(ps,D) );
pos1 = round( VRmin + (VRmax - VRmin) .* rand(ps,D) );
%% First Loop
f