From 313c51b76b750cdbc8d7bc94e209e7cabf515e8d Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Mon, 4 Apr 2016 12:01:54 +0200 Subject: test --- structure/Grid.java | 58 ++++++++++++++++++++++++++++++-------------------- structure/MyGraph.java | 3 ++- 2 files changed, 37 insertions(+), 24 deletions(-) (limited to 'structure') diff --git a/structure/Grid.java b/structure/Grid.java index 73c034e..08dd305 100644 --- a/structure/Grid.java +++ b/structure/Grid.java @@ -10,7 +10,7 @@ public class Grid { } private ArrayList routers=new ArrayList<>(); - private ArrayList> links=new ArrayList<>(); + public ArrayList> links=new ArrayList<>(); private int[] pMoy={50,59,92,50,4,8,6,13,7,1,51,6}; @@ -20,7 +20,7 @@ public class Grid { private Random rand = new Random(); private final int maxWeight=100; - + int debitTotal=0,nbmesure=0; @@ -38,18 +38,20 @@ public class Grid { this.buildEdgeWithRandomWeigth(); //Build fixed link - this.buildPath(); + //this.buildPath(); this.protocol=protocol; switch(protocol){ - case AODV: + case DSDV: this.bestLink=this.getBestLinkIndex(); break; - case DSDV: case CUSTOM: + this.bestLink=this.getBestLinkIndex(); + break; + case AODV: HashMap currentBestLink=new HashMap<>(); - for(int i=0;i<1000;i++){ + for(int i=0;i<100;i++){ int current=this.getBestLinkIndex(); if(currentBestLink.containsKey(current)){ currentBestLink.put(current, currentBestLink.get(current)+1); @@ -73,11 +75,11 @@ public class Grid { maxId=entryId; } - System.out.println("Id : "+ entryId + " max "+ entry); + //System.out.println("Id : "+ entryId + " max "+ entry); } this.bestLink=maxId; - System.out.println("Retenu :"+maxId); + // System.out.println("Retenu :"+maxId); break; @@ -89,32 +91,38 @@ public class Grid { public void buildEdgeWithRandomWeigth(){ - + // First line - this.buildLinkWithRandomWeight(routers.get(0), routers.get(1), 1); - this.buildLinkWithRandomWeight(routers.get(1), routers.get(2),1); + this.buildLinkWithRandomWeight(routers.get(0), routers.get(1), 100); + this.buildLinkWithRandomWeight(routers.get(1), routers.get(2),100); // Second line - this.buildLinkWithRandomWeight(routers.get(3), routers.get(4),69); - this.buildLinkWithRandomWeight(routers.get(4), routers.get(5),20); + this.buildLinkWithRandomWeight(routers.get(3), routers.get(4),100); + this.buildLinkWithRandomWeight(routers.get(4), routers.get(5),50); // Third line - this.buildLinkWithRandomWeight(routers.get(6), routers.get(7),23); - this.buildLinkWithRandomWeight(routers.get(7), routers.get(8),54); + this.buildLinkWithRandomWeight(routers.get(6), routers.get(7),100); + this.buildLinkWithRandomWeight(routers.get(7), routers.get(8),60); // First column - this.buildLinkWithRandomWeight(routers.get(0), routers.get(3),14); - this.buildLinkWithRandomWeight(routers.get(3), routers.get(6),11); + this.buildLinkWithRandomWeight(routers.get(0), routers.get(3),80); + this.buildLinkWithRandomWeight(routers.get(3), routers.get(6),100); // Second column - this.buildLinkWithRandomWeight(routers.get(1), routers.get(4),33); - this.buildLinkWithRandomWeight(routers.get(4), routers.get(7),22); + this.buildLinkWithRandomWeight(routers.get(1), routers.get(4),100); + this.buildLinkWithRandomWeight(routers.get(4), routers.get(7),10); // Third column - this.buildLinkWithRandomWeight(routers.get(2), routers.get(5),11); - this.buildLinkWithRandomWeight(routers.get(5), routers.get(8),47); + this.buildLinkWithRandomWeight(routers.get(2), routers.get(5),100); + this.buildLinkWithRandomWeight(routers.get(5), routers.get(8),100); + + this.buildPath(); + + //System.out.println(this.links.get(this.getBestLinkByProtocol())); + this.debitTotal+=this.getMaxBottleneck(this.links.get(this.getBestLinkByProtocol())); + this.nbmesure++; } @@ -199,7 +207,7 @@ public class Grid { } - private int getMaxBottleneck(ArrayList link){ + public int getMaxBottleneck(ArrayList link){ int max=this.getWeigthOfLink(link.get(0), link.get(1)); for(int j=1;j