?? init.java
字號:
package cn.edu.bit.util.arithmetic.wangli;
public class Init {
static double[] saturq={1000,2010,2100,2400,3000,2650,5000,5500,4000,4100};
static int[] row = {4,2,2,2,3,1,2,3};//零件對應的路徑數量
static double[] q={20,15,8,18,20,25,30,30};//加工的零件
static int[][] tour={//每條路徑的機械時間,行工藝路徑,列對應機床
{10,20,30, 0, 0,40,0,0,0,0},
{ 0,20, 0, 0, 0, 0,0,0,50,0},
{15,0,20,0,0,0,0,35,0,0,0},
{0,0,0,0,20,0,0,40,0,0},
{0,0,0,35,0,0,0,0,0,60},
{0,10,20,0,0,20,0,0,50,0},
{20,0,30,60,0,0,0,0,0,0},
{0,40,0,0,0,70,0,0,0,0},
{0,0,15,0,0,25,0,40,0,60},
{0,0,0,0,0,0,60,0,0,80},
{0,0,0,25,0,35,0,0,0,55},
{0,40,0,0,0,65,0,0,0,0},
{0,0,0,0,20,35,0,45,0,0},
{0,0,0,20,0,0,40,40,0,0},
{15,0,0,15,30,0,0,0,40,60},
{0,0,0,0,0,0,60,110,0,0},
{0,35,35,0,40,0,0,0,70,0},
{20,0,0,0,40,0,0,0,70,0},
{0,0,0,30,0,0,30,60,0,0}
};
// static int[] cost={
// 38,34,34,32,18,25,25,22,30,37,30,32,35,27,44,33,35,39,38
// };
static int[] cost={
78+5,94+5,74+5,112+5,98+4,145+4,65+6,62+6,150+4,117+4,110+3,72+3,115+3,107+4,164+2,113+2,155+4,159+4,118+4
};
static int col = 10;//數組的列,對應機床
static double[] random={
Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),
Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),
Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),
Math.random(),Math.random(),Math.random(),Math.random()
};
static double sumtime = 0;
//
// static void init() {
// t0 = initt0;
// saturq = initsaturq;
// //tour1to12 = getTourInfo(inittour1to12, row, col, q1to12);
// //tour12to1 = getTourInfo(inittour12to1, row, col, q12to1);
// //tour9to4 = getTourInfo(inittour9to4, row, col, q9to4);
// //tour4to9 = getTourInfo(inittour4to9, row, col, q4to9);
//
// double[] temp12to1 = Init.unitary(random, Init.q12to1);
// double[] temp1to12 = Init.unitary(random, Init.q1to12);
// double[] temp4to9 = Init.unitary(random, Init.q4to9);
// double[] temp9to4 = Init.unitary(random, Init.q9to4);
// itojquantity = getQuantityInfo(temp12to1, temp1to12, temp4to9, temp9to4);//所有路段a的時間交通量
// itojtime = getTimeInfo(itojquantity, saturq, t0);//所有路段a的時間
// sumtime = getSumtime(itojquantity, itojtime);
// }
//
// public static double getSumtime(double[][] itojquantity, double[][] itojtime) {
// double sumtime = 0;
// for (int i = 0; i < pointnum; i++) {
// for (int j = 0; j < pointnum; j++) {
// if (itojtime[i][j] != 0) {
// /*if(initsaturq[i][j]<itojquantity[i][j]) {
// sumtime = sumtime + 100*itojtime[i][j] * itojquantity[i][j];
// }
// else {*/
// sumtime = sumtime + itojtime[i][j] * itojquantity[i][j];
// //}
// }
// }
// }
// return sumtime;
// }
//
// public static double getNetTime(double[][] itojtime) {
// double nettime = 0;
// for (int i = 0; i < pointnum; i++) {
// for (int j = 0; j < pointnum; j++) {
// if (itojtime[i][j] != 0) {
// nettime = nettime + itojtime[i][j];
// }
// }
// }
// return nettime;
// }
//
// public static double[][] getTimeInfo(double[][] itojquantity,
// double[][] saturq, double[][] t0) {//所有路段a的時間
// double[][] result = new double[pointnum][pointnum];
// double a = 0.5;
// int b = 4;
// for (int i = 0; i < pointnum; i++) {
// for (int j = 0; j < pointnum; j++) {
// if (saturq[i][j] != 0) {
// result[i][j] = t0[i][j]
// * (1 + a
// * Math.pow(itojquantity[i][j]
// / saturq[i][j], b));
// }
// }
// }
// return result;
// }
//
// public static double[] getLineTime(double[][] itojtime, int[][] inittour) {
// double[] linetime = new double[row];
// for (int i = 0; i < row; i++) {
// double temp = 0.0;
// for (int j = 0; j < col - 1; j++) {
// int first = inittour[i][j];
// int second = inittour[i][j + 1];
// temp = temp + itojtime[first][second];
// }
// linetime[i] = temp;
// }
// return linetime;
// }
//
// public static double[][] getQuantityInfo(double[] tour12to1,double[] tour1to12, double[] tour4to9,
// double[] tour9to4) {//所有路段a的時間交通量
// double[][] result = new double[pointnum][pointnum];
// /**要求result<容量*/
// for (int i = 0; i < row; i++) {
// for (int j = 0; j < col - 1; j++) {
// int first = inittour1to12[i][j];
// int second = inittour1to12[i][j + 1];
// result[first][second] = result[first][second] + tour1to12[i];
// first = inittour12to1[i][j];
// second = inittour12to1[i][j + 1];
// result[first][second] = result[first][second] + tour12to1[i];
// first = inittour9to4[i][j];
// second = inittour9to4[i][j + 1];
// result[first][second] = result[first][second] + tour9to4[i];
// first = inittour4to9[i][j];
// second = inittour4to9[i][j + 1];
// result[first][second] = result[first][second] + tour4to9[i];
// }
// }
// return result;
// }
//
// /*static double[][] getTourInfo(int[][] temp, int row, int col,
// double quantity) {
// double[][] result = new double[row][col + 2];
// for (int i = 0; i < row; i++) {
// double tmp = 0.0;
// if (i != row - 1)
// tmp = quantity * Math.random();
// else
// tmp = quantity;
// double sum = 0.0;
// for (int j = 0; j < col - 1; j++) {
// int first = temp[i][j];
// int second = temp[i][j + 1];
// result[i][j] = first;
// double length = t0[first][second];
// sum += length;
// }
// result[i][col - 1] = temp[i][col - 1];
// result[i][col] = sum;
// result[i][col + 1] = tmp;
// quantity = quantity - tmp;
// }
// return result;
// }*/
public static double[] unitary(double[] result) {//歸一化
double sum = 0.0;
int k=0;
int t=0;
for(int j=0;j<Init.row.length;j++)
{
t=k;
for(int i=0;i<Init.row[j];i++){
sum =sum+ result[k];
k++;
}
for(int i=0;i<Init.row[j];i++){
result[t] = result[t]*Init.q[j] / sum;
t++;
}
sum=0;
}
return result;
}
// public static void getResult(double[][] itojquantity) {
// double sumquantity = 0;
// int sum=0;
// for (int i = 0; i < pointnum; i++) {
// for (int j = 0; j < pointnum; j++) {
// if (itojquantity[i][j] != 0) {
// sum++;
// sumquantity+=itojquantity[i][j];
// }
// }
// }
// double aver=sumquantity/sum;
// double stdev=0.0;
// for (int i = 0; i < pointnum; i++) {
// for (int j = 0; j < pointnum; j++) {
// if (itojquantity[i][j] != 0) {
// stdev+=Math.pow((aver-itojquantity[i][j]), 2);
// }
// }
// }
// stdev=Math.sqrt(stdev/(sum-1));
// LogWriter.log("aver="+ aver);
// LogWriter.log("stdev="+ stdev);
// }
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -