summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-flow/src/main/java
diff options
context:
space:
mode:
authorNiels Thiele <noleu66@posteo.net>2025-07-15 16:59:02 +0200
committerGitHub <noreply@github.com>2025-07-15 16:59:02 +0200
commit089c449762950b4322c04f73ef7fe0e10af615df (patch)
treee39d84af37fa821ffabbb94d25ad6c3de1e29f07 /opendc-simulator/opendc-simulator-flow/src/main/java
parenta5f3c19200026b9476edc39b951eb1003cff0831 (diff)
Implements Virtualization overhead modelling (#357)
Diffstat (limited to 'opendc-simulator/opendc-simulator-flow/src/main/java')
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java4
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowEdge.java10
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowSupplier.java6
3 files changed, 18 insertions, 2 deletions
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) {