###################################################### -*- mode: r -*- #####

maxExperiments = 1000

targetRunner <- function(function(experiment, scenario)
{
  main.script <- "Main.m"
  
  require(matlabr)
  debugLevel       <- scenario$debugLevel
  configuration.id <- experiment$id.configuration
  instance.id      <- experiment$id.instance
  seed             <- experiment$seed
  configuration    <- experiment$configuration
  instance         <- experiment$instance
  switches         <- experiment$switches
  
  args <- irace::buildCommandLine(configuration, switches)
  args <- strsplit(args, split=" ")[[1]]
  matlablr::run_matlab_code(c(args, paset0("run('", main.script, "')")))
  cost <- as.numeric(readLines("hv"))
  return(list(cost = cost))
}
