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 --- .../org/opendc/compute/topology/TopologyFactories.kt | 14 ++++++++++---- .../kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'opendc-compute/opendc-compute-topology') diff --git a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt index 47ba8058..e6b36dba 100644 --- a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt +++ b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt @@ -54,7 +54,6 @@ public fun clusterTopology( random: RandomGenerator = SplittableRandom(0), ): List { val topology = reader.read(file) - return topology.toHostSpecs(random) } @@ -66,7 +65,6 @@ public fun clusterTopology( random: RandomGenerator = SplittableRandom(0), ): List { val topology = reader.read(input) - return topology.toHostSpecs(random) } @@ -74,7 +72,11 @@ public fun clusterTopology( * Helper method to convert a [TopologyJSONSpec] into a list of [HostSpec]s. */ private fun TopologyJSONSpec.toHostSpecs(random: RandomGenerator): List { - return clusters.flatMap { cluster -> List(cluster.count) { cluster.toHostSpecs(random) }.flatten() } + return clusters.flatMap { cluster -> + List(cluster.count) { + cluster.toHostSpecs(random) + }.flatten() + } } /** @@ -87,7 +89,10 @@ private fun ClusterJSONSpec.toHostSpecs(random: RandomGenerator): List hosts.flatMap { host -> ( List(host.count) { - host.toHostSpecs(clusterId, random) + host.toHostSpecs( + clusterId, + random, + ) } ) } @@ -116,6 +121,7 @@ private fun HostJSONSpec.toHostSpecs( ) val powerModel = getPowerModel(powerModel.modelType, powerModel.power, powerModel.maxPower, powerModel.idlePower) + val hostSpec = HostSpec( UUID(random.nextLong(), (hostId).toLong()), diff --git a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt index fbdb4f5f..5e0af541 100644 --- a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt +++ b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt @@ -55,8 +55,9 @@ public data class ClusterJSONSpec( * * @param name The name of the host. * @param cpus List of the different CPUs available in this cluster - * @param memCapacity The amount of RAM memory available in Byte + * @param memory The amount of RAM memory available in Byte * @param powerModel The power model used to determine the power draw of a host + * @param count The power model used to determine the power draw of a host */ @Serializable public data class HostJSONSpec( @@ -108,6 +109,6 @@ public data class MemoryJSONSpec( public data class PowerModelJSONSpec( val modelType: String, val power: Double = 400.0, - val maxPower: Double, val idlePower: Double, + val maxPower: Double, ) -- cgit v1.2.3