Skip to contents

Function that runs one differential evolution metaepoch. Wrapper function for DEoptim::DEoptim.

Usage

deoptim_metaepoch(config_deoptim)

Arguments

config_deoptim
  • list of DEoptim::DEoptim params

Value

list with named fields: solution, population, value. See ga_metaepoch for more details.

Examples

tree_height <- 3
empty_config_deoptim <- lapply(1:tree_height, function(x) {
  list()
})
deoptim_metaepoch(empty_config_deoptim)
#> function (fitness, deme, lower, upper, minimize) 
#> {
#>     deoptim_fitness <- ifelse(minimize, fitness, function(x) {
#>         -1 * fitness(x)
#>     })
#>     config <- config_deoptim[[deme@level]]
#>     ignore_errors <- ifelse(is.null(config$ignore_errors), TRUE, 
#>         config$ignore_errors)
#>     population_size <- nrow(deme@population)
#>     iterations_count <- 5
#>     control <- DEoptim::DEoptim.control(strategy = 4, NP = nrow(deme@population), 
#>         itermax = iterations_count, trace = FALSE)
#>     params <- list(fn = deoptim_fitness, lower = lower, upper = upper, 
#>         control = control)
#>     tryCatch({
#>         result <- do.call(DEoptim::DEoptim, params)
#>     }, error = function(e) {
#>         if (ignore_errors) {
#>             warning("DEoptim::DEoptim failed with error: ", e)
#>             return(NULL)
#>         }
#>         else {
#>             stop("DEoptim::DEoptim failed with error: ", e)
#>         }
#>     })
#>     population <- result$member$pop
#>     value <- ifelse(minimize, result$optim$bestval, result$optim$bestval * 
#>         -1)
#>     fitness_values <- rep(NaN, population_size)
#>     list(solution = result$optim$bestmem, population = population, 
#>         value = value, fitness_values = fitness_values, context = NULL)
#> }
#> <bytecode: 0x5840edbe7fa0>
#> <environment: 0x5840f2866e88>