diff --git a/R/generation.R b/R/generation.R index 9fbf564e..0fff2831 100644 --- a/R/generation.R +++ b/R/generation.R @@ -38,8 +38,9 @@ repairConfigurations <- function(x, parameters, repair) ## Calculates the parameter bounds when parameters domain is dependent getDependentBound <- function(parameters, param, configuration) { - values <- parameters$domain[[param]] - if (is.expression(values)) { + domain <- parameters$domain[[param]] + stopifnot(is.expression(domain)) + # Depends contains parameters that enable param and parameters that define # its domain. If this is a partial configuration, we need only the latter. # Use names() here in case the configuration is simply a list. @@ -47,19 +48,18 @@ getDependentBound <- function(parameters, param, configuration) # If it depends on a parameter that is disabled, then this is disabled. if (anyNA(configuration[deps])) return(NA) - values <- sapply(values, eval, configuration) - irace.assert(all(is.finite(values))) + domain <- sapply(domain, eval, configuration) + irace.assert(all(is.finite(domain))) # Value gets truncated (defined from robotics initial requirements) - if (parameters$types[param] == "i") values <- as.integer(values) - if (values[1] > values[2]) { - irace.error ("Invalid domain (", paste0(values, collapse=", "), + if (parameters$types[param] == "i") domain <- as.integer(domain) + if (domain[[1L]] > domain[[2L]]) { + irace.error ("Invalid domain (", paste0(domain, collapse=", "), ") generated for parameter '", param, "' that depends on parameters (", paste0(parameters$depends[[param]], collapse=", "), "). This is NOT a bug in irace. Check the definition of these parameters.") } - } - values + domain } ## Calculates the parameter bounds when parameters domain is dependent @@ -117,9 +117,9 @@ param_qunif_r <- function(x, domain, transf, digits) upper <- domain[2L] lower <- domain[1L] x <- as.numeric(x) - if (transf == "log") { + if (transf == "log") return(round(transform_from_log(x, transf, lower, upper), digits)) - } + x <- x * (upper - lower) + lower clamp(round(x, digits), lower, upper) }