|
@@ -15,49 +15,47 @@ public class TopologieObjectiveFunction {
|
|
|
//Parameters
|
|
|
|
|
|
//weight for f_g(H)
|
|
|
- static double w_eb = .3, w_max = 0.2, w_holon=.1, w_selection = .1, w_grid = .3;
|
|
|
+ static double w_eb = 0.2, w_max = 0.05, w_holon= 0.1, w_selection = .3, w_grid = 0.35;
|
|
|
|
|
|
|
|
|
//--> f_eb parameter
|
|
|
/**
|
|
|
* Maximum Energie Difference(kappa)
|
|
|
*/
|
|
|
- static double k_eb = 100000.f;
|
|
|
+ static double k_eb = 400000.f;
|
|
|
/**
|
|
|
* Maximum when all on Energie Difference(kappa)
|
|
|
*/
|
|
|
- static double k_max = 100000.f;
|
|
|
+ static double k_max = 350000.f;
|
|
|
|
|
|
//--> f_holon parameter
|
|
|
/**
|
|
|
* maximum penalty from holon flexibilities
|
|
|
*/
|
|
|
- static double k_holon= 200000;
|
|
|
+ static double k_holon= 220000;
|
|
|
|
|
|
|
|
|
//--> f_selection paramaeter;
|
|
|
/**
|
|
|
* average Maximum Cost for selction(kappa) of switch and elements.
|
|
|
*/
|
|
|
- static double k_selection = 4000;
|
|
|
-
|
|
|
- static double cost_switch = 10;
|
|
|
- private static int cost_of_cable_per_meter = 200;
|
|
|
+ static double k_selection = 50000;
|
|
|
+ static double cost_switch = 20;
|
|
|
+ private static double cost_of_cable_per_meter = 0.8;
|
|
|
//--> f_grid parameter
|
|
|
- /**
|
|
|
- * The avergae shortest path maximum length -> kappa for the squash function
|
|
|
- */
|
|
|
- static double k_avg_shortest_path = 400;
|
|
|
|
|
|
- // Disjoint Path Parameter
|
|
|
- //Function1 Decreasing
|
|
|
- static double seperate_X_Value = 3.0;
|
|
|
- // Value between 0 and 100
|
|
|
- static double seperate_Y_Value = 10;
|
|
|
- //Stretching the e-function
|
|
|
- static double lowPenaltyGrowth = 3.0;
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * The avergae shortest path maximum length -> kappa for the squash function
|
|
|
+ */
|
|
|
+ static double k_avg_shortest_path = 1650;
|
|
|
+ //Disjpijoint path cant have zero as output it starts with the value 1
|
|
|
+ static double centerValue_disjoint_path = 1.0;
|
|
|
+ static double k_disjoint_path = 2.4;
|
|
|
+ static double lambda_avg_shortest_path = 10;
|
|
|
+ static double lambda_disjoint_path = 10;
|
|
|
+ static double k_grid = lambda_avg_shortest_path + lambda_disjoint_path;
|
|
|
|
|
|
|
|
|
|
|
@@ -68,7 +66,8 @@ public class TopologieObjectiveFunction {
|
|
|
* {@link TopologieObjectiveFunction#squash}
|
|
|
*/
|
|
|
static double squash_subtract = 1.0f / (1.f + (float) Math.exp(5.0));
|
|
|
-
|
|
|
+ static double range_for_k_avg_shortest_path = range(k_avg_shortest_path);
|
|
|
+ static double range_for_k_disjoint_path = range(k_disjoint_path - centerValue_disjoint_path);
|
|
|
|
|
|
|
|
|
|
|
@@ -116,11 +115,13 @@ public class TopologieObjectiveFunction {
|
|
|
}
|
|
|
|
|
|
double f_maximum = 0;
|
|
|
+ final int timestep = state.getTimestepOfState();
|
|
|
for(DecoratedNetwork net : state.getNetworkList()) {
|
|
|
- final int timestep = state.getTimestepOfState();
|
|
|
- f_maximum += Math.abs(net.getConsumerList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum));
|
|
|
- f_maximum += Math.abs(net.getConsumerSelfSuppliedList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum));
|
|
|
- f_maximum += Math.abs(net.getSupplierList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum));
|
|
|
+ double maximumEnergy = 0;
|
|
|
+ maximumEnergy += net.getConsumerList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum);
|
|
|
+ maximumEnergy += net.getConsumerSelfSuppliedList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum);
|
|
|
+ maximumEnergy += net.getSupplierList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum);
|
|
|
+ f_maximum += Math.abs(maximumEnergy);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -136,7 +137,6 @@ public class TopologieObjectiveFunction {
|
|
|
//calculating f_selection
|
|
|
double f_selection = 0;
|
|
|
double cost = 0;
|
|
|
- int amountOfElemetsInWildcard = 0;
|
|
|
for(DecoratedNetwork net : state.getNetworkList()) {
|
|
|
for(DecoratedHolonObject dHobject : net.getConsumerList()) {
|
|
|
if(dHobject.getModel().getName().contains("Wildcard")){
|
|
@@ -177,60 +177,56 @@ public class TopologieObjectiveFunction {
|
|
|
for(DecoratedNetwork net: state.getNetworkList()) {
|
|
|
Graph G = GraphMetrics.convertDecoratedNetworkToGraph(net);
|
|
|
//We have to penalize single Networks;
|
|
|
- //100 is the maximum penalty for a holon/network
|
|
|
if(G.V.length <= 1) {
|
|
|
- f_grid += 100;
|
|
|
+ f_grid += lambda_avg_shortest_path + lambda_disjoint_path;
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
double avgShortestPath = GraphMetrics.averageShortestDistance(G.V, G.E);
|
|
|
+ //TODO replace minimumCut with avg (edge-) disjoint s-t path
|
|
|
//k-edge-conneted
|
|
|
- //int maximumK = G.V.length - 1;
|
|
|
- int k = GraphMetrics.minimumCut(G.V, G.E);
|
|
|
- double penalty = disjoinPathPenalty(k);
|
|
|
-
|
|
|
- f_grid += 0.5 * squash(penalty, 100) + 0.5 *squash(avgShortestPath, k_avg_shortest_path);
|
|
|
- }
|
|
|
- //Average over all networks
|
|
|
- if(!state.getNetworkList().isEmpty()) {
|
|
|
- f_grid /= state.getNetworkList().size();
|
|
|
+ int disjpointPaths = GraphMetrics.minimumCut(G.V, G.E);
|
|
|
+ f_grid += avgShortestPathPenalty(avgShortestPath) + disjoinPathPenalty(disjpointPaths);
|
|
|
}
|
|
|
+ //take average to encourage splitting
|
|
|
+ f_grid /= state.getNetworkList().size();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //avg disjoint path in jeden holon von jedem zu jedem element
|
|
|
|
|
|
|
|
|
-// System.out.println("f_grid:" + f_grid);
|
|
|
-// System.out.print(" f_eb(" + w_eb * squash(f_eb, k_eb) + ") ");
|
|
|
-// System.out.print(" f_holon(" + w_holon * squash(f_holon, k_holon) + ") ");
|
|
|
-// System.out.print(" f_selection(" + w_selection * squash(f_selection, k_selection) + ") ");
|
|
|
-// System.out.println(" f_grid(" + w_grid * f_grid + ") ");
|
|
|
|
|
|
- /**
|
|
|
- * F_grid is already squashed
|
|
|
- */
|
|
|
+
|
|
|
+
|
|
|
+ printUnsquashedValues(f_eb, f_maximum, f_holon, f_selection, f_grid);
|
|
|
return (float) (w_eb * squash(f_eb, k_eb)
|
|
|
+ w_max * squash(f_maximum, k_max)
|
|
|
+ w_holon * squash(f_holon, k_holon)
|
|
|
+ w_selection * squash(f_selection, k_selection)
|
|
|
- + w_grid * f_grid);
|
|
|
+ + w_grid * squash(f_grid, k_grid));
|
|
|
}
|
|
|
|
|
|
private static String doubleToString(double value) {
|
|
|
return String.format (Locale.US, "%.2f", value);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
private static double disjoinPathPenalty(double value) {
|
|
|
- //von 100 auf 10% bis seperateFunctionValue linear
|
|
|
- //Big Penalty
|
|
|
- if( value < seperate_X_Value) {
|
|
|
- return 100 - ((100 - seperate_Y_Value) / seperate_X_Value) * value;
|
|
|
- }
|
|
|
- //Low Penalty
|
|
|
- else {
|
|
|
- return seperate_Y_Value * Math.exp(lowPenaltyGrowth * (-value + seperate_X_Value));
|
|
|
- }
|
|
|
+ return -(2.0 * lambda_disjoint_path) / (1 + Math.exp(- (value - centerValue_disjoint_path)/ range_for_k_disjoint_path)) + (2.0 * lambda_disjoint_path);
|
|
|
+ }
|
|
|
+ private static double avgShortestPathPenalty(double value) {
|
|
|
+ return (2.0 * lambda_avg_shortest_path) / (1 + Math.exp(- value/ range_for_k_avg_shortest_path)) - lambda_avg_shortest_path;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Attention Math.log calcultae ln not log
|
|
|
+ * @param kappa
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static double range(double kappa) {
|
|
|
+ return - kappa / Math.log(Math.pow(2.0, 0.05) - 1.0 );
|
|
|
}
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* The squashing function in paper
|
|
@@ -252,5 +248,19 @@ public class TopologieObjectiveFunction {
|
|
|
return (supplyPercentage < 100) ? -0.5 * supplyPercentage + 50: supplyPercentage - 100;
|
|
|
}
|
|
|
|
|
|
+ static void printDistribution(double f_eb, double f_maximum, double f_holon, double f_selection, double f_grid){
|
|
|
+ System.out.print(" f_eb(" + w_eb * squash(f_eb, k_eb) + ") ");
|
|
|
+ System.out.print(" f_maximum(" + w_max * squash(f_maximum, k_max) + ") ");
|
|
|
+ System.out.print(" f_holon(" + w_holon * squash(f_holon, k_holon) + ") ");
|
|
|
+ System.out.print(" f_selection(" + w_selection * squash(f_selection, k_selection) + ") ");
|
|
|
+ System.out.println(" f_grid(" + w_grid * f_grid + ") ");
|
|
|
+ }
|
|
|
+ static void printUnsquashedValues(double f_eb, double f_maximum, double f_holon, double f_selection, double f_grid){
|
|
|
+ System.out.print(" f_eb(" + f_eb + ") ");
|
|
|
+ System.out.print(" f_maximum(" + f_maximum + ") ");
|
|
|
+ System.out.print(" f_holon(" + f_holon + ") ");
|
|
|
+ System.out.print(" f_selection(" + f_selection + ") ");
|
|
|
+ System.out.println(" f_grid(" + f_grid + ") ");
|
|
|
+ }
|
|
|
|
|
|
}
|