|
@@ -1,9 +1,7 @@
|
|
package ui.model;
|
|
package ui.model;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
-import java.util.List;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
|
|
+import java.util.stream.Stream;
|
|
import model.HolonElement;
|
|
import model.HolonElement;
|
|
import model.HolonObject;
|
|
import model.HolonObject;
|
|
import ui.model.DecoratedCable.CableState;
|
|
import ui.model.DecoratedCable.CableState;
|
|
@@ -17,219 +15,224 @@ public class DecoratedNetwork {
|
|
private ArrayList<Passiv> passivNoEnergyList = new ArrayList<Passiv>();
|
|
private ArrayList<Passiv> passivNoEnergyList = new ArrayList<Passiv>();
|
|
private ArrayList<DecoratedCable> decoratedCableList = new ArrayList<DecoratedCable>();
|
|
private ArrayList<DecoratedCable> decoratedCableList = new ArrayList<DecoratedCable>();
|
|
|
|
|
|
- public DecoratedNetwork(MinimumNetwork minimumNetwork, int Iteration, FairnessModel actualFairnessModel){
|
|
|
|
- switch(actualFairnessModel) {
|
|
|
|
|
|
+ public DecoratedNetwork(MinimumNetwork minimumNetwork, int Iteration, FairnessModel actualFairnessModel) {
|
|
|
|
+ switch (actualFairnessModel) {
|
|
case AllEqual:
|
|
case AllEqual:
|
|
calculateAllEqualNetwork(minimumNetwork, Iteration);
|
|
calculateAllEqualNetwork(minimumNetwork, Iteration);
|
|
break;
|
|
break;
|
|
case MininumDemandFirst:
|
|
case MininumDemandFirst:
|
|
default:
|
|
default:
|
|
calculateMinimumDemandFirstNetwork(minimumNetwork, Iteration);
|
|
calculateMinimumDemandFirstNetwork(minimumNetwork, Iteration);
|
|
- break;
|
|
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- //Getter:
|
|
|
|
|
|
+ // Getter:
|
|
public ArrayList<Supplier> getSupplierList() {
|
|
public ArrayList<Supplier> getSupplierList() {
|
|
return supplierList;
|
|
return supplierList;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
public ArrayList<Consumer> getConsumerList() {
|
|
public ArrayList<Consumer> getConsumerList() {
|
|
return consumerList;
|
|
return consumerList;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
public ArrayList<Consumer> getConsumerSelfSuppliedList() {
|
|
public ArrayList<Consumer> getConsumerSelfSuppliedList() {
|
|
return consumerSelfSuppliedList;
|
|
return consumerSelfSuppliedList;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
public ArrayList<Passiv> getPassivNoEnergyList() {
|
|
public ArrayList<Passiv> getPassivNoEnergyList() {
|
|
return passivNoEnergyList;
|
|
return passivNoEnergyList;
|
|
}
|
|
}
|
|
- public ArrayList<DecoratedCable> getDecoratedCableList(){
|
|
|
|
|
|
+
|
|
|
|
+ public ArrayList<DecoratedCable> getDecoratedCableList() {
|
|
return decoratedCableList;
|
|
return decoratedCableList;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
- //Calculations:
|
|
|
|
|
|
+
|
|
|
|
+ // Calculations:
|
|
private void calculateMinimumDemandFirstNetwork(MinimumNetwork minimumNetwork, int Iteration) {
|
|
private void calculateMinimumDemandFirstNetwork(MinimumNetwork minimumNetwork, int Iteration) {
|
|
categorize(minimumNetwork, Iteration);
|
|
categorize(minimumNetwork, Iteration);
|
|
- //Sort SupplierList according to the EnergyToSupplyNetwork maximum first.
|
|
|
|
- //Sort ConsumerList according to the MinimumConsumingElementEnergy minimum first.
|
|
|
|
- supplierList.sort((Supplier lhs,Supplier rhs) -> -Float.compare(lhs.getEnergyToSupplyNetwork(), rhs.getEnergyToSupplyNetwork()));
|
|
|
|
- consumerList.sort((Consumer lhs,Consumer rhs) -> Float.compare(lhs.getMinimumConsumingElementEnergy() , rhs.getMinimumConsumingElementEnergy()));
|
|
|
|
- //consumerList.forEach((con) -> System.out.println(con.getMinimumConsumingElementEnergy()));
|
|
|
|
- //consumerList.forEach((con) -> System.out.println("AfterSorting" + con));
|
|
|
|
- float energyToSupplyInTheNetwork = supplierList.stream().map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied()).reduce( 0.0f, (a, b) -> a + b);
|
|
|
|
|
|
+ // Sort SupplierList according to the EnergyToSupplyNetwork maximum first.
|
|
|
|
+ // Sort ConsumerList according to the MinimumConsumingElementEnergy minimum
|
|
|
|
+ // first.
|
|
|
|
+ supplierList.sort((Supplier lhs,
|
|
|
|
+ Supplier rhs) -> -Float.compare(lhs.getEnergyToSupplyNetwork(), rhs.getEnergyToSupplyNetwork()));
|
|
|
|
+ consumerList.sort((Consumer lhs, Consumer rhs) -> Float.compare(lhs.getMinimumConsumingElementEnergy(),
|
|
|
|
+ rhs.getMinimumConsumingElementEnergy()));
|
|
|
|
+ // consumerList.forEach((con) ->
|
|
|
|
+ // System.out.println(con.getMinimumConsumingElementEnergy()));
|
|
|
|
+ // consumerList.forEach((con) -> System.out.println("AfterSorting" + con));
|
|
|
|
+ float energyToSupplyInTheNetwork = supplierList.stream()
|
|
|
|
+ .map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied())
|
|
|
|
+ .reduce(0.0f, (a, b) -> a + b);
|
|
decorateCable(minimumNetwork, energyToSupplyInTheNetwork);
|
|
decorateCable(minimumNetwork, energyToSupplyInTheNetwork);
|
|
-
|
|
|
|
- outerLoop:
|
|
|
|
- for(Consumer con : consumerList)
|
|
|
|
- {
|
|
|
|
- //gehe Supplier list durch wer ihn supplien kann.
|
|
|
|
- for(Supplier sup : supplierList) {
|
|
|
|
- float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
- if(energyRdyToSupply == 0.0f) continue;
|
|
|
|
- float energyNeededForMinimumConsumingElement=con.getMinimumConsumingElementEnergy()-con.getEnergyFromNetwork();
|
|
|
|
- if(energyNeededForMinimumConsumingElement>energyToSupplyInTheNetwork) {
|
|
|
|
- //Dont supply a minimumElement when you cant supply it fully
|
|
|
|
- break outerLoop;
|
|
|
|
- }
|
|
|
|
- if(energyRdyToSupply>=energyNeededForMinimumConsumingElement) {
|
|
|
|
- energyToSupplyInTheNetwork -= energyNeededForMinimumConsumingElement;
|
|
|
|
- supply(con, sup, energyNeededForMinimumConsumingElement);
|
|
|
|
|
|
+
|
|
|
|
+ outerLoop: for (Consumer con : consumerList) {
|
|
|
|
+ // gehe Supplier list durch wer ihn supplien kann.
|
|
|
|
+ for (Supplier sup : supplierList) {
|
|
|
|
+ float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
+ if (energyRdyToSupply == 0.0f)
|
|
|
|
+ continue;
|
|
|
|
+ float energyNeededForMinimumConsumingElement = con.getMinimumConsumingElementEnergy()
|
|
|
|
+ - con.getEnergyFromNetwork();
|
|
|
|
+ if (energyNeededForMinimumConsumingElement > energyToSupplyInTheNetwork) {
|
|
|
|
+ // Dont supply a minimumElement when you cant supply it fully
|
|
|
|
+ break outerLoop;
|
|
|
|
+ }
|
|
|
|
+ if (energyRdyToSupply >= energyNeededForMinimumConsumingElement) {
|
|
|
|
+ energyToSupplyInTheNetwork -= energyNeededForMinimumConsumingElement;
|
|
|
|
+ supply(con, sup, energyNeededForMinimumConsumingElement);
|
|
|
|
+ continue outerLoop;
|
|
|
|
+ } else {
|
|
|
|
+ energyToSupplyInTheNetwork -= energyRdyToSupply;
|
|
|
|
+ supply(con, sup, energyRdyToSupply);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // No more Energy in the network
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ // consumerList.forEach((con) -> System.out.println("AfterSuppliing
|
|
|
|
+ // MinimumDemand " + con));
|
|
|
|
+
|
|
|
|
+ // Sort ConsumerList according to the EnergyNeeded to supply fully after minimum
|
|
|
|
+ // Demand First.
|
|
|
|
+ consumerList.sort((Consumer lhs, Consumer rhs) -> Float.compare(
|
|
|
|
+ lhs.getEnergyNeededFromNetwork() - lhs.getEnergyFromNetwork(),
|
|
|
|
+ rhs.getEnergyNeededFromNetwork() - rhs.getEnergyFromNetwork()));
|
|
|
|
+ // Supply consumer fully
|
|
|
|
+ outerLoop: for (Consumer con : consumerList) {
|
|
|
|
+ // gehe Supplier list durch wer ihn supplien kann.
|
|
|
|
+ for (Supplier sup : supplierList) {
|
|
|
|
+ float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
+ if (energyRdyToSupply == 0.0f)
|
|
|
|
+ continue;
|
|
|
|
+ float energyNeededForFullySupply = con.getEnergyNeededFromNetwork() - con.getEnergyFromNetwork();
|
|
|
|
+ if (energyNeededForFullySupply == 0.0f)
|
|
|
|
+ continue outerLoop;
|
|
|
|
+ if (energyRdyToSupply >= energyNeededForFullySupply) {
|
|
|
|
+ supply(con, sup, energyNeededForFullySupply);
|
|
|
|
+ continue outerLoop;
|
|
|
|
+ } else {
|
|
|
|
+ supply(con, sup, energyRdyToSupply);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // No more Energy in the network
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ // consumerList.forEach((con) -> System.out.println("AfterFullySuplieing" +
|
|
|
|
+ // con));
|
|
|
|
+ // If Energy Left Supply all equal
|
|
|
|
+ // Count EnergyLeft
|
|
|
|
+ float energyLeft = supplierList.stream()
|
|
|
|
+ .map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied())
|
|
|
|
+ .reduce(0.0f, (a, b) -> a + b);
|
|
|
|
+ // System.out.println("EnergyLeft: " + energyLeft);
|
|
|
|
+ if (energyLeft > 0.0f && (consumerList.size() + consumerSelfSuppliedList.size() != 0)) {
|
|
|
|
+ float equalAmountOfEnergyToSupply = energyLeft
|
|
|
|
+ / ((float) (consumerList.size() + consumerSelfSuppliedList.size()));
|
|
|
|
+ outerLoop: for (Consumer con : consumerList) {
|
|
|
|
+ // gehe Supplier list durch wer ihn supplien kann.
|
|
|
|
+ for (Supplier sup : supplierList) {
|
|
|
|
+ float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
+ if (energyRdyToSupply == 0.0f)
|
|
|
|
+ continue;
|
|
|
|
+ float energyNeededToSupplyConsumerTheEqualAmount = equalAmountOfEnergyToSupply
|
|
|
|
+ + con.getEnergyNeededFromNetwork() - con.getEnergyFromNetwork();
|
|
|
|
+ if (energyRdyToSupply >= energyNeededToSupplyConsumerTheEqualAmount) {
|
|
|
|
+ supply(con, sup, energyNeededToSupplyConsumerTheEqualAmount);
|
|
continue outerLoop;
|
|
continue outerLoop;
|
|
- }else
|
|
|
|
- {
|
|
|
|
- energyToSupplyInTheNetwork -= energyRdyToSupply;
|
|
|
|
|
|
+ } else {
|
|
supply(con, sup, energyRdyToSupply);
|
|
supply(con, sup, energyRdyToSupply);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //No more Energy in the network
|
|
|
|
|
|
+ // No more Energy in the network
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- //consumerList.forEach((con) -> System.out.println("AfterSuppliing MinimumDemand " + con));
|
|
|
|
-
|
|
|
|
- //Sort ConsumerList according to the EnergyNeeded to supply fully after minimum Demand First.
|
|
|
|
- consumerList.sort((Consumer lhs,Consumer rhs) -> Float.compare(lhs.getEnergyNeededFromNetwork()-lhs.getEnergyFromNetwork() , rhs.getEnergyNeededFromNetwork()-rhs.getEnergyFromNetwork() ));
|
|
|
|
- //Supply consumer fully
|
|
|
|
- outerLoop:
|
|
|
|
- for(Consumer con : consumerList)
|
|
|
|
- {
|
|
|
|
- //gehe Supplier list durch wer ihn supplien kann.
|
|
|
|
- for(Supplier sup : supplierList) {
|
|
|
|
- float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
- if(energyRdyToSupply == 0.0f) continue;
|
|
|
|
- float energyNeededForFullySupply = con.getEnergyNeededFromNetwork() - con.getEnergyFromNetwork();
|
|
|
|
- if(energyNeededForFullySupply == 0.0f) continue outerLoop;
|
|
|
|
- if(energyRdyToSupply>=energyNeededForFullySupply) {
|
|
|
|
- supply(con, sup, energyNeededForFullySupply);
|
|
|
|
|
|
+ outerLoop: for (Consumer con : consumerSelfSuppliedList) {
|
|
|
|
+ // gehe Supplier list durch wer ihn supplien kann.
|
|
|
|
+ for (Supplier sup : supplierList) {
|
|
|
|
+ float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
+ if (energyRdyToSupply == 0.0f)
|
|
|
|
+ continue;
|
|
|
|
+ float energyNeededToSupplyConsumerTheEqualAmount = equalAmountOfEnergyToSupply
|
|
|
|
+ + con.getEnergyNeededFromNetwork() - con.getEnergyFromNetwork();
|
|
|
|
+ if (energyRdyToSupply >= energyNeededToSupplyConsumerTheEqualAmount) {
|
|
|
|
+ supply(con, sup, energyNeededToSupplyConsumerTheEqualAmount);
|
|
continue outerLoop;
|
|
continue outerLoop;
|
|
- }else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
supply(con, sup, energyRdyToSupply);
|
|
supply(con, sup, energyRdyToSupply);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
- //No more Energy in the network
|
|
|
|
|
|
+ // No more Energy in the network
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- //consumerList.forEach((con) -> System.out.println("AfterFullySuplieing" + con));
|
|
|
|
- //If Energy Left Supply all equal
|
|
|
|
- //Count EnergyLeft
|
|
|
|
- float energyLeft = supplierList.stream().map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied()).reduce( 0.0f, (a, b) -> a + b);
|
|
|
|
- //System.out.println("EnergyLeft: " + energyLeft);
|
|
|
|
- if(energyLeft > 0.0f && (consumerList.size() + consumerSelfSuppliedList.size() != 0))
|
|
|
|
- {
|
|
|
|
- float equalAmountOfEnergyToSupply = energyLeft / ((float)(consumerList.size() + consumerSelfSuppliedList.size()));
|
|
|
|
- outerLoop:
|
|
|
|
- for(Consumer con : consumerList)
|
|
|
|
- {
|
|
|
|
- //gehe Supplier list durch wer ihn supplien kann.
|
|
|
|
- for(Supplier sup : supplierList) {
|
|
|
|
- float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
- if(energyRdyToSupply == 0.0f) continue;
|
|
|
|
- float energyNeededToSupplyConsumerTheEqualAmount = equalAmountOfEnergyToSupply +con.getEnergyNeededFromNetwork()- con.getEnergyFromNetwork();
|
|
|
|
- if(energyRdyToSupply>=energyNeededToSupplyConsumerTheEqualAmount) {
|
|
|
|
- supply(con, sup, energyNeededToSupplyConsumerTheEqualAmount);
|
|
|
|
- continue outerLoop;
|
|
|
|
- }else
|
|
|
|
- {
|
|
|
|
- supply(con, sup, energyRdyToSupply);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //No more Energy in the network
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- outerLoop:
|
|
|
|
- for(Consumer con : consumerSelfSuppliedList)
|
|
|
|
- {
|
|
|
|
- //gehe Supplier list durch wer ihn supplien kann.
|
|
|
|
- for(Supplier sup : supplierList) {
|
|
|
|
- float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
- if(energyRdyToSupply == 0.0f) continue;
|
|
|
|
- float energyNeededToSupplyConsumerTheEqualAmount = equalAmountOfEnergyToSupply +con.getEnergyNeededFromNetwork()- con.getEnergyFromNetwork();
|
|
|
|
- if(energyRdyToSupply>=energyNeededToSupplyConsumerTheEqualAmount) {
|
|
|
|
- supply(con, sup, energyNeededToSupplyConsumerTheEqualAmount);
|
|
|
|
- continue outerLoop;
|
|
|
|
- }else
|
|
|
|
- {
|
|
|
|
- supply(con, sup, energyRdyToSupply);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- //No more Energy in the network
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- //consumerList.forEach((con) -> System.out.println("AfterOverSuppleiing" + con));
|
|
|
|
-
|
|
|
|
- //consumerSelfSuppliedList.forEach((con) -> System.out.println("AfterOverSuppleiing" + con));
|
|
|
|
-
|
|
|
|
|
|
+ // consumerList.forEach((con) -> System.out.println("AfterOverSuppleiing" +
|
|
|
|
+ // con));
|
|
|
|
+
|
|
|
|
+ // consumerSelfSuppliedList.forEach((con) ->
|
|
|
|
+ // System.out.println("AfterOverSuppleiing" + con));
|
|
|
|
+
|
|
calculateStates();
|
|
calculateStates();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private void decorateCable(MinimumNetwork minimumNetwork, float energyToSupplyInTheNetwork) {
|
|
private void decorateCable(MinimumNetwork minimumNetwork, float energyToSupplyInTheNetwork) {
|
|
- //DecoratedCables
|
|
|
|
- //Minimum demand first:
|
|
|
|
- for(IntermediateCableWithState edge: minimumNetwork.getEdgeList()) {
|
|
|
|
- decoratedCableList.add(new DecoratedCable(edge.getModel(), edge.getState(), (edge.getState() == CableState.Working) ? energyToSupplyInTheNetwork : 0.0f));
|
|
|
|
|
|
+ // DecoratedCables
|
|
|
|
+ // Minimum demand first:
|
|
|
|
+ for (IntermediateCableWithState edge : minimumNetwork.getEdgeList()) {
|
|
|
|
+ decoratedCableList.add(new DecoratedCable(edge.getModel(), edge.getState(),
|
|
|
|
+ (edge.getState() == CableState.Working) ? energyToSupplyInTheNetwork : 0.0f));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
private void calculateAllEqualNetwork(MinimumNetwork minimumNetwork, int Iteration) {
|
|
private void calculateAllEqualNetwork(MinimumNetwork minimumNetwork, int Iteration) {
|
|
categorize(minimumNetwork, Iteration);
|
|
categorize(minimumNetwork, Iteration);
|
|
- float energyToSupplyInTheNetwork = supplierList.stream().map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied()).reduce( 0.0f, (a, b) -> a + b);
|
|
|
|
- float energyForEachConsumer = (consumerList.size() != 0) ? energyToSupplyInTheNetwork / consumerList.size() : 0.0f;
|
|
|
|
|
|
+ float energyToSupplyInTheNetwork = supplierList.stream()
|
|
|
|
+ .map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied())
|
|
|
|
+ .reduce(0.0f, (a, b) -> a + b);
|
|
|
|
+ float energyForEachConsumer = (consumerList.size() != 0) ? energyToSupplyInTheNetwork / consumerList.size()
|
|
|
|
+ : 0.0f;
|
|
decorateCable(minimumNetwork, energyToSupplyInTheNetwork);
|
|
decorateCable(minimumNetwork, energyToSupplyInTheNetwork);
|
|
- //Supply consumer equal
|
|
|
|
- outerLoop:
|
|
|
|
- for(Consumer con : consumerList)
|
|
|
|
- {
|
|
|
|
- //gehe Supplier list durch wer ihn supplien kann.
|
|
|
|
|
|
+ // Supply consumer equal
|
|
|
|
+ outerLoop: for (Consumer con : consumerList) {
|
|
|
|
+ // gehe Supplier list durch wer ihn supplien kann.
|
|
float energyNeededForEqualSupply = energyForEachConsumer;
|
|
float energyNeededForEqualSupply = energyForEachConsumer;
|
|
- for(Supplier sup : supplierList) {
|
|
|
|
- float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
- if(energyRdyToSupply == 0.0f) continue;
|
|
|
|
- if(energyRdyToSupply>=energyNeededForEqualSupply) {
|
|
|
|
|
|
+ for (Supplier sup : supplierList) {
|
|
|
|
+ float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
|
|
|
|
+ if (energyRdyToSupply == 0.0f)
|
|
|
|
+ continue;
|
|
|
|
+ if (energyRdyToSupply >= energyNeededForEqualSupply) {
|
|
supply(con, sup, energyNeededForEqualSupply);
|
|
supply(con, sup, energyNeededForEqualSupply);
|
|
continue outerLoop;
|
|
continue outerLoop;
|
|
- }else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
supply(con, sup, energyRdyToSupply);
|
|
supply(con, sup, energyRdyToSupply);
|
|
energyNeededForEqualSupply -= energyRdyToSupply;
|
|
energyNeededForEqualSupply -= energyRdyToSupply;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //No more Energy in the network
|
|
|
|
|
|
+ // No more Energy in the network
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
calculateStates();
|
|
calculateStates();
|
|
}
|
|
}
|
|
|
|
|
|
private void calculateStates() {
|
|
private void calculateStates() {
|
|
- //CalculateStates:
|
|
|
|
|
|
+ // CalculateStates:
|
|
supplierList.forEach(sup -> sup.setState(HolonObjectState.PRODUCER));
|
|
supplierList.forEach(sup -> sup.setState(HolonObjectState.PRODUCER));
|
|
passivNoEnergyList.forEach(sup -> sup.setState(HolonObjectState.NO_ENERGY));
|
|
passivNoEnergyList.forEach(sup -> sup.setState(HolonObjectState.NO_ENERGY));
|
|
- for(Consumer con : this.consumerList)
|
|
|
|
- {
|
|
|
|
|
|
+ for (Consumer con : this.consumerList) {
|
|
setConsumerState(con);
|
|
setConsumerState(con);
|
|
}
|
|
}
|
|
- for(Consumer con : this.consumerSelfSuppliedList)
|
|
|
|
- {
|
|
|
|
|
|
+ for (Consumer con : this.consumerSelfSuppliedList) {
|
|
setConsumerState(con);
|
|
setConsumerState(con);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
private void categorize(MinimumNetwork minimumNetwork, int Iteration) {
|
|
private void categorize(MinimumNetwork minimumNetwork, int Iteration) {
|
|
- //Categorize
|
|
|
|
- for(HolonObject hObject: minimumNetwork.getHolonObjectList()) {
|
|
|
|
|
|
+ // Categorize
|
|
|
|
+ for (HolonObject hObject : minimumNetwork.getHolonObjectList()) {
|
|
float energyNeeded = hObject.getEnergyNeededFromConsumingElements();
|
|
float energyNeeded = hObject.getEnergyNeededFromConsumingElements();
|
|
float energySelfProducing = hObject.getEnergySelfProducingFromProducingElements();
|
|
float energySelfProducing = hObject.getEnergySelfProducingFromProducingElements();
|
|
- if(energyNeeded < energySelfProducing) {
|
|
|
|
|
|
+ if (energyNeeded < energySelfProducing) {
|
|
Supplier sup = new Supplier(hObject, energySelfProducing - energyNeeded, energyNeeded);
|
|
Supplier sup = new Supplier(hObject, energySelfProducing - energyNeeded, energyNeeded);
|
|
supplierList.add(sup);
|
|
supplierList.add(sup);
|
|
} else if (energyNeeded > energySelfProducing) {
|
|
} else if (energyNeeded > energySelfProducing) {
|
|
@@ -239,8 +242,8 @@ public class DecoratedNetwork {
|
|
con.setEnergyFromConsumingElemnets(hObject.getEnergyNeededFromConsumingElements());
|
|
con.setEnergyFromConsumingElemnets(hObject.getEnergyNeededFromConsumingElements());
|
|
con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElements());
|
|
con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElements());
|
|
consumerList.add(con);
|
|
consumerList.add(con);
|
|
- }else if(energyNeeded == energySelfProducing) {
|
|
|
|
-
|
|
|
|
|
|
+ } else if (energyNeeded == energySelfProducing) {
|
|
|
|
+
|
|
if (energySelfProducing == 0.0f) {
|
|
if (energySelfProducing == 0.0f) {
|
|
Passiv pas = new Passiv(hObject);
|
|
Passiv pas = new Passiv(hObject);
|
|
passivNoEnergyList.add(pas);
|
|
passivNoEnergyList.add(pas);
|
|
@@ -252,208 +255,216 @@ public class DecoratedNetwork {
|
|
con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElements());
|
|
con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElements());
|
|
consumerSelfSuppliedList.add(con);
|
|
consumerSelfSuppliedList.add(con);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
private void setConsumerState(Consumer con) {
|
|
private void setConsumerState(Consumer con) {
|
|
- if(con.getEnergySelfSupplied() + con.getEnergyFromNetwork() > con.getEnergyFromConsumingElemnets()) {
|
|
|
|
|
|
+ if (con.getEnergySelfSupplied() + con.getEnergyFromNetwork() > con.getEnergyFromConsumingElemnets()) {
|
|
con.setState(HolonObjectState.OVER_SUPPLIED);
|
|
con.setState(HolonObjectState.OVER_SUPPLIED);
|
|
- }else if(con.getEnergySelfSupplied() + con.getEnergyFromNetwork() == con.getEnergyFromConsumingElemnets()) {
|
|
|
|
|
|
+ } else if (con.getEnergySelfSupplied() + con.getEnergyFromNetwork() == con.getEnergyFromConsumingElemnets()) {
|
|
con.setState(HolonObjectState.SUPPLIED);
|
|
con.setState(HolonObjectState.SUPPLIED);
|
|
- }else if(con.getEnergySelfSupplied() + con.getEnergyFromNetwork() >= con.getMinimumConsumingElementEnergy()) {
|
|
|
|
|
|
+ } else if (con.getEnergySelfSupplied() + con.getEnergyFromNetwork() >= con.getMinimumConsumingElementEnergy()) {
|
|
con.setState(HolonObjectState.PARTIALLY_SUPPLIED);
|
|
con.setState(HolonObjectState.PARTIALLY_SUPPLIED);
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
con.setState(HolonObjectState.NOT_SUPPLIED);
|
|
con.setState(HolonObjectState.NOT_SUPPLIED);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* No Checks.
|
|
* No Checks.
|
|
|
|
+ *
|
|
* @param con
|
|
* @param con
|
|
* @param sup
|
|
* @param sup
|
|
* @param energy
|
|
* @param energy
|
|
*/
|
|
*/
|
|
private void supply(Consumer con, Supplier sup, float energy) {
|
|
private void supply(Consumer con, Supplier sup, float energy) {
|
|
- sup.getConsumerList().add(sup.new ConsumerListEntry(con , energy));
|
|
|
|
|
|
+ sup.getConsumerList().add(sup.new ConsumerListEntry(con, energy));
|
|
sup.setEnergySupplied(sup.getEnergySupplied() + energy);
|
|
sup.setEnergySupplied(sup.getEnergySupplied() + energy);
|
|
con.getSupplierList().add(con.new SupplierListEntry(sup, energy));
|
|
con.getSupplierList().add(con.new SupplierListEntry(sup, energy));
|
|
con.setEnergyFromNetwork(con.getEnergyFromNetwork() + energy);
|
|
con.setEnergyFromNetwork(con.getEnergyFromNetwork() + energy);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public int getAmountOfActiveElements() {
|
|
|
|
+
|
|
|
|
+ return supplierList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0,
|
|
|
|
+ Integer::sum)
|
|
|
|
+ + consumerList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0,
|
|
|
|
+ Integer::sum)
|
|
|
|
+ + consumerSelfSuppliedList.stream().map(object -> object.getModel().getNumberOfActiveElements())
|
|
|
|
+ .reduce(0, Integer::sum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getAmountOfElements() {
|
|
|
|
+
|
|
|
|
+ return supplierList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0, Integer::sum)
|
|
|
|
+ + consumerList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0, Integer::sum)
|
|
|
|
+ + consumerSelfSuppliedList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0,
|
|
|
|
+ Integer::sum)
|
|
|
|
+ + passivNoEnergyList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0,
|
|
|
|
+ Integer::sum);
|
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
|
- public int getAmountOfActiveElements() {
|
|
|
|
-
|
|
|
|
- return supplierList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, Integer::sum)+
|
|
|
|
- consumerList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, Integer::sum)+
|
|
|
|
- consumerSelfSuppliedList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, Integer::sum);
|
|
|
|
- }
|
|
|
|
- public int getAmountOfElements() {
|
|
|
|
-
|
|
|
|
- return supplierList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0, Integer::sum)+
|
|
|
|
- consumerList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0, Integer::sum)+
|
|
|
|
- consumerSelfSuppliedList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0, Integer::sum)+
|
|
|
|
- passivNoEnergyList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0, Integer::sum);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
public int getAmountOfConsumer() {
|
|
public int getAmountOfConsumer() {
|
|
return consumerList.size() + this.consumerSelfSuppliedList.size();
|
|
return consumerList.size() + this.consumerSelfSuppliedList.size();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
public int getAmountOfSupplier() {
|
|
public int getAmountOfSupplier() {
|
|
return supplierList.size();
|
|
return supplierList.size();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
public int getAmountOfConsumerWithState(HolonObjectState state) {
|
|
public int getAmountOfConsumerWithState(HolonObjectState state) {
|
|
- return (int) (consumerList.stream().filter(con -> con.getState() == state).count() + consumerSelfSuppliedList.stream().filter(con -> con.getState() == state).count());
|
|
|
|
|
|
+ return (int) (consumerList.stream().filter(con -> con.getState() == state).count()
|
|
|
|
+ + consumerSelfSuppliedList.stream().filter(con -> con.getState() == state).count());
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
public int getAmountOfPassiv() {
|
|
public int getAmountOfPassiv() {
|
|
return passivNoEnergyList.size();
|
|
return passivNoEnergyList.size();
|
|
}
|
|
}
|
|
|
|
+
|
|
public int getAmountOfHolonObjects() {
|
|
public int getAmountOfHolonObjects() {
|
|
return getAmountOfConsumer() + getAmountOfSupplier() + getAmountOfPassiv();
|
|
return getAmountOfConsumer() + getAmountOfSupplier() + getAmountOfPassiv();
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
public float getTotalConsumption() {
|
|
public float getTotalConsumption() {
|
|
- float energy = consumerList.stream().map(con -> con.getEnergyFromConsumingElemnets()).reduce(0.f, Float::sum) + consumerSelfSuppliedList.stream().map(con -> con.getEnergyFromConsumingElemnets()).reduce(0.f, Float::sum);
|
|
|
|
- energy += supplierList.stream().map(sup -> sup.getEnergySelfConsuming()).reduce(0.f, Float::sum);
|
|
|
|
|
|
+ float energy = consumerList.stream().map(con -> con.getEnergyFromConsumingElemnets()).reduce(0.f, Float::sum)
|
|
|
|
+ + consumerSelfSuppliedList.stream().map(con -> con.getEnergyFromConsumingElemnets()).reduce(0.f,
|
|
|
|
+ Float::sum);
|
|
|
|
+ energy += supplierList.stream().map(sup -> sup.getEnergySelfConsuming()).reduce(0.f, Float::sum);
|
|
return energy;
|
|
return energy;
|
|
}
|
|
}
|
|
-
|
|
|
|
- public float getAverageConsumptionInNetworkForHolonObject(){
|
|
|
|
- return getTotalConsumption() / (float)getAmountOfHolonObjects();
|
|
|
|
|
|
+
|
|
|
|
+ public float getAverageConsumptionInNetworkForHolonObject() {
|
|
|
|
+ return getTotalConsumption() / (float) getAmountOfHolonObjects();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getTotalProduction() {
|
|
public float getTotalProduction() {
|
|
- float energy = consumerList.stream().map(con -> con.getEnergySelfSupplied()).reduce(0.f, Float::sum) + consumerSelfSuppliedList.stream().map(con -> con.getEnergySelfSupplied()).reduce(0.f, Float::sum);
|
|
|
|
- energy += supplierList.stream().map(sup -> sup.getEnergyProducing()).reduce(0.f, Float::sum);
|
|
|
|
|
|
+ float energy = consumerList.stream().map(con -> con.getEnergySelfSupplied()).reduce(0.f, Float::sum)
|
|
|
|
+ + consumerSelfSuppliedList.stream().map(con -> con.getEnergySelfSupplied()).reduce(0.f, Float::sum);
|
|
|
|
+ energy += supplierList.stream().map(sup -> sup.getEnergyProducing()).reduce(0.f, Float::sum);
|
|
return energy;
|
|
return energy;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getAverageProductionInNetworkForHolonObject() {
|
|
public float getAverageProductionInNetworkForHolonObject() {
|
|
- return getTotalProduction() / (float) getAmountOfHolonObjects();
|
|
|
|
|
|
+ return getTotalProduction() / (float) getAmountOfHolonObjects();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* returns the Varianz in Poduction
|
|
* returns the Varianz in Poduction
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public float getVarianzInProductionInNetworkForHolonObjects() {
|
|
public float getVarianzInProductionInNetworkForHolonObjects() {
|
|
float average = getAverageProductionInNetworkForHolonObject();
|
|
float average = getAverageProductionInNetworkForHolonObject();
|
|
- 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);
|
|
|
|
|
|
+ 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();
|
|
return sum / (float) getAmountOfHolonObjects();
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
public float getDeviationInProductionInNetworkForHolonObjects() {
|
|
public float getDeviationInProductionInNetworkForHolonObjects() {
|
|
- return (float)Math.sqrt(getVarianzInProductionInNetworkForHolonObjects());
|
|
|
|
|
|
+ return (float) Math.sqrt(getVarianzInProductionInNetworkForHolonObjects());
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
public float getVarianzInConsumptionInNetworkForHolonObjects() {
|
|
public float getVarianzInConsumptionInNetworkForHolonObjects() {
|
|
float average = getAverageConsumptionInNetworkForHolonObject();
|
|
float average = getAverageConsumptionInNetworkForHolonObject();
|
|
- 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);
|
|
|
|
|
|
+ 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();
|
|
return sum / (float) getAmountOfHolonObjects();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getDeviationInConsumptionInNetworkForHolonObjects() {
|
|
public float getDeviationInConsumptionInNetworkForHolonObjects() {
|
|
- return (float)Math.sqrt(getVarianzInConsumptionInNetworkForHolonObjects());
|
|
|
|
|
|
+ return (float) Math.sqrt(getVarianzInConsumptionInNetworkForHolonObjects());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // HelperFunction
|
|
|
|
+
|
|
|
|
+ public Stream<HolonElement> getElementStream() {
|
|
|
|
+ return Stream.concat(consumerList.stream().flatMap(con -> con.getModel().getElements().stream()),
|
|
|
|
+ Stream.concat(consumerSelfSuppliedList.stream().flatMap(con -> con.getModel().getElements().stream()),
|
|
|
|
+ Stream.concat(supplierList.stream().flatMap(con -> con.getModel().getElements().stream()),
|
|
|
|
+ passivNoEnergyList.stream().flatMap(con -> con.getModel().getElements().stream()))));
|
|
}
|
|
}
|
|
-
|
|
|
|
- //HelperFunction
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
* @return a list of energy
|
|
* @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)) ).map(ele -> -ele.getActualEnergy() ).collect(Collectors.toList()) ;
|
|
|
|
|
|
+ public Stream<Float> getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork() {
|
|
|
|
+ return getElementStream()
|
|
|
|
+ .filter(ele -> (ele.flexList.stream().anyMatch(flex -> flex.offered)))
|
|
|
|
+ .map(ele -> -ele.getActualEnergy());
|
|
}
|
|
}
|
|
-
|
|
|
|
- public List<Float> getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork(){
|
|
|
|
- return getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork().stream().filter(value -> (value > 0.f)).collect(Collectors.toList());
|
|
|
|
|
|
+
|
|
|
|
+ public Stream<Float> getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork() {
|
|
|
|
+ return getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork().filter(value -> (value > 0.f));
|
|
}
|
|
}
|
|
- public List<Float> getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork(){
|
|
|
|
- return getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork().stream().filter(value -> (value < 0.f)).map(value -> -value).collect(Collectors.toList());
|
|
|
|
|
|
+
|
|
|
|
+ public Stream<Float> getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork() {
|
|
|
|
+ return getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork().filter(value -> (value < 0.f))
|
|
|
|
+ .map(value -> -value);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getFlexibilityProductionCapacity() {
|
|
public float getFlexibilityProductionCapacity() {
|
|
- return getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().stream().reduce(0.f, Float::sum);
|
|
|
|
|
|
+ return getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().reduce(0.f, Float::sum);
|
|
}
|
|
}
|
|
|
|
+
|
|
public float getFlexibilityConsumptionCapacity() {
|
|
public float getFlexibilityConsumptionCapacity() {
|
|
- return getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().stream().reduce(0.f, Float::sum);
|
|
|
|
|
|
+ return getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().reduce(0.f, Float::sum);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
public int getAmountOfProductionFlexibilities() {
|
|
public int getAmountOfProductionFlexibilities() {
|
|
- return getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().size();
|
|
|
|
|
|
+ return (int)getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().count();
|
|
}
|
|
}
|
|
|
|
+
|
|
public int getAmountOfConsumptionFlexibilities() {
|
|
public int getAmountOfConsumptionFlexibilities() {
|
|
- return getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().size();
|
|
|
|
|
|
+ return (int)getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().count();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getAverageFlexibilityProduction() {
|
|
public float getAverageFlexibilityProduction() {
|
|
int amount = getAmountOfProductionFlexibilities();
|
|
int amount = getAmountOfProductionFlexibilities();
|
|
- return (amount > 0)? getFlexibilityProductionCapacity() / (float)amount : 0.f;
|
|
|
|
|
|
+ return (amount > 0) ? getFlexibilityProductionCapacity() / (float) amount : 0.f;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getAverageFlexibilityConsumption() {
|
|
public float getAverageFlexibilityConsumption() {
|
|
int amount = getAmountOfConsumptionFlexibilities();
|
|
int amount = getAmountOfConsumptionFlexibilities();
|
|
- return (amount > 0)? getFlexibilityConsumptionCapacity() / (float)amount : 0.f;
|
|
|
|
|
|
+ return (amount > 0) ? getFlexibilityConsumptionCapacity() / (float) amount : 0.f;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getVarianzInFlexibilitieConsumption() {
|
|
public float getVarianzInFlexibilitieConsumption() {
|
|
float average = getAverageFlexibilityConsumption();
|
|
float average = getAverageFlexibilityConsumption();
|
|
- float sum = getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().stream().map(energy -> squared(energy - average)).reduce(0.f, Float::sum);
|
|
|
|
|
|
+ float sum = getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork()
|
|
|
|
+ .map(energy -> squared(energy - average)).reduce(0.f, Float::sum);
|
|
int amountOfFlexibilities = getAmountOfConsumptionFlexibilities();
|
|
int amountOfFlexibilities = getAmountOfConsumptionFlexibilities();
|
|
- return (amountOfFlexibilities > 0)? sum / (float) amountOfFlexibilities : 0.f;
|
|
|
|
|
|
+ return (amountOfFlexibilities > 0) ? sum / (float) amountOfFlexibilities : 0.f;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
public float getVarianzInFlexibilitieProduction() {
|
|
public float getVarianzInFlexibilitieProduction() {
|
|
float average = getAverageFlexibilityProduction();
|
|
float average = getAverageFlexibilityProduction();
|
|
- float sum = getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().stream().map(energy -> squared(energy - average)).reduce(0.f, Float::sum);
|
|
|
|
|
|
+ float sum = getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork()
|
|
|
|
+ .map(energy -> squared(energy - average)).reduce(0.f, Float::sum);
|
|
int amountOfFlexibilities = getAmountOfProductionFlexibilities();
|
|
int amountOfFlexibilities = getAmountOfProductionFlexibilities();
|
|
- return (amountOfFlexibilities > 0)? sum / (float) amountOfFlexibilities : 0.f;
|
|
|
|
|
|
+ return (amountOfFlexibilities > 0) ? sum / (float) amountOfFlexibilities : 0.f;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public float getDiviationInFlexibilityConsumption() {
|
|
public float getDiviationInFlexibilityConsumption() {
|
|
return (float) Math.sqrt(getVarianzInFlexibilitieConsumption());
|
|
return (float) Math.sqrt(getVarianzInFlexibilitieConsumption());
|
|
}
|
|
}
|
|
|
|
+
|
|
public float getDiviationInFlexibilityProduction() {
|
|
public float getDiviationInFlexibilityProduction() {
|
|
return (float) Math.sqrt(getVarianzInFlexibilitieProduction());
|
|
return (float) Math.sqrt(getVarianzInFlexibilitieProduction());
|
|
}
|
|
}
|
|
-
|
|
|
|
- //Help Function
|
|
|
|
|
|
+
|
|
|
|
+ // Help Function
|
|
private float squared(float input) {
|
|
private float squared(float input) {
|
|
return (float) Math.pow(input, 2);
|
|
return (float) Math.pow(input, 2);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|