ParBayesianOptimization icon indicating copy to clipboard operation
ParBayesianOptimization copied to clipboard

Recursive Argument fix

Open novaktim opened this issue 8 months ago • 0 comments

Hey @AnotherSamWilson and @kapsner, really appreciate your work. An average user can run into the “promise already under evaluation” error when a default argument references itself:

iterations = 100

scoringFunction = function(x, iterations = iterations) {
  score = x^iterations
  list(Score = score)
}

bounds = list(x = c(0, 1))

bayes = bayesOpt(scoringFunction, bounds = bounds, initPoints = 10)
# errorMessage --> "promise already under evaluation: recursive default argument reference or earlier problems?"

# afterwards e.g. build better model
print(scoringFunction(x = 0, iterations = 200))

With this in place, the example above now just works fine and all existing unit tests still pass.

novaktim avatar May 06 '25 20:05 novaktim