Using `bboptimize` with a function containing `JuMP` calls

The input c to the function estimate_objective is a vector. JuMP does not support broadcasting lower bounds.

You need

julia> using BlackBoxOptim, JuMP, NLopt

julia> function estimate_objective(c)
           c_scalar = only(c)
           model = Model(NLopt.Optimizer)
           set_optimizer_attribute(model, "algorithm", :LD_MMA)
           @variable(model, x >= c_scalar)
           @objective(model, Min, x^2 + c_scalar)
           JuMP.optimize!(model)
           return objective_value(model)
       end
estimate_objective (generic function with 1 method)

julia> bboptimize(estimate_objective; SearchRange = [(-5.0, 5.0)])
1 Like