|
@@ -52,44 +52,15 @@ public class SGFunctions {
|
|
|
double nw_fitness =0.0;
|
|
|
double object_fitness = 0.0;
|
|
|
|
|
|
- //int nrOfSubnets = control.getSimManager().getSubNets().size();
|
|
|
- //System.out.println("nr of subnets: " + nrOfSubnets);
|
|
|
nw_fitness = networkFitness();
|
|
|
object_fitness = holonObjectFitness();
|
|
|
|
|
|
System.out.println("NW_fitness: " + nw_fitness +" objectFitness: " + object_fitness);
|
|
|
|
|
|
value = nw_fitness + object_fitness;
|
|
|
- /*for (AbstractCpsObject obj : model.getObjectsOnCanvas()) {
|
|
|
- if (obj instanceof HolonObject) {
|
|
|
- int state = ((HolonObject) obj).getState();
|
|
|
- double suppliedPerc = ((HolonObject) obj).getSuppliedPercentage();
|
|
|
- double elementsActive = (double) elementsActive((HolonObject) obj);
|
|
|
- double totalElements = (double) ((HolonObject) obj).getElements().size();
|
|
|
- double difference = Math.abs(1.0 - suppliedPerc) * 100;
|
|
|
- double differenceEle = (1.0 - (elementsActive / totalElements)) * 100;
|
|
|
- // Supply States (see HolonObject class for more informations)
|
|
|
- switch (state) {
|
|
|
- case 0:
|
|
|
- value += (100 * 8);
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- value += difference * 4 + differenceEle;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- value += difference + differenceEle;
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- value += difference + differenceEle;
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- value += difference * 2 + differenceEle;
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return value;
|
|
|
}
|
|
|
|
|
@@ -101,7 +72,27 @@ public class SGFunctions {
|
|
|
double result = 0.0;
|
|
|
ArrayList<SubNet> tmp_sn = HelpFunctions.getCurrentSubnets();
|
|
|
|
|
|
- result = (tmp_sn.size() - 1) * 10000;
|
|
|
+ for (SubNet subNet : tmp_sn) {
|
|
|
+ ArrayList<HolonObject> tmp = subNet.getObjects();
|
|
|
+ for (HolonObject holonObject : tmp) {
|
|
|
+ System.out.println("Current state: " +holonObject.getState());
|
|
|
+ }
|
|
|
+ // float sn_prod =0;
|
|
|
+ //float sn_cons =0;
|
|
|
+
|
|
|
+ float production = control.getSimManager().calculateEnergyWithoutFlexDevices("prod",
|
|
|
+ subNet, model.getCurIteration());
|
|
|
+ float consumption = control.getSimManager().calculateEnergyWithoutFlexDevices("cons",
|
|
|
+ subNet, model.getCurIteration());
|
|
|
+ System.out.println("current production: " + production + " current consumption: " + consumption);
|
|
|
+
|
|
|
+ result += Math.abs(production+consumption)*10;
|
|
|
+ }
|
|
|
+
|
|
|
+ //result = (tmp_sn.size() - 1) * 100;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
/**
|
|
@@ -123,13 +114,13 @@ public class SGFunctions {
|
|
|
|
|
|
for (AbstractCpsObject obj : objList) {
|
|
|
if (obj instanceof HolonObject) {
|
|
|
- float supply = ((HolonObject) obj).getCurrentSupply();
|
|
|
- float energy =((HolonObject) obj).getMaxActiveEnergy();
|
|
|
float suppPercentage = ((HolonObject) obj).getSuppliedPercentage();
|
|
|
+ /*float supply = ((HolonObject) obj).getCurrentSupply();
|
|
|
+ float energy =((HolonObject) obj).getMaxActiveEnergy();
|
|
|
float ownProduction = ((HolonObject) obj).getSelfMadeEnergy(model.getCurIteration());
|
|
|
float maxEnergy = ((HolonObject) obj).getMaxPossibleConsumption();
|
|
|
int elem = ((HolonObject) obj).getNumberOfActiveElements();
|
|
|
-
|
|
|
+ */
|
|
|
if(!(obj.getName().contains("Plant"))) {
|
|
|
result += holonObjectSupplyPenaltyFunction(suppPercentage);
|
|
|
result += holonObjectStatePenalty((HolonObject)obj);
|
|
@@ -176,28 +167,33 @@ public class SGFunctions {
|
|
|
result =0;
|
|
|
else if(activeElements == 0) {
|
|
|
result = 10000;
|
|
|
- }else result = ((maxElements -activeElements)*300);
|
|
|
+ }else result = ((maxElements -activeElements)*600);
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * Pentalty Function that is based on the different states an object can have.
|
|
|
+ * @param obj The holon object that is used for the assessment
|
|
|
+ * @return pentalty value
|
|
|
+ */
|
|
|
private double holonObjectStatePenalty(HolonObject obj) {
|
|
|
float result = 0;
|
|
|
|
|
|
+ //TODO currently no penalties on undesired states, since the state assignment is broken...
|
|
|
int state = obj.getState();
|
|
|
switch (state) {
|
|
|
case 0: result = 0;
|
|
|
break;
|
|
|
- case 1: result = 10;
|
|
|
+ case 1: result = 0;
|
|
|
break;
|
|
|
case 2: result = 0;
|
|
|
break;
|
|
|
case 3: result = 0;
|
|
|
break;
|
|
|
- case 4: result = 5;
|
|
|
+ case 4: result = 0;
|
|
|
break;
|
|
|
- case 5: result = 5;
|
|
|
+ case 5: result = 0;
|
|
|
break;
|
|
|
|
|
|
|