|
@@ -1,6 +1,7 @@
|
|
|
package algorithm.objectiveFunction;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.LinkedList;
|
|
@@ -26,6 +27,9 @@ public class GraphMetrics {
|
|
|
public Vertex(int id){
|
|
|
this.id = id;
|
|
|
}
|
|
|
+ public String toString() {
|
|
|
+ return "" + id;
|
|
|
+ }
|
|
|
}
|
|
|
private static class Edge{
|
|
|
public int idA, idB;
|
|
@@ -42,6 +46,12 @@ public class GraphMetrics {
|
|
|
Edge[] E;
|
|
|
/**Only the Sources/Trains for disjoint Path no Switch or Node**/
|
|
|
Vertex[] S;
|
|
|
+
|
|
|
+ public String toString() {
|
|
|
+ String vList = "V" + Arrays.toString(V);
|
|
|
+ String sList = "S" + Arrays.toString(S);
|
|
|
+ return vList + ", " + sList;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -57,20 +67,24 @@ public class GraphMetrics {
|
|
|
List<Integer> sourcesList = new ArrayList<Integer>();
|
|
|
int count = 0;
|
|
|
for(Consumer con: net.getConsumerList()) {
|
|
|
- objectToId.put(con.getModel(), count++);
|
|
|
+ objectToId.put(con.getModel(), count);
|
|
|
sourcesList.add(count);
|
|
|
+ count++;
|
|
|
}
|
|
|
for(Consumer con: net.getConsumerSelfSuppliedList()) {
|
|
|
- objectToId.put(con.getModel(), count++);
|
|
|
+ objectToId.put(con.getModel(), count);
|
|
|
sourcesList.add(count);
|
|
|
+ count++;
|
|
|
}
|
|
|
for(Passiv pas: net.getPassivNoEnergyList()) {
|
|
|
- objectToId.put(pas.getModel(), count++);
|
|
|
+ objectToId.put(pas.getModel(), count);
|
|
|
sourcesList.add(count);
|
|
|
+ count++;
|
|
|
}
|
|
|
for(Supplier sup: net.getSupplierList()) {
|
|
|
- objectToId.put(sup.getModel(), count++);
|
|
|
+ objectToId.put(sup.getModel(), count);
|
|
|
sourcesList.add(count);
|
|
|
+ count++;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -159,7 +173,7 @@ public class GraphMetrics {
|
|
|
G.S[1] = new Vertex(1);
|
|
|
G.S[2] = new Vertex(2);
|
|
|
G.S[3] = new Vertex(3);
|
|
|
-
|
|
|
+ System.out.println(G);
|
|
|
System.out.println("minimumCut: " + minimumCut(G.V, G.E));
|
|
|
System.out.println("AvgShortestDistance " + averageShortestDistance(G));
|
|
|
System.out.println("DisjointPath " + averageEdgeDisjointPathProblem(G));
|
|
@@ -372,7 +386,11 @@ public class GraphMetrics {
|
|
|
double sum = 0.0;
|
|
|
for(int s = 0; s < G.S.length; s++) {
|
|
|
for(int t = s; t < G.S.length; t++) {
|
|
|
- sum += D[G.S[s].id][G.S[t].id];
|
|
|
+ try {
|
|
|
+ sum += D[G.S[s].id][G.S[t].id];
|
|
|
+ }catch(java.lang.ArrayIndexOutOfBoundsException E) {
|
|
|
+ System.out.println(G);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//Returns the Average
|