Browse Source

Network + ObjectiveFuntion

Troppmann, Tom 3 years ago
parent
commit
c7494a4246

BIN
exampleNetworks/Topologie_Version0.holon


+ 32 - 17
src/algorithm/objectiveFunction/TopologieObjectiveFunction.java

@@ -49,6 +49,16 @@ public class TopologieObjectiveFunction {
 	 */
 	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;
+	
+	
+	
 	
 	
 	//pre-calculated parameters for partial function terms:
@@ -108,9 +118,9 @@ public class TopologieObjectiveFunction {
 		double f_maximum = 0;
 		for(DecoratedNetwork net : state.getNetworkList()) {
 			final int timestep = state.getTimestepOfState();
-			f_maximum += Math.abs(net.getConsumerList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep)).reduce(0.f, Float::sum));
-			f_maximum += Math.abs(net.getConsumerSelfSuppliedList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep)).reduce(0.f, Float::sum));
-			f_maximum += Math.abs(net.getSupplierList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep)).reduce(0.f, Float::sum));
+			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));
 		}
 		
 		
@@ -167,6 +177,7 @@ 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;
 				continue;
@@ -174,25 +185,20 @@ public class TopologieObjectiveFunction {
 			
 			
 			double avgShortestPath = GraphMetrics.averageShortestDistance(G.V,  G.E);
-			double squached = squash(avgShortestPath, k_avg_shortest_path);
-			//System.out.println("AVG:" + avgShortestPath + "  squached:" + squached);
-			
 			//k-edge-conneted
-			int maximumK = G.V.length - 1;
-			if(maximumK != 0) {
-				int k = GraphMetrics.minimumCut(G.V, G.E);				
-				double proportion = k/(double)maximumK;
-				//System.out.println("proportion ("+ k+"/"+ maximumK+")=" + proportion);
-				squached =  0.5 * squash(1.0-proportion, 1) + 0.5 *squached;
-			}
-			f_grid += squached;
+			//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();		
 		}
-		//System.out.println("f_grid:" + f_grid);
 		
 		
+//      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)  + ") ");
@@ -213,7 +219,17 @@ public class TopologieObjectiveFunction {
 	}
 	
 	
-	
+	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));
+		}
+	}
 	
 	
 	/**
@@ -233,7 +249,6 @@ public class TopologieObjectiveFunction {
 	 */
 	static public double supplyPenalty(double supply) {
 		double supplyPercentage = 100 * supply;
-		//	double test = (supplyPercentage < 100) ? -0.5 * supplyPercentage + 50: supplyPercentage - 100;
 		return (supplyPercentage < 100) ? -0.5 * supplyPercentage + 50: supplyPercentage - 100;
 	}