summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-simulator/src/main/kotlin
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2025-03-29 13:59:35 +0100
committerGitHub <noreply@github.com>2025-03-29 13:59:35 +0100
commitaf632099d05636af3274ee95ada6b962703a67f0 (patch)
treeeea693722038de825a3728c65751d20115766feb /opendc-compute/opendc-compute-simulator/src/main/kotlin
parentb20dd5ebb48465470b9632dc92ecfb1794a8a4bf (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-compute/opendc-compute-simulator/src/main/kotlin')
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/MemorizingScheduler.kt2
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TaskStopper.kt4
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TimeshiftScheduler.kt7
3 files changed, 8 insertions, 5 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/MemorizingScheduler.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/MemorizingScheduler.kt
index 4a561e95..25e559fd 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/MemorizingScheduler.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/MemorizingScheduler.kt
@@ -40,7 +40,7 @@ public class MemorizingScheduler(
) : ComputeScheduler {
// We assume that there will be max 200 tasks per host.
// The index of a host list is the number of tasks on that host.
- private val hostsQueue = List(20000, { mutableListOf<HostView>() })
+ private val hostsQueue = List(100, { mutableListOf<HostView>() })
private var minAvailableHost = 0
private var numHosts = 0
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TaskStopper.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TaskStopper.kt
index 4ea526b7..7549bb1c 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TaskStopper.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TaskStopper.kt
@@ -79,7 +79,9 @@ public class TaskStopper(
isHighCarbon = noForecastUpdateCarbonIntensity(newCarbonIntensity)
} else {
val forecast = carbonModel!!.getForecast(forecastSize)
- val quantileIndex = (forecastSize * forecastThreshold).roundToInt()
+
+ val localForecastSize = forecast.size
+ val quantileIndex = (localForecastSize * forecastThreshold).roundToInt()
val thresholdCarbonIntensity = forecast.sorted()[quantileIndex]
isHighCarbon = newCarbonIntensity > thresholdCarbonIntensity
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TimeshiftScheduler.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TimeshiftScheduler.kt
index 2f9b4364..f402c5a5 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TimeshiftScheduler.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TimeshiftScheduler.kt
@@ -171,10 +171,11 @@ public class TimeshiftScheduler(
}
val forecast = carbonModel!!.getForecast(forecastSize)
- val forecastSize = forecast.size
- val shortQuantileIndex = (forecastSize * shortForecastThreshold).roundToInt()
+ val localForecastSize = forecast.size
+
+ val shortQuantileIndex = (localForecastSize * shortForecastThreshold).roundToInt()
val shortCarbonIntensity = forecast.sorted()[shortQuantileIndex]
- val longQuantileIndex = (forecastSize * longForecastThreshold).roundToInt()
+ val longQuantileIndex = (localForecastSize * longForecastThreshold).roundToInt()
val longCarbonIntensity = forecast.sorted()[longQuantileIndex]
shortLowCarbon = newCarbonIntensity < shortCarbonIntensity