This is my MATLAB program caculate the sparse solutions of convex model
argmin x ((lamda/2-Gk’*fk)‘x+1/2x’*Gk’Gkx)
which is from a famous paper that proved it convex model.However, there is a error when i use cvx:
error use cvx/quad_form (line 230)
The second argument must be positive or negative semidefinite.
error * (line 261)
[ z2, success ] = quad_form( xx, P, Q, R );
error Untitled (line 29)
minimize((lamda/2-Gk’*fk)‘x+1/2x’*Gk’Gkx)
Gk is a feature matrix, fk and x are vector.The below is my MATLAB program.
%SIS = Sparse Induced Similarity measure
%NBNN = Naive Bayes Nearest Neighbor
dataset = [563.040100000000,604.600759000000,608.418658000000,599.603524000000,599.932447000000,589.974080000000,584.956001000000,558.492663000000,522.063771000000,413.950989000000,365.698203000000,408.299725000000,406.741558000000,539.924191000000,463.248421000000,364.972904000000,492.960979000000,377.626823000000,406.755078000000;
551.354061000000,595.293689000000,600.846930000000,589.910141000000,590.720368000000,580.155333000000,583.782799000000,547.710449000000,509.391176000000,422.905500000000,395.834004000000,420.033893000000,415.903299000000,552.429722000000,472.207869000000,380.573875000000,497.314272000000,392.798475000000,415.540101000000;
558.841823000000,602.695222000000,606.079160000000,595.898279000000,595.826672000000,583.718956000000,577.709217000000,549.152197000000,520.786587000000,419.933232000000,378.041071000000,414.697291000000,415.351395000000,552.569509000000,469.999105000000,368.337243000000,489.859401000000,383.747792000000,416.103708000000;
574.396313000000,615.680923000000,621.741016000000,609.491984000000,608.755619000000,596.788941000000,591.146454000000,562.984194000000,533.156934000000,416.221116000000,368.898438000000,414.239117000000,405.292444000000,551.603765000000,461.514907000000,367.291222000000,494.053886000000,379.404714000000,404.911573000000;
565.431355000000,610.068065000000,613.871011000000,601.716520000000,605.760485000000,589.469477000000,584.162810000000,555.572306000000,524.661870000000,413.662858000000,365.854133000000,410.271530000000,406.531621000000,545.594105000000,465.022485000000,363.992783000000,490.562853000000,376.401188000000,405.776038000000;
564.644537000000,604.740316000000,604.806791000000,590.275336000000,596.953853000000,594.665459000000,607.405226000000,555.109910000000,514.337787000000,454.817404000000,404.828169000000,449.024500000000,445.875488000000,582.002714000000,512.200956000000,395.938936000000,518.893635000000,403.036403000000,446.116675000000;
531.915957000000,548.729591000000,575.648270000000,572.338874000000,565.806460000000,564.312044000000,558.608661000000,543.351123000000,513.231486000000,470.633638000000,434.172705000000,462.902488000000,461.276338000000,579.485013000000,510.408706000000,412.017724000000,530.314031000000,438.971096000000,460.773599000000;
565.444377000000,608.487507000000,611.521049000000,597.945495000000,602.339663000000,594.331358000000,601.024023000000,553.303266000000,522.572149000000,443.398718000000,397.167587000000,433.999516000000,433.994875000000,579.247971000000,494.756832000000,386.436829000000,506.203710000000,398.496233000000,433.498090000000;
561.742528000000,601.245625000000,605.267844000000,596.364258000000,596.943556000000,586.153679000000,578.814536000000,556.040010000000,517.216441000000,422.855644000000,395.611460000000,419.430659000000,410.826694000000,560.179682000000,466.168875000000,375.453696000000,497.159927000000,395.376212000000,411.194564000000;
550.292791000000,592.486623000000,598.709728000000,588.883870000000,587.602305000000,576.805611000000,566.261507000000,537.529519000000,509.343492000000,447.245311000000,409.934287000000,443.129843000000,446.487464000000,563.257339000000,506.476390000000,398.298943000000,515.701252000000,404.517275000000,445.654535000000;
542.469270000000,579.412138000000,580.929872000000,574.271040000000,572.976620000000,570.194128000000,567.048495000000,542.043823000000,504.810462000000,455.171750000000,421.993041000000,444.868141000000,445.552254000000,571.255999000000,497.839315000000,401.919722000000,511.690283000000,405.665018000000,445.861164000000;
559.244519000000,604.834589000000,610.437946000000,598.141598000000,599.579674000000,585.223408000000,576.937405000000,548.540276000000,519.168002000000,427.177459000000,399.644776000000,422.428093000000,417.894392000000,557.863030000000,471.428816000000,379.899441000000,493.764864000000,393.657892000000,418.170867000000;
547.478535000000,585.854927000000,592.561031000000,585.046701000000,581.289845000000,570.443953000000,566.545236000000,543.896407000000,505.127156000000,425.750254000000,393.049434000000,420.044473000000,419.431925000000,558.919036000000,476.445859000000,373.751538000000,495.406529000000,394.962572000000,419.722112000000;
595.626505000000,639.430692000000,643.517499000000,626.310220000000,636.894858000000,613.852504000000,607.526143000000,571.133338000000,543.500286000000,415.319491000000,370.478706000000,415.243578000000,410.784172000000,550.864983000000,463.901547000000,369.638122000000,499.180944000000,373.480171000000,409.405329000000;
561.816808000000,602.308911000000,606.073159000000,596.909809000000,596.167921000000,582.212995000000,577.676339000000,552.231971000000,525.895440000000,427.622898000000,385.292392000000,420.429989000000,417.048726000000,552.305689000000,471.852911000000,374.814079000000,495.974597000000,389.970291000000,417.220754000000]’;%it’s a feature matrix
[data_n,data_l] = size(dataset);
for input_n = 1:data_n
fk = dataset(:,input_n);
Gk = dataset;
Gk(:,input_n)=[];
[Gk_l,Gk_n] = size(Gk);
cvx_startup;
cvx_begin
variables x(Gk_n) lamda
minimize((lamda/2-Gk’*fk)‘x+1/2x’*Gk’Gkx)
subject to
x >= 0
cvx_end
end
error use cvx/quad_form (line 230)
The second argument must be positive or negative semidefinite.
error * (line 261)
[ z2, success ] = quad_form( xx, P, Q, R );
error Untitled (line 29)
minimize((lamda/2-Gk’*fk)‘x+1/2x’*Gk’Gkx)
Thank you.