public class tax{
public static void main(String[] args) {
int t,t2;
double startk,startc;
double w1,b1,x;
double[] tk=new double[101];
double[] tks=new double[101];
int[] ep=new int[101];
double maxwel;
maxwel=-999;
for (t=1;t<101;t++){
tks[t]=0.2;
}
t2=0;
while(t2<10000){
for (t=1;t<101;t++){
x=Math.random();
ep[t]=0;
if (x<0.33)ep[t]=-1;
if (x>0.66)ep[t]=1;
}
for (t=1;t<101;t++){
tk[t]=tks[t]+0.01*ep[t];
if (tk[t]>0.99)tk[t]=0.99;
if (tk[t]<0)tk[t]=0;
}
startk=10;
startc=start(tk,startk);
w1=wel(tk,startk,startc);
b1=bud(tk,startk,startc);
if(b1<0)w1=-999;
for (t=1;t<101;t++){
if(w1>maxwel)tks[t]=tk[t];
}
if(w1>maxwel)maxwel=w1;
t2=t2+1;
}
for (t=1;t<101;t++){
System.out.println(tks[t]);
}
}
static double bud(double[] tk,double startk,double startc){
double k1,c1,r1,b1;
double a,beta,gov,tax,value;
int t;
b1=0;
a=0.33;
gov=0.05;
beta=0.95;
k1=startk;
c1=startc;
t=1;
value=1;
while(t<100){
tax=tk[t]*a*Math.pow(k1,a);
b1=b1+value*(tax-gov);
k1=k1+Math.pow(k1,a)-c1-gov;
r1=(1-tk[t+1])*a*Math.pow(k1,a-1);
value=value/(1+r1);
c1=c1*(beta*(1+r1));
t=t+1;
}
return b1;
}
static double wel(double[] tk,double startk,double startc){
double k1,c1,w1,r1;
double a,beta,gov;
int t;
w1=0;
a=0.33;
gov=0.05;
beta=0.95;
k1=startk;
c1=startc;
t=1;
while(t<100){
w1=w1+Math.pow(beta,t-1)*Math.log(c1);
k1=k1+Math.pow(k1,a)-c1-gov;
r1=(1-tk[t+1])*a*Math.pow(k1,a-1);
c1=c1*(beta*(1+r1));
t=t+1;
}
return w1;
}
static double start(double[] tk,double startk){
double c1,c2,startc;
double ch;
int s;
c1=0.1;
c2=10;
s=0;
while(s<30){
startc=(c1+c2)/2;
ch=check(tk,startk,startc);
if (ch<50)c1=startc;
if (ch>50)c2=startc;
s=s+1;
}
return c1;
}
static double check(double[] tk,double startk,double startc){
double a,gov,beta;
double c1,k1,r1;
int t,t1;
double ch;
gov=0.05;
a=0.33;
beta=0.95;
k1=startk;
c1=startc;
t=1;
ch=0;
while(t<200){
k1=k1+Math.pow(k1,a)-c1-gov;
if (k1<0)ch=100;
if (ch>50)t=300;
t1=t+1;
if (t1>100)t1=100;
r1=(1-tk[t1])*a*Math.pow(k1,a-1);
c1=c1*(beta*(1+r1));
t=t+1;
}
return ch;
}
}
最終更新:2010年01月23日 23:58