diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2025-03-29 13:59:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-29 13:59:35 +0100 |
| commit | af632099d05636af3274ee95ada6b962703a67f0 (patch) | |
| tree | eea693722038de825a3728c65751d20115766feb /opendc-simulator/opendc-simulator-compute/src/main | |
| parent | b20dd5ebb48465470b9632dc92ecfb1794a8a4bf (diff) | |
Fixed a small problem with getForeCast (#328)
* Fixed a small problem with carbon forecasts that would cause problems when the simulation would leave the coverage of the carbon Trace
* Fixed a small problem with carbon forecasts that would cause problems when the simulation would leave the coverage of the carbon Trace
* Fixed a bug
* spotless applied
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.java | 6 |
1 files changed, 5 insertions, 1 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 3cf36ece..e1c99071 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 @@ -134,7 +134,11 @@ public class CarbonModel extends FlowNode { } public double[] getForecast(int forecastSize) { - return this.fragments.subList(this.fragment_index + 1, this.fragment_index + forecastSize).stream() + return this.fragments + .subList( + Math.min(this.fragment_index + 1, this.fragments.size() - 1), + Math.min(this.fragment_index + forecastSize, this.fragments.size())) + .stream() .mapToDouble(CarbonFragment::getCarbonIntensity) .toArray(); } |
