aboutsummaryrefslogtreecommitdiff
path: root/structure/Grid.java
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-04-04 12:01:54 +0200
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-04-04 12:01:54 +0200
commit313c51b76b750cdbc8d7bc94e209e7cabf515e8d (patch)
treefac855a33f96a8d3d94b65bc7cbfeb975a03326b /structure/Grid.java
parent996c9fc3464cbec9ee8ac7e0d4a5b27879a70ece (diff)
test
Diffstat (limited to 'structure/Grid.java')
-rw-r--r--structure/Grid.java58
1 files changed, 35 insertions, 23 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;
+ }