Skip to content
Snippets Groups Projects
Commit 9e672e40 authored by Marcel Samir Becker's avatar Marcel Samir Becker
Browse files

Implemented review suggestions

parent 16d5f2e1
No related branches found
No related tags found
1 merge request!215Redesign Strategy, Load, and Resources data types
...@@ -128,12 +128,21 @@ class TheodoliteExecutor( ...@@ -128,12 +128,21 @@ class TheodoliteExecutor(
config.searchStrategy.benchmarkExecutor.results, config.searchStrategy.benchmarkExecutor.results,
"${resultsFolder}exp${this.config.executionId}-result" "${resultsFolder}exp${this.config.executionId}-result"
) )
// Create expXYZ_demand.csv file // Create expXYZ_demand.csv file or expXYZ_capacity.csv depending on metric
when(config.metric) {
Metric.DEMAND ->
ioHandler.writeToCSVFile( ioHandler.writeToCSVFile(
"${resultsFolder}exp${this.config.executionId}_demand", "${resultsFolder}exp${this.config.executionId}_demand",
calculateDemandMetric(config.loads, config.searchStrategy.benchmarkExecutor.results), calculateMetric(config.loads, config.searchStrategy.benchmarkExecutor.results),
listOf("load","resources") listOf("load","resources")
) )
Metric.CAPACITY ->
ioHandler.writeToCSVFile(
"${resultsFolder}exp${this.config.executionId}_capacity",
calculateMetric(config.resources, config.searchStrategy.benchmarkExecutor.results),
listOf("resource", "loads")
)
}
} }
kubernetesBenchmark.teardownInfrastructure() kubernetesBenchmark.teardownInfrastructure()
} }
...@@ -148,8 +157,8 @@ class TheodoliteExecutor( ...@@ -148,8 +157,8 @@ class TheodoliteExecutor(
return executionID return executionID
} }
private fun calculateDemandMetric(loads: List<Int>, results: Results): List<List<String>> { private fun calculateMetric(xValues: List<Int>, results: Results): List<List<String>> {
return loads.map { listOf(it.toString(), results.getOptYDimensionValue(it).toString()) } return xValues.map { listOf(it.toString(), results.getOptYDimensionValue(it).toString()) }
} }
} }
...@@ -19,12 +19,7 @@ class InitialGuessSearchStrategy(benchmarkExecutor: BenchmarkExecutor, guessStra ...@@ -19,12 +19,7 @@ class InitialGuessSearchStrategy(benchmarkExecutor: BenchmarkExecutor, guessStra
override fun findSuitableResource(load: Int, resources: List<Int>): Int? { override fun findSuitableResource(load: Int, resources: List<Int>): Int? {
if(resources.isEmpty()) { if(this.guessStrategy == null){
logger.info { "You need to specify resources to be checked for the InitialGuessSearchStrategy to work." }
return null
}
if(guessStrategy == null){
logger.info { "Your InitialGuessSearchStrategy doesn't have a GuessStrategy. This is not supported." } logger.info { "Your InitialGuessSearchStrategy doesn't have a GuessStrategy. This is not supported." }
return null return null
} }
...@@ -88,12 +83,7 @@ class InitialGuessSearchStrategy(benchmarkExecutor: BenchmarkExecutor, guessStra ...@@ -88,12 +83,7 @@ class InitialGuessSearchStrategy(benchmarkExecutor: BenchmarkExecutor, guessStra
override fun findSuitableLoad(resource: Int, loads: List<Int>): Int?{ override fun findSuitableLoad(resource: Int, loads: List<Int>): Int?{
if(loads.isEmpty()) { if(this.guessStrategy == null){
logger.info { "You need to specify resources to be checked for the InitialGuessSearchStrategy to work." }
return null
}
if(guessStrategy == null){
logger.info { "Your InitialGuessSearchStrategy doesn't have a GuessStrategy. This is not supported." } logger.info { "Your InitialGuessSearchStrategy doesn't have a GuessStrategy. This is not supported." }
return null return null
} }
......
...@@ -27,15 +27,14 @@ abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor, val gues ...@@ -27,15 +27,14 @@ abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor, val gues
*/ */
fun applySearchStrategyByMetric(loads: List<Int>, resources: List<Int>, metric: Metric) { fun applySearchStrategyByMetric(loads: List<Int>, resources: List<Int>, metric: Metric) {
if (metric.value == "demand") { when(metric) {
// demand metric Metric.DEMAND ->
for (load in loads) { for (load in loads) {
if (benchmarkExecutor.run.get()) { if (benchmarkExecutor.run.get()) {
this.findSuitableResource(load, resources) this.findSuitableResource(load, resources)
} }
} }
} else { Metric.CAPACITY ->
// capacity metric
for (resource in resources) { for (resource in resources) {
if (benchmarkExecutor.run.get()) { if (benchmarkExecutor.run.get()) {
this.findSuitableLoad(resource, loads) this.findSuitableLoad(resource, loads)
......
...@@ -27,25 +27,25 @@ class Results (val metric: Metric) { ...@@ -27,25 +27,25 @@ class Results (val metric: Metric) {
fun setResult(experiment: Pair<Int, Int>, successful: Boolean) { fun setResult(experiment: Pair<Int, Int>, successful: Boolean) {
this.results[experiment] = successful this.results[experiment] = successful
if(metric.value == "demand" && optInstances.containsKey(experiment.first)){ when (metric) {
Metric.DEMAND ->
if (optInstances.containsKey(experiment.first)) {
if(optInstances[experiment.first]!! > experiment.second) { if(optInstances[experiment.first]!! > experiment.second) {
optInstances[experiment.first] = experiment.second optInstances[experiment.first] = experiment.second
} }
} } else {
else if(metric.value == "demand" && !optInstances.containsKey(experiment.first)){
if(!successful){ if(!successful){
optInstances[experiment.first] = Int.MAX_VALUE optInstances[experiment.first] = Int.MAX_VALUE
}else { }else {
optInstances[experiment.first] = experiment.second optInstances[experiment.first] = experiment.second
} }
} }
else if(metric.value == "capacity" && optInstances.containsKey(experiment.second)){ Metric.CAPACITY ->
if (optInstances.containsKey(experiment.second)) {
if (optInstances[experiment.second]!! < experiment.first){ if (optInstances[experiment.second]!! < experiment.first){
optInstances[experiment.second] = experiment.first optInstances[experiment.second] = experiment.first
} }
} } else {
else if(metric.value == "capacity" && !optInstances.containsKey(experiment.second)){
if(!successful){ if(!successful){
optInstances[experiment.second] = Int.MIN_VALUE optInstances[experiment.second] = Int.MIN_VALUE
} else { } else {
...@@ -53,6 +53,7 @@ class Results (val metric: Metric) { ...@@ -53,6 +53,7 @@ class Results (val metric: Metric) {
} }
} }
} }
}
/** /**
* Get the result for an experiment. * Get the result for an experiment.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment