From cd696da4c50a150f1d01fec27eef5a043b57b95a Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Fri, 3 Oct 2025 13:53:18 +0200 Subject: Removed a bug in MaxMinFlowDistributor. (#376) * Small update to the FLowDistributor --- .../org/opendc/simulator/compute/workload/VirtualMachine.java | 10 ---------- .../distributionPolicies/MaxMinFairnessFlowDistributor.java | 10 ++++++++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/VirtualMachine.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/VirtualMachine.java index a3ee4f97..5da8d3fe 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/VirtualMachine.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/VirtualMachine.java @@ -61,14 +61,6 @@ public final class VirtualMachine extends SimWorkload implements FlowSupplier { private final PerformanceCounters[] resourcePerformanceCounters = new PerformanceCounters[ResourceType.values().length]; - // private final Hashtable resourceDemands = new Hashtable<>(); - // private final Hashtable resourceSupplies = new Hashtable<>(); - // private final Hashtable resourceCapacities = new Hashtable<>(); - // private final Hashtable resourceTimeScalingFactor = new Hashtable<>(); // formerly known - // as d - // private final Hashtable distributorEdges = new Hashtable<>(); - // private final Hashtable resourcePerformanceCounters = new Hashtable<>(); - private final long checkpointInterval; private final long checkpointDuration; private final double checkpointIntervalScaling; @@ -326,7 +318,6 @@ public final class VirtualMachine extends SimWorkload implements FlowSupplier { */ @Override public void pushOutgoingDemand(FlowEdge supplierEdge, double newDemand) { - // FIXME: Needs to be assigned to specific resource if multiple exist -> add resource Id as parameter this.pushOutgoingDemand(supplierEdge, newDemand, supplierEdge.getSupplierResourceType()); } @@ -338,7 +329,6 @@ public final class VirtualMachine extends SimWorkload implements FlowSupplier { */ @Override public void pushOutgoingDemand(FlowEdge supplierEdge, double newDemand, ResourceType resourceType) { - // FIXME: Needs to be assigned to specific resource if multiple exist -> add resource Id as parameter this.resourceDemands[resourceType.ordinal()] = newDemand; this.distributorEdges[resourceType.ordinal()].pushDemand(newDemand, false, resourceType); } diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/distributionPolicies/MaxMinFairnessFlowDistributor.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/distributionPolicies/MaxMinFairnessFlowDistributor.java index 875412c6..e5e4eb59 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/distributionPolicies/MaxMinFairnessFlowDistributor.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/distributionPolicies/MaxMinFairnessFlowDistributor.java @@ -43,13 +43,19 @@ public class MaxMinFairnessFlowDistributor extends FlowDistributor { } protected void updateOutgoingDemand() { + if (this.totalIncomingDemand == this.previousTotalDemand) { + this.outgoingDemandUpdateNeeded = false; + this.updateOutgoingSupplies(); + return; + } + + this.previousTotalDemand = this.totalIncomingDemand; + for (FlowEdge supplierEdge : this.supplierEdges.values()) { this.pushOutgoingDemand(supplierEdge, this.totalIncomingDemand / this.supplierEdges.size()); } this.outgoingDemandUpdateNeeded = false; - - this.invalidate(); } // TODO: This should probably be moved to the distribution strategy -- cgit v1.2.3