summaryrefslogtreecommitdiff
path: root/opendc-compute
diff options
context:
space:
mode:
authorRadu Nicolae <rnicolae04@gmail.com>2024-04-22 13:51:39 +0200
committerGitHub <noreply@github.com>2024-04-22 13:51:39 +0200
commitd4c1d8468a17eb7adf8bf20949c2fdc4b2f93fec (patch)
tree3ab47cd41633615ae187c2a2923ac09ae48ccbd3 /opendc-compute
parentd652fa2fa76556edd81d3b8087a0c943d462ec49 (diff)
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
Diffstat (limited to 'opendc-compute')
-rw-r--r--opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/TopologyFactories.kt14
-rw-r--r--opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/JSONSpecs.kt5
2 files changed, 13 insertions, 6 deletions
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<HostSpec> {
val topology = reader.read(file)
-
return topology.toHostSpecs(random)
}
@@ -66,7 +65,6 @@ public fun clusterTopology(
random: RandomGenerator = SplittableRandom(0),
): List<HostSpec> {
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<HostSpec> {
- 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<HostSpec>
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,
)