19# epoh
function y=opt(x,ARL0)
m1=15;m2=15;
n=5;
p=x(1); %p=0.1
m=1.2;
hw=x(2); %hw=1.0274
w=(2*hw)/(2*m1-1);
L=1+5*sqrt(p/(2-p)*(2/n));
%L=1+5*(sqrt(2*p/((2-p)*n)))
q=L/m2;
R=zeros(m1*m2,m1*m2);
for i=0:1:m1-1
for j=0:1:m2-1
for k=0:1:m1-1
for l=0:1:m2-1
h=max(m,(l+0.5)*q);
aa=log(h)/(1-1/h);
a1=(k-i-0.5)*w/(1-1/h)+aa;
a2=(k-i+0.5)*w/(1-1/h)+aa;
b1=(l-(1-p)*(j+0.5))*q/p;
b2=(l+1-(1-p)*(j+0.5))*q/p;
if k==0
temp=b1;
T1=gamcdf(temp,2.5,0.4);
temp=max(b1,min(a2,b2));
T2=gamcdf(temp,2.5,0.4);
R(i*m2+(j+1),k*m2+(l+1))=T2-T1;
function y=opt(x,ARL0)
m1=15;m2=15;
n=5;
p=x(1); %p=0.1
m=1.2;
hw=x(2); %hw=1.0274
w=(2*hw)/(2*m1-1);
L=1+5*sqrt(p/(2-p)*(2/n));
%L=1+5*(sqrt(2*p/((2-p)*n)))
q=L/m2;
R=zeros(m1*m2,m1*m2);
for i=0:1:m1-1
for j=0:1:m2-1
for k=0:1:m1-1
for l=0:1:m2-1
h=max(m,(l+0.5)*q);
aa=log(h)/(1-1/h);
a1=(k-i-0.5)*w/(1-1/h)+aa;
a2=(k-i+0.5)*w/(1-1/h)+aa;
b1=(l-(1-p)*(j+0.5))*q/p;
b2=(l+1-(1-p)*(j+0.5))*q/p;
if k==0
temp=b1;
T1=gamcdf(temp,2.5,0.4);
temp=max(b1,min(a2,b2));
T2=gamcdf(temp,2.5,0.4);
R(i*m2+(j+1),k*m2+(l+1))=T2-T1;
elseif k~=0
temp=min(b2,max(a1,b1));
T1=gamcdf(temp,2.5,0.4);
temp=max(b1,min(a2,b2));
T2=gamcdf(temp,2.5,0.4);
R(i*m2+(j+1),k*m2+(l+1))=T2-T1;
end; %end if
end;
end;
end;
end;
PM=0*ones(1,m1*m2);
PM(1)=1;
x(1)
x(2)
PM*inv(eye(m1*m2,m1*m2)-R)*ones(m1*m2,1)
y=abs(ARL0-PM*inv(eye(m1*m2,m1*m2)-R)*ones(m1*m2,1))
epoh老师,您好!
p=0.1是怎么来的?有什么用?
hw=1.0274是怎么来的?有什么用?
>> ARL0=1000;
x0=[0.1;1.8];
lb=[0.05;1.7];
ub=[0.2;1.9];
[x,fval]=fmincon(@(x)opt(x,ARL0),x0,[],[],[],[],lb,ub)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 260
ans =
0.1000
ans =
1.8000
ans =
753.0236
y =
246.9764
ans =
0.1000
ans =
1.8000
ans =
753.0235
y =
246.9765
ans =
0.1000
ans =
1.8000
ans =
753.0236
y =
246.9764
ans =
0.0500
ans =
1.9000
ans =
791.7859
y =
208.2141
ans =
0.0500
ans =
1.9000
ans =
791.7865
y =
208.2135
ans =
0.0500
ans =
1.9000
ans =
791.7859
y =
208.2141
ans =
0.0941
ans =
1.9000
ans =
954.6719
y =
45.3281