jmejia8 / Metaheuristics.jl

High-performance metaheuristics for optimization coded purely in Julia.
https://jmejia8.github.io/Metaheuristics.jl/stable/
Other
253 stars 27 forks source link

3.3 version: many types stopped working #83

Closed aplavin closed 1 year ago

aplavin commented 1 year ago

Not sure if intended (then the version is breaking, and should be bumped to 4 instead) or not (then types should be relaxed), but:

Metaheuristics@3.2:

julia> using Metaheuristics, StaticArrays
julia> f(x) = 10length(x) + sum( x.^2 - 10cos.(2π*x)  )
julia> D = 10
julia> bounds = [-5*@SVector(ones(D)) 5*@SVector(ones(D))]'
julia> result = optimize(f, bounds)
+=========== RESULT ==========+
< ...> 

Metaheuristics@3.3:

julia> using Metaheuristics, StaticArrays
julia> f(x) = 10length(x) + sum( x.^2 - 10cos.(2π*x)  )
julia> D = 10
julia> bounds = [-5*@SVector(ones(D)) 5*@SVector(ones(D))]'
julia> result = optimize(f, bounds)
ERROR: MethodError: no method matching BoxConstrainedSpace(::SVector{10, Float64}, ::SVector{10, Float64}, ::SVector{10, Float64}, ::Int64, ::Bool)
<...>
jmejia8 commented 1 year ago

Thank you for reporting. The issue will be solved in SearchSpaces.jl (maybe by relaxing the type bounds).

aplavin commented 1 year ago

Same with numbers instead of vectors: 1d optimization doesn't work, the error seems different.

julia> bounds = [-5; 5;;]
2×1 Matrix{Int64}:
 -5
  5

julia> result = optimize(f, bounds)
ERROR: MethodError: no method matching create_solution(::Int64, ::Problem{BoxConstrainedSpace{Int64}}; ε::Float64)