From 128a1db017545597a5c035b7960eb3fd36b5f987 Mon Sep 17 00:00:00 2001 From: Hongyu <39747921+HongyuHe@users.noreply.github.com> Date: Fri, 23 Apr 2021 09:48:27 +0200 Subject: simulator: Add the MSE power model (#121) This change adds a power model for optimizing the mean squared error to the available power models in OpenDC. --- .../experiments/energy21/EnergyExperiment.kt | 4 ++++ .../compute/power/AsymptoticPowerModel.kt | 12 +++++----- .../simulator/compute/power/CubicPowerModel.kt | 10 ++++---- .../simulator/compute/power/LinearPowerModel.kt | 10 ++++---- .../simulator/compute/power/MsePowerModel.kt | 27 ++++++++++++++++++++++ .../simulator/compute/power/SqrtPowerModel.kt | 10 ++++---- .../simulator/compute/power/SquarePowerModel.kt | 10 ++++---- .../simulator/compute/power/PowerModelTest.kt | 1 + 8 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/MsePowerModel.kt (limited to 'simulator') diff --git a/simulator/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt b/simulator/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt index e974428c..bb6dcd3a 100644 --- a/simulator/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt +++ b/simulator/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt @@ -203,6 +203,10 @@ public class EnergyExperiment : Experiment("Energy Modeling 2021") { ) }, + MSE { + override val driver: ScalingDriver = SimpleScalingDriver(MsePowerModel(206.0, 56.4, 1.4)) + }, + ASYMPTOTIC { override val driver: ScalingDriver = SimpleScalingDriver(AsymptoticPowerModel(206.0, 56.4, 0.3, false)) }, diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/AsymptoticPowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/AsymptoticPowerModel.kt index fc08891d..ddc6d5b1 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/AsymptoticPowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/AsymptoticPowerModel.kt @@ -7,7 +7,7 @@ import kotlin.math.pow * The asymptotic power model partially adapted from GreenCloud. * * @param maxPower The maximum power draw of the server in W. - * @param staticPower The power draw of the server in halting state in W. + * @param idlePower The power draw of the server at its lowest utilization level in W. * @param asymUtil A utilization level at which the server attains asymptotic, * i.e., close to linear power consumption versus the offered load. * For most of the CPUs,a is in [0.2, 0.5]. @@ -15,17 +15,17 @@ import kotlin.math.pow */ public class AsymptoticPowerModel( private val maxPower: Double, - private val staticPower: Double, + private val idlePower: Double, private val asymUtil: Double, private val isDvfsEnabled: Boolean, ) : PowerModel { - private val factor: Double = (maxPower - staticPower) / 100 + private val factor: Double = (maxPower - idlePower) / 100 public override fun computePower(utilization: Double): Double = if (isDvfsEnabled) - staticPower + (factor * 100) / 2 * (1 + utilization.pow(3) - E.pow(-utilization.pow(3) / asymUtil)) + idlePower + (factor * 100) / 2 * (1 + utilization.pow(3) - E.pow(-utilization.pow(3) / asymUtil)) else - staticPower + (factor * 100) / 2 * (1 + utilization - E.pow(-utilization / asymUtil)) + idlePower + (factor * 100) / 2 * (1 + utilization - E.pow(-utilization / asymUtil)) - override fun toString(): String = "AsymptoticPowerModel[max=$maxPower,static=$staticPower,asymptotic=$asymUtil]" + override fun toString(): String = "AsymptoticPowerModel[max=$maxPower,idle=$idlePower,asymptotic=$asymUtil]" } diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/CubicPowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/CubicPowerModel.kt index 1fff01f9..9c44438a 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/CubicPowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/CubicPowerModel.kt @@ -6,14 +6,14 @@ import kotlin.math.pow * The cubic power model partially adapted from CloudSim. * * @param maxPower The maximum power draw of the server in W. - * @param staticPower The power draw of the server in halting state in W. + * @param idlePower The power draw of the server at its lowest utilization level in W. */ -public class CubicPowerModel(private val maxPower: Double, private val staticPower: Double) : PowerModel { - private val factor: Double = (maxPower - staticPower) / 100.0.pow(3) +public class CubicPowerModel(private val maxPower: Double, private val idlePower: Double) : PowerModel { + private val factor: Double = (maxPower - idlePower) / 100.0.pow(3) public override fun computePower(utilization: Double): Double { - return staticPower + factor * (utilization * 100).pow(3) + return idlePower + factor * (utilization * 100).pow(3) } - override fun toString(): String = "CubicPowerModel[max=$maxPower,static=$staticPower]" + override fun toString(): String = "CubicPowerModel[max=$maxPower,idle=$idlePower]" } diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/LinearPowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/LinearPowerModel.kt index 9ccf734b..0f45afae 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/LinearPowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/LinearPowerModel.kt @@ -4,17 +4,17 @@ package org.opendc.simulator.compute.power * The linear power model partially adapted from CloudSim. * * @param maxPower The maximum power draw of the server in W. - * @param staticPower The power draw of the server in halting state in W. + * @param idlePower The power draw of the server at its lowest utilization level in W. */ -public class LinearPowerModel(private val maxPower: Double, private val staticPower: Double) : PowerModel { +public class LinearPowerModel(private val maxPower: Double, private val idlePower: Double) : PowerModel { /** * The linear interpolation factor of the model. */ - private val factor: Double = (maxPower - staticPower) / 100 + private val factor: Double = (maxPower - idlePower) / 100 public override fun computePower(utilization: Double): Double { - return staticPower + factor * utilization * 100 + return idlePower + factor * utilization * 100 } - override fun toString(): String = "LinearPowerModel[max=$maxPower,static=$staticPower]" + override fun toString(): String = "LinearPowerModel[max=$maxPower,idle=$idlePower]" } diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/MsePowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/MsePowerModel.kt new file mode 100644 index 00000000..8486d680 --- /dev/null +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/MsePowerModel.kt @@ -0,0 +1,27 @@ +package org.opendc.simulator.compute.power + +import kotlin.math.pow + +/** + * The power model that minimizes the mean squared error (MSE) + * to the actual power measurement by tuning the calibration parameter. + * @see + * Fan et al., Power provisioning for a warehouse-sized computer, ACM SIGARCH'07 + * + * @param maxPower The maximum power draw of the server in W. + * @param idlePower The power draw of the server at its lowest utilization level in W. + * @param calibrationParam The parameter set to minimize the MSE. + */ +public class MsePowerModel( + private val maxPower: Double, + private val idlePower: Double, + private val calibrationParam: Double, +) : PowerModel { + private val factor: Double = (maxPower - idlePower) / 100 + + public override fun computePower(utilization: Double): Double { + return idlePower + factor * (2 * utilization - utilization.pow(calibrationParam)) * 100 + } + + override fun toString(): String = "MsePowerModel[max=$maxPower,idle=$idlePower,MSE_param=$calibrationParam]" +} diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SqrtPowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SqrtPowerModel.kt index a4732e68..afa1d82f 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SqrtPowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SqrtPowerModel.kt @@ -6,14 +6,14 @@ import kotlin.math.sqrt * The square root power model partially adapted from CloudSim. * * @param maxPower The maximum power draw of the server in W. - * @param staticPower The power draw of the server in halting state in W. + * @param idlePower The power draw of the server at its lowest utilization level in W. */ -public class SqrtPowerModel(private val maxPower: Double, private val staticPower: Double) : PowerModel { - private val factor: Double = (maxPower - staticPower) / sqrt(100.0) +public class SqrtPowerModel(private val maxPower: Double, private val idlePower: Double) : PowerModel { + private val factor: Double = (maxPower - idlePower) / sqrt(100.0) override fun computePower(utilization: Double): Double { - return staticPower + factor * sqrt(utilization * 100) + return idlePower + factor * sqrt(utilization * 100) } - override fun toString(): String = "SqrtPowerModel[max=$maxPower,static=$staticPower]" + override fun toString(): String = "SqrtPowerModel[max=$maxPower,idle=$idlePower]" } diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SquarePowerModel.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SquarePowerModel.kt index eb78eebc..82a9d37d 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SquarePowerModel.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/SquarePowerModel.kt @@ -6,14 +6,14 @@ import kotlin.math.pow * The square power model partially adapted from CloudSim. * * @param maxPower The maximum power draw of the server in W. - * @param staticPower The power draw of the server in halting state in W. + * @param idlePower The power draw of the server at its lowest utilization level in W. */ -public class SquarePowerModel(private val maxPower: Double, private val staticPower: Double) : PowerModel { - private val factor: Double = (maxPower - staticPower) / 100.0.pow(2) +public class SquarePowerModel(private val maxPower: Double, private val idlePower: Double) : PowerModel { + private val factor: Double = (maxPower - idlePower) / 100.0.pow(2) override fun computePower(utilization: Double): Double { - return staticPower + factor * (utilization * 100).pow(2) + return idlePower + factor * (utilization * 100).pow(2) } - override fun toString(): String = "SquarePowerModel[max=$maxPower,static=$staticPower]" + override fun toString(): String = "SquarePowerModel[max=$maxPower,idle=$idlePower]" } diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt index 60af0eb0..dd93302b 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt @@ -62,6 +62,7 @@ internal class PowerModelTest { Arguments.of(SquarePowerModel(350.0, 200.0), 321.5), Arguments.of(CubicPowerModel(350.0, 200.0), 309.35), Arguments.of(SqrtPowerModel(350.0, 200.0), 342.302), + Arguments.of(MsePowerModel(350.0, 200.0, 1.4), 340.571), Arguments.of(AsymptoticPowerModel(350.0, 200.0, 0.3, false), 338.765), Arguments.of(AsymptoticPowerModel(350.0, 200.0, 0.3, true), 323.072), ) -- cgit v1.2.3