Browse Source

Merge branch 'CalculationFeature' of git@git.tk.informatik.tu-darmstadt.de:carlos.garcia/praktikum-holons.git into CalculationFeature

Tom Troppmann 5 years ago
parent
commit
32b862d9de
1 changed files with 9 additions and 7 deletions
  1. 9 7
      src/exampleAlgorithms/PSOAlgotihm.java

+ 9 - 7
src/exampleAlgorithms/PSOAlgotihm.java

@@ -620,6 +620,8 @@ public class PSOAlgotihm implements Algorithm {
 		for(DecoratedNetwork net : state.getNetworkList()) {
 			object_fitness += net.getConsumerList().stream().map(con -> holonObjectSupplyPenaltyFunction(con.getSupplyBarPercentage()) + inactiveHolonElementPenalty(con.getModel())).reduce(0.0, (a, b) -> (a + b));
 			//warum war das im network fitness und nicht hier im Object fitness??
+			object_fitness += net.getConsumerList().stream().map(con -> StateToDouble(con.getState())).reduce(0.0, (a,b) -> (a+b));
+			//System.out.println("objectfitness for statestuff: " + object_fitness);
 			object_fitness += net.getPassivNoEnergyList().stream().map(con -> 1000.0).reduce(0.0, (a, b) -> (a + b));
 			object_fitness += net.getSupplierList().stream().map(sup -> inactiveHolonElementPenalty(sup.getModel())).reduce(0.0, (a, b) -> (a + b));
 			object_fitness += net.getConsumerSelfSuppliedList().stream().map(con -> inactiveHolonElementPenalty(con.getModel())).reduce(0.0, (a, b) -> (a + b));
@@ -641,8 +643,8 @@ public class PSOAlgotihm implements Algorithm {
 		int maxElements = obj.getElements().size();
 		
 		//result = (float) Math.pow((maxElements -activeElements),2)*10;
-		result = (float) Math.pow(5, 4* (maxElements -activeElements)/maxElements) - 1 ;
-		
+		result = (float) Math.pow(5, 4* ( (float) maxElements - (float) activeElements)/ (float) maxElements) - 1 ;
+		//System.out.println("max: " + maxElements + " active: " + activeElements + " results in penalty: " + result);
 	return result;
 		
 	}
@@ -685,15 +687,15 @@ public class PSOAlgotihm implements Algorithm {
 	private double StateToDouble(HolonObjectState state) {
 		switch (state) {
 		case NOT_SUPPLIED:
-			return 10.0;
+			return 300.0;
 		case NO_ENERGY:
-			return 15.0;
+			return 100.0;
 		case OVER_SUPPLIED:
-			return 5.0;
+			return 200.0;
 		case PARTIALLY_SUPPLIED:
-			return 3.0;
+			return 100.0;
 		case PRODUCER:
-			return 2.0;
+			return 0;
 		case SUPPLIED:
 			return 0;
 		default: