Skip to content

Commit

Permalink
* R/generation.R(getDependentBound): Simplify.
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Mar 3, 2024
1 parent d8137a4 commit 849a82d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions R/generation.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ 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.
deps <- intersect(names(configuration), parameters$depends[[param]])
# 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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 849a82d

Please sign in to comment.