mlr-org / bbotk

Black-box optimization framework for R.
https://bbotk.mlr-org.com
GNU Lesser General Public License v3.0
22 stars 9 forks source link

gensa update breaks #214

Closed mb706 closed 11 months ago

mb706 commented 11 months ago

The example in the README.md uses GenSA but fails with the very new version that will probably end up on CRAN soon:

> library("bbotk")
Loading required package: paradox
> fun = function(xs) {
  - (xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10
}

# set domain
domain = ps(
  x1 = p_dbl(-10, 10),
  x2 = p_dbl(-5, 5)
)

# set codomain
codomain = ps(
  y = p_dbl(tags = "maximize")
)

# create Objective object
objective = ObjectiveRFun$new(
  fun = fun,
  domain = domain,
  codomain = codomain,
  properties = "deterministic"
)

# Define termination criterion
terminator = trm("evals", n_evals = 10)

# create optimization instance
instance = OptimInstanceSingleCrit$new(
  objective = objective,
  terminator = terminator
)

# load optimizer
optimizer = opt("gensa")

# trigger optimization
optimizer$optimize(instance)
INFO  [13:49:59.346] [bbotk] Starting to optimize 2 parameter(s) with '<OptimizerGenSA>' and '<TerminatorEvals> [n_evals=10, k=0]'
Error in GenSA::GenSA(par = NULL, fn = inst$objective_function, lower = inst$search_space$lower,  : 
  Trace mat has to be activated to have no improvment stop criteria to work.

the gensa 1.1.11 found here: https://cran.r-project.org/incoming/archive/

mb706 commented 11 months ago

problem is this

https://github.com/mlr-org/bbotk/blob/d5530698fb5034f86ce838af6b2476f55573edce/R/OptimizerGenSA.R#L84

be-marc commented 11 months ago

Thanks. Fixed by #215.