アットウィキロゴ

dfkl

class pro{
public static void main(String args[]){
int s;
double th[]=new double[101];
double c[]=new double[101];
double x[]=new double[101];
double lam,h,e;
int n1,n2;
double c1,x1,y1,u1,b1;
double maxu,maxx,maxc;
double lam1,lam2;
int t1,t2,t3;
for (s=1;s<101;s++){
th[s]=1+0.01*s;
x[s]=0.5;
c[s]=th[s]*(1-x[s]);
}
lam1=5;
lam2=0.1;
t3=0;
while(t3<100){
lam=(lam1+lam2)/2;
for (s=1;s<101;s++){
t2=0;
h=0.01;
while(t2<5){
t1=0;
h=h/2;
while (t1<100){
maxu=-999;
maxc=c[s];
maxx=x[s];
for (n1=-1;n1<2;n1++){
for (n2=-1;n2<2;n2++){
c1=c[s]+n1*h;
x1=x[s]+n2*h;
y1=th[s]*(1-x1);
u1=Math.log(c1)+Math.log(x1)+lam*(y1-c1);
if(u1>maxu)maxc=c1;
if(u1>maxu)maxx=x1;
if(u1>maxu)maxu=u1;
}
}
c[s]=maxc;
x[s]=maxx;
t1=t1+1;
}
t2=t2+1;
}
}
b1=0;
for (s=1;s<101;s++){
b1=b1+th[s]*(1-x[s])-c[s];
}
System.out.println(lam);
if (b1>0)lam1=lam;
if (b1<0)lam2=lam;
if (b1*b1<0.001)t3=1000;
t3=t3+1;
}
for (s=1;s<101;s++){
System.out.println(x[s]);
}



}
}
最終更新:2010年06月23日 19:13