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-compute/opendc-compute-failure | |
| 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-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() } |
