|
@@ -46,6 +46,7 @@ import ui.model.DecoratedGroupNode;
|
|
|
import ui.model.DecoratedNetwork;
|
|
|
import ui.model.DecoratedState;
|
|
|
import ui.model.Model;
|
|
|
+import ui.model.DecoratedHolonObject.HolonObjectState;
|
|
|
|
|
|
public class FlexExample implements Algorithm {
|
|
|
|
|
@@ -229,6 +230,7 @@ public class FlexExample implements Algorithm {
|
|
|
}
|
|
|
}
|
|
|
updateVisual();
|
|
|
+ calculateAllResults(result);
|
|
|
println("Amount of activatedFlex:" + result.activatedFlex + " Amount of deactivatedElements:"+ result.deactivatedElements + " TotalCost:"+result.totalCost);
|
|
|
printElapsedTime();
|
|
|
disableGuiInput(false);
|
|
@@ -402,9 +404,44 @@ public class FlexExample implements Algorithm {
|
|
|
|
|
|
println("Activated FlexThisTimeStep: "+ amountflexActivated+" CostForThisTimeStep:" + costForThisTimeStep);
|
|
|
result.totalCost += costForThisTimeStep;
|
|
|
-
|
|
|
}
|
|
|
+ calculateStateResult(result);
|
|
|
+ }
|
|
|
+ private void calculateStateResult(RunResult result) {
|
|
|
+ control.calculateStateOnlyForCurrentTimeStep();
|
|
|
+ RunResult.TimeStepStateResult timeStepState = result.addTimeStepStateResult();
|
|
|
+
|
|
|
+ for(DecoratedNetwork network: control.getSimManager().getActualDecorState().getNetworkList()) {
|
|
|
+ timeStepState.amountOfConsumer += network.getAmountOfConsumer();
|
|
|
+ timeStepState.amountOfConsumerOverSupplied += network.getAmountOfConsumerWithState(HolonObjectState.OVER_SUPPLIED);
|
|
|
+ timeStepState.amountOfConsumerPartiallySupplied += network.getAmountOfConsumerWithState(HolonObjectState.PARTIALLY_SUPPLIED);
|
|
|
+ timeStepState.amountOfConsumerSupplied += network.getAmountOfConsumerWithState(HolonObjectState.SUPPLIED);
|
|
|
+ timeStepState.amountOfConsumerUnSupplied += network.getAmountOfConsumerWithState(HolonObjectState.NOT_SUPPLIED);
|
|
|
+ timeStepState.amountOfPassiv += network.getAmountOfPassiv();
|
|
|
+ timeStepState.amountOfProducer += network.getAmountOfSupplier();
|
|
|
+ }
|
|
|
+ println("Producer: " + timeStepState.amountOfProducer);
|
|
|
+ println("Consumer: " + timeStepState.amountOfConsumer);
|
|
|
+ println("ConsumerOverSupplied: " + timeStepState.amountOfConsumerOverSupplied);
|
|
|
+ println("ConsumerSupplied: " + timeStepState.amountOfConsumerSupplied);
|
|
|
+ println("ConsumerPartiallySupplied: " + timeStepState.amountOfConsumerPartiallySupplied);
|
|
|
+ println("ConsumerUnSupplied: " + timeStepState.amountOfConsumerUnSupplied);
|
|
|
+ println("ConsumerUnSupplied: " + timeStepState.amountOfPassiv);
|
|
|
+ }
|
|
|
+ private void calculateAllResults(RunResult result) {
|
|
|
+ println("----------");
|
|
|
+ println("Average producer proportion: " + result.getAvergaeProportionWithState(HolonObjectState.PRODUCER));
|
|
|
+ println("Average producer OverSupplied: " + result.getAvergaeProportionWithState(HolonObjectState.OVER_SUPPLIED));
|
|
|
+ println("Average producer Supplied: " + result.getAvergaeProportionWithState(HolonObjectState.SUPPLIED));
|
|
|
+ println("Average producer PartiallySupplied: " + result.getAvergaeProportionWithState(HolonObjectState.PARTIALLY_SUPPLIED));
|
|
|
+ println("Average producer NotSupplied: " + result.getAvergaeProportionWithState(HolonObjectState.NOT_SUPPLIED));
|
|
|
+ println("Average producer NoEnergy: " + result.getAvergaeProportionWithState(HolonObjectState.NO_ENERGY));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private float shutDownAllConsumerElementsWithPriority(FlexManager flexManager, Set<HolonElement> allHolonElemntsInThisNetwork,
|
|
|
Priority emergencyShutDownPriority, RunResult result) {
|
|
|
|
|
@@ -561,6 +598,48 @@ public class FlexExample implements Algorithm {
|
|
|
public int activatedFlex = 0;
|
|
|
public int deactivatedElements = 0;
|
|
|
public int totalCost = 0;
|
|
|
+ public LinkedList<TimeStepStateResult> timeStepList = new LinkedList<TimeStepStateResult>();
|
|
|
+
|
|
|
+
|
|
|
+ public TimeStepStateResult addTimeStepStateResult(){
|
|
|
+ TimeStepStateResult aResult = new TimeStepStateResult();
|
|
|
+ timeStepList.add(aResult);
|
|
|
+ return aResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public class TimeStepStateResult{
|
|
|
+ public int amountOfProducer = 0;
|
|
|
+ public int amountOfConsumer = 0;
|
|
|
+ public int amountOfPassiv = 0;
|
|
|
+ public int amountOfConsumerOverSupplied = 0;
|
|
|
+ public int amountOfConsumerSupplied = 0;
|
|
|
+ public int amountOfConsumerPartiallySupplied = 0;
|
|
|
+ public int amountOfConsumerUnSupplied= 0;
|
|
|
+
|
|
|
+ public float getProportionWithState(HolonObjectState state) {
|
|
|
+ float amountOfObjects = amountOfProducer + amountOfConsumer + amountOfPassiv;
|
|
|
+ switch(state) {
|
|
|
+ case NOT_SUPPLIED:
|
|
|
+ return (float) amountOfConsumerUnSupplied / amountOfObjects;
|
|
|
+ case NO_ENERGY:
|
|
|
+ return (float) amountOfPassiv / amountOfObjects;
|
|
|
+ case OVER_SUPPLIED:
|
|
|
+ return (float) amountOfConsumerOverSupplied / amountOfObjects;
|
|
|
+ case PARTIALLY_SUPPLIED:
|
|
|
+ return (float) amountOfConsumerPartiallySupplied / amountOfObjects;
|
|
|
+ case PRODUCER:
|
|
|
+ return (float) amountOfProducer / amountOfObjects;
|
|
|
+ case SUPPLIED:
|
|
|
+ return (float) amountOfConsumerSupplied / amountOfObjects;
|
|
|
+ default:
|
|
|
+ return 0.f;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public float getAvergaeProportionWithState(HolonObjectState state) {
|
|
|
+ return timeStepList.stream().map(step -> step.getProportionWithState(state)).reduce((a,b) -> (a + b)).orElse(0.f) / (float) 100;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private class Handle<T>{
|