DecoratedNetwork.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. package ui.model;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.stream.Collectors;
  5. import classes.HolonElement;
  6. import classes.HolonObject;
  7. import holeg.HolegGateway;
  8. import holeg.HolegPowerFlowContext;
  9. import holeg.PowerFlowSettings;
  10. import ui.controller.FlexManager;
  11. import ui.model.DecoratedCable.CableState;
  12. import ui.model.DecoratedHolonObject.HolonObjectState;
  13. import ui.model.Model.FairnessModel;
  14. public class DecoratedNetwork {
  15. private ArrayList<Supplier> supplierList = new ArrayList<Supplier>();
  16. private ArrayList<Consumer> consumerList = new ArrayList<Consumer>();
  17. private ArrayList<Consumer> consumerSelfSuppliedList = new ArrayList<Consumer>();
  18. private ArrayList<Passiv> passivNoEnergyList = new ArrayList<Passiv>();
  19. private ArrayList<DecoratedCable> decoratedCableList = new ArrayList<DecoratedCable>();
  20. private int timestep;
  21. private Object lockObject = new Object();
  22. public DecoratedNetwork(PowerFlowSettings settings, MinimumNetwork minimumNetwork, int Iteration, FairnessModel actualFairnessModel, FlexManager flexManager){
  23. this.timestep = Iteration;
  24. switch(actualFairnessModel) {
  25. case AllEqual:
  26. calculateAllEqualNetwork(minimumNetwork, Iteration, flexManager);
  27. break;
  28. case MininumDemandFirst:
  29. calculateMinimumDemandFirstNetwork(minimumNetwork, Iteration, flexManager);
  30. break;
  31. case PowerFlowAnalysis:
  32. HolegGateway.solve(settings, minimumNetwork, Iteration, flexManager, this);
  33. break;
  34. }
  35. }
  36. public void clear() {
  37. supplierList.clear();
  38. consumerList.clear();
  39. consumerSelfSuppliedList.clear();
  40. passivNoEnergyList.clear();
  41. decoratedCableList.clear();
  42. }
  43. //Getter:
  44. public Object getLockObject() {
  45. return lockObject;
  46. }
  47. public ArrayList<Supplier> getSupplierList() {
  48. return supplierList;
  49. }
  50. public ArrayList<Consumer> getConsumerList() {
  51. return consumerList;
  52. }
  53. public ArrayList<Consumer> getConsumerSelfSuppliedList() {
  54. return consumerSelfSuppliedList;
  55. }
  56. public ArrayList<Passiv> getPassivNoEnergyList() {
  57. return passivNoEnergyList;
  58. }
  59. public ArrayList<DecoratedCable> getDecoratedCableList(){
  60. return decoratedCableList;
  61. }
  62. //Calculations:
  63. private void calculateMinimumDemandFirstNetwork(MinimumNetwork minimumNetwork, int Iteration, FlexManager flexManager) {
  64. categorize(minimumNetwork, Iteration, flexManager);
  65. //Sort SupplierList according to the EnergyToSupplyNetwork maximum first.
  66. //Sort ConsumerList according to the MinimumConsumingElementEnergy minimum first.
  67. supplierList.sort((Supplier lhs,Supplier rhs) -> -Float.compare(lhs.getEnergyToSupplyNetwork(), rhs.getEnergyToSupplyNetwork()));
  68. consumerList.sort((Consumer lhs,Consumer rhs) -> Float.compare(lhs.getMinimumConsumingElementEnergy() , rhs.getMinimumConsumingElementEnergy()));
  69. //consumerList.forEach((con) -> System.out.println(con.getMinimumConsumingElementEnergy()));
  70. //consumerList.forEach((con) -> System.out.println("AfterSorting" + con));
  71. float energyToSupplyInTheNetwork = supplierList.stream().map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied()).reduce( 0.0f, (a, b) -> a + b);
  72. decorateCable(minimumNetwork, energyToSupplyInTheNetwork);
  73. outerLoop:
  74. for(Consumer con : consumerList)
  75. {
  76. //gehe Supplier list durch wer ihn supplien kann.
  77. for(Supplier sup : supplierList) {
  78. float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
  79. if(energyRdyToSupply == 0.0f) continue;
  80. float energyNeededForMinimumConsumingElement=con.getMinimumConsumingElementEnergy()-con.getEnergyFromNetwork();
  81. if(energyNeededForMinimumConsumingElement>energyToSupplyInTheNetwork) {
  82. //Dont supply a minimumElement when you cant supply it fully
  83. break outerLoop;
  84. }
  85. if(energyRdyToSupply>=energyNeededForMinimumConsumingElement) {
  86. energyToSupplyInTheNetwork -= energyNeededForMinimumConsumingElement;
  87. supply(con, sup, energyNeededForMinimumConsumingElement);
  88. continue outerLoop;
  89. }else
  90. {
  91. energyToSupplyInTheNetwork -= energyRdyToSupply;
  92. supply(con, sup, energyRdyToSupply);
  93. }
  94. }
  95. //No more Energy in the network
  96. break;
  97. }
  98. //consumerList.forEach((con) -> System.out.println("AfterSuppliing MinimumDemand " + con));
  99. //Sort ConsumerList according to the EnergyNeeded to supply fully after minimum Demand First.
  100. consumerList.sort((Consumer lhs,Consumer rhs) -> Float.compare(lhs.getEnergyNeededFromNetwork()-lhs.getEnergyFromNetwork() , rhs.getEnergyNeededFromNetwork()-rhs.getEnergyFromNetwork() ));
  101. //Supply consumer fully
  102. outerLoop:
  103. for(Consumer con : consumerList)
  104. {
  105. //gehe Supplier list durch wer ihn supplien kann.
  106. for(Supplier sup : supplierList) {
  107. float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
  108. if(energyRdyToSupply == 0.0f) continue;
  109. float energyNeededForFullySupply = con.getEnergyNeededFromNetwork() - con.getEnergyFromNetwork();
  110. if(energyNeededForFullySupply == 0.0f) continue outerLoop;
  111. if(energyRdyToSupply>=energyNeededForFullySupply) {
  112. supply(con, sup, energyNeededForFullySupply);
  113. continue outerLoop;
  114. }else
  115. {
  116. supply(con, sup, energyRdyToSupply);
  117. }
  118. }
  119. //No more Energy in the network
  120. break;
  121. }
  122. //consumerList.forEach((con) -> System.out.println("AfterFullySuplieing" + con));
  123. //If Energy Left Supply all equal
  124. //Count EnergyLeft
  125. float energyLeft = supplierList.stream().map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied()).reduce( 0.0f, (a, b) -> a + b);
  126. //System.out.println("EnergyLeft: " + energyLeft);
  127. if(energyLeft > 0.0f && (consumerList.size() + consumerSelfSuppliedList.size() != 0))
  128. {
  129. float equalAmountOfEnergyToSupply = energyLeft / ((float)(consumerList.size() + consumerSelfSuppliedList.size()));
  130. outerLoop:
  131. for(Consumer con : consumerList)
  132. {
  133. //gehe Supplier list durch wer ihn supplien kann.
  134. for(Supplier sup : supplierList) {
  135. float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
  136. if(energyRdyToSupply == 0.0f) continue;
  137. float energyNeededToSupplyConsumerTheEqualAmount = equalAmountOfEnergyToSupply +con.getEnergyNeededFromNetwork()- con.getEnergyFromNetwork();
  138. if(energyRdyToSupply>=energyNeededToSupplyConsumerTheEqualAmount) {
  139. supply(con, sup, energyNeededToSupplyConsumerTheEqualAmount);
  140. continue outerLoop;
  141. }else
  142. {
  143. supply(con, sup, energyRdyToSupply);
  144. }
  145. }
  146. //No more Energy in the network
  147. break;
  148. }
  149. outerLoop:
  150. for(Consumer con : consumerSelfSuppliedList)
  151. {
  152. //gehe Supplier list durch wer ihn supplien kann.
  153. for(Supplier sup : supplierList) {
  154. float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
  155. if(energyRdyToSupply == 0.0f) continue;
  156. float energyNeededToSupplyConsumerTheEqualAmount = equalAmountOfEnergyToSupply +con.getEnergyNeededFromNetwork()- con.getEnergyFromNetwork();
  157. if(energyRdyToSupply>=energyNeededToSupplyConsumerTheEqualAmount) {
  158. supply(con, sup, energyNeededToSupplyConsumerTheEqualAmount);
  159. continue outerLoop;
  160. }else
  161. {
  162. supply(con, sup, energyRdyToSupply);
  163. }
  164. }
  165. //No more Energy in the network
  166. break;
  167. }
  168. }
  169. //consumerList.forEach((con) -> System.out.println("AfterOverSuppleiing" + con));
  170. //consumerSelfSuppliedList.forEach((con) -> System.out.println("AfterOverSuppleiing" + con));
  171. calculateStates();
  172. }
  173. private void decorateCable(MinimumNetwork minimumNetwork, float energyToSupplyInTheNetwork) {
  174. //DecoratedCables
  175. //Minimum demand first:
  176. for(IntermediateCableWithState edge: minimumNetwork.getEdgeList()) {
  177. decoratedCableList.add(new DecoratedCable(edge.getModel(), edge.getState(), (edge.getState() == CableState.Working) ? energyToSupplyInTheNetwork : 0.0f, 0));
  178. }
  179. }
  180. private void calculateAllEqualNetwork(MinimumNetwork minimumNetwork, int Iteration, FlexManager flexManager) {
  181. categorize(minimumNetwork, Iteration, flexManager);
  182. float energyToSupplyInTheNetwork = supplierList.stream().map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied()).reduce( 0.0f, (a, b) -> a + b);
  183. float energyForEachConsumer = (consumerList.size() != 0) ? energyToSupplyInTheNetwork / consumerList.size() : 0.0f;
  184. decorateCable(minimumNetwork, energyToSupplyInTheNetwork);
  185. //Supply consumer equal
  186. outerLoop:
  187. for(Consumer con : consumerList)
  188. {
  189. //gehe Supplier list durch wer ihn supplien kann.
  190. float energyNeededForEqualSupply = energyForEachConsumer;
  191. for(Supplier sup : supplierList) {
  192. float energyRdyToSupply = sup.getEnergyToSupplyNetwork() - sup.getEnergySupplied();
  193. if(energyRdyToSupply == 0.0f) continue;
  194. if(energyRdyToSupply>=energyNeededForEqualSupply) {
  195. supply(con, sup, energyNeededForEqualSupply);
  196. continue outerLoop;
  197. }else
  198. {
  199. supply(con, sup, energyRdyToSupply);
  200. energyNeededForEqualSupply -= energyRdyToSupply;
  201. }
  202. }
  203. //No more Energy in the network
  204. break;
  205. }
  206. calculateStates();
  207. }
  208. public void calculateStates() {
  209. //CalculateStates:
  210. supplierList.forEach(sup -> sup.setState(HolonObjectState.PRODUCER));
  211. passivNoEnergyList.forEach(sup -> sup.setState(HolonObjectState.NO_ENERGY));
  212. for(Consumer con : this.consumerList)
  213. {
  214. setConsumerState(con);
  215. }
  216. for(Consumer con : this.consumerSelfSuppliedList)
  217. {
  218. setConsumerState(con);
  219. }
  220. }
  221. private void categorize(MinimumNetwork minimumNetwork, int Iteration, FlexManager flexManager) {
  222. //Categorize
  223. for(HolonObject hObject: minimumNetwork.getHolonObjectList()) {
  224. float energyNeeded = hObject.getEnergyNeededFromConsumingElementsWithFlex(Iteration, flexManager);
  225. float energySelfProducing = hObject.getEnergySelfProducingFromProducingElementsWithFlex(Iteration, flexManager);
  226. if(energyNeeded < energySelfProducing) {
  227. Supplier sup = new Supplier(hObject, energySelfProducing - energyNeeded, energyNeeded, 0, 0, false, 0);
  228. supplierList.add(sup);
  229. } else if (energyNeeded > energySelfProducing) {
  230. Consumer con = new Consumer(hObject, energyNeeded - energySelfProducing, 0, 0, 0,false, 0);
  231. con.setMinimumConsumingElementEnergy(hObject.getMinimumConsumingElementEnergyWithFlex(Iteration, flexManager));
  232. con.setEnergyFromConsumingElemnets(hObject.getEnergyNeededFromConsumingElementsWithFlex(Iteration, flexManager));
  233. con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElementsWithFlex(Iteration, flexManager));
  234. consumerList.add(con);
  235. }else if(energyNeeded == energySelfProducing) {
  236. if (energySelfProducing == 0.0f) {
  237. Passiv pas = new Passiv(hObject, 0);
  238. passivNoEnergyList.add(pas);
  239. } else {
  240. Consumer con = new Consumer(hObject, 0.0f, 0, 0,0,false, 0);
  241. con.setEnergyNeededFromNetwork(0.0f);
  242. con.setMinimumConsumingElementEnergy(hObject.getMinimumConsumingElementEnergyWithFlex(Iteration, flexManager));
  243. con.setEnergyFromConsumingElemnets(hObject.getEnergyNeededFromConsumingElementsWithFlex(Iteration, flexManager));
  244. con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElementsWithFlex(Iteration, flexManager));
  245. consumerSelfSuppliedList.add(con);
  246. }
  247. }
  248. }
  249. }
  250. private void setConsumerState(Consumer con) {
  251. if(con.getEnergySelfSupplied() + con.getEnergyFromNetwork() > con.getEnergyFromConsumingElemnets()) {
  252. con.setState(HolonObjectState.OVER_SUPPLIED);
  253. }else if(con.getEnergySelfSupplied() + con.getEnergyFromNetwork() == con.getEnergyFromConsumingElemnets()) {
  254. con.setState(HolonObjectState.SUPPLIED);
  255. }else if(con.getEnergySelfSupplied() + con.getEnergyFromNetwork() >= con.getMinimumConsumingElementEnergy()) {
  256. con.setState(HolonObjectState.PARTIALLY_SUPPLIED);
  257. }else {
  258. con.setState(HolonObjectState.NOT_SUPPLIED);
  259. }
  260. }
  261. /**
  262. * No Checks.
  263. * @param con
  264. * @param sup
  265. * @param energy
  266. */
  267. private void supply(Consumer con, Supplier sup, float energy) {
  268. sup.getConsumerList().add(sup.new ConsumerListEntry(con , energy));
  269. sup.setEnergySupplied(sup.getEnergySupplied() + energy);
  270. con.getSupplierList().add(con.new SupplierListEntry(sup, energy));
  271. con.setEnergyFromNetwork(con.getEnergyFromNetwork() + energy);
  272. }
  273. public int getAmountOfActiveElements() {
  274. return supplierList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, Integer::sum)+
  275. consumerList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, Integer::sum)+
  276. consumerSelfSuppliedList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, Integer::sum);
  277. }
  278. public int getAmountOfElements() {
  279. return supplierList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0, Integer::sum)+
  280. consumerList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0, Integer::sum)+
  281. consumerSelfSuppliedList.stream().map(object -> object.getModel().getNumberOfElements()).reduce(0, Integer::sum);
  282. }
  283. public int getAmountOfConsumer() {
  284. return consumerList.size() + this.consumerSelfSuppliedList.size();
  285. }
  286. public int getAmountOfSupplier() {
  287. return supplierList.size();
  288. }
  289. public int getAmountOfConsumerWithState(HolonObjectState state) {
  290. return (int) (consumerList.stream().filter(con -> con.getState() == state).count() + consumerSelfSuppliedList.stream().filter(con -> con.getState() == state).count());
  291. }
  292. public int getAmountOfPassiv() {
  293. return passivNoEnergyList.size();
  294. }
  295. public int getAmountOfHolonObjects() {
  296. return getAmountOfConsumer() + getAmountOfSupplier() + getAmountOfPassiv();
  297. }
  298. public float getTotalConsumption() {
  299. float energy = consumerList.stream().map(con -> con.getEnergyFromConsumingElemnets()).reduce(0.f, Float::sum) + consumerSelfSuppliedList.stream().map(con -> con.getEnergyFromConsumingElemnets()).reduce(0.f, Float::sum);
  300. energy += supplierList.stream().map(sup -> sup.getEnergySelfConsuming()).reduce(0.f, Float::sum);
  301. return energy;
  302. }
  303. public float getAverageConsumptionInNetworkForHolonObject(){
  304. return getTotalConsumption() / (float)getAmountOfHolonObjects();
  305. }
  306. public float getTotalProduction() {
  307. float energy = consumerList.stream().map(con -> con.getEnergySelfSupplied()).reduce(0.f, Float::sum) + consumerSelfSuppliedList.stream().map(con -> con.getEnergySelfSupplied()).reduce(0.f, Float::sum);
  308. energy += supplierList.stream().map(sup -> sup.getEnergyProducing()).reduce(0.f, Float::sum);
  309. return energy;
  310. }
  311. public float getAverageProductionInNetworkForHolonObject() {
  312. return getTotalProduction() / (float) getAmountOfHolonObjects();
  313. }
  314. /**
  315. * returns the Varianz in Poduction
  316. * @return
  317. */
  318. public float getVarianzInProductionInNetworkForHolonObjects() {
  319. float average = getAverageProductionInNetworkForHolonObject();
  320. float sum = consumerList.stream().map(con -> squared(con.getEnergySelfSupplied() - average)).reduce(0.f, Float::sum)
  321. + consumerSelfSuppliedList.stream().map(con -> squared(con.getEnergySelfSupplied() - average)).reduce(0.f, Float::sum)
  322. + supplierList.stream().map(sup -> squared(sup.getEnergyProducing() - average)).reduce(0.f, Float::sum);
  323. return sum / (float) getAmountOfHolonObjects();
  324. }
  325. public float getDeviationInProductionInNetworkForHolonObjects() {
  326. return (float)Math.sqrt(getVarianzInProductionInNetworkForHolonObjects());
  327. }
  328. public float getVarianzInConsumptionInNetworkForHolonObjects() {
  329. float average = getAverageConsumptionInNetworkForHolonObject();
  330. float sum = consumerList.stream().map(con -> squared(con.getEnergyFromConsumingElemnets() - average)).reduce(0.f, Float::sum)
  331. + consumerSelfSuppliedList.stream().map(con -> squared(con.getEnergyFromConsumingElemnets() - average)).reduce(0.f, Float::sum)
  332. + supplierList.stream().map(sup -> squared(sup.getEnergySelfConsuming() - average)).reduce(0.f, Float::sum);
  333. return sum / (float) getAmountOfHolonObjects();
  334. }
  335. public float getDeviationInConsumptionInNetworkForHolonObjects() {
  336. return (float)Math.sqrt(getVarianzInConsumptionInNetworkForHolonObjects());
  337. }
  338. //HelperFunction
  339. /**
  340. *
  341. * @return a list of energy
  342. */
  343. public List<Float> getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork() {
  344. List<HolonElement> eleList = consumerList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList());
  345. eleList.addAll(consumerSelfSuppliedList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList()));
  346. eleList.addAll(supplierList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList()));
  347. eleList.addAll(passivNoEnergyList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList()));
  348. return eleList.stream().filter(ele -> (ele.flexList.stream().anyMatch(flex -> flex.offered && flex.fulfillsConstrains())) ).map(ele -> -ele.getEnergyAtTimeStep(timestep) ).collect(Collectors.toList()) ;
  349. }
  350. public List<Float> getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork(){
  351. return getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork().stream().filter(value -> (value > 0.f)).collect(Collectors.toList());
  352. }
  353. public List<Float> getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork(){
  354. return getListOfEnergyThatIsOfferedByFlexibilitiesInThisNetwork().stream().filter(value -> (value < 0.f)).map(value -> -value).collect(Collectors.toList());
  355. }
  356. public float getFlexibilityProductionCapacity() {
  357. return getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().stream().reduce(0.f, Float::sum);
  358. }
  359. public float getFlexibilityConsumptionCapacity() {
  360. return getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().stream().reduce(0.f, Float::sum);
  361. }
  362. public int getAmountOfProductionFlexibilities() {
  363. return getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().size();
  364. }
  365. public int getAmountOfConsumptionFlexibilities() {
  366. return getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().size();
  367. }
  368. public float getAverageFlexibilityProduction() {
  369. int amount = getAmountOfProductionFlexibilities();
  370. return (amount > 0)? getFlexibilityProductionCapacity() / (float)amount : 0.f;
  371. }
  372. public float getAverageFlexibilityConsumption() {
  373. int amount = getAmountOfConsumptionFlexibilities();
  374. return (amount > 0)? getFlexibilityConsumptionCapacity() / (float)amount : 0.f;
  375. }
  376. public float getVarianzInFlexibilitieConsumption() {
  377. float average = getAverageFlexibilityConsumption();
  378. float sum = getListOfEnergyInConsumptionThatIsOfferedByFlexibilitiesInThisNetwork().stream().map(energy -> squared(energy - average)).reduce(0.f, Float::sum);
  379. int amountOfFlexibilities = getAmountOfConsumptionFlexibilities();
  380. return (amountOfFlexibilities > 0)? sum / (float) amountOfFlexibilities : 0.f;
  381. }
  382. public float getVarianzInFlexibilitieProduction() {
  383. float average = getAverageFlexibilityProduction();
  384. float sum = getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork().stream().map(energy -> squared(energy - average)).reduce(0.f, Float::sum);
  385. int amountOfFlexibilities = getAmountOfProductionFlexibilities();
  386. return (amountOfFlexibilities > 0)? sum / (float) amountOfFlexibilities : 0.f;
  387. }
  388. public float getDiviationInFlexibilityConsumption() {
  389. return (float) Math.sqrt(getVarianzInFlexibilitieConsumption());
  390. }
  391. public float getDiviationInFlexibilityProduction() {
  392. return (float) Math.sqrt(getVarianzInFlexibilitieProduction());
  393. }
  394. //Help Function
  395. private float squared(float input) {
  396. return (float) Math.pow(input, 2);
  397. }
  398. }