アットウィキロゴ

最適非線形所得税k

package non;
 
import ce00582.json.json;
 
public class pro {
 
    int s,e; 
int th[]= new int[101]; 
int c[]= new int[101]; 
int y[]= new int[101]; 
 double h;
 
 int creditnumber,datanumber;
    String[] type=new String[20];
    String[] credit=new String[20];
   String[][] data=new String[50000][20]; 
 
    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;
 
time=0;
 
while(time<100){
 
nonlinear sub2=new nonlinear();
sub2.th=th;
sub2.h=h;
sub2.c=c;
sub2.y=y;
sub2.makedata();
c=sub2.c;
y=sub2.y;
e=sub2.e;
 
 
System.out.println(e);
 
 
if(e<3)time=1000;
 
time=time+1;
 
}
 
 
 
 
 
 datanumber=100;
 
    creditnumber=3;
    credit[1]="c";
       credit[2]="y";
          credit[3]="th";
 
           type[2]="number";
           type[1]="number";
     type[3]="number";
 
     double c1;
 
     for(s=1;s<datanumber+1;s++){
     c1=c[s]*h;
         data[s][1]=""+c1;
     c1=y[s]*h;
         data[s][2]=""+c1;
         c1=th[s]*h;
     data[s][3]=""+c1;
 
     }
 
 
    json subj=new json();
    subj.type=type;
    subj.credit=credit;
    subj.data=data;
    subj.datanumber=datanumber;
    subj.creditnumber=creditnumber;
    subj.makedata("non.json");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
}
 
 
 
}
 
 
 
 
 
package non;
 
 
 
class nonlinear{ 
 
int s,t,j,n1,n2,q,qx1,nx1,nx2,nsc,nsy,e; 
int[] th= new int[101]; 
int[] c= new int[101]; 
int[] y= new int[101]; 
double[][][] ux= new double[101][11][11]; 
double[][][] wx= new double[101][11][11]; 
double[][][][] v= new double[100][11][11][51]; 
int[][][][] gotoc= new int[100][11][11][51]; 
int[][][][] gotoy= new int[100][11][11][51]; 
int[][][][] gotoq= new int[100][11][11][51]; 
double[][] endv=new double[11][11]; 
int[][] endc=new int[11][11]; 
int[][] endy=new int[11][11]; 
int[][] endq=new int[11][11]; 
int[] opc= new int[101]; 
int[] opy= new int[101]; 
int[] opq= new int[101]; 
double tl,tr,w1,u1,c1,l1,vs,v1; 
double h,dc,dy; 
double yp1,yp2; 
int z,qx; 
double maxv;
 
void makedata(){ 
 
 
for (s=1;s<101;s++){ 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
c1=(c[s]+n1)*h; 
l1=(double)(y[s]+n2)/th[s]; 
u1=u(c1,1-l1);   
ux[s][n1+5][n2+5]=u1; 
} 
} 
} 
 
 
for (s=1;s<100;s++){ 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
c1=(c[s]+n1)*h; 
l1=(double)(y[s]+n2)/th[s+1]; 
u1=u(c1,1-l1);   
wx[s][n1+5][n2+5]=u1; 
} 
} 
} 
 
 
 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
for (q=-25;q<26;q++){ 
v[1][n1+5][n2+5][q+25]=-999; 
} 
} 
}  
 
 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
q=n2-n1; 
v[1][n1+5][n2+5][q+25]=ux[1][n1+5][n2+5]; 
} 
} 
 
 
 
 
 
for (s=2;s<100;s++){ 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
for (q=-25;q<26;q++){ 
u1=ux[s][n1+5][n2+5]; 
qx=q+n1-n2; 
z=0; 
if (qx>25)z=100;   
if (qx<-25)z=100;   
if (z>50)qx=0;   
maxv=-999; 
nsc=0; 
nsy=0;  
for (nx1=-5;nx1<6;nx1++){ 
for (nx2=-5;nx2<6;nx2++){  
v1=u1+v[s-1][nx1+5][nx2+5][qx+25];    
w1=wx[s-1][nx1+5][nx2+5];
if(w1>u1)v1=-999;
if(v1>maxv)nsc=nx1;
if(v1>maxv)nsy=nx2;
if(v1>maxv)maxv=v1;
} 
} 
if(z>50)maxv=-999;
gotoc[s][n1+5][n2+5][q+25]=nsc; 
gotoy[s][n1+5][n2+5][q+25]=nsy; 
gotoq[s][n1+5][n2+5][q+25]=qx; 
v[s][n1+5][n2+5][q+25]=maxv; 
}
}
}
}
 
 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
u1=ux[100][n1+5][n2+5]; 
qx=n1-n2; 
maxv=-999; 
nsc=0; 
nsy=0; 
for (nx1=-5;nx1<6;nx1++){ 
for (nx2=-5;nx2<6;nx2++){ 
v1=u1+v[99][nx1+5][nx2+5][qx+25]; 
if(wx[99][nx1+5][nx2+5]>u1)v1=-999;
if(v1>maxv)nsc=nx1;
if(v1>maxv)nsy=nx2;
if(v1>maxv)maxv=v1;
} 
} 
endc[n1+5][n2+5]=nsc; 
endy[n1+5][n2+5]=nsy; 
endq[n1+5][n2+5]=qx; 
endv[n1+5][n2+5]=maxv; 
} 
} 
 
nsc=0; 
nsy=0; 
maxv=-999;
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
 if (endv[n1+5][n2+5]>maxv)nsc=n1;
 if (endv[n1+5][n2+5]>maxv)nsy=n2;
if (endv[n1+5][n2+5]>maxv)maxv=endv[n1+5][n2+5];
} 
} 
 
 
 
 
 
int j;
 
System.out.println(maxv);
 
opc[100]=nsc; 
opy[100]=nsy; 
opc[99]=endc[opc[100]+5][opy[100]+5]; 
opy[99]=endy[opc[100]+5][opy[100]+5]; 
opq[99]=endq[opc[100]+5][opy[100]+5]; 
 
for (j=1;j<99;j++){ 
s=99-j; 
opc[s]=gotoc[s+1][opc[s+1]+5][opy[s+1]+5][opq[s+1]+25]; 
opy[s]=gotoy[s+1][opc[s+1]+5][opy[s+1]+5][opq[s+1]+25]; 
opq[s]=gotoq[s+1][opc[s+1]+5][opy[s+1]+5][opq[s+1]+25]; 
} 
 
 
e=0; 
for (s=1;s<101;s++){ 
e=e+opc[s]*opc[s]+opy[s]*opy[s]; 
} 
 
 
 
for (s=1;s<101;s++){ 
c[s]=c[s]+opc[s]; 
y[s]=y[s]+opy[s]; 
} 
 
 
 
 
 
 
 
} 
 
 
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 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; 
} 
 
}
 
最終更新:2013年12月31日 11:21