Skip to content
Snippets Groups Projects
Commit 1525fb49 authored by Simon Ehrenstein's avatar Simon Ehrenstein
Browse files

Implement search strategies

parent ddbd4004
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus,!78Resolve "Implement Quarkus/Kotlin protype"
Showing
with 137 additions and 2 deletions
package theodolite
import theodolite.strategies.SearchAlgorithm
data class ExperimentConfig(
val useCase: Int,
val expId: Int,
val dimValues: Array<Int>,
val replicass: Array<Int>,
val partitions: Int,
val cpuLimit: String,
val memoryLimit: String,
val executionMinutes: Float,
val prometheusBaseUrl: String,
val reset: Boolean,
val namespace: String,
val resultPath: String,
val configurations: Any,
val restrictionStrategy: SearchAlgorithm,
val searchStrategy: SearchStrategy,
val benchmark: Any, // TODO
val sloChecker: Any // TODO
) {
}
\ No newline at end of file
package theodolite
class ExperimentExecutor(
val config: ExperimentConfig
) {
fun run() {
this.config.restrictionStrategy.restrictResource();
}
}
\ No newline at end of file
...@@ -6,9 +6,29 @@ import io.quarkus.runtime.annotations.QuarkusMain ...@@ -6,9 +6,29 @@ import io.quarkus.runtime.annotations.QuarkusMain
object Main { object Main {
@JvmStatic @JvmStatic
fun main(args: Array<String>) { fun main(args: Array<String>) {
println("Running main method") println("Starting Benchmarks")
val config: ExperimentConfig = ExperimentConfig(
exp_id = 0,
use_case = 1,
dim_values = arrayOf(1,2,3),
configurations = TODO(),
domain_restriction_strategy = TODO(),
cpu_limit = "1000m",
execution_minutes = 5f,
memory_limit = "4gb",
namespace = "default",
partitions = 10,
prometheus_base_url = "http://localhost:9090",
replicass = arrayOf(1,2,3),
reset = false,
result_path = "./results",
search_strategy = TODO(),
subexperiment_evaluator = TODO(),
subexperiment_executor = TODO()
)
//Quarkus.run() val executor: ExperimentExecutor = ExperimentExecutor(config)
executor.run()
} }
} }
package theodolite.strategies
import theodolite.strategies.searchstrategy.Benchmark
import theodolite.strategies.searchstrategy.SearchStrategy
class BinarySearch(benchmark: Benchmark) : SearchStrategy(benchmark) {
override fun findSuitableResources(load: Int, resources: List<Int>): Int {
}
}
\ No newline at end of file
package theodolite.strategies
import theodolite.strategies.restriction.CompositeRestriction
import theodolite.strategies.restriction.Restriction
class EvenResourcesRestriction(childRestriction: Restriction) : CompositeRestriction(childRestriction) {
override fun restrict(loads: List<Int>, resources: List<Int>) {
val filteredResources: List<Int> = resources.filter { x -> x % 2 == 0 };
this.childRestriction.restrict(loads, filteredResources);
}
}
\ No newline at end of file
package theodolite.strategies
import theodolite.strategies.searchstrategy.Benchmark
import theodolite.strategies.searchstrategy.SearchStrategy
class LinearSearch(benchmark: Benchmark) : SearchStrategy(benchmark) {
override fun findSuitableResources(load: Int, resources: List<Int>): Int {
for (res in resources) {
if (this.benchmark.execute(load, res)) return resources.indexOf(res);
}
return resources.size;
}
}
\ No newline at end of file
package theodolite.strategies
import theodolite.strategies.restriction.PrimitiveRestriction
import theodolite.strategies.searchstrategy.SearchStrategy
class LowerBoundRestriction(searchStrategy: SearchStrategy) : PrimitiveRestriction(searchStrategy) {
override fun restrict(loads: List<Int>, resources: List<Int>): List<Int> {
val lowerBounds: MutableList<Int> = ArrayList<Int>();
var lowerBound = 0;
for (load in loads) {
lowerBound = this.searchStrategy.findSuitableResources(load, resources.subList(lowerBound, resources.size));
lowerBounds.add(lowerBound);
}
return lowerBounds;
}
}
\ No newline at end of file
package theodolite.strategies.restriction
abstract class CompositeRestriction(val childRestriction: Restriction): Restriction {
}
\ No newline at end of file
package theodolite.strategies.restriction
import theodolite.strategies.searchstrategy.SearchStrategy
abstract class PrimitiveRestriction(val searchStrategy: SearchStrategy): Restriction {
}
\ No newline at end of file
package theodolite.strategies.restriction
interface Restriction {
fun restrict(loads: List<Int>, resources: List<Int>): List<Int>;
}
\ No newline at end of file
package theodolite.strategies.searchstrategy
class Benchmark {
fun execute(load: Int, res: Int): Boolean {
return true;
}
}
\ No newline at end of file
package theodolite.strategies.searchstrategy
abstract class SearchStrategy(val benchmark: Benchmark) {
abstract fun findSuitableResources(load: Int, resources: List<Int>): Int;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment