アットウィキロゴ

lpXX

class pro{
public static void main(String args[]){
double th1,th2,cs1,xs1,cs2,xs2;
double h;
double uc1,ux1,uc2,ux2,u1,u2;
double x[][]=new double[11][20];
double x3;
int m,n,p;
int t2,t3;
h=0.001;
th1=1;
th2=0.9;
cs1=0.5;
xs1=0.5;
cs2=0.45;
xs2=0.5;

t3=0;
while(t3<5){
t2=0;
while(t2<100){
uc1=1/cs1;
ux1=1/xs1;
uc2=1/cs2;
x3=1-th2*(1-xs2)/th1;
ux2=th2/(th1*x3);
u1=Math.log(cs1)+Math.log(xs1)-uc1*cs1-ux1*xs1;
u2=Math.log(cs2)+Math.log(xs2)-uc2*cs2-ux2*xs2;

for (m=0;m<11;m++){
for (n=0;n<20;n++){
x[m][n]=0;
}
}

x[1][1]=1;
x[1][0]=cs1+h;
x[2][1]=-1;
x[2][0]=-cs1+h;
x[3][2]=1;
x[3][0]=xs1+h;
x[4][2]=-1;
x[4][0]=-xs1+h;

x[5][3]=1;
x[5][0]=cs2+h;
x[6][3]=-1;
x[6][0]=-cs2+h;
x[7][4]=1;
x[7][0]=xs2+h;
x[8][4]=-1;
x[8][0]=-xs2+h;

x[9][1]=1;
x[9][2]=th1;
x[9][3]=1;
x[9][4]=th2;
x[9][0]=th1+th2;

x[10][1]=-uc1;
x[10][2]=-ux1;
x[10][3]=uc2;
x[10][4]=ux2;
x[10][0]=u1-u2;

x[1][5]=1;
x[2][6]=1;
x[3][7]=1;
x[4][8]=1;
x[5][9]=1;
x[6][10]=1;
x[7][11]=1;
x[8][12]=1;
x[9][13]=1;
x[10][14]=1;

System.out.println(u1-u2);

x=f1(x);

x[0][1]=1/cs1;
x[0][2]=1/xs1;
x[0][3]=1/cs2;
x[0][4]=1/xs2;

x=f2(x);

p=ch(x);
if (p<4)t2=1000;
System.out.println(p);

while(p>3){
for (m=1;m<11;m++){
if (x[m][1]>0)cs1=x[m][0]/x[m][1];
if (x[m][1]<0)cs1=x[m][0]/x[m][1];
}

for (m=1;m<11;m++){
if (x[m][2]>0)xs1=x[m][0]/x[m][2];
if (x[m][2]<0)xs1=x[m][0]/x[m][2];
}

for (m=1;m<11;m++){
if (x[m][3]>0)cs2=x[m][0]/x[m][3];
if (x[m][3]<0)cs2=x[m][0]/x[m][3];
}

for (m=1;m<11;m++){
if (x[m][4]>0)xs2=x[m][0]/x[m][4];
if (x[m][4]<0)xs2=x[m][0]/x[m][4];
}
p=0;
}
System.out.println(cs1);
System.out.println(cs2);
System.out.println(xs1);
System.out.println(xs2);

t2=t2+1;
}
h=h/2;
t3=t3+1;
}

}
public static int ch(double[][] x){
int m;
int p1,p2,p3,p4,p;
p=0;
p1=0;
for (m=1;m<11;m++){
if (x[m][1]==0)p1=p1+1;
}
if (p1==9)p=p+1;

p2=0;
for (m=1;m<11;m++){
if (x[m][2]==0)p2=p2+1;
}
if (p2==9)p=p+1;

p3=0;
for (m=1;m<11;m++){
if (x[m][3]==0)p3=p3+1;
}
if (p3==9)p=p+1;

p4=0;
for (m=1;m<11;m++){
if (x[m][3]==0)p4=p4+1;
}
if (p4==9)p=p+1;

return p;
}
public static double[][] f1(double[][] x){
int m,n,maxm,maxn,t1,px;
double maxv,minv,under,op,z;
System.out.println(x[1][1]);
x[0][15]=-1;
x[0][16]=-1;
x[0][17]=-1;
x[0][18]=-1;
x[0][19]=-1;

x[2][15]=-1;
x[4][16]=-1;
x[6][17]=-1;
x[8][18]=-1;
x[10][19]=-1;

for (n=0;n<20;n++){
x[0][n]=x[0][n]-x[2][n]-x[4][n]-x[6][n]-x[8][n]-x[10][n];
}

maxn=999;
maxv=0;
for (n=1;n<20;n++){
if(x[0][n]>maxv)maxn=n;
if(x[0][n]>maxv)maxv=x[0][n];
}
if (maxn>900)t1=1000;

t1=0;
while(t1<100){
maxm=999;
minv=999;
for (m=1;m<11;m++){
under=x[m][maxn];
px=0;
if (under==0)px=100;
if (px>50)under=1;
op=x[m][0]/under;
if (op<0)px=100;
if (px>50)op=1000;
if (op<minv)maxm=m;
if (op<minv)minv=op;
}

for (m=0;m<11;m++){
z=x[m][maxn]/x[maxm][maxn];
if (m==maxm)z=0;
for (n=0;n<20;n++){
x[m][n]=x[m][n]-z*x[maxm][n];
}
}

maxn=999;
maxv=0;
for (n=1;n<20;n++){
if(x[0][n]>maxv)maxn=n;
if(x[0][n]>maxv)maxv=x[0][n];
}
if (maxn>900)t1=1000;
t1=t1+1;
}

return x;
}

public static double[][] f2(double[][] x){
int m,n,maxm,maxn,t1,px;
double maxv,minv,under,op,z;
maxn=999;
maxv=0;
for (n=1;n<15;n++){
if(x[0][n]>maxv)maxn=n;
if(x[0][n]>maxv)maxv=x[0][n];
}
if (maxn>900)t1=1000;

t1=0;
while(t1<100){
maxm=999;
minv=999;
for (m=1;m<11;m++){
under=x[m][maxn];
px=0;
if (under==0)px=100;
if (px>50)under=1;
op=x[m][0]/under;
if (op<0)px=100;
if (px>50)op=1000;
if (op<minv)maxm=m;
if (op<minv)minv=op;
}

for (m=0;m<11;m++){
z=x[m][maxn]/x[maxm][maxn];
if (m==maxm)z=0;
for (n=0;n<15;n++){
x[m][n]=x[m][n]-z*x[maxm][n];
}
}

maxn=999;
maxv=0;
for (n=1;n<15;n++){
if(x[0][n]>maxv)maxn=n;
if(x[0][n]>maxv)maxv=x[0][n];
}
if (maxn>900)t1=1000;
t1=t1+1;
}
return x;
}

}
最終更新:2010年06月20日 18:11