アットウィキロゴ

問題あり

class pro{

int mlong,nlong,nx;
double[][] a=new double[61][101];
double[] b=new double[61];
double[] x=new double[41];
double h,c1,y1,c2,y2;
int t,mx;
double[] c=new double[11];
double[] y=new double[11];
double[] th=new double[11];
double[] u=new double[11];
double[] w=new double[11];
int s,ch;

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

pro(){

mlong=60;
nlong=100;

h=0.01;
for(s=1;s<11;s++){
th[s]=s;
y[s]=0.5*th[s];
c[s]=y[s];
}

t=0;
while(t<100){

for(s=1;s<11;s++){
u[s]=Math.log(c[s])+Math.log(1-y[s]/th[s]);
}

for(s=1;s<10;s++){
w[s]=Math.log(c[s])+Math.log(1-y[s]/th[s+1]);
}


for(mx=0;mx<mlong+1;mx++){
for(nx=1;nx<nlong+1;nx++){
a[mx][nx]=0;
}
b[mx]=0;
}

for(s=1;s<11;s++){
a[0][4*s-3]=1/c[s];
a[0][4*s-2]=-1/c[s];
a[0][4*s-1]=-1/(th[s]-y[s]);
a[0][4*s]=1/(th[s]-y[s]);
}


for(s=1;s<11;s++){
a[60][4*s-3]=1;
a[60][4*s-2]=-1;
a[60][4*s-1]=-1;
a[60][4*s]=1;
}

for(s=1;s<11;s++){
a[6*s-5][4*s-3]=1;
a[6*s-4][4*s-2]=1;
a[6*s-3][4*s-1]=1;
a[6*s-2][4*s]=1;
a[6*s-1][4*s]=1;
}

for(s=1;s<10;s++){
a[6*s][4*s-3]=1/c[s];
a[6*s][4*s-2]=-1/c[s];
a[6*s][4*s-1]=-1/(th[s+1]-y[s]);
a[6*s][4*s]=1/(th[s+1]-y[s]);
a[6*s][4*s+1]=-1/c[s+1];
a[6*s][4*s+2]=1/c[s+1];
a[6*s][4*s+3]=1/(th[s+1]-y[s+1]);
a[6*s][4*s+4]=-1/(th[s+1]-y[s+1]);
}

for(s=1;s<61;s++){
a[s][40+s]=1;
}

for(s=1;s<10;s++){
b[6*s-5]=h;
b[6*s-4]=h;
b[6*s-3]=h;
b[6*s-2]=h;
b[6*s-1]=y[s];
b[6*s]=u[s+1]-w[s];
}

s=10;
b[6*s-5]=h;
b[6*s-4]=h;
b[6*s-3]=h;
b[6*s-2]=h;
b[6*s-1]=y[s];
b[60]=0;

lp sub=new lp();
sub.mlong=mlong;
sub.nlong=nlong;
sub.a=a;
sub.b=b;
sub.makedata();
x=sub.x;

System.out.println(t);

ch=check();

System.out.println(ch);

for(s=1;s<11;s++){
if(ch<50)c[s]=c[s]+x[4*s-3]-x[4*s-2];
if(ch<50)y[s]=y[s]+x[4*s-1]-x[4*s];
}

if(ch>50)h=0.9*h;
t=t+1;
}

for(s=1;s<11;s++){
System.out.print(c[s]);
System.out.print(",");
System.out.println(y[s]);
}


}
int check(){
int ch;
double[] cs=new double[11];
double[] ys=new double[11];

for(s=1;s<11;s++){
cs[s]=c[s]+x[4*s-3]-x[4*s-2];
ys[s]=y[s]+x[4*s-1]-x[4*s];
}
for(s=1;s<11;s++){
u[s]=Math.log(cs[s])+Math.log(1-ys[s]/th[s]);
}
for(s=1;s<10;s++){
w[s]=Math.log(cs[s])+Math.log(1-ys[s]/th[s+1]);
}
ch=0;
for(s=1;s<10;s++){
if(u[s+1]<w[s])ch=100;
}
return ch;
}

}
最終更新:2011年08月25日 11:39