Hello everybody,
I am new to Julia and I am struggling to understand the behaviour of the following code, in which I perform the minimization of a function using the package BlackBoxOptim.
function includeProof(z::Real, x::Real)
RangePoints=(-5.0, 5.0)
function ToMin(y::Real)
(1.0 - z*x)^2 + 100.0 * (x - (y+x)^2)^2
end
res = bboptimize(ToMin; SearchRange = RangePoints, NumDimensions=1)
end
see = includeProof(1.1,1.1)
In particular, I would expect that this piece of code returned the output of res.
However, the following error appears
MethodError: no method matching (::var"#ToMin#2"{Float64, Float64})(::Vector{Float64})
Closest candidates are:
(::var"#ToMin#2")(::Real) at In[4]:3
Stacktrace:
[1] fitness(x::Vector{Float64}, p::FunctionBasedProblem{var"#ToMin#2"{Float64, Float64}, ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing})
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/I3lfp/src/problem.jl:61
[2] setup_problem(func::Function, parameters::ParamsDictChain)
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/I3lfp/src/bboptimize.jl:37
[3] bbsetup(functionOrProblem::Function, parameters::Dict{Symbol, Any}; kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:SearchRange, :NumDimensions), Tuple{Tuple{Float64, Float64}, Int64}}})
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/I3lfp/src/bboptimize.jl:111
[4] bboptimize(functionOrProblem::Function, parameters::Dict{Symbol, Any}; kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:SearchRange, :NumDimensions), Tuple{Tuple{Float64, Float64}, Int64}}})
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/I3lfp/src/bboptimize.jl:92
[5] includeProof(z::Float64, x::Float64)
@ Main ./In[4]:6
[6] top-level scope
@ In[5]:1
[7] eval
@ ./boot.jl:368 [inlined]
[8] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1428
I do not get why there is a method error and, in particular, where does this piece
(::var"#ToMin#2"{Float64, Float64})(::Vector{Float64})
come from.
Thanks a lot!