|
@@ -78,8 +78,7 @@ public class SimulationManager {
|
|
|
// negative value
|
|
|
float energySurplus = production + consumption;
|
|
|
|
|
|
- float minConsumption = calculateMinimumEnergy(singleSubNet,
|
|
|
- timeStep);
|
|
|
+ //float minConsumption = calculateMinimumEnergy(singleSubNet, timeStep);
|
|
|
|
|
|
// --------------- use flexible devices ---------------
|
|
|
if (energySurplus != 0 && model.useFlexibleDevices()) {
|
|
@@ -187,14 +186,8 @@ public class SimulationManager {
|
|
|
.getCurrentEnergyAtTimeStep(x));
|
|
|
}
|
|
|
} else {
|
|
|
- float minEnergy = hl.getMinEnergy(x);
|
|
|
- if ((production + minConsumption) >= 0) {
|
|
|
- hl.setState(HolonObject.PARTIALLY_SUPPLIED);
|
|
|
- currentProduction += minEnergy;
|
|
|
- hl.setCurrentSupply(-minEnergy);
|
|
|
- partiallySuppliedList.add(hl);
|
|
|
- } else if (hl
|
|
|
- .checkIfPartiallySupplied(timeStep)) {
|
|
|
+ float minEnergy = hl.getMinEnergy(x);
|
|
|
+ if (hl.checkIfPartiallySupplied(timeStep)) {
|
|
|
hl.setState(HolonObject.PARTIALLY_SUPPLIED);
|
|
|
currentProduction += minEnergy;
|
|
|
hl.setCurrentSupply(-minEnergy);
|
|
@@ -622,32 +615,42 @@ public class SimulationManager {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Calculate the Minimum Energy.
|
|
|
+ * Calculate the Minimum Energy of a Subnet.
|
|
|
*
|
|
|
* @param sN
|
|
|
* Subnet
|
|
|
* @param x
|
|
|
* Integer
|
|
|
- * @return the Calculated minimum Energy
|
|
|
+ * @return the Calculated minimum Energy of a Subnet
|
|
|
*/
|
|
|
private float calculateMinimumEnergy(SubNet sN, int x) {
|
|
|
- float min = 0;
|
|
|
- float minElement = 0;
|
|
|
+ float minimummConsumptionSubnet = 0;
|
|
|
for (HolonObject hl : sN.getObjects()) {
|
|
|
- if (hl.getElements().size() > 0
|
|
|
- && hl.getElements().get(0).getOverallEnergyAtTimeStep(x) < 0) {
|
|
|
- minElement = hl.getElements().get(0)
|
|
|
- .getOverallEnergyAtTimeStep(x);
|
|
|
+ float minElement = 0;
|
|
|
+ // Search for a activ element
|
|
|
+ for (HolonElement he : hl.getElements()) {
|
|
|
+ if (he.isActive()) {
|
|
|
+ float overallEnergy = he.getOverallEnergyAtTimeStep(x);
|
|
|
+ if (overallEnergy < 0) {
|
|
|
+ // Is a consumer
|
|
|
+ minElement = overallEnergy;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
for (HolonElement he : hl.getElements()) {
|
|
|
- float overallEnergy = he.getOverallEnergyAtTimeStep(x);
|
|
|
- if (minElement < overallEnergy && overallEnergy < 0) {
|
|
|
- minElement = overallEnergy;
|
|
|
+ if (he.isActive()) {
|
|
|
+ float overallEnergy = he.getOverallEnergyAtTimeStep(x);
|
|
|
+
|
|
|
+ if (minElement < overallEnergy && overallEnergy < 0) {
|
|
|
+ // is a smaller consumer
|
|
|
+ minElement = overallEnergy;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- min = min + minElement;
|
|
|
+ minimummConsumptionSubnet += minElement;
|
|
|
}
|
|
|
- return min;
|
|
|
+ System.out.println("MinimumEnergy = "+ minimummConsumptionSubnet);
|
|
|
+ return minimummConsumptionSubnet;
|
|
|
}
|
|
|
|
|
|
/**
|