アットウィキロゴ

p082101

package iron;
 
public class pro {
 
       int s;
  double[] p=new double[101];
double[] y=new double[101];
    double[] pi=new double[101];
    double maxy,miny;
    double h;
    int[] k=new int[101];
    double[] ys=new double[101];
     double[][] x=new double[1000][10];
     double[] sol=new double[100];
     double[][] v=new double[1000][161];
    int[][] gotok=new int[1000][151];
 
    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];
 
 
int[] vv=new int[500];
int[] pp=new int[500];
 
 
 
 
 
int[] op=new int[161];
 
public static void main(String[] args) {
        pro t=new pro();
    }
    pro(){
 
 
        int s;
 
        catchdata sub=new catchdata();
        sub.makedata();
        y=sub.y;
        p=sub.p;
        year=sub.year;
        month=sub.month;
 
 
 
 
 
      pi[1]=0;
      for(s=2;s<85;s++){
      pi[s]=p[s]-p[s-1];
      }
 
 
     maxy=0;
      miny=999;
 
      for(s=1;s<85;s++){
      if(y[s]>maxy)maxy=y[s];    
      if(y[s]<miny)miny=y[s];
      }  
 
      System.out.println(miny+","+maxy);
 
 
 
 
 
      for(s=1;s<85;s++){
      k[s]=100;
      }
 
      int tr;
 
      for(tr=1;tr<11;tr++){
 
 
 
      for(s=1;s<85;s++){
      x[s][1]=1;
      x[s][2]=y[s]-90-0.1*k[s];
      }
 
      ols sub3=new ols();
      sub3.datanumber=84;
      sub3.number=2;
      sub3.x=x;
      sub3.y=pi;
      sub3.makedata();
      sol=sub3.sol;
 
      System.out.println(sol[1]+","+sol[2]);
 
 
 for(s=1;s<150;s++){
 double p1=sol[1]+sol[2]*(y[1]-90-0.1*s);
 v[1][s]=(p1-pi[1])*(p1-pi[1]);
   }
 
   int t,sx,sxs;
  double u1,v1,minv;
 
 for(t=2;t<85;t++){
 for(s=1;s<150;s++){  
 double p1=sol[1]+sol[2]*(y[t]-90-0.1*s);
u1=(p1-pi[t])*(p1-pi[t]);
minv=9999;    
sxs=0;
for(sx=1;sx<150;sx++){   
    v1=u1+v[t-1][sx];
    double e=(s-sx)*(s-sx);
    if(e>50)v1=9999;
    if(v1<minv)sxs=sx;
    if(v1<minv)minv=v1;
    }
v[t][s]=minv;
   gotok[t][s]=sxs;
}
}   
 
 
 
     minv=9999;
        sx=0;
         for(s=1;s<150;s++){
         if(v[84][s]<minv)sx=s;
         if(v[84][s]<minv)minv=v[84][s];
         }
 
        op[84]=sx;
         for(s=1;s<84;s++){
         sx=op[84-s+1];
         op[84-s]=gotok[84-s+1][sx];
         }
 
 
          for(s=1;s<85;s++){
          k[s]=op[s];
          }
 
 
 
    }      
 
 
 
         for(s=1;s<85;s++){
         System.out.println(year[s]+"年"+month[s]+"月,"+(90+0.1*k[s])+","+y[s]);
          }
 
 
 
 
 
 
 
 
 
 
    }
 
 
     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;
 
 
 
}
 
 
 
}
 
 
 
package iron;
 
 
public class ols {
 
    int s,s1,s2;
    int datanumber,number;
    double x1;
    double[][] a=new double[100][100];
     double[] b=new double[100];
     double[] y=new double[1000];
    double[][] x=new double[1000][10];
     double[] sol=new double[100];
 
    void makedata(){
 
 
 
     for(s1=1;s1<number+1;s1++){
    for(s2=1;s2<number+1;s2++){   
     x1=0;   
    for(s=1;s<datanumber+1;s++){
    x1=x1+x[s][s1]*x[s][s2];
    }
    a[s1][s2]=x1;
    }
    }
 
 
 
    for(s1=1;s1<number+1;s1++){
    x1=0;   
    for(s=1;s<datanumber+1;s++){
    x1=x1+x[s][s1]*y[s];
    }
    b[s1]=x1;
    }
 
    double z;
 
   for(s1=1;s1<number+1;s1++){
   for(s2=1;s2<number+1;s2++){   
   z=a[s2][s1]/a[s1][s1];  
   if(s1==s2)z=0;
   for(s=1;s<number+1;s++){
   a[s2][s]=a[s2][s]-z*a[s1][s];
   } 
   b[s2]=b[s2]-z*b[s1];
   }
   }
 
   for(s1=1;s1<number+1;s1++){
   sol[s1]=b[s1]/a[s1][s1];
   }
 
 
 
 
 
    }
}
 
 
package iron;
 
 
public class catchdata{
 
 
    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];
 
    void makedata(){
 
 
        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="b7";
 
 
        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="2AJ0000000";
 
      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 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;
 
 
 
}
 
 
 
}
 
 
 
 
package iron;
 
import java.sql.*; 
 
class select_p{ 
 
Connection dbx;   
Statement stx;   
String sqx; 
ResultSet  rsx; 
 
int key; 
String word;
int sx,number;
int[] year=new int[500];
String[] v=new String[500];
int[] month=new int[500];
 
void makedata(String db,String tab,String b1){ 
 
String url = "jdbc:h2:"+db+";create=true";   
String usr = "";   
String pwd = ""; 
 
 
 try
          {
            Class.forName("org.h2.Driver");
 
dbx = DriverManager.getConnection(url, usr, pwd); 
} catch (Exception ex) { ex.printStackTrace();} 
 
sx=0;
try {   
stx = dbx.createStatement(); 
sqx="select * from "+tab+" WHERE bus like "+change(b1);   
rsx = stx.executeQuery(sqx); 
if (rsx != null) { 
while (rsx.next()) { 
sx=sx+1;
v[sx]= rsx.getString("value");
year[sx]=rsx.getInt("year");
month[sx]=rsx.getInt("month");
} 
} 
 
number=sx;
 
 
rsx.close(); 
stx.close(); 
dbx.close(); 
 
} catch (Exception ex) {ex.printStackTrace();} 
 
 
 
 
} 
 
String change(String word){
String e;
e="'"+word+"'";
return e;    
}    
 
 
 
}
 
package iron;
 
 
import java.sql.*; 
 
class select_y{ 
 
Connection dbx;   
Statement stx;   
String sqx; 
ResultSet  rsx; 
 
int key; 
String word;
int sx,number;
int[] year=new int[50000];
int[] month=new int[50000];
String[] v=new String[50000];
 
void makedata(String db,String tab,String b1){ 
 
String url = "jdbc:h2:"+db+";create=true";   
String usr = "";   
String pwd = ""; 
 
 
 try
          {
            Class.forName("org.h2.Driver");
 
dbx = DriverManager.getConnection(url, usr, pwd); 
} catch (Exception ex) { ex.printStackTrace();} 
 
sx=0;
try {   
stx = dbx.createStatement(); 
sqx="select * from "+tab+" where bus like "+change(b1);   
rsx = stx.executeQuery(sqx); 
if (rsx != null) { 
while (rsx.next()) { 
sx=sx+1;
v[sx]= rsx.getString("value");
year[sx]=rsx.getInt("year");
month[sx]=rsx.getInt("month");
} 
} 
 
number=sx;
 
 
rsx.close(); 
stx.close(); 
dbx.close(); 
 
} catch (Exception ex) {ex.printStackTrace();} 
 
 
 
 
} 
 
String change(String word){
String e;
e="'"+word+"'";
return e;    
}    
 
 
 
}
 
最終更新:2015年08月21日 12:46