class pro{
public static void main(String args[]){
double tl,tr,l1,c1,b1;
int n;
double th[]=new double[101];
for (n=1;n<101;n++){
th[n]=0.02*n;
}
tl=0.2;
tr=0.1;
b1=bud(th,tl,tl,tr,tr);
System.out.println(b1);
}
public static double bud(double[] th,double t1,double t2,double tr1,double tr2){
double c1,y1,b1;
int n;
b1=0;
for (n=1;n<101;n++){
c1=con(th[n],t1,t2,tr1,tr2);
y1=th[n]*lab(th[n],t1,t2,tr1,tr2);
b1=b1+y1-c1;
}
return b1;
}
public static double con(double th1,double t1,double t2,double tr1,double tr2){
double c1,c2,y1,y2,l1,l2,u1,u2;
l1=lx(th1,t1,tr1);
y1=th1*l1;
if (y1>0.5)l1=0.5/th1;
if (y1>0.5)y1=0.5;
c1=(1-t1)*y1+tr1;
u1=u(c1,1-l1);
l2=lx(th1,t2,tr2);
y2=(1-t2)*l2;
if (y2<0.5)l2=0.5/th1;
if (y2<0.5)y2=0.5;
c2=(1-t2)*y2+tr2;
u2=u(c2,1-l2);
if (u2>u1)c1=c2;
return c1;
}
public static double lab(double th1,double t1,double t2,double tr1,double tr2){
double c1,c2,y1,y2,l1,l2,u1,u2;
l1=lx(th1,t1,tr1);
y1=th1*l1;
if (y1>0.5)l1=0.5/th1;
if (y1>0.5)y1=0.5;
c1=(1-t1)*y1+tr1;
u1=u(c1,1-l1);
l2=lx(th1,t2,tr2);
y2=(1-t2)*l2;
if (y2<0.5)l2=0.5/th1;
if (y2<0.5)y2=0.5;
c2=(1-t2)*y2+tr2;
u2=u(c2,1-l2);
if (u2>u1)l1=l2;
return l1;
}
public static double lx(double th1,double tl,double tr){
double w1,l1;
w1=(1-tl)*th1;
l1=(w1-tr)/(2*w1);
if (l1<0)l1=0;
return l1;
}
public static double u(double c1,double x1){
double c2,x2,z2,u2;
c2=c1;
x2=x1;
z2=0;
if (c2<0)z2=100;
if (c2==0)z2=100;
if (x2>1)z2=100;
if (x2<0)z2=100;
if (x2==0)z2=100;
if (z2>50)c2=0.01;
if (z2>50)x2=0.5;
u2=Math.log(c2)+Math.log(x2);
if (z2>50)u2=-999;
return u2;
}
}
最終更新:2010年04月15日 15:47