summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-failure/src/main
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-failure/src/main
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-failure/src/main')
-rw-r--r--opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt3
1 files changed, 2 insertions, 1 deletions
diff --git a/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt b/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt
index 9b92cf33..1c7d1e7d 100644
--- a/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt
+++ b/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt
@@ -27,6 +27,7 @@ import java.util.SplittableRandom
import java.util.random.RandomGenerator
import kotlin.math.max
import kotlin.math.min
+import kotlin.math.roundToInt
/**
* A [VictimSelector] that stochastically selects a set of hosts to be failed.
@@ -73,7 +74,7 @@ public class StochasticVictimSelector(
): List<SimHost> {
// clamp value between 0.0 and 1.0
val intensity = min(1.0, max(0.0, failureIntensity))
- val numberOfHosts = (hosts.size * intensity).toInt()
+ val numberOfHosts = (hosts.size * intensity).roundToInt()
return hosts.asSequence().shuffled().take(numberOfHosts).toList()
}