アットウィキロゴ

ふfdさ

import java.io.*;

class tax{

int s1,s2;
double th1[]=new double[6];
double th2[]=new double[6];
double c[][]=new double[6][6];
double y1[][]=new double[6][6];
double y2[][]=new double[6][6];    
double cp[][][]=new double[6][6][3];
double yp1[][][]=new double[6][6][3];
double yp2[][][]=new double[6][6][3];
double u[][][]=new double[6][6][3];
double w[][][]=new double[6][6][3];
double z[][][]=new double[6][6][3];
int op[][]=new int[6][6];
double h,maxv;
double cs,ys1,ys2;
int n,e,e1,e2,e3;

public static void main(String args[]){
tax test=new tax();
}


tax(){

for (s1=1;s1<6;s1++){
th1[s1]=0.2*s1;
}

for (s2=1;s2<6;s2++){
th2[s2]=0.1*s2;
}

linear ln=new linear();;
ln.th1=th1;
ln.th2=th2;
ln.makedata();
c=ln.c;
y1=ln.y1;
y2=ln.y2;


h=0.001;
while(h>0.0005){

for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
for (n=-1;n<2;n++){  
cs=c[s1][s2]-n*h;
ys1=y1[s1][s2];
ys2=y2[s1][s2];
u[s1][s2][n+1]=ux(cs,1-ys1/th1[s1],1-ys2/th2[s2]);    
}
}
}

for (s1=1;s1<5;s1++){
for (s2=1;s2<6;s2++){
for (n=-1;n<2;n++){  
cs=c[s1][s2]-n*h;
ys1=y1[s1][s2];
ys2=y2[s1][s2];
w[s1][s2][n+1]=ux(cs,1-ys1/th1[s1+1],1-ys2/th2[s2]);    
}
}
}


for (s1=1;s1<6;s1++){
for (s2=1;s2<5;s2++){
for (n=-1;n<2;n++){  
cs=c[s1][s2]-n*h;
ys1=y1[s1][s2];
ys2=y2[s1][s2];
z[s1][s2][n+1]=ux(cs,1-ys1/th1[s1],1-ys2/th2[s2+1]);    
}
}
}

for (s1=1;s1<6;s1++){
for (s2=1;s2<5;s2++){
for (n=-1;n<2;n++){  
cp[s1][s2][n+1]=c[s1][s2]-n*h;
yp1[s1][s2][n+1]=y1[s1][s2];
yp2[s1][s2][n+1]=y2[s1][s2];      
}
}
}

non nl=new non();
nl.th1=th1;
nl.th2=th2;
nl.z=z;
nl.u=u;
nl.w=w;
nl.cp=cp;
nl.yp1=yp1;
nl.yp2=yp2;
nl.makedata();
maxv=nl.maxv;
op=nl.op;
e1=nl.e;

for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
n=op[s1][s2];
c[s1][s2]=c[s1][s2]-h*n;
}
}


for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
for (n=-1;n<2;n++){  
cs=c[s1][s2];
ys1=y1[s1][s2]+n*h;
ys2=y2[s1][s2];
u[s1][s2][n+1]=ux(cs,1-ys1/th1[s1],1-ys2/th2[s2]);    
}
}
}

for (s1=1;s1<5;s1++){
for (s2=1;s2<6;s2++){
for (n=-1;n<2;n++){  
cs=c[s1][s2];
ys1=y1[s1][s2]+n*h;
ys2=y2[s1][s2];
w[s1][s2][n+1]=ux(cs,1-ys1/th1[s1+1],1-ys2/th2[s2]);    
}
}
}



for (s1=1;s1<6;s1++){
for (s2=1;s2<5;s2++){
for (n=-1;n<2;n++){  
cs=c[s1][s2];
ys1=y1[s1][s2]+n*h;
ys2=y2[s1][s2];
z[s1][s2][n+1]=ux(cs,1-ys1/th1[s1],1-ys2/th2[s2+1]);    
}
}
}

for (s1=1;s1<6;s1++){
for (s2=1;s2<5;s2++){
for (n=-1;n<2;n++){  
cp[s1][s2][n+1]=c[s1][s2];
yp1[s1][s2][n+1]=y1[s1][s2]+n*h;
yp2[s1][s2][n+1]=y2[s1][s2];      
}
}
}

nl.z=z;
nl.u=u;
nl.w=w;
nl.cp=cp;
nl.yp1=yp1;
nl.yp2=yp2;
nl.makedata();
maxv=nl.maxv;
op=nl.op;
e2=nl.e;

for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
n=op[s1][s2];
y1[s1][s2]=y1[s1][s2]+h*n;
}
}

for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
for (n=-1;n<2;n++){  
cs=c[s1][s2];
ys1=y1[s1][s2];
ys2=y2[s1][s2]+n*h;
u[s1][s2][n+1]=ux(cs,1-ys1/th1[s1],1-ys2/th2[s2]);    
}
}
}


for (s1=1;s1<5;s1++){
for (s2=1;s2<6;s2++){
for (n=-1;n<2;n++){  
cs=c[s1][s2];
ys1=y1[s1][s2];
ys2=y2[s1][s2]+n*h;
w[s1][s2][n+1]=ux(cs,1-ys1/th1[s1+1],1-ys2/th2[s2]);    
}
}
}


for (s1=1;s1<6;s1++){
for (s2=1;s2<5;s2++){
for (n=-1;n<2;n++){  
cs=c[s1][s2];
ys1=y1[s1][s2];
ys2=y2[s1][s2]+n*h;
z[s1][s2][n+1]=ux(cs,1-ys1/th1[s1],1-ys2/th2[s2+1]);    
}
}
}


for (s1=1;s1<6;s1++){
for (s2=1;s2<5;s2++){
for (n=-1;n<2;n++){  
cp[s1][s2][n+1]=c[s1][s2];
yp1[s1][s2][n+1]=y1[s1][s2];
yp2[s1][s2][n+1]=y2[s1][s2]+n*h;      
}
}
}


nl.z=z;
nl.u=u;
nl.w=w;
nl.cp=cp;
nl.yp1=yp1;
nl.yp2=yp2;
nl.makedata();
maxv=nl.maxv;
op=nl.op;
e3=nl.e;

for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
n=op[s1][s2];
y2[s1][s2]=y2[s1][s2]+h*n;
}
}

e=e1+e2+e3;
System.out.println(e);
System.out.println(maxv);

if(e<1)h=h/2;

}

writefile();

}

void writefile(){

int s1,s2;

try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter("data.txt")));

for(s1=1;s1<6;s1++){
for(s2=1;s2<6;s2++){
pw.print("<");
pw.print(s1);
pw.print(">");
pw.print("<");
pw.print(s2);
pw.print(">");
pw.print("<");
pw.print(c[s1][s2]);
pw.print(">");
pw.print("<");
pw.print(y1[s1][s2]);
pw.print(">");
pw.print("<");
pw.print(y2[s1][s2]);
pw.println(">");
}
}
  
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }


}




double ux(double c1,double x1,double x2){
double c2,x3,x4,u1;
int px;
c2=c1;
x3=x1;
x4=x2;
px=0;
if (c2<0)px=100;
if (c2==0)px=100;
if (x3<0)px=100;
if (x3==0)px=100;
if (x3>1)px=100;
if (x4<0)px=100;
if (x4==0)px=100;
if (x4>1)px=100;
if (px>50)c2=0.5;
if (px>50)x3=0.5;
if (px>50)x4=0.5;
u1=Math.log(c2)+Math.log(x3)+Math.log(x4);
if (px>50)u1=-999;
return u1;
}

}
最終更新:2011年08月08日 13:46