|
@@ -162,15 +162,6 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- public HolonElement getMinimalConsumingElement() {
|
|
|
|
- HolonElement min = elements.get(0);
|
|
|
|
- for (HolonElement e : elements) {
|
|
|
|
- if (e.getOverallEnergy() < 0 && e.getOverallEnergy() > min.getOverallEnergy()) {
|
|
|
|
- min = e;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return min;
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
* Getter for the current energy at a given timestep.
|
|
* Getter for the current energy at a given timestep.
|
|
@@ -388,17 +379,17 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
|
|
|
* Calculates the minimumEnergy Needed to turn on atleast on device
|
|
* Calculates the minimumEnergy Needed to turn on atleast on device
|
|
* of this HolonObject
|
|
* of this HolonObject
|
|
- * @param x Timestep of the calculation
|
|
+ * @param timestep Timestep of the calculation
|
|
* @return minEnergy, -inf if no Devices are consuming power
|
|
* @return minEnergy, -inf if no Devices are consuming power
|
|
*/
|
|
*/
|
|
- public float getMinEnergy(int x) {
|
|
+ public float getMinEnergy(int timestep) {
|
|
if (getElements().size() == 0) {
|
|
if (getElements().size() == 0) {
|
|
return Float.NEGATIVE_INFINITY;
|
|
return Float.NEGATIVE_INFINITY;
|
|
}
|
|
}
|
|
float minConsum = Float.NEGATIVE_INFINITY;
|
|
float minConsum = Float.NEGATIVE_INFINITY;
|
|
for (HolonElement e : getElements()) {
|
|
for (HolonElement e : getElements()) {
|
|
if (e.isActive()) {
|
|
if (e.isActive()) {
|
|
- float overallEnergy = e.getOverallEnergyAtTimeStep(x);
|
|
+ float overallEnergy = e.getOverallEnergyAtTimeStep(timestep);
|
|
if (minConsum < 0 && (overallEnergy > minConsum && overallEnergy < 0)) {
|
|
if (minConsum < 0 && (overallEnergy > minConsum && overallEnergy < 0)) {
|
|
minConsum = overallEnergy;
|
|
minConsum = overallEnergy;
|
|
}
|
|
}
|
|
@@ -406,7 +397,75 @@ public class HolonObject extends AbstractCpsObject {
|
|
}
|
|
}
|
|
return minConsum;
|
|
return minConsum;
|
|
}
|
|
}
|
|
-
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * This Method returns the smallest consuming HolonElement that is ACTIVE.
|
|
|
|
+ * If the HolonObject has no Consumer its return null.
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The smallest consuming HolonElement or null.
|
|
|
|
+ */
|
|
|
|
+ public HolonElement getMinimumConsumingElement(int timestep){
|
|
|
|
+ return getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) < 0) ).max((lhs,rhs) -> Float.compare(lhs.getEnergyAtTimeStep(timestep), rhs.getEnergyAtTimeStep(timestep))).orElse(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ * This Method returns the smallest consuming HolonElement'Energy that is ACTIVE.
|
|
|
|
+ * If the HolonObject has no Consumer its return 0.
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The smallest consuming HolonElement or 0.
|
|
|
|
+ */
|
|
|
|
+ public float getMinimumConsumingElementEnergy(int timestep){
|
|
|
|
+ return getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) < 0) ).map(element -> -element.getEnergyAtTimeStep(timestep)).min((lhs,rhs) ->Float.compare(lhs, rhs)).orElse(0.0f);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ * This Method returns the Energy of a HolonObject. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE.
|
|
|
|
+ * If the HolonObject have no HolonElement its return 0;
|
|
|
|
+ * Is the returned Energy negative then the HolonObject need Energy because its consuming HolonElements need more Energy then the producing HolonElements.
|
|
|
|
+ * Is the returned Energy positive its reversed.
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The Energy of the HolonObject.
|
|
|
|
+ */
|
|
|
|
+ public float getEnergyAtTimeStep(int timestep)
|
|
|
|
+ {
|
|
|
|
+ return getElements().stream().filter(element -> element.isActive()).map(element -> element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ * This Method returns the Energy that all HolonElements from the HolonObject produce by itself. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE and are Producer.
|
|
|
|
+ * If the HolonObject have no HolonElement its return 0;
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The Energy of the producing HolonElements.
|
|
|
|
+ */
|
|
|
|
+ public float getEnergySelfProducingFromProducingElements(int timestep) {
|
|
|
|
+ return getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) > 0)).map(element -> element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ * This Method returns the Energy of all HolonElements from the HolonObject that are consuming. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE and are Consumer.
|
|
|
|
+ * If the HolonObject have no HolonElement its return 0;
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The Energy of the consuming HolonElements.
|
|
|
|
+ */
|
|
|
|
+ public float getEnergyNeededFromConsumingElements(int timestep) {
|
|
|
|
+ return getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) < 0)).map(element -> -element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * This Method calculate the amount of HolonElements that are consuming Energy and are ACTIVE.
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The amount of HolonElements that are consuming Energy.
|
|
|
|
+ */
|
|
|
|
+ public int countConsumingElements(int timestep) {
|
|
|
|
+ return (int) getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) < 0)).count();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ * This Method calculate the amount of HolonElements that are producing Energy and are ACTIVE.
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The amount of HolonElements that are producing Energy.
|
|
|
|
+ */
|
|
|
|
+ public int countProducingElements(int timestep) {
|
|
|
|
+ return (int) getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) > 0)).count();
|
|
|
|
+ }
|
|
|
|
|
|
* Get the Color.
|
|
* Get the Color.
|
|
*
|
|
*
|