package miti4;
import tool.*;
public class pro {
String file;
int s,datanumber;
String[] data=new String[10000];
String str;
int ou,ip;
String[] credit=new String[100];
String[] index=new String[100];
double[][] x=new double[100][100];
double[] y=new double[100];
int number;
double[] ex=new double[100];
double[] im=new double[100];
double x1;
double[] c=new double[54];
double[][] rate=new double[54][54];
double[] alpha=new double[54];
double[] ys=new double[54];
double[] ims=new double[54];
double[] cs=new double[54];
public static void main(String[] args) {
pro test=new pro();
}
pro(){
number=53;
file="miti2.csv";
readfile sub=new readfile();
sub.makedata(file,"UTF-8");
datanumber=sub.datanumber;
data=sub.data;
for(s=1;s<datanumber+1;s++){
str=data[s];
String[] x1=str.split(",");
ip=Integer.parseInt(x1[0]);
ou=Integer.parseInt(x1[2]);
index[ip]=x1[1];
credit[ou]=x1[3];
x[ou][ip]=Double.parseDouble(x1[4]);
}
for(s=1;s<number+1;s++){
y[s]=x[73][s];
ex[s]=x[63][s];
im[s]=-x[68][s];
}
pre();
ys=y;
cs=c;
ims=im;
cs[49]=cs[49]+100;
sol();
double y1;
for(s=1;s<number+1;s++){
y1=ys[s]-y[s];
System.out.println(s+","+credit[s]+","+y1);
}
}
void sol(){
int t;
double e1;
t=0;
while(t<50){
e1=cal();
if(e1<0.0001)t=100;
t=t+1;
}
}
void pre(){
double x2;
for(ip=1;ip<number+1;ip++){
x2=0;
for(ou=1;ou<number+1;ou++){
x2=x2+x[ou][ip];
}
c[ip]=y[ip]+im[ip]-ex[ip]-x2;
}
for(ou=1;ou<number+1;ou++){
for(ip=1;ip<number+1;ip++){
rate[ou][ip]=x[ou][ip]/y[ou];
}
}
for(ip=1;ip<number+1;ip++){
x2=0;
for(ou=1;ou<number+1;ou++){
x2=x2+x[ou][ip];
}
alpha[ip]=im[ip]/(c[ip]+x2);
}
}
double cal(){
double[] yp=new double[100];
double[] imp=new double[100];
int s;
double y1,x2;
for(ip=1;ip<number+1;ip++){
y1=ex[ip]-ims[ip]+cs[ip];
for(ou=1;ou<number+1;ou++){
y1=y1+rate[ou][ip]*ys[ou];
}
yp[ip]=y1;
}
for(ip=1;ip<number+1;ip++){
x2=cs[ip];
for(ou=1;ou<number+1;ou++){
x2=x2+rate[ou][ip]*ys[ou];
}
imp[ip]=alpha[ip]*x2;
}
double ep;
ep=0;
for(s=1;s<number+1;s++){
ep=ep+(ys[s]-yp[s])*(ys[s]-yp[s]);
}
ims=imp;
ys=yp;
return ep;
}
}
最終更新:2014年02月03日 03:11