From d4c1d8468a17eb7adf8bf20949c2fdc4b2f93fec Mon Sep 17 00:00:00 2001 From: Radu Nicolae Date: Mon, 22 Apr 2024 13:51:39 +0200 Subject: Merged scenario and portfolio (#220) * sync with the master branch * rebase * multimodel - simulation is currently run as many times as you can see a model * factory method - handles models without given params * removed redundant flags * modelType * flags removed * implemented output into a folder * multimodel ipynb setup - to be implemented and also ran as a python script, when the simulation occurs * towards a mutimodel python implementation - issue observed - the saved files have same data? * json parsing handles now lists for topology, workloads, allocaitonPolicies, powerModels * scenarioFile inputs lists, and creates multiple combinations of scenarios * multi-model prediction repaired, now we predict using multiple models * commit before removing powerModel from scenario * commit after removing powerModel from scenario * commit after removing powerModel from scenario (and actually running) * powermodels now can output their name and full name (with min and max) * now we can select where to output (seed or output folder) * input files - clear naming + output naming improved * minimal changes * all tests passing + json files from tests updated to the new json format * json files from topology now accept only one power model (instead of list) * json files from topology now accept only one power model (instead of list) * multi and single input from tests updated to match the format * tests passed locally * spotless applies * demo folder removed --- .../compute/power/CPUPowerModelsFactory.kt | 12 +++ .../simulator/compute/power/CpuPowerModel.java | 6 ++ .../simulator/compute/power/CpuPowerModels.java | 89 +++++++++++++++++++--- 3 files changed, 95 insertions(+), 12 deletions(-) (limited to 'opendc-simulator') diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CPUPowerModelsFactory.kt b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CPUPowerModelsFactory.kt index e47c1c80..e2f852f8 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CPUPowerModelsFactory.kt +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CPUPowerModelsFactory.kt @@ -38,3 +38,15 @@ public fun getPowerModel( else -> throw IllegalArgumentException("Unknown power modelType $modelType") } } + +public fun getPowerModel(modelType: String): CpuPowerModel { + return when (modelType) { + "constant" -> CpuPowerModels.constant(200.0) + "sqrt" -> CpuPowerModels.sqrt(350.0, 200.0) + "linear" -> CpuPowerModels.linear(350.0, 200.0) + "square" -> CpuPowerModels.square(350.0, 200.0) + "cubic" -> CpuPowerModels.cubic(350.0, 200.0) + + else -> throw IllegalArgumentException("Unknown power modelType $modelType") + } +} diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CpuPowerModel.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CpuPowerModel.java index e023d098..73f9357d 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CpuPowerModel.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CpuPowerModel.java @@ -35,4 +35,10 @@ public interface CpuPowerModel { * @return A double value of CPU power consumption (in W). */ double computePower(double utilization); + + String getName(); + + default String getFullName() { + return getName(); + } } diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CpuPowerModels.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CpuPowerModels.java index 5d3d936b..7ba9eaed 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CpuPowerModels.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CpuPowerModels.java @@ -42,7 +42,7 @@ public class CpuPowerModels { /** * Construct a square root {@link CpuPowerModel} that is adapted from CloudSim. * - * @param maxPower The maximum power draw of the server in W. + * @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. */ public static CpuPowerModel sqrt(double maxPower, double idlePower) { @@ -52,7 +52,7 @@ public class CpuPowerModels { /** * Construct a linear {@link CpuPowerModel} that is adapted from CloudSim. * - * @param maxPower The maximum power draw of the server in W. + * @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. */ public static CpuPowerModel linear(double maxPower, double idlePower) { @@ -62,7 +62,7 @@ public class CpuPowerModels { /** * Construct a square {@link CpuPowerModel} that is adapted from CloudSim. * - * @param maxPower The maximum power draw of the server in W. + * @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. */ public static CpuPowerModel square(double maxPower, double idlePower) { @@ -72,7 +72,7 @@ public class CpuPowerModels { /** * Construct a cubic {@link CpuPowerModel} that is adapted from CloudSim. * - * @param maxPower The maximum power draw of the server in W. + * @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. */ public static CpuPowerModel cubic(double maxPower, double idlePower) { @@ -83,11 +83,11 @@ public class CpuPowerModels { * Construct a {@link CpuPowerModel} that minimizes the mean squared error (MSE) * to the actual power measurement by tuning the calibration parameter. * - * @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 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 calibrationFactor The parameter set to minimize the MSE. * @see - * Fan et al., Power provisioning for a warehouse-sized computer, ACM SIGARCH'07 + * Fan et al., Power provisioning for a warehouse-sized computer, ACM SIGARCH'07 */ public static CpuPowerModel mse(double maxPower, double idlePower, double calibrationFactor) { return new MsePowerModel(maxPower, idlePower, calibrationFactor); @@ -96,12 +96,12 @@ public class CpuPowerModels { /** * Construct an asymptotic {@link CpuPowerModel} adapted from GreenCloud. * - * @param maxPower The maximum power draw of the server in W. + * @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 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]. - * @param dvfs A flag indicates whether DVFS is enabled. + * @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]. + * @param dvfs A flag indicates whether DVFS is enabled. */ public static CpuPowerModel asymptotic(double maxPower, double idlePower, double asymUtil, boolean dvfs) { return new AsymptoticPowerModel(maxPower, idlePower, asymUtil, dvfs); @@ -147,6 +147,11 @@ public class CpuPowerModels { public String toString() { return "ConstantPowerModel[power=" + power + "]"; } + + @Override + public String getName() { + return "ConstantPowerModel"; + } } private abstract static class MaxIdlePowerModel implements CpuPowerModel { @@ -176,6 +181,16 @@ public class CpuPowerModels { public double computePower(double utilization) { return idlePower + factor * Math.sqrt(utilization * 100); } + + @Override + public String getName() { + return "SqrtPowerModel"; + } + + @Override + public String getFullName() { + return ("sqrtPowerModel-" + idlePower + "-" + maxPower); + } } private static final class LinearPowerModel extends MaxIdlePowerModel { @@ -190,6 +205,16 @@ public class CpuPowerModels { public double computePower(double utilization) { return idlePower + factor * utilization * 100; } + + @Override + public String getName() { + return "LinearPowerModel"; + } + + @Override + public String getFullName() { + return ("linearPowerModel-" + idlePower + "-" + maxPower); + } } private static final class SquarePowerModel extends MaxIdlePowerModel { @@ -204,6 +229,16 @@ public class CpuPowerModels { public double computePower(double utilization) { return idlePower + factor * Math.pow(utilization * 100, 2); } + + @Override + public String getName() { + return "SquarePowerModel"; + } + + @Override + public String getFullName() { + return ("squarePowerModel-" + idlePower + "-" + maxPower); + } } private static final class CubicPowerModel extends MaxIdlePowerModel { @@ -218,6 +253,16 @@ public class CpuPowerModels { public double computePower(double utilization) { return idlePower + factor * Math.pow(utilization * 100, 3); } + + @Override + public String getName() { + return "CubicPowerModel"; + } + + @Override + public String getFullName() { + return ("cubicPowerModel-" + idlePower + "-" + maxPower); + } } private static final class MsePowerModel extends MaxIdlePowerModel { @@ -240,6 +285,11 @@ public class CpuPowerModels { return "MsePowerModel[max=" + maxPower + ",idle=" + idlePower + ",calibrationFactor=" + calibrationFactor + "]"; } + + @Override + public String getName() { + return "MsePowerModel"; + } } private static final class AsymptoticPowerModel extends MaxIdlePowerModel { @@ -273,6 +323,11 @@ public class CpuPowerModels { return "AsymptoticPowerModel[max=" + maxPower + ",idle=" + idlePower + ",asymUtil=" + asymUtil + ",dvfs=" + dvfs + "]"; } + + @Override + public String getName() { + return "AsymptoticPowerModel"; + } } private static final class InterpolationPowerModel implements CpuPowerModel { @@ -304,6 +359,11 @@ public class CpuPowerModels { public String toString() { return "InterpolationPowerModel[levels=" + Arrays.toString(powerLevels) + "]"; } + + @Override + public String getName() { + return "InterpolationPowerModel"; + } } private static final class ZeroIdlePowerDecorator implements CpuPowerModel { @@ -326,5 +386,10 @@ public class CpuPowerModels { public String toString() { return "ZeroIdlePowerDecorator[delegate=" + delegate + "]"; } + + @Override + public String getName() { + return "ZeroIdlePowerDecorator"; + } } } -- cgit v1.2.3