diff --git a/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestriction.kt b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestriction.kt index 2e5a51018fd742abbb18edb1d788a6644e94d2f1..b1c436c32153b8a22e8dbabe6b0dbfd895f7a804 100644 --- a/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestriction.kt +++ b/theodolite/src/main/kotlin/rocks/theodolite/core/strategies/restrictionstrategy/LowerBoundRestriction.kt @@ -13,11 +13,9 @@ import rocks.theodolite.core.Results class LowerBoundRestriction(results: Results) : RestrictionStrategy(results) { override fun apply(xValue: Int, yValues: List<Int>): List<Int> { - val maxXValue: Int? = this.results.getMaxBenchmarkedXDimensionValue(xValue) - var lowerBound: Int? = this.results.getOptYDimensionValue(maxXValue) - if (lowerBound == null) { - lowerBound = yValues[0] - } + val maxXValue = this.results.getMaxBenchmarkedXDimensionValue(xValue) + // Get previous largest y value or restrict to empty list + val lowerBound: Int = this.results.getOptYDimensionValue(maxXValue) ?: return listOf() return yValues.filter { x -> x >= lowerBound } } diff --git a/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategyTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategyTest.kt index 40cf803d68382ea380f0afc67adf3afbd70f9960..155ceb847eebbd9219707182cbd85cd475c7995b 100644 --- a/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategyTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/InitialGuessSearchStrategyTest.kt @@ -9,12 +9,37 @@ import rocks.theodolite.kubernetes.TestExperimentRunner import rocks.theodolite.core.strategies.guessstrategy.PrevInstanceOptGuess import rocks.theodolite.core.Results import rocks.theodolite.core.createResultsFromArray +import rocks.theodolite.core.strategies.restrictionstrategy.LowerBoundRestriction private val logger = KotlinLogging.logger {} @QuarkusTest class InitialGuessSearchStrategyTest { + @Test + fun initialGuessSearchNoMatch() { + val mockResults = createResultsFromArray(arrayOf( + arrayOf(true, true), + arrayOf(false, false), + arrayOf(true, true), + ), Metric.DEMAND) + val mockLoads: List<Int> = (1..3).toList() + val mockResources: List<Int> = (1..2).toList() + val results = Results(Metric.DEMAND) + val guessStrategy = PrevInstanceOptGuess() + val benchmarkExecutor = TestExperimentRunner(results, mockResults) + val strategy = InitialGuessSearchStrategy(benchmarkExecutor,guessStrategy, results) + + val actual: MutableList<Int?> = mutableListOf() + val expected: List<Int?> = listOf(1, null, 1) + + for (load in mockLoads) { + actual.add(strategy.findSuitableResource(load, mockResources)) + } + + assertEquals(expected, actual) + } + @Test fun testInitialGuessSearch() { val mockResults = createResultsFromArray(arrayOf( diff --git a/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearchTest.kt b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearchTest.kt index dbd5454fc2e2de1ed433f534915c820b55860eba..b1f97667f0a19d00f9cf3ea0b2c8c2497a81d773 100644 --- a/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearchTest.kt +++ b/theodolite/src/test/kotlin/rocks/theodolite/core/strategies/searchstrategy/RestrictionSearchTest.kt @@ -14,7 +14,6 @@ import rocks.theodolite.core.createResultsFromArray class RestrictionSearchTest { @Test - @Disabled("Currently failing, has to be fixed") fun restrictionSearchNoMatch() { val mockResults = createResultsFromArray(arrayOf( arrayOf(true, true),