package iron;
public class pro {
int sx,number;
int[] year=new int[500];
int[] month=new int[500];
int[] y1=new int[500];
int[] m1=new int[500];
double[] delta=new double[500];
double[] p=new double[500];
double[] y=new double[500];
int[] vv=new int[500];
int[] pp=new int[500];
String[] im=new String[500];
String[] ex=new String[500];
String[] name=new String[500];
double[][] q=new double[3][3];
double[][] v=new double[101][11];
int[][] gotok=new int[101][11];
int[] op=new int[101];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
int s;
int yy,mm;
yy=2007;
mm=12;
for(s=1;s<85;s++){
mm=mm+1;
if(mm>12)yy=yy+1;
if(mm>12)mm=1;
year[s]=yy;
month[s]=mm;
}
String db,tab;
db="bp";
tab="bp";
int b1;
String c1;
c1="b11";
select_p sub=new select_p();
sub.makedata(db,tab,c1);
number=sub.number;
ex=sub.v;
y1=sub.year;
m1=sub.month;
int h;
int t=0;
for(t=1;t<85;t++){
for(s=1;s<number+1;s++){
h=0;
if(year[t]==y1[s])h=h+1;
if(month[t]==m1[s])h=h+1;
if(h==2)p[t]=num(ex[s]);
}
}
db="iip";
tab="iip";
c1="2AA0000000";
select_y sub2=new select_y();
sub2.makedata(db,tab,c1);
number=sub2.number;
ex=sub2.v;
y1=sub2.year;
m1=sub2.month;
for(t=1;t<85;t++){
for(s=1;s<number+1;s++){
h=0;
if(year[t]==y1[s])h=h+1;
if(month[t]==m1[s])h=h+1;
if(h==2)y[t]=num(ex[s]);
}
}
double maxy,miny;
maxy=0;
miny=500;
for(s=1;s<85;s++){
if(y[s]>maxy)maxy=y[s];
if(y[s]<miny)miny=y[s];
}
pp[1]=1;
for(s=2;s<85;s++){
pp[s]=1;
if(p[s]<p[s-1])pp[s]=2;
}
for(s=1;s<85;s++){
vv[s]=(int)((10*(y[s]-miny))/(maxy-miny))+1;
if(vv[s]>10)vv[s]=10;
}
number=84;
q[1][1]=0.9;
q[1][2]=0.1;
q[2][1]=0.1;
q[2][2]=0.9;
for(s=1;s<11;s++){
v[1][s]=u(1,s);
}
int sx,sxs;
double v1,e1,maxv;
for(t=2;t<number+1;t++){
for(s=1;s<11;s++){
double u1=u(t,s);
maxv=-999;
sxs=0;
for(sx=1;sx<11;sx++){
v1=u1+v[t-1][sx];
e1=(s-sx)*(s-sx);
if(e1>1)v1=-999;
if(v1>maxv)sxs=sx;
if(v1>maxv)maxv=v1;
}
gotok[t][s]=sxs;
v[t][s]=maxv;
}
}
maxv=-999;
sx=0;
for(s=1;s<11;s++){
if(v[number][s]>maxv)sx=s;
if(v[number][s]>maxv)maxv=v[number][s];
}
op[number]=sx;
for(s=1;s<number;s++){
sx=op[number-s+1];
op[number-s]=gotok[number-s+1][sx];
}
for(s=1;s<number+1;s++){
System.out.println(op[s]+","+vv[s]);
}
}
double u(int t,int k1){
double p1,u1;
int h;
p1=0.5;
h=0;
if(pp[t]==1)h=h+1;
if(vv[t]>k1-1)h=h+1;
if(h==2)p1=q[1][1];
h=0;
if(pp[t]==2)h=h+1;
if(vv[t]>k1-1)h=h+1;
if(h==2)p1=q[1][2];
h=0;
if(pp[t]==1)h=h+1;
if(vv[t]<k1)h=h+1;
if(h==2)p1=q[2][1];
h=0;
if(pp[t]==2)h=h+1;
if(vv[t]<k1)h=h+1;
if(h==2)p1=q[2][2];
u1=Math.log(p1);
return u1;
}
int numx(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
double num(String str){
double nx;
nx=0;
try{
nx=Double.parseDouble(str);
}catch (Exception e) {}
return nx;
}
}
最終更新:2015年07月30日 21:55