clc
clear
close all
A=[0.000985 0.002529 0.000073 0.465188 0.396493 0.010491 0.006677 0.117564;
0.002740 0.000106 0.000557 0.647801 0.343779 0.004177 0.000420 0.000420;
0.001532 0.000367 0.000239 0.531187 0.372365 0.007384 0.002469 0.028271;
0.001863 0.001265 0.000310 0.576412 0.364581 0.006254 0.003543 0.000921;
0.000007 0.000008 0.000277 0.991821 0.007066 0.000045 0.000047 0.000729;
0.000005 0.000005 0.000263 0.987540 0.011185 0.000099 0.000107 0.000795;
0.000008 0.000008 0.000251 0.979665 0.017921 0.000183 0.000064 0.001900;
0.000007 0.000010 0.000027 0.983709 0.012784 0.000314 0.000048 0.003100;
0.001278 0.650776 0.018781 0.306294 0.021743 0.000233 0.000051 0.000846;
0.000953 0.683952 0.024946 0.264046 0.024415 0.000247 0.000417 0.001022;
0.002293 0.705478 0.028977 0.238811 0.022378 0.000290 0.000112 0.001652;
0.001518 0.695229 0.021995 0.253713 0.024929 0.000448 0.000161 0.002008;
0.000548 0.001338 0.001158 0.206910 0.393305 0.091821 0.020847 0.284073;
0.000270 0.000206 0.010293 0.159033 0.031379 0.166245 0.316287 0.316287;
0.004698 0.001240 0.002395 0.235241 0.330723 0.117418 0.035490 0.272793;
0.000834 0.000045 0.000853 0.150793 0.320173 0.061099 0.233102 0.233102];
c=[1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 0 1;0 0 0 1;0 0 0 1;0 0 0 1];
A=A';
y=zeros(4,16);
x=zeros(4,16);
theta=abs(randn(4,16));
alfa=0.05*ones(4,16);
sigma=0.01;
k=0.02;
I=0.5*ones(1,6);
n=0;
E=zeros(4,4);
w=abs(randn(4,4));
w0=abs(randn(4,4));
v=abs(randn(4,8));
v0=abs(randn(4,8));
B=zeros(4,16);
B=B+w*x;
C=zeros(4,16);
C=C+v*A;
y=k*y+B-alfa.*x+C-theta*(1-k);
%z=2.0*ones();
%y=k*y+beta*(B+A)-z.*(x-I);
%z=z./log(exp(1)+lamada*(1-z));
x=1./(1+exp(-y/sigma));
E0=zeros(4,4);
E0=E0+w*x*x';
%计算误差
con=ones(4,16);
con2=ones(4,16);
f=c'-x;
g=f*x'*(con-x);
e=w'*g*y'*(con2-y);
SL1=abs(randn(4,16));
SL2=abs(randn(4,16));
w=w+SL1*g'*y;
v=v+SL2*e'*A;
%优化
E=zeros(4,4);
E=E+w*x*x';
if E<=E0
E0=E;
w0=w;
v0=v;
end
dsum=0;
for i=1:2
for j=1:5
dsum=dsum+abs(f(i,j));
end
end
n=n+1;
error(n)=dsum;
end
n1=1:n;
plot(n1,error,'r:.')