DecoratedNetwork.java 20 KB

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