From 089c449762950b4322c04f73ef7fe0e10af615df Mon Sep 17 00:00:00 2001 From: Niels Thiele Date: Tue, 15 Jul 2025 16:59:02 +0200 Subject: Implements Virtualization overhead modelling (#357) --- .../org/opendc/simulator/engine/graph/FlowDistributor.java | 4 ++-- .../main/java/org/opendc/simulator/engine/graph/FlowEdge.java | 10 ++++++++++ .../java/org/opendc/simulator/engine/graph/FlowSupplier.java | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'opendc-simulator/opendc-simulator-flow') diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java index cae3e8a1..c388293b 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java @@ -102,7 +102,6 @@ public abstract class FlowDistributor extends FlowNode implements FlowSupplier, protected abstract void updateOutgoingDemand(); - // TODO: This should probably be moved to the distribution strategy protected abstract void updateOutgoingSupplies(); public abstract double[] distributeSupply( @@ -120,6 +119,7 @@ public abstract class FlowDistributor extends FlowNode implements FlowSupplier, this.incomingDemands.add(0.0); this.outgoingSupplies.add(0.0); this.consumerResourceType = consumerEdge.getConsumerResourceType(); + this.outgoingDemandUpdateNeeded = true; } @Override @@ -233,7 +233,7 @@ public abstract class FlowDistributor extends FlowNode implements FlowSupplier, @Override public void pushOutgoingDemand(FlowEdge supplierEdge, double newDemand) { - supplierEdge.pushDemand(newDemand, false, this.getSupplierResourceType()); + supplierEdge.pushDemand(newDemand, false, this.getSupplierResourceType(), this.consumerEdges.size()); } @Override diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowEdge.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowEdge.java index db2a2944..1e65998b 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowEdge.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowEdge.java @@ -177,6 +177,16 @@ public class FlowEdge { this.supplierIndex = supplierIndex; } + public void pushDemand(double newDemand, boolean forceThrough, ResourceType resourceType, int consumerCount) { + // or store last resource type in the edge + if ((newDemand == this.demand) && !forceThrough) { + return; + } + + this.demand = newDemand; + this.supplier.handleIncomingDemand(this, newDemand, resourceType, consumerCount); + } + public void pushDemand(double newDemand, boolean forceThrough, ResourceType resourceType) { // or store last resource type in the edge if ((newDemand == this.demand) && !forceThrough) { diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowSupplier.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowSupplier.java index eb665b8c..2f5f80ef 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowSupplier.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowSupplier.java @@ -32,6 +32,12 @@ public interface FlowSupplier { handleIncomingDemand(consumerEdge, newDemand); } + default void handleIncomingDemand( + FlowEdge consumerEdge, double newDemand, ResourceType resourceType, int consumerCount) { + handleIncomingDemand(consumerEdge, newDemand); + } + ; + void pushOutgoingSupply(FlowEdge consumerEdge, double newSupply); default void pushOutgoingSupply(FlowEdge consumerEdge, double newSupply, ResourceType resourceType) { -- cgit v1.2.3