アットウィキロゴ

最適所得税 別解法

package non;
 
class pro{ 
 
int s,e; 
int th[]= new int[101]; 
int c[]= new int[101]; 
int y[]= new int[101]; 
 double h;
 
public static void main(String args[]){ 
pro test=new pro(); 
} 
 
pro(){ 
 
 h=0.01;   
 
for (s=1;s<101;s++){ 
th[s]=10*s; 
} 
 
nearlinear sub=new nearlinear();
sub.th=th;
sub.h=h;
sub.makedata();
c=sub.c;
y=sub.y;
 
int time;
 
for(time=1;time<11;time++){
 
non sub2=new non();
sub2.th=th;
sub2.h=h;
sub2.c=c;
sub2.y=y;
sub2.makedata();
c=sub2.c;
y=sub2.y;
 
}
 
 
}
}
 
 
package non;
 
class faststep{ 
 
int[] th=new int[101];
double h;
int[] c=new int[101];
int[] y=new int[101];
double[][][] ux=new double[101][21][21];
double[][][] wx=new double[101][21][21];
int[][][] nearu=new int[101][21][21];
int[][][] nearw=new int[101][21][21];
double[][][] us=new double[101][21][21];
int[][][] nearus=new int[101][21][21];
int[] ws=new int[101];
int[][][] cs=new int[101][21][21];
int[][][] ys=new int[101][21][21];
 
int s,m,n,b,mx,bx;
 int c1,y1;
 double u1;
int z; 
 
void makedata(){ 
 
for(s=1;s<101;s++){    
for(m=-10;m<11;m++){    
for(n=-10;n<11;n++){    
c1=c[s]+m;
y1=y[s]+n;    
ux[s][m+10][n+10]=makeu(s,c1,y1);        
}
}
}
 
for(s=1;s<101;s++){    
for(m=-10;m<11;m++){    
for(n=-10;n<11;n++){    
u1=ux[s][m+10][n+10];
nearu[s][m+10][n+10]=translate(u1);   
}
}
}
 
for(s=1;s<100;s++){    
for(m=-10;m<11;m++){    
for(n=-10;n<11;n++){    
c1=c[s]+m;
y1=y[s]+n;    
wx[s][m+10][n+10]=makeu(s+1,c1,y1);        
}
}
}
 
for(s=1;s<100;s++){    
for(m=-10;m<11;m++){    
for(n=-10;n<11;n++){    
u1=wx[s][m+10][n+10];
nearw[s][m+10][n+10]=translate(u1);   
}
}
}
 
 
m=0;
n=0;
for(s=1;s<100;s++){   
u1=wx[s][m+10][n+10];   
ws[s]=translate(u1);
}
 
int w1;
double maxv;
int ms,ns;
int u2;
 
for(s=1;s<100;s++){
for(b=-10;b<11;b++){
for(mx=-10;mx<11;mx++){
maxv=-999;
u2=0;
ms=0;
ns=0;
for(m=-10;m<11;m++){
n=b-m;
z=0;
if(n>10)z=100;
if(n<-10)z=100;
if(z>50)n=0;
w1=nearw[s][m+10][n+10]-ws[s];
if(w1>mx)z=100;
u1=ux[s][m+10][n+10];
if(z>50)u1=-999;
if(u1>maxv)u2=nearu[s][m+10][n+10];
if(u1>maxv)ms=m;
if(u1>maxv)ns=n;
if(u1>maxv)maxv=u1;
}
us[s][mx+10][b+10]=maxv;
cs[s][mx+10][b+10]=ms+c[s];
ys[s][mx+10][b+10]=ns+y[s];
nearus[s][mx+10][b+10]=u2;
}
}
}
 
 
 
 
 
 
 
}
int translate(double u1){
double t1,z;
int t2;
z=0;
if(u1<-100)z=100;
if(z>50)u1=1;
t1=Math.exp(u1);
t2=(int)(t1/h); 
if(z>50)t2=-999;
return t2;
}
 
 
 
double makeu(int s,int c1,int y1){
double u1,c2,x2;
c2=c1*h;
x2=1-(double)y1/th[s];
u1=u(c2,x2);
return u1;
}
 
double u(double c1,double x1){ 
double u1,c2,x2; 
int pp; 
pp=0; 
c2=c1; 
x2=x1; 
if (c2<0)pp=100; 
if (x2<0)pp=100; 
if (x2>1)pp=100; 
if (x2==0)pp=100; 
if (pp>50)c2=0.5; 
if (pp>50)x2=0.5; 
u1=Math.log(c2)+Math.log(x2); 
if (pp>50)u1=-999; 
return u1; 
} 
 
}
 
 
 
package non;
 
class linear{ 
 
int s; 
double th[]= new double[101]; 
double c[]= new double[101]; 
double y[]= new double[101]; 
double tl,tr,w1; 
double c1,y1; 
 
void makedata(){ 
 
tl=tls(th); 
tr=trs(tl,th); 
for (s=1;s<101;s++){ 
y1=th[s]*lx(s,tl,tr,th); 
c1=tr+(1-tl)*y1; 
c[s]=c1;
y[s]=y1;
} 
 
} 
 
double lx(int s,double tl,double tr,double th[]){ 
double w1,l1; 
w1=(1-tl)*th[s]; 
l1=(w1-tr)/(2*+w1); 
if (l1<0)l1=0; 
return l1; 
} 
 
double bud(double tl,double tr,double th[]){ 
double c1,y1,b1; 
int s; 
b1=0; 
for (s=1;s<101;s++){ 
y1=th[s]*lx(s,tl,tr,th); 
c1=(1-tl)*y1+tr; 
b1=b1+y1-c1; 
} 
return b1; 
} 
 
double trs(double tl,double th[]){ 
double tr1,tr2,tr3,b1,b2; 
int t; 
tr1=0.1; 
tr2=0.2; 
b1=bud(tl,tr1,th); 
t=0; 
while(t<100){ 
b2=bud(tl,tr2,th); 
tr3=tr2-b2*(tr2-tr1)/(b2-b1); 
tr1=tr2; 
tr2=tr3; 
b1=b2; 
if (b2*b2<0.0001)t=1000; 
t=t+1; 
} 
return tr2; 
} 
 
double tls(double th[]){ 
int m; 
double tl,tr,w1,maxw,maxtl; 
maxw=-999; 
maxtl=0; 
for (m=10;m<50;m++){ 
tl=0.01*m; 
tr=trs(tl,th); 
w1=wel(tl,tr,th); 
if (w1>maxw)maxtl=tl; 
if (w1>maxw)maxw=w1; 
} 
return maxtl; 
} 
 
double wel(double tl,double tr,double th[]){ 
double c1,l1,w1; 
int s; 
w1=0; 
for (s=1;s<101;s++){ 
l1=lx(s,tl,tr,th); 
c1=(1-tl)*th[s]*l1+tr; 
w1=w1+u(c1,1-l1);; 
} 
return w1; 
} 
 
double u(double c1,double x1){ 
double u1,c2,x2; 
int pp; 
pp=0; 
c2=c1; 
x2=x1; 
if (c2<0)pp=100; 
if (x2<0)pp=100; 
if (x2>1)pp=100; 
if (x2==0)pp=100; 
if (pp>50)c2=0.5; 
if (pp>50)x2=0.5; 
u1=Math.log(c2)+Math.log(x2); 
if (pp>50)u1=-999; 
return u1; 
} 
 
}
 
 
 
 
package non;
 
 
class nearlinear{ 
 
int s; 
int th[]= new int[101]; 
double ths[]= new double[101]; 
double cs[]= new double[101]; 
double ys[]= new double[101]; 
int c[]= new int[101]; 
int y[]= new int[101]; 
double tl,tr,w1; 
double c1,y1; 
double h;
 
 
void makedata(){ 
 
for (s=1;s<101;s++){ 
ths[s]=th[s]*h; 
} 
 
linear sub=new linear();
sub.th=ths;
sub.makedata();
cs=sub.c;
ys=sub.y;
 
for (s=1;s<101;s++){ 
c[s]=(int)(cs[s]/h);
y[s]=(int)(ys[s]/h);
} 
 
 
 
 
}
}
 
 
package non;
 
class non{ 
 
int[] th=new int[101];
double h;
int[] c=new int[101];
int[] y=new int[101];
double[][][] us=new double[101][21][21];
double[][][] ux=new double[101][21][21];
double[][][] vs=new double[101][21][101];
int[][][] gotom=new int[101][21][101];
int[][][] gotob=new int[101][21][101];
int[][][] nearu=new int[101][21][21];
int[] ws=new int[101];
int[] opm=new int[101];
int[] opb=new int[101];
int m,mx,b,s,bx;
double u1;
int[][][] cs=new int[101][21][21];
int[][][] ys=new int[101][21][21];
 
 
 
void makedata(){ 
 
    faststep sub=new faststep();
    sub.th=th;
    sub.h=h;
    sub.c=c;
    sub.y=y;
    sub.makedata();
    us=sub.us;
    ux=sub.ux;
    ws=sub.ws;
    nearu=sub.nearu;
 
 
    for(mx=-10;mx<11;mx++){
    for(b=-50;b<51;b++){
    vs[1][mx+10][b+50]=-999;
    }
    }
 
 
 
     for(mx=-10;mx<11;mx++){
    for(b=-10;b<11;b++){
    vs[1][mx+10][b+50]=us[1][mx+10][b+10];
    }
    }
 
 
     int b1,z,u2,w1;
double v1,maxv;
     int mxs,bxs;
 
 
for(s=2;s<100;s++){
    for(m=-10;m<11;m++){
    for(b=-50;b<51;b++){
    maxv=-999;
    mxs=0;
    bxs=0;
 
    for(bx=-10;bx<11;bx++){ 
    u1=us[s][m+10][bx+10];
    u2=nearu[s][m+10][bx+10];
    b1=b-bx;
    z=0;
    if(b1>50)z=100;
    if(b1<-50)z=100;
    if(z>50)b1=0;
    for(mx=-10;mx<11;mx++){ 
    w1=ws[s-1]+mx;
    if(w1>u2)z=100;
    v1=u1+vs[s-1][mx+10][b1+50];
    if(z>50)v1=-999;
    if(v1>maxv)mxs=mx;
    if(v1>maxv)bxs=b1;
    if(v1>maxv)maxv=v1;
    }
    }
    vs[s][m+10][b+50]=maxv;
    gotom[s][m+10][b+50]=mxs;
    gotob[s][m+10][b+50]=bxs;
    }
}
}
 
 
int m1,n1;
 
int mm,nn;
 
 
s=100;
maxv=-999;
mm=0;
nn=0;
 
mxs=0;
bxs=0;
for(m1=-10;m1<10;m1++){
for(n1=-10;n1<10;n1++){
u1=ux[s][m1+10][n1+10];
u2=nearu[s][m1+10][n1+10];
bx=m1-n1;
for(mx=-10;mx<10;mx++){
w1=ws[s-1]+mx;
z=0;
if(w1>u2)z=100;
v1=u1+vs[s-1][mx+10][bx+50];
if(z>50)v1=-999;
if(v1>maxv)mxs=mx;
if(v1>maxv)bxs=bx;
if(v1>maxv)mm=m1;
if(v1>maxv)nn=n1;
if(v1>maxv)maxv=v1;
}
}
}
 
System.out.println(maxv);
 
opm[99]=mxs;
opb[99]=bxs;
 
int t;
 
for(t=1;t<99;t++){
s=100-t;
m=opm[s];
b=opb[s];
opm[s-1]=gotom[s][m+10][b+50];
opb[s-1]=gotob[s][m+10][b+50];
}
 
 
for(s=1;s<100;s++){
m=opm[s];
b=opb[s]-opb[s-1];
 
 
 
c[s]=cs[s][m+10][b+10];
y[s]=ys[s][m+10][b+10];
}
 
c[100]=c[100]+mm;
y[100]=y[100]+nn;
 
 
 
 
 
 
 
}
 
 
}
 
最終更新:2013年09月25日 03:06