diff options
Diffstat (limited to 'opendc-compute/opendc-compute-failure')
| -rw-r--r-- | opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt | 3 |
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() } |
