|
@@ -3,6 +3,8 @@ package psoAlgoCode;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Vector;
|
|
|
|
|
|
+import org.omg.PortableInterceptor.NON_EXISTENT;
|
|
|
+
|
|
|
import classes.AbstractCpsObject;
|
|
|
import classes.HolonElement;
|
|
|
import classes.HolonObject;
|
|
@@ -50,7 +52,7 @@ public class SGFunctions {
|
|
|
|
|
|
//int nrOfSubnets = control.getSimManager().getSubNets().size();
|
|
|
//System.out.println("nr of subnets: " + nrOfSubnets);
|
|
|
- networkFitness();
|
|
|
+ value += networkFitness();
|
|
|
value += holonObjectFitness();
|
|
|
|
|
|
/*for (AbstractCpsObject obj : model.getObjectsOnCanvas()) {
|
|
@@ -100,7 +102,7 @@ public class SGFunctions {
|
|
|
System.out.println("Subnetsize: " + (subNet.getObjects().size()));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ result = (tmp_sn.size() - 1) * 300;
|
|
|
return result;
|
|
|
}
|
|
|
/**
|
|
@@ -132,6 +134,7 @@ public class SGFunctions {
|
|
|
System.out.println(obj.getName());
|
|
|
if(!(obj.getName().contains("Plant"))) {
|
|
|
result += holonObjectSupplyPenaltyFunction(suppPercentage);
|
|
|
+ result += holonObjectStatePenalty((HolonObject)obj);
|
|
|
|
|
|
}
|
|
|
result += inactiveHolonElementPenalty((HolonObject)obj);
|
|
@@ -159,14 +162,14 @@ public class SGFunctions {
|
|
|
if(supplyPercentage == 1)
|
|
|
return result;
|
|
|
else if(supplyPercentage < 1 && supplyPercentage >= 0.25)
|
|
|
- result = 100/supplyPercentage;
|
|
|
+ result = (float) (1/supplyPercentage *1.5);
|
|
|
else if (supplyPercentage < 0.25)
|
|
|
- result = 100/supplyPercentage * 2; //Scalar value might be problematic for large/specific examples
|
|
|
+ result = 1/supplyPercentage * 2; //Scalar value might be problematic for large/specific examples
|
|
|
else if (supplyPercentage < 1.25)
|
|
|
- result = 100 * supplyPercentage *2 ;
|
|
|
- else result = 100 * supplyPercentage * 3;
|
|
|
+ result = 1 * supplyPercentage *2 ;
|
|
|
+ else result = 1 * supplyPercentage * 3;
|
|
|
if(Float.isInfinite(result) || Float.isNaN(result))
|
|
|
- result = 10000;
|
|
|
+ result = 100;
|
|
|
System.out.println("Low penalty function value: " + result + " with supply value: " + supplyPercentage);
|
|
|
return result;
|
|
|
}
|
|
@@ -179,13 +182,42 @@ public class SGFunctions {
|
|
|
if(activeElements == maxElements)
|
|
|
result =0;
|
|
|
else if(activeElements == 0) {
|
|
|
- result = 10000;
|
|
|
- }else result = ((maxElements -activeElements)*600);
|
|
|
+ result = 100;
|
|
|
+ }else result = ((maxElements -activeElements)*200);
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private double holonObjectStatePenalty(HolonObject obj) {
|
|
|
+ float result = 0;
|
|
|
+
|
|
|
+ int state = obj.getState();
|
|
|
+ switch (state) {
|
|
|
+ case 0: result = 0;
|
|
|
+ break;
|
|
|
+ case 1: result = 10;
|
|
|
+ break;
|
|
|
+ case 2: result = 0;
|
|
|
+ break;
|
|
|
+ case 3: result = 0;
|
|
|
+ break;
|
|
|
+ case 4: result = 5;
|
|
|
+ break;
|
|
|
+ case 5: result = 5;
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|