|
@@ -49,12 +49,17 @@ public class SGFunctions {
|
|
implementState();
|
|
implementState();
|
|
HelpFunctions.calculateStateForTimeStepPSO(model, control);
|
|
HelpFunctions.calculateStateForTimeStepPSO(model, control);
|
|
double value = 0.0;
|
|
double value = 0.0;
|
|
|
|
+ double nw_fitness =0.0;
|
|
|
|
+ double object_fitness = 0.0;
|
|
|
|
|
|
//int nrOfSubnets = control.getSimManager().getSubNets().size();
|
|
//int nrOfSubnets = control.getSimManager().getSubNets().size();
|
|
//System.out.println("nr of subnets: " + nrOfSubnets);
|
|
//System.out.println("nr of subnets: " + nrOfSubnets);
|
|
- value += networkFitness();
|
|
|
|
- value += holonObjectFitness();
|
|
|
|
|
|
+ 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()) {
|
|
/*for (AbstractCpsObject obj : model.getObjectsOnCanvas()) {
|
|
if (obj instanceof HolonObject) {
|
|
if (obj instanceof HolonObject) {
|
|
int state = ((HolonObject) obj).getState();
|
|
int state = ((HolonObject) obj).getState();
|
|
@@ -94,15 +99,9 @@ public class SGFunctions {
|
|
*/
|
|
*/
|
|
private double networkFitness() {
|
|
private double networkFitness() {
|
|
double result = 0.0;
|
|
double result = 0.0;
|
|
- ArrayList<SubNet> tmp_sn = control.getSimManager().getSubNets();
|
|
|
|
- int totalNrOfObjects = model.getObjectsOnCanvas().size();
|
|
|
|
-
|
|
|
|
- System.out.println("Total number of objects is: " + totalNrOfObjects);
|
|
|
|
- for (SubNet subNet : tmp_sn) {
|
|
|
|
- System.out.println("Subnetsize: " + (subNet.getObjects().size()));
|
|
|
|
- }
|
|
|
|
|
|
+ ArrayList<SubNet> tmp_sn = HelpFunctions.getCurrentSubnets();
|
|
|
|
|
|
- result = (tmp_sn.size() - 1) * 300;
|
|
|
|
|
|
+ result = (tmp_sn.size() - 1) * 10000;
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
@@ -121,8 +120,7 @@ public class SGFunctions {
|
|
private double holonObjectFitness() {
|
|
private double holonObjectFitness() {
|
|
double result = 0.0;
|
|
double result = 0.0;
|
|
ArrayList<AbstractCpsObject> objList = model.getObjectsOnCanvas();
|
|
ArrayList<AbstractCpsObject> objList = model.getObjectsOnCanvas();
|
|
- System.out.println("total consumption works: " + control.getTotalConsumption(objList));
|
|
|
|
- //TODO Annoying as fuck... think think
|
|
|
|
|
|
+
|
|
for (AbstractCpsObject obj : objList) {
|
|
for (AbstractCpsObject obj : objList) {
|
|
if (obj instanceof HolonObject) {
|
|
if (obj instanceof HolonObject) {
|
|
float supply = ((HolonObject) obj).getCurrentSupply();
|
|
float supply = ((HolonObject) obj).getCurrentSupply();
|
|
@@ -130,21 +128,15 @@ public class SGFunctions {
|
|
float suppPercentage = ((HolonObject) obj).getSuppliedPercentage();
|
|
float suppPercentage = ((HolonObject) obj).getSuppliedPercentage();
|
|
float ownProduction = ((HolonObject) obj).getSelfMadeEnergy(model.getCurIteration());
|
|
float ownProduction = ((HolonObject) obj).getSelfMadeEnergy(model.getCurIteration());
|
|
float maxEnergy = ((HolonObject) obj).getMaxPossibleConsumption();
|
|
float maxEnergy = ((HolonObject) obj).getMaxPossibleConsumption();
|
|
|
|
+ int elem = ((HolonObject) obj).getNumberOfActiveElements();
|
|
|
|
|
|
- System.out.println(obj.getName());
|
|
|
|
if(!(obj.getName().contains("Plant"))) {
|
|
if(!(obj.getName().contains("Plant"))) {
|
|
result += holonObjectSupplyPenaltyFunction(suppPercentage);
|
|
result += holonObjectSupplyPenaltyFunction(suppPercentage);
|
|
result += holonObjectStatePenalty((HolonObject)obj);
|
|
result += holonObjectStatePenalty((HolonObject)obj);
|
|
|
|
|
|
}
|
|
}
|
|
result += inactiveHolonElementPenalty((HolonObject)obj);
|
|
result += inactiveHolonElementPenalty((HolonObject)obj);
|
|
-
|
|
|
|
-
|
|
|
|
- System.out.println("min ele" + ((HolonObject) obj).getMinimalConsumingElement().toString());
|
|
|
|
- //if(((HolonObject) obj).getCurrentEnergyAtTimeStep(model.getCurIteration())/maxEnergy <;
|
|
|
|
-
|
|
|
|
- System.out.println("Own production: " + ownProduction + "Provided Supply and energy: " + supply + " and " + energy + " with total possible energy: " + maxEnergy
|
|
|
|
- + " is supply percentage: " + suppPercentage);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -161,16 +153,17 @@ public class SGFunctions {
|
|
float result = 0;
|
|
float result = 0;
|
|
if(supplyPercentage == 1)
|
|
if(supplyPercentage == 1)
|
|
return result;
|
|
return result;
|
|
- else if(supplyPercentage < 1 && supplyPercentage >= 0.25)
|
|
|
|
- result = (float) (1/supplyPercentage *1.5);
|
|
|
|
- else if (supplyPercentage < 0.25)
|
|
|
|
- result = 1/supplyPercentage * 2; //Scalar value might be problematic for large/specific examples
|
|
|
|
- else if (supplyPercentage < 1.25)
|
|
|
|
- result = 1 * supplyPercentage *2 ;
|
|
|
|
- else result = 1 * supplyPercentage * 3;
|
|
|
|
|
|
+ else if(supplyPercentage < 1 && supplyPercentage >= 0.25) // undersupplied inbetween 25% and 100%
|
|
|
|
+ result = (float) (1/supplyPercentage *15);
|
|
|
|
+ else if (supplyPercentage < 0.25) //undersupplied with less than 25%
|
|
|
|
+ result = 1/supplyPercentage * 20;
|
|
|
|
+ else if (supplyPercentage < 1.25) //Oversupplied less than 25%
|
|
|
|
+ result = 1 * supplyPercentage *20 ;
|
|
|
|
+ else result = 1 * supplyPercentage * 30; //Oversupplied more than 25%
|
|
|
|
+
|
|
if(Float.isInfinite(result) || Float.isNaN(result))
|
|
if(Float.isInfinite(result) || Float.isNaN(result))
|
|
result = 100;
|
|
result = 100;
|
|
- System.out.println("Low penalty function value: " + result + " with supply value: " + supplyPercentage);
|
|
|
|
|
|
+
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -182,8 +175,8 @@ public class SGFunctions {
|
|
if(activeElements == maxElements)
|
|
if(activeElements == maxElements)
|
|
result =0;
|
|
result =0;
|
|
else if(activeElements == 0) {
|
|
else if(activeElements == 0) {
|
|
- result = 100;
|
|
|
|
- }else result = ((maxElements -activeElements)*200);
|
|
|
|
|
|
+ result = 10000;
|
|
|
|
+ }else result = ((maxElements -activeElements)*300);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
|
|