指数锥规划定义为 ( y exp ( x / y ) ≤ z , y > 0 ) (y\exp(x/y)\leq z, y>0) (yexp(x/y)≤z,y>0),等效于相对熵规划,YALMIP不一定会检测到指数锥,可以使用persepective expoential.
LR问题的凸规划方程为 ∑ log ( 1 + exp − y i ( a T x i + b ) ) \sum \log(1+\exp^{-y_i(a^Tx_i+b)}) ∑log(1+exp−yi(aTxi+b)) 可以使用logsumexp直接求解,也可以进行分解后等效转换 { log ( 1 + e z ) = log ( e 0 + e z ) log ( e 0 + e − y i ( a T x i + b ) ) ≤ t i → e 0 + e − y i ( a T x i + b ) ≤ e t i \begin{cases} \log(1+e^z)=\log(e^0+e^z)\\ \log(e^0+e^{-y_i(a^Tx_i+b)})\leq t_i\to e^0+e^{-y_i(a^Tx_i+b)}\leq e^{t_i} \end{cases} {log(1+ez)=log(e0+ez)log(e0+e−yi(aTxi+b))≤ti→e0+e−yi(aTxi+b)≤eti 令 { e − t i ≤ z i e − y i ( a T x i + b ) − t i ≤ u i \begin{cases} e^{-t_i}\leq z_i\\ e^{-y_i(a^Tx_i+b)-t_i}\leq u_i \end{cases} {e−ti≤zie−yi(aTxi+b)−ti≤ui 约束转化为 z i + u i ≤ 1 z_i+u_i\leq 1 zi+ui≤1 目标函数为 min ∑ t i \min \sum t_i min∑ti
%% 产生两种数据点 N = 50; blues = randn(2,N/2); reds = randn(2,N/2)+2; clf hold on plot(reds(1,:),reds(2,:),'r*'); plot(blues(1,:),blues(2,:),'b*') hold off使用logsumexp算子求解
%% logsumexp (需要使用mosek 9)进行求解 % blue = 1, red=-1 x = [blues reds]; y = [ones(1, length(blues)) repmat(-1, 1, length(reds))]; a = sdpvar(2, 1); b = sdpvar(1); J = sum(logsumexp([zeros(length(y), 1) (-y.*(a'*x+b))']')); optimize([], J)统计分类结果
%% count class = sign(value(a'*x+b)); % 进行分类 classB = find(class==1); % 蓝色点 classR = find(class==-1); % 红色点 hold on; plot(x(1, classB), x(2, classB), 'bo') plot(x(1, classR), x(2, classR), 'ro') hold off; nnz(sign(value(a'*x+b))-y) % 计算出非零点的数量,即分类错误点的数量relative entropy optimization and its applications Exponential cone programming