diff options
| author | Sacheendra Talluri <sacheendra.t@gmail.com> | 2025-03-27 16:14:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-27 16:14:39 +0100 |
| commit | b20dd5ebb48465470b9632dc92ecfb1794a8a4bf (patch) | |
| tree | 0aeab9ad4b366cfe9e8aa79f841563e7f91758ab /opendc-simulator/opendc-simulator-compute/src/main/java/org | |
| parent | ea45406229c8349e44c88f4112fe25435b59e4e9 (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/java/org')
| -rw-r--r-- | opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java | 6 |
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) { |
