Commit e5b5eadb authored by Hu Jintao's avatar Hu Jintao

测试转发功能融合

parent fbbafe90
......@@ -66,7 +66,7 @@ public class BisheTestMain implements ApplicationRunner {
result = doMap.result;
flag = repetition(result);
}
System.out.println("optimal mapping scheme"+Arrays.toString(result));
DataPackage dataPackage = new DataPackage();
//路径表
......
......@@ -133,9 +133,9 @@ public class DoMap {
DoMap doMap = new DoMap();
Par best_par = doMap.main_bpso(k, c, dev, n1, n2, D, lt, nt, link, n, s, c1, c2, num, slot, mapdev);
if (best_par.fit != 0){
//System.out.println(1 / best_par.fit);
/* System.out.println(Arrays.toString(best_par.task));
System.out.println(Arrays.toString(best_par.taskfinal));*/
System.out.println(1 / best_par.fit);
System.out.println(Arrays.toString(best_par.task));
System.out.println(Arrays.toString(best_par.taskfinal));
//赋值节点映射结果
int itemp = 0;
for (int a:best_par.taskfinal
......@@ -474,6 +474,7 @@ public class DoMap {
*/
// boolean flag = true;
// while (flag) {
// while (true) {
for (int i = 0; i < nn; i++) {
//更新速度
par.v[i] = s * par.v[i] + c1 * random.nextDouble() * (best_par.bestx[i] - par.x[i]) + c2 * random.nextDouble() * (par.bestx[i] - par.x[i]);
......@@ -485,21 +486,21 @@ public class DoMap {
}
}
//更新位置
int maxIndex=0;//假设第一个元素为最大值 那么下标设为0
for(int i =0;i<par.v.length-1;i++){
if(par.v[maxIndex]<par.v[i+1]){
maxIndex=i+1;
int maxIndex = 0;//假设第一个元素为最大值 那么下标设为0
for (int i = 0; i < par.v.length - 1; i++) {
if (par.v[maxIndex] < par.v[i + 1]) {
maxIndex = i + 1;
}
}
for (int i = (maxIndex/n2)*n2;i<(maxIndex/n2+1)*n2;i++){
if (i == maxIndex){
for (int i = (maxIndex / n2) * n2; i < (maxIndex / n2 + 1) * n2; i++) {
if (i == maxIndex) {
par.x[i] = 1;
}else{
} else {
par.x[i] = 0;
}
}
/* boolean flag2 = true;
/* boolean flag2 = true;
for (int i = 0; i < nn; i += n2) {
int sum = 0;
for (int j = 0; j < n2; j++) {
......@@ -513,7 +514,7 @@ public class DoMap {
if (!flag2) {
continue;
}*/
// flag = false;
// flag = false;
//extract 提取映射结果
par.task[0] = 0;
......@@ -522,12 +523,14 @@ public class DoMap {
for (int i = 0; i < n1 * n2; i += n2) {
for (int j = 0; j < n2; j++) {
if (par.x[i + j] == 1) {
par.task[index] = num*(j/mapdev) +(j%mapdev) + 1;
par.task[index] = num * (j / mapdev) + (j % mapdev) + 1;
index++;
break;
}
}
}
isRepitition(par.task);
// }
//排序
int temp;
for(int p = 0; p<(c-1); p++) {
......@@ -548,6 +551,14 @@ public class DoMap {
}
}
private void isRepitition(int[] task) {
for (int i = 1;i<task.length-1;i++){
for (int j = i+1;j<task.length-1;j++){
if (task[i]==task[j] && task[j]%30<29) task[j]+=1;
}
}
}
// }
/**
* 计算适应度值
......
......@@ -5,6 +5,4 @@ bishe:
cloud-url: 192.168.31.198:9091
# cloud-url: 192.168.31.198:9090
slot=20000
slot: 20000
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment