summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/main
diff options
context:
space:
mode:
authorSacheendra Talluri <sacheendra.t@gmail.com>2025-03-27 16:14:39 +0100
committerGitHub <noreply@github.com>2025-03-27 16:14:39 +0100
commitb20dd5ebb48465470b9632dc92ecfb1794a8a4bf (patch)
tree0aeab9ad4b366cfe9e8aa79f841563e7f91758ab /opendc-simulator/opendc-simulator-compute/src/main
parentea45406229c8349e44c88f4112fe25435b59e4e9 (diff)
Support carbon forecasting in timeshift (#327)
* Remove task from scheduler bookkeeping after failure * Support carbon forecasting in timeshift * Register scheduler and carbonmodel in context * Preliminary working task stopping; carbon intensity bug * Working carbon based stop. Two timeshift thresholds * Add a pause state task and guest * Move task stopper to allocation spec * Start tracking num pauses
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src/main')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java
index 3bbdba66..3cf36ece 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java
@@ -133,6 +133,12 @@ public class CarbonModel extends FlowNode {
receiver.updateCarbonIntensity(this.current_fragment.getCarbonIntensity());
}
+ public double[] getForecast(int forecastSize) {
+ return this.fragments.subList(this.fragment_index + 1, this.fragment_index + forecastSize).stream()
+ .mapToDouble(CarbonFragment::getCarbonIntensity)
+ .toArray();
+ }
+
public static <T, U> List<U> castList(List<T> list, Class<U> clazz) {
List<U> result = new ArrayList<>();
for (T element : list) {