class tax05{
public static void main(String args[]){
int s1,s2,n1,n2;
double th1[]=new double[11];
double th2[]=new double[11];
double c[][]=new double[11][11];
double y1[]=new double[11];
double y2[]=new double[11];
for (s1=1;s1<11;s1++){
th1[s1]=0.2*s1;
}
for (s2=1;s2<11;s2++){
th2[s2]=0.1*s2;
}
for (n1=0;n1<11;n1++){
y1[n1]=0.1*n1;
}
for (n2=0;n2<11;n2++){
y2[n2]=0.1*n2;
}
for (n1=0;n1<11;n1++){
for (n2=0;n2<11;n2++){
c[n1][n2]=y1[n1]+y2[n2];
}
}
s1=5;
s2=5;
n1=mprefer(s1,s2,th1,th2,c,y1,y2);
n2=fprefer(s1,s2,th1,th2,c,y1,y2);
}
public static int mprefer(int s1,int s2,double[] th1,double[] th2, double[][] c,double[] y1,double[] y2){
int n1,n2,nx1,nx2;
double u1,c1,x1,x2,maxu;
maxu=-999;
nx1=0;
nx2=0;
for (n1=0;n1<11;n1++){
for (n2=0;n2<11;n2++){
c1=c[n1][n2];
x1=1-y1[n1]/th1[s1];
x2=1-y2[n2]/th2[s2];
u1=u(c1,x1,x2);
if (u1>maxu)nx1=n1;
if (u1>maxu)nx2=n2;
if (u1>maxu)maxu=u1;
}
}
return nx1;
}
public static int fprefer(int s1,int s2,double[] th1,double[] th2, double[][] c,double[] y1,double[] y2){
int n1,n2,nx1,nx2;
double u1,c1,x1,x2,maxu;
maxu=-999;
nx1=0;
nx2=0;
for (n1=0;n1<11;n1++){
for (n2=0;n2<11;n2++){
c1=c[n1][n2];
x1=1-y1[n1]/th1[s1];
x2=1-y2[n2]/th2[s2];
u1=u(c1,x1,x2);
if (u1>maxu)nx1=n1;
if (u1>maxu)nx2=n2;
if (u1>maxu)maxu=u1;
}
}
return nx2;
}
public static double u(double c1,double x1,double x2){
double u1,c2,x3,x4;
int h;
c2=c1;
x3=x1;
x4=x2;
h=0;
if (c2<0)h=100;
if (c2==0)h=100;
if (x3<0)h=100;
if (x3==0)h=100;
if (x3>1)h=100;
if (x4<0)h=100;
if (x4==0)h=100;
if (x4>1)h=100;
if (h>50)c2=0.5;
if (h>50)x3=0.5;
if (h>50)x4=0.5;
u1=Math.log(c2)+Math.log(x3)+Math.log(x4);
if (h>50)u1=-999;
return u1;
}
}
最終更新:2010年05月08日 05:56