Commit 26898473 authored by Hu Jintao's avatar Hu Jintao

增加单位拓扑

parent 6a7798ab
package top.ninwoo.test.doMap;
import top.ninwoo.test.sateTopo.entity.SimData;
import top.ninwoo.test.sateTopo.entity.WeiXingData;
import top.ninwoo.test.sateTopo.service.impl.ToponetImpl;
import top.ninwoo.test.sateTopo.service.impl.WeixingImpl;
import java.io.File;
import java.util.*;
public class CycleTopoUnit {
public static void main(String[] args) { cycleTp(); }
public static HashMap<Integer, int[][]> cycleTp(){
//从文本中获取卫星的数据
WeixingImpl wx = new WeixingImpl();
ToponetImpl tp = new ToponetImpl();
SimData sd = new SimData();
//tp.delHistory();
File file = new File("topusim_1.txt");
//D:\LabratoryJavaPro\codingDownload\latestCoding\
List<WeiXingData> wxData = null;
{
try {
wxData = wx.iniTopo(file,sd.getZhouqi());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
//初始topo
int[][] toponet = tp.getTopology(wxData,sd);
//去掉ovs
int[][] topoNet = new int[30][30];
for (int i = 0;i<topoNet.length;i++){
for (int j = 0;j<topoNet.length;j++){
topoNet[i][j] = toponet[i][j];
}
}
HashMap<Integer, int[][]> TopoStore = new HashMap<>();
TopoStore.put(0,topoNet);
for (int i = 1;i<sd.getZhouqi()/sd.getJiange(); i++) {
int time = i * sd.getJiange();
List<WeiXingData> changetp = wx.changeTopo(wxData,time);
int[][] changeTopo = tp.getTopology(changetp,sd);
//去掉ovs
for (int k = 0;k<topoNet.length;k++){
for (int j = 0;j<topoNet.length;j++){
topoNet[k][j] = changeTopo[k][j];
}
}
for (int k = 0;k<topoNet.length;k++){
for (int j = k+1;j<topoNet.length;j++){
topoNet[k][j] = topoNet[j][k];
}
}
TopoStore.put(i,topoNet);
}
int count = 0;
int count2 = -1;
Iterator<Map.Entry<Integer, int[][]>> iterator = TopoStore.entrySet().iterator();
while(iterator.hasNext()){
int[][] value = iterator.next().getValue();
for (int i = 0;i<value.length;i++){
if (i>0){
boolean equals = Arrays.equals(value[i], topoNet[i]);
count += (equals?1:0);
}
for (int j = 0;j<topoNet.length;j++){
topoNet[i][j] = value[i][j];
}
}
for (int k = 0;k<topoNet.length;k++){
for (int j = k+1;j<topoNet.length;j++){
topoNet[k][j] = topoNet[j][k];
}
}
if (count != 30){
count2++;
}
System.out.println(Arrays.deepToString(topoNet));
System.out.println("=========================================");
System.out.println(count2);
}
return TopoStore;
}
}
......@@ -95,7 +95,7 @@ public class DoMap {
//slotnum = 3;
dev = num*slotnum;
n2 = dev - N_STABLE*slotnum;
//组装最短路矩阵
//1组装最短路矩阵
double[][] edgeWeight = WTEG();
//最短路由矩阵
/*System.out.println("DoMap直连边权重");
......@@ -103,14 +103,15 @@ public class DoMap {
InterSlotDijstraV2 dijs = new InterSlotDijstraV2(num, slot);
InterSlotDijstraV2.pathRecord pathRecord = dijs.dijstra(edgeWeight, testLatency);
//2最短路由矩阵
double[][] lt = pathRecord.pathWeight;
for(int i = 0;i<lt.length;i++){
for(int j = 0;j<lt.length;j++){
lt[i][j] *= D;
}
}
/*System.out.println("最短路由");
System.out.println(Arrays.deepToString(lt));*/
System.out.println("最短路由");
System.out.println(Arrays.deepToString(lt));
for (int i = 0;i<nt.length;i++) {
nt[i] = (D * 1000) / nt[i];
}
......@@ -139,7 +140,7 @@ public class DoMap {
for (int i = 0;i<route.length;i++){
route[i] = new Stack<Integer>();
}
//根据分配结果,回溯每一条路由
//3根据分配结果,回溯每一条路由
int[][] lastHop = pathRecord.lastHop;
for (int i = 0;i<link[0].length;i++){
int start = best_par.taskfinal[link[0][i]];
......@@ -194,6 +195,7 @@ public class DoMap {
}
}
//组装大矩阵
private static double[][] WTEG() {
//获取当前3时隙拓扑
......@@ -232,7 +234,7 @@ public class DoMap {
}
}
// System.out.println(Arrays.deepToString(slot1));
currentTp = cycleTp.get((slotKey)%300+1);
currentTp = cycleTp.get((slotKey++)%300+1);
double[][] slot2 = new double[num][num];
for(int i = 0;i<slot2.length;i++){
for(int j = 0;j<slot2.length;j++){
......@@ -246,7 +248,7 @@ public class DoMap {
}
}
}
currentTp = cycleTp.get((slotKey)%300+1);
currentTp = cycleTp.get((slotKey++)%300+1);
double[][] slot3 = new double[num][num];
for(int i = 0;i<slot3.length;i++){
for(int j = 0;j<slot3.length;j++){
......
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