From 39a1d8a027328b1d4d353f4545a6530077fa6268 Mon Sep 17 00:00:00 2001 From: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com> Date: Sat, 6 Jan 2024 11:58:26 +0100 Subject: [PATCH] Using maxTime > 0 with elitist=0 now gives a clear error rather than fail later (fix #65) --- NEWS.md | 4 +++- R/readConfiguration.R | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 08c6a17c..fcfa9cb8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -45,7 +45,9 @@ logFile has been renamed to `"instanceID"`. This data frame should not be accessed directly. Instead use the new function `get_instanceID_seed_pairs()`. - + + * Using `maxTime > 0` with `elitist=0` now gives a clear error rather than fail later (fix #65). + ## New features and improvements diff --git a/R/readConfiguration.R b/R/readConfiguration.R index 164fe5b8..01bf3b38 100644 --- a/R/readConfiguration.R +++ b/R/readConfiguration.R @@ -668,10 +668,8 @@ checkScenario <- function(scenario = defaultScenario()) irace.error (quote.param(param), " must be a real value within [0, 1].") } - if (!is.na(scenario$minExperiments)) { - scenario$maxExperiments <- max(scenario$maxExperiments, - scenario$minExperiments) - } + if (!is.na(scenario$minExperiments)) + scenario$maxExperiments <- max(scenario$maxExperiments, scenario$minExperiments) ## Only maxExperiments or maxTime should be set. Negative values are not ## allowed. @@ -690,10 +688,12 @@ checkScenario <- function(scenario = defaultScenario()) if (scenario$maxTime > 0 && (scenario$budgetEstimation <= 0 || scenario$budgetEstimation >= 1)) irace.error(quote.param("budgetEstimation"), " must be within (0,1).") + + if (scenario$maxTime > 0 && !scenario$elitist) + irace.error(quote.param("maxTime"), " requires using 'elitist=1'") - if (is.na (scenario$softRestartThreshold)) { - scenario$softRestartThreshold <- 10^(- scenario$digits) - } + if (is.na(scenario$softRestartThreshold)) + scenario$softRestartThreshold <- 10^(-scenario$digits) if (scenario$deterministic && scenario$firstTest * scenario$blockSize > length(scenario$instances)) {