Hi Manuel,
Thank you so much for your detailed explanation! It is so helpful. The code has run successfully now.
I notice that in the example, the instances can include multiple datasets (instances = list(dataset1, dataset2)). Just some follow-up questions about this example, if I want to include three datasets, run the algo on each of the datasets, and summarize the final result by averaging the results from these three datasets. Should the code be something like this:
//
library(irace)
# target runner function
target.runner <- function(experiment, scenario) {
instance <- experiment$instance
configuration <- experiment$configuration
# run algorithm on each dataset
res <- list()
for(i in 1:3) {
res[[i]] <-my_algo(instance[[i]])
}
res_final <- list("value" = as.numeric(sapply(res, mean)) # ensure the final result returns a single value
return(list(cost =
res_final$value))
}
# scenario
scenario <- list(targetRunner = target.runner,
instances = list(dataset1, dataset2, dataset3),
maxExperiments = 200,
logFile = "")
# check that the scenario is valid.
checkIraceScenario(scenario, parameters = parameters)
//
I am not sure if for-loop should be used within the target.runner function or not.
In addition, to make it run faster, I want to use parallel computing and then modify the code for the scenario as follows while keeping the other parts the same:
//
# get cores
n.cores <- parallel::detectCores()
# scenario
scenario <- list(targetRunner = target.runner,
instances = list(dataset1, dataset2, dataset3),
maxExperiments = 200,
parallel = n.cores,
logFile = "")
//
In this way, if n.cores = 12, I assume that each dataset will take 4 cores and be applied to the algorithm in parallel. Do I understand it correctly?
Thank you once again!
Best regards,
Phoebe