アットウィキロゴ

最適非線形所得税の失敗

package linear;
 
class pro{ 
 
int s; 
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;
 
 
nonlinear sub2=new nonlinear();
sub2.th=th;
sub2.h=h;
sub2.c=c;
sub2.y=y;
sub2.makedata();
c=sub2.c;
y=sub2.y;
 
}
}
 
package linear;
 
 
 
public class nonlinear{
 
 double[][][] u=new double[101][3][3];
 double[][][] w=new double[101][3][3];
 double[][][][] v=new double[101][3][3][21];
  int[][][][] gotom=new int[101][3][3][21];
   int[][][][] goton=new int[101][3][3][21];
    int[][][][] gotob=new int[101][3][3][21];
 
    int[] c=new int[101];
 int[] y=new int[101];
 int[] th=new int[101];
 
   int[] opc=new int[101];
 int[] opy=new int[101];
 
 int[][] endm=new int[3][3];
   int[][] endn=new int[3][3];
    int[][] endb=new int[3][3];
 
 double h;   
 int s,m,n,b,bx;
 int c1,y1;
 
 
 
 
void makedata(){    
 
    int mode;
    mode=0;
 
    while(mode<50){
 
 
    for(s=1;s<101;s++){
     for(m=-1;m<2;m++){
        for(n=-1;n<2;n++){
         c1=c[s]+m;
    y1=y[s]+n;
 u[s][m+1][n+1]=ux(s,c1,y1);   
        }
     }
    }
 
    for(s=1;s<100;s++){
     for(m=-1;m<2;m++){
        for(n=-1;n<2;n++){
         c1=c[s]+m;
    y1=y[s]+n;
 w[s][m+1][n+1]=ux(s+1,c1,y1);   
        }
     }
    }
 
    s=1;
    for(m=-1;m<2;m++){
        for(n=-1;n<2;n++){
         for(b=-10;b<11;b++){
 v[s][m+1][n+1][b+10]=-999;   
        }
     }
    }
 
     s=1;
    for(m=-1;m<2;m++){
    for(n=-1;n<2;n++){
     b=n-m;
 v[s][m+1][n+1][b+10]=u[s][m+1][n+1];   
    }
     }
 
    double u1,maxv,v1,w1;
    int z,mx,nx,mxs,nxs,bxs;
 
    for(s=2;s<10;s++){
    for(m=-1;m<2;m++){
    for(n=-1;n<2;n++){
    for(b=-10;b<11;b++){
    u1=u[s][m+1][n+1];
    bx=b-n+m;
    z=0;
    if(bx<-10)z=100;
    if(bx>10)z=100;
    if(z>10)bx=0;
    maxv=-999;
    mxs=0;
    nxs=0;
    bxs=0;
    for(mx=-1;mx<2;mx++){
    for(nx=-1;nx<2;nx++){
    v1=u1+v[s-1][mx+1][nx+1][bx+10];
    w1=w[s-1][mx+1][nx+1];
    if(w1>u1)v1=-999;
    if(z>50)v1=-999;
     if(v1>maxv)mxs=mx;
      if(v1>maxv)nxs=nx;
       if(v1>maxv)bxs=bx;
    if(v1>maxv)maxv=v1;
    }
    }
    v[s][m+1][n+1][b+10]=maxv;
    gotom[s][m+1][n+1][b+10]=mxs;  
    goton[s][m+1][n+1][b+10]=nxs; 
    gotob[s][m+1][n+1][b+10]=bxs; 
    }
    }
    }
    }
 
    double supv;
    int ms,ns,bs;
 
 
    s=100;
    supv=-999;
    ms=0;
    ns=0;
    for(m=-1;m<2;m++){
    for(n=-1;n<2;n++){
    u1=u[s][m+1][n+1];
    bx=m-n;
    maxv=-999;
    mxs=0;
    nxs=0;
    bxs=0;
    for(mx=-1;mx<2;mx++){
    for(nx=-1;nx<2;nx++){
    v1=u1+v[s-1][mx+1][nx+1][bx+10];
    w1=w[s-1][mx+1][nx+1];
    if(w1>u1)v1=-999;
    if(v1>maxv)mxs=mx;
    if(v1>maxv)nxs=nx;
    if(v1>maxv)bxs=bx;
    if(v1>maxv)maxv=v1;
    }
    }
    endm[m+1][n+1]=mxs;
    endn[m+1][n+1]=nxs;
    endb[m+1][n+1]=bxs;
    if(maxv>supv)ms=m;
    if(maxv>supv)ns=n;
    if(maxv>supv)supv=maxv;    
    }
    }
 
 
    System.out.println(supv);
 
    opc[100]=ms;
    opy[100]=ns;
 
    bs=ms-ns;
 
    mxs=endm[ms+1][ns+1];
    nxs=endn[ms+1][ns+1];
 
    opc[99]=mxs;
    opy[99]=nxs;     
 
    int t;
 
    for(t=1;t<99;t++){
    ms=opc[100-t];
    ns=opy[100-t];
opc[99-t]=gotom[100-t][ms+1][ns+1][bs+10];
opy[99-t]=goton[100-t][ms+1][ns+1][bs+10];
bs=goton[100-t][ms+1][ns+1][bs+10];
    }
 
    for(s=1;s<101;s++){
    c[s]=c[s]+opc[s];
     y[s]=y[s]+opy[s];
    }
 
    int ep;
 
    ep=0;
    for(s=1;s<101;s++){
    ep=ep+opc[s]*opc[s];
     ep=ep+opy[s]*opy[s];
    }
 
   System.out.println(ep);
 
    if(ep<3)mode=1000;
 
   mode=mode+1;
 
    }
 
 
 
 
 
 
 
}
double ux(int s,int c1,int y1){
double c2,x2,u1;
int z;
c2=c1*h;
x2=1-(double)y1/th[s];
z=0;
if(c2<0)z=100;
if(x2<0)z=100;
if(x2>1)z=100;
u1=-999;
if(z<50)u1=Math.log(c2)+Math.log(x2);
return u1;
 
}
}
 
 
package linear;
 
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 linear;
 
 
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);
} 
 
 
 
 
}
}
 
最終更新:2013年09月24日 01:57