diff options
Diffstat (limited to 'structure')
| -rw-r--r-- | structure/Grid.java | 58 | ||||
| -rw-r--r-- | structure/MyGraph.java | 3 |
2 files changed, 37 insertions, 24 deletions
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<Router> routers=new ArrayList<>(); - private ArrayList<ArrayList<Integer>> links=new ArrayList<>(); + public ArrayList<ArrayList<Integer>> 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<Integer,Integer> 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<Integer> link){ + public int getMaxBottleneck(ArrayList<Integer> link){ int max=this.getWeigthOfLink(link.get(0), link.get(1)); for(int j=1;j<link.size()-1;j++){ int currentMax=this.getWeigthOfLink(link.get(j), link.get(j+1)); @@ -286,11 +294,12 @@ public class Grid { * @return the bestLinkByProtocol */ public int getBestLinkByProtocol() { + if(this.protocol==Protocol.CUSTOM){ this.counterCUSTOM--; if(this.counterCUSTOM==0){ this.bestLink=this.getBestLinkIndex(); - this.counterCUSTOM=5; + this.counterCUSTOM=2; } } @@ -299,6 +308,9 @@ public class Grid { + public int getDebitMoy(){ + return this.debitTotal/this.nbmesure; + } diff --git a/structure/MyGraph.java b/structure/MyGraph.java index 1c2dc0f..be9e504 100644 --- a/structure/MyGraph.java +++ b/structure/MyGraph.java @@ -147,13 +147,14 @@ public class MyGraph extends SingleGraph{ } + if(this.grid.getBestLinkByProtocol()==this.grid.getBestLinkIndex()){ this.success++; } else{ this.miss++; } - System.out.println("Success = " + this.success + " Miss = " + this.miss + " try number :"+(this.success+this.miss)) ; + //System.out.println("Success = " + this.success + " Miss = " + this.miss + " try number :"+(this.success+this.miss)) ; //Build bestLink this.showBestLink(); |
