Commit d97aae8f authored by Hu Jintao's avatar Hu Jintao

显示拓扑变化

parent 83edb31a
......@@ -17,72 +17,86 @@ public class CycleTopo {
ToponetImpl tp = new ToponetImpl();
SimData sd = new SimData();
//tp.delHistory();
File file = new File("topusim_1.txt");
//D:\LabratoryJavaPro\codingDownload\latestCoding\
File file = new File("D:\\LabratoryJavaPro\\codingDownload\\latestCoding\\topusim_1.txt");
List<WeiXingData> wxData = null;
{
try {
wxData = wx.iniTopo(file,sd.getZhouqi());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
//初始topo
double[][] toponet = tp.getWeightedTopology(wxData,sd);
//去掉ovs
double[][] topoNet = new double[30][30];
for (int i = 0;i<topoNet.length;i++){
for (int j = 0;j<topoNet.length;j++){
topoNet[i][j] = toponet[i][j];
}
}
sd.setJiange(20);
sd.setC0(3e10);
//存储全周期拓扑
HashMap<Integer, double[][]> TopoStore = new HashMap<>();
TopoStore.put(0,topoNet);
for (int i = 1;i<sd.getZhouqi()/sd.getJiange(); i++) {
out:for (int i = 0; i<sd.getZhouqi()/sd.getJiange(); i++) {
//Thread.sleep(2000);
int time = i * sd.getJiange();
List<WeiXingData> changetp = wx.changeTopo(wxData,time);
double[][] changeTopo = tp.getWeightedTopology(changetp,sd);
double[][] topoChange = tp.getWeightedTopology(changetp,sd);
/*//输出topo
for(int m = 0;m<topoChange.length;m++){
for(int n= 0;n<topoChange[0].length;n++){
System.out.print(topoChange[m][n] + " ");
}
System.out.println(" ");
}*/
//去掉ovs
for (int k = 0;k<topoNet.length;k++){
//去掉ovs
double[][] topoNet = new double[30][30];
for (int p = 0;p<topoNet.length;p++){
for (int j = 0;j<topoNet.length;j++){
topoNet[k][j] = changeTopo[k][j];
topoNet[p][j] = topoChange[p][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);
}
/*
* 对比全周期拓扑
* count记录重复拓扑行数
* count2记录不同拓扑数目
* */
int count = 0;
int count2 = -1;
int count2 = 0;
Iterator<Map.Entry<Integer, double[][]>> iterator = TopoStore.entrySet().iterator();
while(iterator.hasNext()){
while (iterator.hasNext()){
double[][] value = iterator.next().getValue();
System.out.println(Arrays.deepToString(value));
System.out.println("=========================================");
System.out.println(count2);
while (iterator.hasNext()){
double[][] valueNext = iterator.next().getValue();
for (int i = 0;i<value.length;i++){
if (i>0){
boolean equals = Arrays.equals(value[i], topoNet[i]);
boolean equals = Arrays.equals(value[i], valueNext[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){
System.out.println(Arrays.deepToString(valueNext));
System.out.println("=========================================");
System.out.println(count2);
count2++;
}
/* System.out.println(Arrays.deepToString(topoNet));
System.out.println("=========================================");
System.out.println(count2);*/
count=0;
value=valueNext;
}
}
System.out.println("所有topo完成");
return TopoStore;
}
......
package top.ninwoo.test.doMap;
import top.ninwoo.test.sateTopo.entity.SimData;
/*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;
......@@ -16,8 +16,10 @@ public class CycleTopoUnit {
WeixingImpl wx = new WeixingImpl();
ToponetImpl tp = new ToponetImpl();
SimData sd = new SimData();
sd.setJiange(60);
sd.setC0(3e10);
//tp.delHistory();
File file = new File("topusim_1.txt");
File file = new File("D:\\LabratoryJavaPro\\codingDownload\\latestCoding\\topusim_1.txt");
//D:\LabratoryJavaPro\codingDownload\latestCoding\
List<WeiXingData> wxData = null;
{
......@@ -36,6 +38,7 @@ public class CycleTopoUnit {
topoNet[i][j] = toponet[i][j];
}
}
//存储全周期拓扑
HashMap<Integer, int[][]> TopoStore = new HashMap<>();
TopoStore.put(0,topoNet);
......@@ -56,12 +59,36 @@ public class CycleTopoUnit {
}
TopoStore.put(i,topoNet);
}
*//*
* 对比全周期拓扑
* count记录重复拓扑行数
* count2记录不同拓扑数目
* *//*
int count = 0;
int count2 = -1;
Iterator<Map.Entry<Integer, int[][]>> iterator = TopoStore.entrySet().iterator();
while(iterator.hasNext()){
while (iterator.hasNext()){
int[][] value = iterator.next().getValue();
System.out.println(Arrays.deepToString(value));
System.out.println("=========================================");
while (iterator.hasNext()){
int[][] valueNext = iterator.next().getValue();
for (int i = 0;i<value.length;i++){
boolean equals = Arrays.equals(value[i], valueNext[i]);
count += (equals?1:0);
}
if (count != 30){
System.out.println(Arrays.deepToString(valueNext));
System.out.println("=========================================");
count2++;
}
count=0;
value=valueNext;
}
System.out.println(count2);
}
*//*for (int i = 0;i<value.length;i++){
if (i>0){
boolean equals = Arrays.equals(value[i], topoNet[i]);
count += (equals?1:0);
......@@ -69,8 +96,8 @@ public class CycleTopoUnit {
for (int j = 0;j<topoNet.length;j++){
topoNet[i][j] = value[i][j];
}
}
for (int k = 0;k<topoNet.length;k++){
}*//*
*//*for (int k = 0;k<topoNet.length;k++){
for (int j = k+1;j<topoNet.length;j++){
topoNet[k][j] = topoNet[j][k];
}
......@@ -78,11 +105,107 @@ public class CycleTopoUnit {
}
if (count != 30){
count2++;
}*//*
*//* System.out.println(Arrays.deepToString(topoNet));
System.out.println("=========================================");
System.out.println(count2);*//*
return TopoStore;
}
System.out.println(Arrays.deepToString(topoNet));
}*/
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) throws IllegalAccessException{ cycleTp(); }
public static HashMap<Integer, int[][]> cycleTp() throws IllegalAccessException{
//从文本中获取卫星的数据
WeixingImpl wx = new WeixingImpl();
ToponetImpl tp = new ToponetImpl();
SimData sd = new SimData();
//tp.delHistory();
File file = new File("D:\\LabratoryJavaPro\\codingDownload\\latestCoding\\topusim_1.txt");
List<WeiXingData> wxData = wx.iniTopo(file,sd.getZhouqi());
/*int[][] topoInit = tp.getTopology(wxData,sd);
//输出topo
for(int j = 0;j<topoInit.length;j++){
for(int k= 0;k<topoInit[0].length;k++){
System.out.print(topoInit[j][k] + " ");
}
System.out.println(" ");
} */
sd.setJiange(60);
sd.setC0(3e10);
//存储全周期拓扑
HashMap<Integer, int[][]> TopoStore = new HashMap<>();
out:for (int i = 0; i<sd.getZhouqi()/sd.getJiange(); i++) {
//Thread.sleep(2000);
int time = i * sd.getJiange();
List<WeiXingData> changetp = wx.changeTopo(wxData,time);
int[][] topoChange = tp.getTopology(changetp,sd);
/*//输出topo
for(int m = 0;m<topoChange.length;m++){
for(int n= 0;n<topoChange[0].length;n++){
System.out.print(topoChange[m][n] + " ");
}
System.out.println(" ");
}*/
TopoStore.put(i,topoChange);
}
/*
* 对比全周期拓扑
* count记录重复拓扑行数
* count2记录不同拓扑数目
* */
int count = 0;
int count2 = 0;
Iterator<Map.Entry<Integer, int[][]>> iterator = TopoStore.entrySet().iterator();
while (iterator.hasNext()){
int[][] value = iterator.next().getValue();
System.out.println(Arrays.deepToString(value));
System.out.println("=========================================");
System.out.println(count2);
while (iterator.hasNext()){
int[][] valueNext = iterator.next().getValue();
for (int i = 0;i<value.length;i++){
boolean equals = Arrays.equals(value[i], valueNext[i]);
count += (equals?1:0);
}
if (count != 30){
System.out.println(Arrays.deepToString(valueNext));
System.out.println("=========================================");
System.out.println(count2);
count2++;
}
count=0;
value=valueNext;
}
}
System.out.println("所有topo完成");
return TopoStore;
}
}
......@@ -7,9 +7,11 @@ import lombok.Data;
*/
@Data
public class SimData {
//设置时间,默认为 2020-01-01 00-00-00
//24小时制
private String defaultDate = "2020-01-01 00-00-00";
//时间间隔,默认值为10
private int jiange = 20;
private int jiange = 10;
//周期值,默认值为100分钟,即为6000秒
private int zhouqi = 6000;
//todo:这里因该预设默认值
......@@ -27,7 +29,7 @@ public class SimData {
private double lamda = 0.05;
//星间信道容量最低容限
private double c0 = 4*10e7;
private double c0 = 10e9;
public double ptGtGr(){
return pt*gt*gr;
......
......@@ -22,7 +22,7 @@ public class WeiXingData {
//卫星的序列号
private Integer index;
//运行时间
private Integer lastime = 0;
private int lastime = 0;
@Override
public String toString(){
......
......@@ -82,7 +82,7 @@ public class ToponetImpl implements Toponet {
double r = this.distance(a, b);
double channelCapacity;
channelCapacity = sd.getBandwidth()*Math.log(1+(sd.ptGtGr()/(Math.pow(4*Math.PI*r*sd.getJiange()/sd.getLamda(),2)*sd.n0B())))/Math.log(2);
channelCapacity = sd.getBandwidth()*Math.log(1+(sd.ptGtGr()/(Math.pow(4*Math.PI*r/sd.getLamda(),2)*sd.n0B())))/Math.log(2);
return channelCapacity;
}
......
package top.ninwoo.test.sateTopo.service.impl;
import top.ninwoo.test.sateTopo.entity.SimData;
import top.ninwoo.test.sateTopo.entity.WeiXingData;
import top.ninwoo.test.sateTopo.service.Weixing;
......@@ -16,8 +15,6 @@ import java.util.Map;
public class WeixingImpl implements Weixing {
SimData simData = new SimData();
@Override
public List<Map> parseTxt(File file) {
String str;
......@@ -77,10 +74,11 @@ public class WeixingImpl implements Weixing {
}
@Override
public List<WeiXingData> addWSpeed(List<WeiXingData> wx, int zhouqi) {
public List<WeiXingData> addWSpeed(List<WeiXingData> wx,int zhouqi) {
for(int i=0;i<wx.size();i++){
if(wx.get(i).getTag().equals(true)){
wx.get(i).setSpeed(2*Math.PI*(1/zhouqi));}
Double speed = 2*Math.PI/zhouqi;
wx.get(i).setSpeed(speed);}
else{wx.get(i).setSpeed((-1)*2*Math.PI*(1/zhouqi));}
}
return wx;
......@@ -90,7 +88,7 @@ public class WeixingImpl implements Weixing {
public List<WeiXingData> addAxis(List<WeiXingData> wx) {
for (int i = 0; i < wx.size(); i++) {
Float High = wx.get(i).getHigh();
Double hudu = Math.toRadians(wx.get(i).getSpeed() * wx.get(i).getLastime());
Double hudu = wx.get(i).getSpeed() * wx.get(i).getLastime();
Double Alpha = Math.toRadians(wx.get(i).getAlpha());
Double Beta = Math.toRadians(wx.get(i).getBeta());
Double Gamma = Math.toRadians(wx.get(i).getGamma());
......@@ -212,7 +210,7 @@ public class WeixingImpl implements Weixing {
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public List<WeiXingData> iniTopo(File file, int zhouqi) throws IllegalAccessException {
public List<WeiXingData> iniTopo(File file,int zhouqi) throws IllegalAccessException {
List<Map> maps = this.parseTxt(file);
List<WeiXingData> wxData = this.initNet(maps);
wxData = this.initChangeTopo(wxData,zhouqi);
......@@ -233,7 +231,7 @@ public class WeixingImpl implements Weixing {
}
@Override
public List<WeiXingData> initChangeTopo(List<WeiXingData> wxData, int zhouqi) {
public List<WeiXingData> initChangeTopo(List<WeiXingData> wxData,int zhouqi) {
wxData = this.addWSpeed(wxData,zhouqi);
wxData = this.addAxis(wxData);
this.checkWX(wxData);
......
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