|
@@ -1,7 +1,9 @@
|
|
|
package ui.model;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
-
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import classes.HolonElement;
|
|
|
import classes.HolonObject;
|
|
|
import ui.controller.FlexManager;
|
|
|
import ui.model.DecoratedCable.CableState;
|
|
@@ -14,8 +16,10 @@ public class DecoratedNetwork {
|
|
|
private ArrayList<Consumer> consumerSelfSuppliedList = new ArrayList<Consumer>();
|
|
|
private ArrayList<Passiv> passivNoEnergyList = new ArrayList<Passiv>();
|
|
|
private ArrayList<DecoratedCable> decoratedCableList = new ArrayList<DecoratedCable>();
|
|
|
+ private int timestep;
|
|
|
|
|
|
public DecoratedNetwork(MinimumNetwork minimumNetwork, int Iteration, FairnessModel actualFairnessModel, FlexManager flexManager){
|
|
|
+ this.timestep = Iteration;
|
|
|
switch(actualFairnessModel) {
|
|
|
case AllEqual:
|
|
|
calculateAllEqualNetwork(minimumNetwork, Iteration, flexManager);
|
|
@@ -332,35 +336,105 @@ public class DecoratedNetwork {
|
|
|
*/
|
|
|
public float getVarianzInProductionInNetworkForHolonObjects() {
|
|
|
float average = getAverageProductionInNetworkForHolonObject();
|
|
|
- float sum = consumerList.stream().map(con -> sqared(con.getEnergySelfSupplied() - average)).reduce(0.f, Float::sum)
|
|
|
- + consumerSelfSuppliedList.stream().map(con -> sqared(con.getEnergySelfSupplied() - average)).reduce(0.f, Float::sum)
|
|
|
- + supplierList.stream().map(sup -> sqared(sup.getEnergyProducing() - average)).reduce(0.f, Float::sum);
|
|
|
+ float sum = consumerList.stream().map(con -> squared(con.getEnergySelfSupplied() - average)).reduce(0.f, Float::sum)
|
|
|
+ + consumerSelfSuppliedList.stream().map(con -> squared(con.getEnergySelfSupplied() - average)).reduce(0.f, Float::sum)
|
|
|
+ + supplierList.stream().map(sup -> squared(sup.getEnergyProducing() - average)).reduce(0.f, Float::sum);
|
|
|
return sum / (float) getAmountOfHolonObjects();
|
|
|
}
|
|
|
|
|
|
|
|
|
- public float getDispersionInProductionInNetworkForHolonObjects() {
|
|
|
+ public float getDiviationInProductionInNetworkForHolonObjects() {
|
|
|
return (float)Math.sqrt(getVarianzInProductionInNetworkForHolonObjects());
|
|
|
}
|
|
|
|
|
|
|
|
|
public float getVarianzInConsumptionInNetworkForHolonObjects() {
|
|
|
float average = getAverageConsumptionInNetworkForHolonObject();
|
|
|
- float sum = consumerList.stream().map(con -> sqared(con.getEnergyFromConsumingElemnets() - average)).reduce(0.f, Float::sum)
|
|
|
- + consumerSelfSuppliedList.stream().map(con -> sqared(con.getEnergyFromConsumingElemnets() - average)).reduce(0.f, Float::sum)
|
|
|
- + supplierList.stream().map(sup -> sqared(sup.getEnergySelfConsuming() - average)).reduce(0.f, Float::sum);
|
|
|
+ float sum = consumerList.stream().map(con -> squared(con.getEnergyFromConsumingElemnets() - average)).reduce(0.f, Float::sum)
|
|
|
+ + consumerSelfSuppliedList.stream().map(con -> squared(con.getEnergyFromConsumingElemnets() - average)).reduce(0.f, Float::sum)
|
|
|
+ + supplierList.stream().map(sup -> squared(sup.getEnergySelfConsuming() - average)).reduce(0.f, Float::sum);
|
|
|
return sum / (float) getAmountOfHolonObjects();
|
|
|
}
|
|
|
|
|
|
- public float getDispersionInConsumptionInNetworkForHolonObjects() {
|
|
|
+ public float getDiviationInConsumptionInNetworkForHolonObjects() {
|
|
|
return (float)Math.sqrt(getVarianzInConsumptionInNetworkForHolonObjects());
|
|
|
}
|
|
|
|
|
|
+ //HelperFunction
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @return a list of energy
|
|
|
+ */
|
|
|
+ public List<Float> getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork() {
|
|
|
+ List<HolonElement> eleList = consumerList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList());
|
|
|
+ eleList.addAll(consumerSelfSuppliedList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList()));
|
|
|
+ eleList.addAll(supplierList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList()));
|
|
|
+ eleList.addAll(passivNoEnergyList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList()));
|
|
|
+ return eleList.stream().filter(ele -> (ele.flexList.stream().anyMatch(flex -> flex.offered && flex.fulfillsConstrains())) ).map(ele -> -ele.getEnergyAtTimeStep(timestep) ).collect(Collectors.toList()) ;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Float> getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork(){
|
|
|
+ return getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork().stream().filter(value -> (value > 0.f)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ public List<Float> getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork(){
|
|
|
+ return getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork().stream().filter(value -> (value < 0.f)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ public float getFlexibilityProductionCapacity() {
|
|
|
+ return getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().stream().reduce(0.f, Float::sum);
|
|
|
+ }
|
|
|
+ public float getFlexibilityConsumptionCapacity() {
|
|
|
+ return getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().stream().reduce(0.f, Float::sum);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public int getAmountOfProductionFlexibilities() {
|
|
|
+ return getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().size();
|
|
|
+ }
|
|
|
+ public int getAmountOfConsumptionFlexibilities() {
|
|
|
+ return getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().size();
|
|
|
+ }
|
|
|
+
|
|
|
+ public float getAverageFlexibilityProduction() {
|
|
|
+ int amount = getAmountOfProductionFlexibilities();
|
|
|
+ return (amount > 0)? getFlexibilityProductionCapacity() / (float)amount : 0.f;
|
|
|
+ }
|
|
|
+
|
|
|
+ public float getAverageFlexibilityConsumption() {
|
|
|
+ int amount = getAmountOfConsumptionFlexibilities();
|
|
|
+ return (amount > 0)? getFlexibilityConsumptionCapacity() / (float)amount : 0.f;
|
|
|
+ }
|
|
|
+
|
|
|
+ public float getVarianzInFlexibilitieConsumption() {
|
|
|
+ float average = getAverageFlexibilityConsumption();
|
|
|
+ float sum = getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().stream().map(energy -> squared(energy - average)).reduce(0.f, Float::sum);
|
|
|
+ int amountOfFlexibilities = getAmountOfConsumptionFlexibilities();
|
|
|
+ return (amountOfFlexibilities > 0)? sum / (float) amountOfFlexibilities : 0.f;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public float getVarianzInFlexibilitieProduction() {
|
|
|
+ float average = getAverageFlexibilityProduction();
|
|
|
+ float sum = getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().stream().map(energy -> squared(energy - average)).reduce(0.f, Float::sum);
|
|
|
+ int amountOfFlexibilities = getAmountOfProductionFlexibilities();
|
|
|
+ return (amountOfFlexibilities > 0)? sum / (float) amountOfFlexibilities : 0.f;
|
|
|
+ }
|
|
|
+
|
|
|
+ public float getDiviationInFlexibilityConsumption() {
|
|
|
+ return (float) Math.sqrt(getVarianzInFlexibilitieConsumption());
|
|
|
+ }
|
|
|
+ public float getDiviationInFlexibilityProduction() {
|
|
|
+ return (float) Math.sqrt(getVarianzInFlexibilitieProduction());
|
|
|
+ }
|
|
|
+
|
|
|
//Help Function
|
|
|
- private float sqared(float input) {
|
|
|
+ private float squared(float input) {
|
|
|
return (float) Math.pow(input, 2);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|