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

Metric Differentiation, findSuitableLoad implemented for LinearSearch and FullSearch

parent 83de527c
No related branches found
No related tags found
1 merge request!215Redesign Strategy, Load, and Resources data types
......@@ -118,19 +118,25 @@ class TheodoliteExecutor(
)
val config = buildConfig()
//TODO: Differentiate metrics here
// when (config.metric) {
// "demand" -> // execute benchmarks for each load
// "capacity" -> // execute benchmarks for each resource amount
// }
// execute benchmarks for each load
//execute benchmarks for each load for the demand metric, or for each resource amount for capacity metric
try {
if (config.metric == "demand") {
//demand metric
for (load in config.loads) {
if (executor.run.get()) {
config.searchStrategy.findSuitableResource(load, config.resources)
}
}
} else {
//capacity metric
for (resource in config.resources) {
if (executor.run.get()) {
config.searchStrategy.findSuitableLoad(resource, config.loads)
}
}
}
} finally {
ioHandler.writeToJSONFile(
config.searchStrategy.benchmarkExecutor.results,
......
......@@ -21,6 +21,10 @@ class BinarySearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm
return resources[result]
}
override fun findSuitableLoad(resource: Resource, loads: List<LoadDimension>): LoadDimension? {
TODO("Not yet implemented")
}
/**
* Apply binary search.
*
......
......@@ -22,10 +22,20 @@ class FullSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchmar
for (res in resources) {
logger.info { "Running experiment with load '${load.get()}' and resources '${res.get()}'" }
val result = this.benchmarkExecutor.runExperiment(load, res)
//TODO: that actually doesnt make sense no? Shouldnt it be == null?
if (result && minimalSuitableResources != null) {
minimalSuitableResources = res
}
}
return minimalSuitableResources
}
override fun findSuitableLoad(resource: Resource, loads: List<LoadDimension>): LoadDimension? {
var maxSuitableLoad: LoadDimension? = null
for (load in loads) {
logger.info { "Running experiment with resources '${resource.get()}' and load '${load.get()}'" }
if (this.benchmarkExecutor.runExperiment(load, resource)) maxSuitableLoad = load
}
return maxSuitableLoad
}
}
......@@ -90,4 +90,8 @@ class InitialGuessSearchStrategy(benchmarkExecutor: BenchmarkExecutor, guessStra
}
return null
}
override fun findSuitableLoad(resource: Resource, loads: List<LoadDimension>): LoadDimension? {
TODO("Not yet implemented")
}
}
\ No newline at end of file
......@@ -16,10 +16,22 @@ class LinearSearch(benchmarkExecutor: BenchmarkExecutor) : SearchStrategy(benchm
override fun findSuitableResource(load: LoadDimension, resources: List<Resource>): Resource? {
for (res in resources) {
logger.info { "Running experiment with load '${load.get()}' and resources '${res.get()}'" }
if (this.benchmarkExecutor.runExperiment(load, res)) return res
}
return null
}
// Stops after having the first load which is not possible anymore with the current resource, maybe some later load still possible tho
// kinda like GuessSearchStrat case -> differentiate or is it fine like that?
override fun findSuitableLoad(resource: Resource, loads: List<LoadDimension>): LoadDimension? {
var maxSuitableLoad: LoadDimension? = null
for (load in loads) {
logger.info { "Running experiment with resources '${resource.get()}' and load '${load.get()}'" }
if (this.benchmarkExecutor.runExperiment(load, resource)) {
maxSuitableLoad = load
} else break
}
return maxSuitableLoad
}
}
......@@ -27,4 +27,10 @@ class RestrictionSearch(
}
return this.searchStrategy.findSuitableResource(load, restrictedResources)
}
//TODO: not sure if it makes sense but actually doing the same as for finding suitable resource with the restrictions
override fun findSuitableLoad(resource: Resource, loads: List<LoadDimension>): LoadDimension? {
//erste Zeile komisch, wird auch bei resource so gemacht aber warum? das ist doch ne liste warum also toList?
TODO("Not yet implemented")
}
}
\ No newline at end of file
......@@ -25,4 +25,14 @@ abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor, val gues
* @return suitable resource for the specified load, or null if no suitable resource exists.
*/
abstract fun findSuitableResource(load: LoadDimension, resources: List<Resource>): Resource?
/**
* Find biggest suitable load from the specified load list for the given resource amount.
*
* @param resource the [Resource] to be tested.
* @param loads List of all possible [LoadDimension]s.
*
* @return suitable load for the specified resource amount, or null if no suitable load exists.
*/
abstract fun findSuitableLoad(resource: Resource, loads: List<LoadDimension>) : LoadDimension?
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment