以下算法是matlab写的:
for i=1:n
for j=1:n
H(i,j) = Y(i)*Y(j)*svkernel(ker,X(i,:),X(j,:));
end
end
H = H+1e-10*eye(size(H));
f=zeros(n,1); %%因为quadprog解的是问题:min 0.5*x'*H*x + f'*x。此处只有前一部分,因此f设为0
Aeq=zeros(1,n);
for i=1:n
Aeq(i)=(Y(i)==1); %%%当yi=-1的时候,alphai=1;
end
beq=n_minus; %%Aeq*x=beq.完成最后一个约束。它和倒数第二个约束是重复的。
vlb = zeros(n,1); % Set the bounds: alphas >= 0
vub =ones(n,1); % alphas <= 1
A = [];
b = [];
% Aeq=Y';
% beq=0;
alpha=quadprog(H,f,A,b,Aeq,beq,vlb,vub);
出现错误如下:
Warning: Large-scale method does not currently solve this problem formulation,
using medium-scale method instead.
> In quadprog at 264
In main_svcpath at 57
Maximum number of iterations exceeded; increase options.MaxIter.
To continue solving the problem with the current solution as the
starting point, set x0 = x before calling quadprog. |