function [ x ] = step1_mission( )
%%%%%%%%%% Begin %%%%%%%%%%
H = [1 -1; -1 2];
f = [-2; -6];
A = [1 1; -1 2; 2 1];
b = [2; 2; 3];
x = quadprog(H,f,A,b);
%%%%%%%%%% End %%%%%%%%%%
end
第2关:支持向量机及其对偶问题
function [sv] = step2_mission( X,Y )
options = optimset;
options.LargeScale = 'off';
options.Display = 'off';
%%%%%%%%%% Begin %%%%%%%%%%
n = length(Y);
H = (Y'*Y).*(X'*X);
f = -ones(n,1);
Aeq = Y;
beq = 0;
lb = zeros(n,1);
ub = ones(n,1);
a0 = zeros(n,1);
%%%%%%%%%% End %%%%%%%%%%
[a,fval,eXitflag,output,lambda] = quadprog(H,f,[],[],Aeq,beq,lb,ub,a0,options);
sv_label = find(a==max(a));
sv = X(:,sv_label);
end