Closed
Description
This works:
# Creates the problem with Float64 initial value.
using Optimization, OptimizationBBO
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
p = [1.0, 100.0]
prob = OptimizationProblem(rosenbrock, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
sol = solve(prob, BBO_adaptive_de_rand_1_bin_radiuslimited())
but if we force x0
to be an Vector{Any}
it fails
# Creates the problem with Any initial value.
x0 = Any[0.0, 0.0]
prob = OptimizationProblem(rosenbrock, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
sol = solve(prob, BBO_adaptive_de_rand_1_bin_radiuslimited()) # ERROR: MethodError: no method matching iterate(::BlackBoxOptim.ContinuousRectSearchSpace)
This is not too far-fetched to happen. I.e. I had a routine which creates a starting vector my concatenating two vectors. If one of these is empty this happen:
[[]; [1.0, 2.0]] # isa Vector{Any}