Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
%%______________________________________________________________________________
%% This function is to build the GP objective - maximimum likelihood estimation
%% This function is created by Kai Zhou 7/31/2019
%%______________________________________________________________________________
function Pos = Obj_PSO(b)
global x1;
global y1;
global k1
global numInp
x = x1;
y = y1;
num = length(x(:,1));
C = zeros(num,num);
fi = b(end);
b(end) = [];
for i = 1:num
for j= 1:num
C(i,j) = k1(x(i, :)',x(j, :)',b,fi);
end
end
perb2_2 = 1e-6;
P1 = zeros(num,1) + 1;
H = [P1, x];
if rcond(C)>1e-20
signn = 1;
else
signn = 0;
end
if signn == 1
Beta = zeros(numInp+1,1);
Temp1 = inv(C+perb2_2*eye(size(C)));
Temp2 = y-H*Beta;
Temp2 = reshape(Temp2,[],1);
end
part2 = 0;
if signn == 1
sig = det(C);
if sig<0
part2 = 1e50;
signn = 0;
elseif sig == 0
[tt1,tt2]=eig(C);
if min(diag(tt2))<0
part2 = 1e50;
signn = 0;
else
for i = 1:length(C)
part2 = part2+log(tt2(i,i));
end
end
else
part2 = log(det(C));
end
else
part2 = 1e50;
signn = 0;
end
if signn == 1
Pos = part2 + Temp2'*Temp1*Temp2;
else
Pos = 2e50;
end
end